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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()2 \9 s3 ^& S' d! w/ T+ z( v& L5 G
  2. {
    % c2 J. ]! O4 s. H) V! I
  3.     try' L# r6 u; q& V; E+ s( Z. Y
  4.     {
    : H4 e+ }" a+ v8 e& G
  5.         //---- Enter your callback code here -----1 |% G: ~, o. r" e- Y

  6. % p2 D5 T% `+ p7 G8 S9 J6 A, C
  7.                                 
    / R/ z9 t* O" S
  8.                 tree_control0->InserTColumn(0,"Name",140);
    $ Y+ b- j4 M0 f3 e& r8 A
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    , S* q, h8 h* _% f3 Q' C: J
  10.             tree_control0->InsertColumn(2," Up to Date",70);0 n4 @) J/ M: U. t
  11. - E+ M6 |9 C5 g
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
    0 z" M1 S" ?& {- ~
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    - w0 j) B8 v8 Y! {* V
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
    1 L0 d- {0 q/ S$ |
  15. + a; D( X4 L- n, m
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    ' E( L2 h1 ?* D* V* A

  17. + P# X% L& n0 t
  18.                 // create historymode
    ; x2 ?+ ?' j; Y( p: q# |) ^
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    ! A1 j4 O2 n3 a  a3 M3 V$ o# E  |7 j
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);+ o& a# S$ k# L, C
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);
    2 R3 m1 O3 E! _4 z
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);
    5 z  t8 Z. l9 T( U0 Q4 m
  23.                 tree_control0->SetSortRootNodes(false);1 F/ w9 G5 O( l3 k' }
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);3 U/ y' A: q* t  Q
  25.                 // get all the features with values * T. [2 Y# U  I" H% m

  26. 8 E4 }8 W0 I' ~- M* K7 Z' G
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();
    5 l) e, D8 B. s: w( y' W7 P
  28.                 // insert the features
    % q; w8 ~6 f8 s; @% T; w
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)6 G$ h* A5 N* F
  30.                 {. K6 V1 h# P9 ~8 K7 a3 q
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    ' _" P6 F- e0 D4 Z0 o6 E/ v6 y. n
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);7 v, z' `/ ]. S' ?+ r! I% O
  33.                         # F$ l( }; }' |# Z' _
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());9 U; G" T9 u3 Y7 P
  35.                         featureNode->SetColumnDisplayText(2,"check");
    $ N- U7 a3 }$ t3 B9 S
  36. $ e- T' P( R) c0 e6 I' J$ H
  37.                 }
    - W1 H2 z/ Q  M8 @, @  D
  38.         1 E; q, E! A6 g) c; i/ G7 o
  39. ) e. s9 b' d0 }# Z' \2 Q  \
  40.     }
    ' l1 Q$ s5 w0 ~  F) I& }
  41.     catch(exception& ex)& \: \! o. A/ W" P
  42.     {
    % Y& v# i7 }$ p- |7 j
  43.         //---- Enter your exception handling code here -----& M7 w; D  h: F4 @* J
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());! `. u! l! h$ Y% ^
  45.     }) J' ]6 F3 |/ p4 P9 ~( \
  46. }# O' b# v, }; _, @
复制代码
- Y7 x1 ?# ?5 l0 ]2 ^% ?4 l% j9 G! {' ~

; a1 i; T2 t- Y& @2 R1 t2 ~& [treelist的创建,需要在dialogShown_cb()里面定义treelist的内容
: i' l8 A3 y4 `5 Q! Q& P
+ n4 z% O& K% E3 L2 i1 b首先通过InsertColumn 定义列,有了列才能创建节点Node- L. g# A. @( _2 X( Z( k: x
- R; q2 t/ h* G' [
这个顺序非常重要!: W- r! _1 f! b

( v5 [* O8 z; S" t# K0 [! H3 q/ z

treelist 树控件创建

treelist 树控件创建

5 V1 q  H+ e( I0 n
% F# j1 o* a/ h2 w5 E
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了