|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- void tree::dialogShown_cb()4 P3 {; a Z$ a Q
- {
0 ]5 G3 u" V' X3 ~' g- d - try
5 b9 H. G* W$ u1 a ^& w - {
" h2 [3 I% {& Z" l3 t* G - //---- Enter your callback code here -----# i; h$ h- }% g% s8 r$ L- d
- . L. W0 I# S' O. L
- 9 G) Z4 x$ c9 j( u+ a
- tree_control0->InserTColumn(0,"Name",140);
9 w- `, {; @$ X! ^( V - tree_control0->InsertColumn(1,"Feature Type",90);
h9 V% I* v P! D. [ - tree_control0->InsertColumn(2," Up to Date",70);7 S+ G2 I3 ^: B% R
0 [* C) Y' W- @+ g% Q" p- tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);8 O m3 i. J ?, _) G5 E' t/ Q0 f
- tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
: I( I( d8 G6 C; k4 f# y - tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);" f& I5 U" z( Y$ E4 D ]6 f% N1 m
- 5 M. t, B* ^2 U0 X" G% m& K
- tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
8 ~5 s0 x, H" e; ]) S" ?% x
' t% _7 U9 l0 t, T0 w% F# V2 c- // create historymode
* z) w$ N$ ~, x - historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
' I; \- z& E! a7 x7 B# Y - viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
/ B9 c2 ^$ o/ d2 K' E) |; i6 Y9 q/ c - camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);% V" Z2 e9 Z( S& d. `$ e9 V$ b
- modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);5 ~# y. k( p. }6 x/ p
- tree_control0->SetSortRootNodes(false);* E" F: Y- Y9 ]* Q2 l+ `
- modelhistoryNode->Expand(Node::ExpandOptionExpand);
$ m& n8 b/ K9 L6 A - // get all the features with values
0 w8 a2 h8 H5 |3 N* ^0 h5 B9 T6 A8 U - 3 y; s% E% r7 ]3 x- I
- std::vector <Features::Feature *> nodeFeatures = getfeatures();
1 x: v" Q6 ?2 e# o6 m7 _, b. B - // insert the features
8 t" u7 \) u' b - for(int i = 0 ; i < nodeFeatures.size();++i)
6 u6 u o2 {: `% k4 c4 p - {
+ I' O- L! }) z - Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
- \. ? \3 ]: J6 z - tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
: f: p* ^- _ W) P' q -
' `( m, ~" h, S - featureNode->SetColumnDisplayText(1, nodeFeatures[i]->FeatureType());( ~1 N& e0 Z* _& _
- featureNode->SetColumnDisplayText(2,"check");9 ~8 O# @- U2 {) f) A& a0 W. V' D
" ]6 x' K5 h4 C( P- }% ^& x. u5 h6 W
- , H( p( @" k/ Y' h! R+ j4 ?
' n" k E# N |6 D T: j4 i, B0 W8 i- }" x& O- |1 t( o. ~" b; ?; Z/ Q
- catch(exception& ex)! W: u+ r6 B; V$ D( M: n
- {( P( u8 o% [+ L1 K
- //---- Enter your exception handling code here -----
: h5 f+ E3 l# {' _, _* v - tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());. U% [; {6 M+ L0 n
- }
& @8 S S7 q. P; e' K - }# |: V9 C6 f* @: V8 r$ E
复制代码 ( [1 a* b E8 [# { D1 M
; d+ |$ f2 J0 s3 w, h' w
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容
. j. s4 r8 q- O" {9 h9 W# l1 I* h2 k, l2 L: m. `. C
首先通过InsertColumn 定义列,有了列才能创建节点Node
6 \0 n8 }4 u- b9 n; {0 H) k% n" b1 R4 J5 q
这个顺序非常重要!% t$ Z6 o5 y* ?
: n7 t4 _7 Q7 v3 ^' u1 ^7 t
treelist 树控件创建
$ |, Z7 S7 {: o8 b; a U/ b1 \8 a
9 z0 v! S; ^0 j8 x5 W" H |
|