PLM之家PLMHome-国产软件践行者

[二次开发源码] NX二次开发中treelist 树控件创建的逻辑过程

[复制链接]

2014-2-12 19:13:34 7532 0

admin 发表于 2014-2-12 19:13:34 |阅读模式

admin 楼主

2014-2-12 19:13:34

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
  1. void tree::dialogShown_cb(); V8 l( N' a( G0 V: r) m$ _5 X% k- f7 y
  2. {
    1 m% s( i5 n" k% V6 A" x
  3.     try1 |# e8 q! `5 s* l3 y# k
  4.     {& X+ o2 t9 J: y0 w, z* {) F
  5.         //---- Enter your callback code here -----
    % `- f% E% l! @$ N$ z2 ?
  6. ! x. {+ `# w" i* g+ P* O7 y6 H; g
  7.                                 : Z: U" [$ k1 L" r3 Y3 c- p1 @
  8.                 tree_control0->InserTColumn(0,"Name",140);
    , o1 j% i6 {. W, e: q: Q" q
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    * @5 V9 t3 m: U- f( O
  10.             tree_control0->InsertColumn(2," Up to Date",70);
    ( q  n  f( B8 B. }! {% `

  11. * ^& q! g3 d; t2 ^* P
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
    6 _( ^; Q6 H2 J9 ?0 V& l
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    & v/ J, l: o) K$ C8 Q. L
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);% I" V, ~( P! H" X

  15. # I; K4 v8 S( |  {
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    % z- e5 v0 r& M
  17. 7 m" E! w+ A7 @! w1 W0 j
  18.                 // create historymode) G) r; y. t. x
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);" t: d8 k) i; l5 L, h% U. }
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    - b, e2 T" Q! @- G  U/ ]
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);/ b0 a7 ?6 V& T
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);6 `2 N% C: H1 a% L7 P+ w
  23.                 tree_control0->SetSortRootNodes(false);
    + ^' s# f4 S; F# t
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    7 f& T! ^4 N& h2 G+ q: i
  25.                 // get all the features with values / Q/ n7 r* s% `* a1 J2 g

  26. ; y) H) y' d% c' G& G. B2 x6 H
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();9 o' P! y9 V. ~1 n1 C+ \
  28.                 // insert the features+ N' {4 b& A$ J( Q
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i); y: e5 X7 I# N' {) t
  30.                 {" ^, H; D, R2 Y; c. B% H# F) O+ z
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    " U% O" e' Y# f! Q! `* J
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);, ?0 L/ p7 S) Y/ p' _
  33.                         8 \* F: S9 k5 Y
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());2 s% p! e( w% `
  35.                         featureNode->SetColumnDisplayText(2,"check");9 i9 A% S; X" \, s3 }7 W
  36. ' I$ k9 R2 m& K
  37.                 }
    8 @3 c/ d9 b) Z5 _4 k
  38.         
    5 ]9 |' U1 f% [

  39. 0 |$ c0 t/ J# }9 T
  40.     }% Y, e8 h/ ~* G$ [+ {; @
  41.     catch(exception& ex)$ j% t  u3 G, x) O: v
  42.     {* ^/ c4 {  j+ f2 H  J/ e
  43.         //---- Enter your exception handling code here -----
    ( a9 h- h, {5 P7 V0 A$ P
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());7 t2 C, B1 [4 C9 U; ~9 x& V4 R
  45.     }" d% l! ^4 f; V' z9 U  r" @* g) K
  46. }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 树控件创建

treelist 树控件创建
5 K& Z! ]4 W4 A# |& M* ^; O9 t; m

% s( a6 T* d0 E& g# E
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了