|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- void tree::dialogShown_cb(); V8 l( N' a( G0 V: r) m$ _5 X% k- f7 y
- {
1 m% s( i5 n" k% V6 A" x - try1 |# e8 q! `5 s* l3 y# k
- {& X+ o2 t9 J: y0 w, z* {) F
- //---- Enter your callback code here -----
% `- f% E% l! @$ N$ z2 ? - ! x. {+ `# w" i* g+ P* O7 y6 H; g
- : Z: U" [$ k1 L" r3 Y3 c- p1 @
- tree_control0->InserTColumn(0,"Name",140);
, o1 j% i6 {. W, e: q: Q" q - tree_control0->InsertColumn(1,"Feature Type",90);
* @5 V9 t3 m: U- f( O - tree_control0->InsertColumn(2," Up to Date",70);
( q n f( B8 B. }! {% `
* ^& q! g3 d; t2 ^* P- tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
6 _( ^; Q6 H2 J9 ?0 V& l - tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
& v/ J, l: o) K$ C8 Q. L - tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);% I" V, ~( P! H" X
# I; K4 v8 S( | {- tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
% z- e5 v0 r& M - 7 m" E! w+ A7 @! w1 W0 j
- // create historymode) G) r; y. t. x
- historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);" t: d8 k) i; l5 L, h% U. }
- viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
- b, e2 T" Q! @- G U/ ] - camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);/ b0 a7 ?6 V& T
- modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);6 `2 N% C: H1 a% L7 P+ w
- tree_control0->SetSortRootNodes(false);
+ ^' s# f4 S; F# t - modelhistoryNode->Expand(Node::ExpandOptionExpand);
7 f& T! ^4 N& h2 G+ q: i - // get all the features with values / Q/ n7 r* s% `* a1 J2 g
; y) H) y' d% c' G& G. B2 x6 H- std::vector <Features::Feature *> nodeFeatures = getfeatures();9 o' P! y9 V. ~1 n1 C+ \
- // insert the features+ N' {4 b& A$ J( Q
- for(int i = 0 ; i < nodeFeatures.size();++i); y: e5 X7 I# N' {) t
- {" ^, H; D, R2 Y; c. B% H# F) O+ z
- Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
" U% O" e' Y# f! Q! `* J - tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);, ?0 L/ p7 S) Y/ p' _
- 8 \* F: S9 k5 Y
- featureNode->SetColumnDisplayText(1, nodeFeatures[i]->FeatureType());2 s% p! e( w% `
- featureNode->SetColumnDisplayText(2,"check");9 i9 A% S; X" \, s3 }7 W
- ' I$ k9 R2 m& K
- }
8 @3 c/ d9 b) Z5 _4 k -
5 ]9 |' U1 f% [
0 |$ c0 t/ J# }9 T- }% Y, e8 h/ ~* G$ [+ {; @
- catch(exception& ex)$ j% t u3 G, x) O: v
- {* ^/ c4 { j+ f2 H J/ e
- //---- Enter your exception handling code here -----
( a9 h- h, {5 P7 V0 A$ P - tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());7 t2 C, B1 [4 C9 U; ~9 x& V4 R
- }" d% l! ^4 f; V' z9 U r" @* g) K
- }8 t# y: a0 K7 c! a* q! `3 C5 S
复制代码
# E. r* u. S. \- T
5 W. r7 l% \6 s+ m5 F8 ?treelist的创建,需要在dialogShown_cb()里面定义treelist的内容: v B( s$ G( T% H
7 ^: J- _9 |1 U& b3 Q
首先通过InsertColumn 定义列,有了列才能创建节点Node
; q$ ^4 j% v( @$ X7 m. ~3 a9 j7 R6 _) D) F& \1 b
这个顺序非常重要!. w8 O' j& R$ [, c, X( j
2 T, W" U) q" q( m# c
treelist 树控件创建
5 K& Z! ]4 W4 A# |& M* ^; O9 t; m
% s( a6 T* d0 E& g# E |
|