PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()
    ' g- q! _! g8 Z; z( h, e- g
  2. {
    1 F/ p/ f& r+ f0 m/ G4 j- E6 B% h: O
  3.     try; p' U2 H) @+ |  @& a
  4.     {# O& J/ m; l% K" b
  5.         //---- Enter your callback code here -----% ~+ }  A! q# X1 \
  6. / v% w* ~- ~& j% L9 T; j" ?
  7.                                 " o; c/ c. W0 F4 d
  8.                 tree_control0->InserTColumn(0,"Name",140);5 y$ o4 u% d, e8 \. n
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);7 N- N/ Q4 m! c& b% q. @
  10.             tree_control0->InsertColumn(2," Up to Date",70);
    - j0 u; ]8 n$ x1 E/ N; g$ L) S6 ~% x: L
  11. " h4 I3 z( e% q2 O, d2 S: @
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);% u8 r, `' Y7 s( a! V
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    % e' B; @+ z$ v  ]: g
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
    6 B0 [. m; ?6 C2 ?6 ~8 E& |% E
  15. 0 V6 L7 Y. C. J  o8 n
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);) R' v& A( y% R. C7 B7 V, B- O: {
  17. 2 W! e- g9 N' N/ X7 f4 N
  18.                 // create historymode7 ~+ U( g$ _( i' m7 L
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    7 M% u7 a6 D8 `# z, n
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    & I% N" a% ?/ S# |
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);) Q' o) |( N4 M6 ^8 }9 ~& W9 h, ^
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);3 U8 N2 r& B; i8 B" c" ~/ s' C
  23.                 tree_control0->SetSortRootNodes(false);( {- k) r0 Y# q4 |
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    : w" z. u% W( u5 [% o* ^( G. m
  25.                 // get all the features with values
    3 a; h" U  L- B3 Z0 |- q4 V) {6 [/ _
  26. - z, [: v* _+ V5 |% j
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();5 ^& ~3 V8 Y' s0 Z( h- S8 m
  28.                 // insert the features
    % [+ y' V. x$ i
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)+ w* E0 J# w- N, ]
  30.                 {9 [4 }: F- ]5 P/ ~% K& c$ \' a! i7 q& Q
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    ( Z1 f' T) e) {: Z8 d
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);" z( g' K* a, U+ N1 N
  33.                         
    # A. x! s# }: d% s& v
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    ( D! K. I5 |5 N" s4 c$ }: I
  35.                         featureNode->SetColumnDisplayText(2,"check");
      f" f3 |, r! C$ D9 m$ w& g
  36. . }: l# r# }, T- r1 O% U( h: z
  37.                 }
    ! K: E6 [, I  e* u" r
  38.         
    & Z5 x3 ]/ l2 h

  39. $ l$ a3 {  b9 ~% O" U$ [# y0 D, x( [* O
  40.     }8 W. r/ M3 F/ o1 d3 \3 a8 F, N( K) e
  41.     catch(exception& ex)) S+ U8 c9 M7 z1 Z6 C( a) D5 W# d# C
  42.     {" h2 f3 n0 u4 R. C
  43.         //---- Enter your exception handling code here -----
    ) ~. b  C/ F- C; Z' I0 p& L$ ^5 z$ ]
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());$ r9 w2 G, A; _# q+ n( C2 Z
  45.     }  h- X  h. N% F  N( I4 e
  46. }' J7 q. O2 S5 X4 j
复制代码
3 ?. C+ F9 X2 Z" W7 N) b
# J2 e3 e; @, v1 g3 D
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容
2 Q2 p1 u) f# z' q. F$ D' ^- m3 Y6 v7 f
首先通过InsertColumn 定义列,有了列才能创建节点Node
9 s0 z! v% b4 x5 p7 \( |
$ H: N6 Z) X$ f, R这个顺序非常重要!
+ |, ^6 M7 G3 Y: F3 S9 y0 U4 H4 h2 ]/ V/ k6 N3 x

treelist 树控件创建

treelist 树控件创建

0 h" T4 r* B9 s- }; }) i4 `: e3 M  I6 U" c6 `
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了