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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb(), B6 w1 j! P5 L" S1 f9 D
  2. {
    ' w/ x& l0 M: c9 i
  3.     try
    # P% m+ T7 Q3 b  K$ a
  4.     {
    $ Z- a) m6 ~; ^
  5.         //---- Enter your callback code here -----( t- m& w. H6 D7 A
  6. 8 z  X% N# ]+ R: o4 \: a
  7.                                 , S1 @1 M5 K2 P5 H/ T: M( d" D0 x% v+ F
  8.                 tree_control0->InserTColumn(0,"Name",140);
    * d$ b( q7 x/ R+ s) x, F! d) q1 {& G
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);. A. ]: L4 R* r2 J6 v2 V
  10.             tree_control0->InsertColumn(2," Up to Date",70);  O% I$ A. P; Q4 C7 h3 s& @
  11. 1 F9 i5 N  ~* g9 [
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);( H5 ?% H" W- I
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    3 ~  p2 Z8 H2 E, B' p- r7 n- s+ o( W
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);- f1 i0 H) ?: D" e3 m: x
  15. . Z! u# B1 c& L$ t
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    ) r2 m" ^! u) ~1 V! W9 ^# q
  17. 1 y7 z  I: H0 A
  18.                 // create historymode+ Z) q0 l+ e5 u; `* g# J5 j
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);1 ~  S3 G: {  a& H8 n  D
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    ; ^: L" J( ?* R+ m
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);
    & b, \7 u' _4 k' r9 r4 D
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);) T. t$ W1 Z% T; ?% r% }
  23.                 tree_control0->SetSortRootNodes(false);
    / Y1 x3 `( [0 e1 B6 p
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    # j5 e( b' G+ }/ s7 V# H
  25.                 // get all the features with values
    ! Z4 w* x9 B3 T
  26. & I; W; {" v( m- O+ h& W
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();
    5 y4 ?4 u( f- W, m9 J" H: e  X- F
  28.                 // insert the features
    5 d; g6 l. M' w! t8 u
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)
    & l1 w" h, l3 ^+ q
  30.                 {5 [$ V" U0 G+ N  P7 P% K8 x1 ^+ h
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());. d3 Y- W) ]# {9 {) j
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
    8 C$ Q- s1 J% q. q) C! K
  33.                         
    , j' |8 T' q0 b# U/ }7 M
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    # t  W0 U9 ~- g; V% q& ^
  35.                         featureNode->SetColumnDisplayText(2,"check");3 v' S  }; I. S$ O- A6 t

  36. 5 t0 P2 l- s. r7 ]: N
  37.                 }, x% F6 W+ p6 ^- y+ |
  38.         ) g; X8 I1 S2 x4 ]* E: i
  39.   |; t" t( n; E8 Q# |
  40.     }/ v4 b0 `' Q# b- o
  41.     catch(exception& ex)/ u' Y- r: l) n! H
  42.     {9 ]. F/ E% A' d) f/ D2 s  |
  43.         //---- Enter your exception handling code here -----) y8 r/ m3 Q+ P0 p8 N
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    * A5 a1 E7 d# h* \
  45.     }; U) }) t+ k- ~, G( H: @
  46. }
    0 X5 n7 K% r. s) _, u: D. o+ y
复制代码

5 T' l- S; F+ `# v8 J) t1 U
  S1 {( T$ p4 Y9 d# [( Vtreelist的创建,需要在dialogShown_cb()里面定义treelist的内容$ ^* Q9 L( H/ @6 y  j

% \! P4 \' x" b  T' s8 i# E" j首先通过InsertColumn 定义列,有了列才能创建节点Node
% [' C. s: g. {/ q' i; p! P. Q6 v* Q8 @
这个顺序非常重要!: x7 o+ u8 ^+ F& c3 i

1 i/ k. n9 w  N% a& b+ k

treelist 树控件创建

treelist 树控件创建
" E- p/ J1 i" w+ m
8 S) ^9 T2 J7 O0 x0 a
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了