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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()
    $ g  j( E0 I  _# e
  2. {
    " [- P5 x  V7 o8 ?' t, `
  3.     try
    ; G1 y' U" b2 L4 E& w8 d  ^
  4.     {' v  D# \! ^' A4 L3 \7 A9 f
  5.         //---- Enter your callback code here -----
    2 L# t: ?* N( v4 U

  6. ) u! j* w% x* q$ k9 q( p
  7.                                 
    6 x1 ?" L$ t" u, G
  8.                 tree_control0->InserTColumn(0,"Name",140);
    ! `8 }+ z: R* i$ B0 Y0 Y" E4 Q8 D
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);* ^6 |% |$ i6 s( c% ?2 S9 E
  10.             tree_control0->InsertColumn(2," Up to Date",70);0 i7 a( \; V& g$ T6 [. [0 _
  11. : F+ ^+ A7 o5 N2 X" `
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
    6 n( h( ^; j0 S; L5 c: K
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);$ O2 `6 _4 Q, v4 Z9 @
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
    ) {% W9 [+ M5 X4 j/ B
  15. : d# l2 ?3 F& r+ D) s
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);+ b1 n9 ^- T2 K- x+ s* a
  17. & o2 {+ ]! ^6 A& U7 i
  18.                 // create historymode
    ! p1 W& b* M: a0 z( G: ~
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    , D* Y! P! ^/ W
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    - H& f. l4 g5 |; Y# d1 c2 W" T1 C+ a
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);
    6 Q9 A) C. V" G% c$ o
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);1 e8 X8 P9 _( Y4 g' G
  23.                 tree_control0->SetSortRootNodes(false);0 @. @' n$ D+ n3 i$ F( h  s
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);! |# V  j( l& |) ~6 M
  25.                 // get all the features with values 0 k- P: ]# O6 n* A  {  U
  26. . y3 \5 |  W) Z6 s9 Y& p
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();: c# l7 R" k* b( e  ~
  28.                 // insert the features
    3 ?: s: Y' ~0 {
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)
    ( O6 V+ ?4 e1 B
  30.                 {- Q" j3 R" U% H& t$ U# P2 i' s
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    6 U7 j. i, z2 `3 {
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);1 e' t  |% n- |. p1 \' H% @# h/ w1 H
  33.                         , l6 R  ]( U0 j7 H! Q
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());+ G1 o2 b9 [( ^) b6 h9 B
  35.                         featureNode->SetColumnDisplayText(2,"check");
    . T. X. o  o" c' H& P4 `
  36. % \' e* }) O' Y# P! \7 ]# |2 d
  37.                 }$ c. R! L( t9 `; n* ^
  38.         + k6 |0 g, b! N0 y; J
  39. 3 j+ q( y/ z2 A6 u
  40.     }! I$ j$ O' c+ \7 p0 [
  41.     catch(exception& ex)# O2 W6 S  r: u0 @+ k, N
  42.     {
    2 O! [- o+ T* f: b6 \# D
  43.         //---- Enter your exception handling code here -----
    # ]) L9 Z# h6 G+ z$ X
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());" G: l' J. m1 ^  ^! K% C8 e% t! d% |
  45.     }$ M7 f# ^7 }7 z4 z9 D8 H
  46. }5 I+ q( M$ q+ p5 l1 h7 F
复制代码
% Z  {; L! h& L. K

9 N& G: {: _. O# htreelist的创建,需要在dialogShown_cb()里面定义treelist的内容3 I/ k8 H" m( @+ i; P; e

; B) k, V. r; i首先通过InsertColumn 定义列,有了列才能创建节点Node
$ w8 `( Z6 L) Y" [
) _1 ?2 ?8 I. v( I+ U5 ]这个顺序非常重要!
9 ~; t& x2 v( E6 F% Z1 u) {0 G! s2 _1 [! i3 L; A) c4 t( g

treelist 树控件创建

treelist 树控件创建

, l6 W) ~& E- W, _1 _. ?+ U3 @8 w0 i1 f( B0 A2 ~+ m! v
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了