|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- void tree::dialogShown_cb()
* Q( A* T$ m& U# h' Y - {" ^2 c! n) u5 o8 ~! b
- try
$ H. I5 ~' ^( h- d, ] f t$ h. r - {% q6 Q. ~1 F9 J) Q& h
- //---- Enter your callback code here -----
: E" Z) L- a: z$ X8 O
7 w& ]! B% S3 R* L% D, d9 R% t- 6 U4 C$ ~' ~& z3 {/ K
- tree_control0->InserTColumn(0,"Name",140);& W( | A" ^5 H9 `' U# k8 I
- tree_control0->InsertColumn(1,"Feature Type",90);
5 d( S1 U i4 k$ g: v; P0 [ - tree_control0->InsertColumn(2," Up to Date",70);
* N5 U1 T6 H: U2 Z% `4 M# o4 @$ p
! m7 w* X6 R' a8 \6 l' c6 g- tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
- r2 h! d1 W- v' P3 ^1 \1 w - tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);( W% o/ V- T. K, I0 ^6 z; y
- tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
% j% [( I* T1 q/ J# O6 L$ ~0 c- K) [ - # V3 L5 ^# S Q" O, i
- tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);- U; z4 S7 j) h) f! K: g! {
7 w9 w4 B1 o0 F+ ^- // create historymode
6 S4 L% ?! p( z' ^2 [& [ - historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);# o" z6 {' L* U$ K+ \1 v8 M
- viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast); D5 I8 a. b4 t$ [6 W v) ^
- camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);5 b* o) ^( O" I" y' z8 Y' L
- modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);* _5 I5 h7 U/ Y3 K
- tree_control0->SetSortRootNodes(false);& |1 w0 Y8 V4 Q% T8 j2 ]& v0 Y& ^! b
- modelhistoryNode->Expand(Node::ExpandOptionExpand);
+ e1 C+ W. U4 C6 K1 P' H% S9 d, p - // get all the features with values 4 e. F- t5 i* x, V1 J6 `" d
3 _2 q% }% V2 f" y0 w8 a- std::vector <Features::Feature *> nodeFeatures = getfeatures();
7 o# m, n$ k8 k+ f* [ o - // insert the features
& X% C) j; r# [6 n: K; c - for(int i = 0 ; i < nodeFeatures.size();++i) n& k$ }, c) [0 o T1 R9 Y
- {
5 h( S+ k; M4 ^* Q' s; _7 l - Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());) D- {, c$ B9 D7 o( k
- tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
( f1 ^, n6 P0 C* d -
% v% J; o/ Q) e4 @8 j- i: M C - featureNode->SetColumnDisplayText(1, nodeFeatures[i]->FeatureType());
2 N. y$ D% N! s6 p9 X - featureNode->SetColumnDisplayText(2,"check");
4 M! T0 g% A9 T! o0 i8 I* b% ]* L* J
, O/ k& `4 A. Q6 ?4 p* b- }
/ d4 w$ U# A+ R: N: ^9 r" ` -
. Q8 h6 a. B+ `1 V, n - 3 ~6 h& C( P* j5 m3 ^
- }, ^5 e! P8 N, a0 H- Z; Z
- catch(exception& ex)5 M7 a+ s- @) B# n& h: V
- {
4 e" \1 B/ F6 t; Z) p c - //---- Enter your exception handling code here -----* M. J+ L" S8 T! `$ M( W4 }; H
- tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());" f$ b# i' K: n; S
- }- F/ a" }) O7 v X) I
- }- m8 _8 V: Q3 w! K% N" {8 `0 T
复制代码 , B" R1 W. L( `4 `& p* C
1 A1 X% A& T4 @/ H9 Q
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容& g& @3 S' q& R8 [9 ^/ P
7 |# n3 |) v6 ~& s, N
首先通过InsertColumn 定义列,有了列才能创建节点Node4 g! e9 l2 A% f- H8 T* p
. [2 V" x8 ]! p! z- }
这个顺序非常重要!
4 Q$ ~# B7 [$ ~+ Q, ~8 G" b5 q( l+ @9 _
, s" d. v, E% ~, W& B- N8 j
treelist 树控件创建
* C4 N0 a6 M5 w7 Z% |; r% e% e; o
8 s8 ~0 F! O3 {# p+ ~6 | |
|