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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()
    ; b9 i% ~/ C) W# D
  2. {
    5 a- d' I2 o2 d  ^' l
  3.     try
    $ u) }4 L6 B7 M% V
  4.     {
    9 N( {: Z2 f$ u/ j
  5.         //---- Enter your callback code here -----
    / Q1 }) ^! }& u4 h: A

  6. + K8 Z( `% N$ X  c+ t9 g
  7.                                 1 ~; O9 y0 m+ u/ b
  8.                 tree_control0->InserTColumn(0,"Name",140);! e9 H8 A! S/ E& ]5 p
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    8 m% f! c3 U% _5 |2 Z
  10.             tree_control0->InsertColumn(2," Up to Date",70);6 z/ [0 I0 d+ P7 E- T5 S- r

  11. " s5 {3 M& L$ ~, J
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
    : s2 i, u7 [8 J: [$ K. d1 |
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);( l  k# G6 X& _# K) S
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
    5 t) x7 M5 a4 V0 |& B) f
  15. $ R+ Y$ T! g4 z, C& u) L  B
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);0 v$ c+ T; d& u: o
  17. ) q- G+ H, [8 p7 P4 k, R7 r9 r
  18.                 // create historymode* f3 L8 L/ u/ L. ~
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);; @$ T+ c, |- Y* i
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    % v: k% z; s/ j8 f2 b$ _
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);1 J0 {9 s2 c, A$ q% _
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);6 r' O& @" s) x& F. z$ V
  23.                 tree_control0->SetSortRootNodes(false);
    2 n! W$ x3 j, ]' t# f
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    * o4 U3 g7 Z2 G* o' ^8 V- ?2 v
  25.                 // get all the features with values 0 u- o% h+ Z9 _4 i
  26. & d! y* x" {6 ?$ V6 \+ F2 x
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();7 F( q4 Y' \* N8 m$ W
  28.                 // insert the features+ c' r' I7 O! c9 R
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)) t8 O( g) r; F, N
  30.                 {
    / P: v$ y' N" t! A3 U  b# i
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    ; {4 m7 L, f: \; A
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);7 t- g: v, L: v' Y6 L
  33.                         
    ( @: W+ y+ a# O/ D1 |( x3 ~
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());0 ?! d; x$ n3 `& R
  35.                         featureNode->SetColumnDisplayText(2,"check");
    8 D! a# v5 w7 P$ t

  36. : r4 p) \( ~. |5 R' L* u
  37.                 }  [, _9 r8 T: @) Y) C  F( ], @
  38.         . S% ?+ J4 ?( Y+ r7 j8 a- o2 D
  39. " N5 T5 Z! G$ C
  40.     }
    + s; p) m1 S) c8 ~+ Q
  41.     catch(exception& ex)
    ) P4 ]* {" ~- Y7 E( v, E
  42.     {
    ! \. @9 J  C. e5 @
  43.         //---- Enter your exception handling code here -----, ?; t: }9 K) d% @, G
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());$ E8 p4 q( W$ }! v* f" ?  B
  45.     }
    % P7 c+ V4 n2 C
  46. }* l1 D" e# v! \6 N" W
复制代码

3 u) v) l4 u2 x- o' E/ {* v8 F* A9 ]# X9 }) d2 M# t# R5 W
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容) c5 x1 t9 V. b

4 F& t+ l6 t0 h2 E2 ~0 Q0 t1 I首先通过InsertColumn 定义列,有了列才能创建节点Node
$ E0 g2 l6 F, `: l6 w: h- T0 p! Z7 U. t. H
这个顺序非常重要!3 U6 r5 g0 D0 z
4 C" u2 h2 c/ B3 U7 S/ S: \4 Q

treelist 树控件创建

treelist 树控件创建

1 H0 i/ j+ k, A$ y; i8 @/ W: W+ b1 X) w, H: e  n+ _' W
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了