|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- void tree::dialogShown_cb()# {1 p3 I. K/ @4 X
- {& Q$ Z% h$ B+ }& \& v5 z
- try
: m7 Q8 `! d. W$ C5 c6 P - {1 ]( Q) Z2 s/ b; r0 p1 r& R
- //---- Enter your callback code here -----' K3 P4 c+ ?4 t7 v" d, b1 {& T1 j$ O
6 p7 |6 }- e* i. i-
) k4 d; d+ d4 E% J - tree_control0->InserTColumn(0,"Name",140);! |/ R: r$ O V/ m5 f; b8 Z3 R
- tree_control0->InsertColumn(1,"Feature Type",90);1 ]$ ^0 E& O; c/ J# G
- tree_control0->InsertColumn(2," Up to Date",70);) y4 ?0 ]3 |/ ?$ b" f/ u. `
: G/ F2 a) y b+ S& w- tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
3 i- h1 z0 A: }0 H9 g3 U+ ~' T - tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
5 l1 g; v( i6 F( j8 u$ ^8 s - tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);, l1 i* c" Z& a$ }' ^7 O3 e) m
- 6 Q4 |# p3 n) f6 m( K; @
- tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);$ [- f8 o* D. R
/ t- U; E+ l7 z6 W- // create historymode( c( P. N# T' e6 n: [5 n
- historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);: A6 u0 Y; g/ S# J9 x$ s. _
- viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);) k$ M2 \" }% O7 l1 M
- camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);
/ I5 Q6 s+ U9 r! H6 z - modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);8 e0 e. Q Y5 `8 I% D) R
- tree_control0->SetSortRootNodes(false);) w6 O3 W/ |* D0 u4 e* L4 b: x& z
- modelhistoryNode->Expand(Node::ExpandOptionExpand);' b. H3 N" i/ e1 a& ^
- // get all the features with values ) o7 {) m* _8 G: M4 J4 `0 B# `
; ^ }7 T# p5 d; `- std::vector <Features::Feature *> nodeFeatures = getfeatures();
4 X. \: J( z- b2 _1 s/ C L0 P - // insert the features) L$ X+ @ J! l1 M1 S% b! [' H
- for(int i = 0 ; i < nodeFeatures.size();++i)0 g! }2 K E5 V- v( g
- {
' o, ~* n, C5 K( \ - Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
8 D* W2 c4 m) K& M' z - tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);6 N% }6 D6 [ d7 `7 H9 m
- ! b1 [ v4 h5 x9 B4 f8 ]1 P$ T
- featureNode->SetColumnDisplayText(1, nodeFeatures[i]->FeatureType());
, I- i" N% I& b5 A - featureNode->SetColumnDisplayText(2,"check");
; R4 h5 ~4 S* q: r0 h& E; \ - - R# |" c$ x* V$ r7 @8 b
- }
9 I7 R( b6 q# p8 n4 g1 b* z - ; ~$ F9 h" m) u6 O8 `
# l7 Z0 N& y/ N$ m+ S1 B5 o( Q- }
, K: ~" W3 \* n: B6 {* p$ r7 ^% Y& x" @ - catch(exception& ex)- B$ F. |1 n8 u) m, H* k5 N
- {
9 b! y8 ?/ [- _/ n- k5 M - //---- Enter your exception handling code here -----
3 B# U' z' f+ T, ^ - tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());- W: C$ e2 k: E) y. X
- }
9 }- s- x8 e3 ~8 B; O7 m - }. M$ Z% M/ @1 G8 w: Z2 h' ?
复制代码 3 c9 F2 c2 d# y5 V! M
* |* v0 l0 Q& C1 S1 p% Rtreelist的创建,需要在dialogShown_cb()里面定义treelist的内容
- V0 o2 z! A$ j1 C6 ^- v) U/ k6 R$ I2 B1 O: i7 s0 A! r
首先通过InsertColumn 定义列,有了列才能创建节点Node
9 k& d! f# F1 W( x' m1 P0 ?: d8 S. `! H) L
这个顺序非常重要!( ?( {6 O/ n7 W, F( g
2 k0 y- F0 `: C, u3 w
treelist 树控件创建
0 d. L7 n1 `' W
; G# j% n9 h( L( p! N& {8 R6 }
|
|