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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()3 C3 W0 g) S4 X: B! X
  2. {
    * v' F0 z: v0 ^
  3.     try4 Z( H* F( h; C0 ]; O
  4.     {
    ( O! ~+ B' z1 z) W3 b
  5.         //---- Enter your callback code here -----
    & ^/ F; x9 `# c# s3 B  i2 U
  6. 5 E3 Y! J3 G9 ^5 S1 j
  7.                                 8 n1 V5 Y8 N' q2 Y
  8.                 tree_control0->InserTColumn(0,"Name",140);
    8 e6 a; V8 k4 I* L' l) e
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);; i" m& u! t, M5 H# g& P/ e
  10.             tree_control0->InsertColumn(2," Up to Date",70);8 ~3 @! I$ M, v$ J0 j, B9 }
  11. , g( q/ U; U5 ^0 d# [( D  E6 E
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
    4 V. d& t& x7 K3 u2 R4 o
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    $ {! P# P2 o$ l$ t: ?, h" H) Z! I' s9 B
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
    3 K- [& h, z0 ?" D% s  y

  15. : k3 {: |$ i0 U& c# A
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);5 L, H, h9 c2 H
  17. 4 Y* M" O# C/ @$ Q2 e! |% }) B
  18.                 // create historymode
    , r* z7 O: N/ N6 l
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);- `1 g% k- Q2 L- R
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    7 J! @" t0 D1 m+ H( ]
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);
    ; o4 V0 b+ h* v- d4 y
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);
    1 Z) ^% n4 L( S( Q  g
  23.                 tree_control0->SetSortRootNodes(false);3 [7 N$ X/ s2 Q0 t$ P5 _- B
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);; t0 u4 \$ d+ q
  25.                 // get all the features with values
    : m2 r' V; f2 f; h- H6 M# ^9 U

  26. * h$ X4 h) V7 k
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();
    0 e5 e7 s7 k, w5 \6 V& r8 |( A% n- ^) S2 M
  28.                 // insert the features6 u" O; w2 F4 B: o' ^& {) [- O
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)5 `$ ?: e" \  K8 t1 l3 S: U5 f
  30.                 {
    4 r/ K0 Y* l5 z- p5 ~
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    ) ^; c" P$ x) [: j' P! Q0 W9 Z- l
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
    ) |8 W, v0 J7 Q4 M, n, A: U
  33.                         
    - J: C5 T1 e7 r( D5 |4 V+ x2 |
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());2 `# v' C& L- q
  35.                         featureNode->SetColumnDisplayText(2,"check");' b! b% F, e5 \; u. W

  36. 0 L% I% h; T3 o3 \' A5 h5 g
  37.                 }" G& H1 z7 P7 ~% o8 n
  38.         
    ) w( A( N2 _& E7 O6 J

  39. # q" T- v" H& t$ Y
  40.     }$ x+ @4 G# M# H- u1 e) h+ l
  41.     catch(exception& ex)
    ! d- G" U3 q- U3 F3 i. }
  42.     {
    ; }. N$ B6 D6 y
  43.         //---- Enter your exception handling code here -----
    , h  s5 s8 z! d! s3 F0 o- ?0 q) l
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());' o8 t: |; {, }
  45.     }
    2 ~1 O) o6 b5 l+ B! z( q
  46. }
    $ D  |6 P2 p) y8 t! |
复制代码

5 w7 K0 Z  \' j
* u) E/ M; `5 ]0 rtreelist的创建,需要在dialogShown_cb()里面定义treelist的内容0 O  w* @( d2 d4 a2 e: M8 U

; y- j/ y' e, t/ f6 K首先通过InsertColumn 定义列,有了列才能创建节点Node
+ d! g- W. [; C' y  `% u( Q/ w  q  g
这个顺序非常重要!* O) I6 ^& _, u. H3 z
/ ^- v1 ]) C( R; p/ p' X

treelist 树控件创建

treelist 树控件创建

7 Y0 ~/ `. Q# ^- }/ E1 {
. \% d8 s& z! P' a9 d
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了