|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- void tree::dialogShown_cb()2 @. ?' r, q& _% s( H/ v# j+ F
- {# `* x( c. ^$ g) a
- try& T# u. f% P! t; f# ]2 e
- {% Q. {6 z R4 }/ k
- //---- Enter your callback code here -----3 W& [# L. v# |0 d5 E% }3 _4 n5 `+ H$ Y
- " [6 ^ e& V" y
-
' I9 w$ L" b) n4 D0 o& m' U8 e - tree_control0->InserTColumn(0,"Name",140);8 F/ Q# T0 L$ V& _' D
- tree_control0->InsertColumn(1,"Feature Type",90);
6 q) p5 B" E9 o6 h# s9 t: m - tree_control0->InsertColumn(2," Up to Date",70);9 l, n. F, m8 S5 z* p3 R' q
- 8 L* P3 L. O0 J2 U+ n2 Z( p _
- tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
% ?8 E0 q4 a# C8 `0 S - tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);& y7 L m1 F' m6 R" F# l8 m/ [
- tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);$ M6 _3 ` t! t1 w% \# Q& [* ^
- & x( v/ p# G! m( Z4 e, k4 h( V5 h3 _
- tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
" S' G) E& G: L) M. E- _8 a - $ ?+ L* J% \( `) S" l/ o/ q
- // create historymode
+ w7 X n: d5 @( t- w1 i - historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);" ^- E; L- S8 _5 s# b3 f
- viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
; `2 \7 M! R3 L - camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);; |) n+ P2 n( f
- modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);6 d9 e2 S) n3 }: z" x% q
- tree_control0->SetSortRootNodes(false);7 _/ h) W( M+ g3 ]0 d, r+ P; a
- modelhistoryNode->Expand(Node::ExpandOptionExpand);& r) s# z, f; L) r- s' ~
- // get all the features with values
; c2 A2 P; J+ Z5 q3 Y$ Z3 @ - 8 U$ ~! y; d! @
- std::vector <Features::Feature *> nodeFeatures = getfeatures();2 Y" M5 |/ \7 p9 L0 E% f& V/ F' L5 ]
- // insert the features
% k) D& `" {- W0 L/ U( \; R& R - for(int i = 0 ; i < nodeFeatures.size();++i)- a1 u+ o1 g$ a) F1 a+ R# j* m% Q
- {6 [/ c! J( Z2 X# |% X, f. k
- Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
& [+ k+ E) J! S# n- R I - tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);* k! `1 p7 H2 z, v! K/ c5 L
-
# u" v$ N" O7 s1 u/ h% U - featureNode->SetColumnDisplayText(1, nodeFeatures[i]->FeatureType());8 G% V( A9 }! A- W+ q5 N
- featureNode->SetColumnDisplayText(2,"check");( |4 U l/ j \ o& O* m
- 5 f7 K' z5 J% B5 |) u: U5 ^3 \
- }
4 k" O5 l; e0 d( v - ! `4 F" a# b" a" [ E& R) `
/ s4 Y: G9 a' k1 m1 _& B: t. k( I; y- }( K6 J5 C- ~ V* x5 h5 u( ~
- catch(exception& ex)
* q5 @% r0 J. ~3 r - {8 o; W2 |! ]1 x. _2 l
- //---- Enter your exception handling code here -----
* v8 R, I) f# X/ f - tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what()); m' B/ C& I# y7 \, C- y+ `+ x
- }
# E8 F4 e8 P3 d; {7 C# E - }
8 R4 F* B k' G! C& i- M( U0 Y" b
复制代码 1 N' p* X6 ^2 u0 ~
- w3 A) @* L" a) P7 c
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容! A& I% t; _' [" Z
5 t8 R j( Z- h9 n3 I, D
首先通过InsertColumn 定义列,有了列才能创建节点Node
6 Q) v6 p% k3 O. u% ~7 Z, U
; m* `% \6 A" j! F# v这个顺序非常重要!# e5 m0 j! G6 k5 ^( v
" L: s+ ]% k" b8 J
treelist 树控件创建
) t/ r7 D# ^% B7 l% k8 Y! B. _
% B- E2 M5 b7 p. p6 S |
|