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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()2 @. ?' r, q& _% s( H/ v# j+ F
  2. {# `* x( c. ^$ g) a
  3.     try& T# u. f% P! t; f# ]2 e
  4.     {% Q. {6 z  R4 }/ k
  5.         //---- Enter your callback code here -----3 W& [# L. v# |0 d5 E% }3 _4 n5 `+ H$ Y
  6. " [6 ^  e& V" y
  7.                                 
    ' I9 w$ L" b) n4 D0 o& m' U8 e
  8.                 tree_control0->InserTColumn(0,"Name",140);8 F/ Q# T0 L$ V& _' D
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    6 q) p5 B" E9 o6 h# s9 t: m
  10.             tree_control0->InsertColumn(2," Up to Date",70);9 l, n. F, m8 S5 z* p3 R' q
  11. 8 L* P3 L. O0 J2 U+ n2 Z( p  _
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
    % ?8 E0 q4 a# C8 `0 S
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);& y7 L  m1 F' m6 R" F# l8 m/ [
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);$ M6 _3 `  t! t1 w% \# Q& [* ^
  15. & x( v/ p# G! m( Z4 e, k4 h( V5 h3 _
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    " S' G) E& G: L) M. E- _8 a
  17. $ ?+ L* J% \( `) S" l/ o/ q
  18.                 // create historymode
    + w7 X  n: d5 @( t- w1 i
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);" ^- E; L- S8 _5 s# b3 f
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    ; `2 \7 M! R3 L
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);; |) n+ P2 n( f
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);6 d9 e2 S) n3 }: z" x% q
  23.                 tree_control0->SetSortRootNodes(false);7 _/ h) W( M+ g3 ]0 d, r+ P; a
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);& r) s# z, f; L) r- s' ~
  25.                 // get all the features with values
    ; c2 A2 P; J+ Z5 q3 Y$ Z3 @
  26. 8 U$ ~! y; d! @
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();2 Y" M5 |/ \7 p9 L0 E% f& V/ F' L5 ]
  28.                 // insert the features
    % k) D& `" {- W0 L/ U( \; R& R
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)- a1 u+ o1 g$ a) F1 a+ R# j* m% Q
  30.                 {6 [/ c! J( Z2 X# |% X, f. k
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    & [+ k+ E) J! S# n- R  I
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);* k! `1 p7 H2 z, v! K/ c5 L
  33.                         
    # u" v$ N" O7 s1 u/ h% U
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());8 G% V( A9 }! A- W+ q5 N
  35.                         featureNode->SetColumnDisplayText(2,"check");( |4 U  l/ j  \  o& O* m
  36. 5 f7 K' z5 J% B5 |) u: U5 ^3 \
  37.                 }
    4 k" O5 l; e0 d( v
  38.         ! `4 F" a# b" a" [  E& R) `

  39. / s4 Y: G9 a' k1 m1 _& B: t. k( I; y
  40.     }( K6 J5 C- ~  V* x5 h5 u( ~
  41.     catch(exception& ex)
    * q5 @% r0 J. ~3 r
  42.     {8 o; W2 |! ]1 x. _2 l
  43.         //---- Enter your exception handling code here -----
    * v8 R, I) f# X/ f
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());  m' B/ C& I# y7 \, C- y+ `+ x
  45.     }
    # E8 F4 e8 P3 d; {7 C# E
  46. }
    8 R4 F* B  k' G! C& i- M( U0 Y" b
复制代码
1 N' p* X6 ^2 u0 ~
- w3 A) @* L" a) P7 c
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容! A& I% t; _' [" Z
5 t8 R  j( Z- h9 n3 I, D
首先通过InsertColumn 定义列,有了列才能创建节点Node
6 Q) v6 p% k3 O. u% ~7 Z, U
; m* `% \6 A" j! F# v这个顺序非常重要!# e5 m0 j! G6 k5 ^( v

" L: s+ ]% k" b8 J

treelist 树控件创建

treelist 树控件创建
) t/ r7 D# ^% B7 l% k8 Y! B. _

% B- E2 M5 b7 p. p6 S
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了