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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()" O% A+ B8 I* A4 Y3 r' l) Z
  2. {5 f+ `" \5 z) c6 Q6 k  D8 n
  3.     try
    - V( J$ n6 A( E; B$ N; R
  4.     {4 e7 k3 P1 b/ y
  5.         //---- Enter your callback code here -----" R" u; v( P# \& N! U

  6. 6 q2 T7 T" ?2 n0 p9 Q$ M
  7.                                 
    - w% ^) b3 d5 T
  8.                 tree_control0->InserTColumn(0,"Name",140);
    3 Q7 h1 R$ P) ^) h
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    / B4 ~# x9 W; D& O
  10.             tree_control0->InsertColumn(2," Up to Date",70);7 X) @+ J$ z! ~- {# j8 |
  11. 3 v, U' `. H7 E( |+ u9 V( P' a
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);  H4 B1 R5 q# o$ b- f$ L
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    ! l' P6 W+ H' V$ H+ F; t! M0 [/ F
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
    ' @1 K8 X( V- V5 t# z
  15. % P+ I- X, I1 w3 r  ^: e3 Z
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);" E: E* g% I! s/ y& c+ k

  17. 7 o( S8 p- L4 r2 u4 ~
  18.                 // create historymode
    * R- t" s* S, |8 ]+ B
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    $ N/ f  p. }7 T- m7 {% }# ?0 t
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    - r; A% x6 K2 `
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);+ I) I9 j4 I/ _" [& ~; C5 l
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);; l  f: p; L0 ]+ h0 i
  23.                 tree_control0->SetSortRootNodes(false);5 E! m- T' ]) j' F% D/ S
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    ( Z3 L* a8 T9 @3 Q8 u- V! x
  25.                 // get all the features with values
    ) n) e& t* m5 @, {! t7 d

  26. & U* h( A+ R4 D6 l6 P- [
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();
    " L0 G! T6 J5 g6 H  b) E8 t
  28.                 // insert the features
    / @. B4 E% n4 u8 d  A  q# Q
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)9 s. |9 e+ @4 c+ p
  30.                 {
    : e: X. c0 [! ^9 R- q5 b  q
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    8 ]* q: z, K- a8 A+ o+ y
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
    9 X% `6 f5 ?( A- U
  33.                         ; j# f7 v: P) J1 D, W* C; w
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());% K$ t0 X$ e' B' l8 E/ {! b5 f
  35.                         featureNode->SetColumnDisplayText(2,"check");
    ' e- p1 [' ~% ^

  36. $ p/ O: {3 ~7 d/ N, @
  37.                 }
    5 A) l0 j# w2 z8 n/ q+ W
  38.         * C" c$ C% x9 C0 V

  39. 6 w( H" L. N5 p1 l
  40.     }
    ( a$ \; n* F* x7 E6 |( |) h+ B% d
  41.     catch(exception& ex)
    : p4 L% h+ x; T8 V
  42.     {( O6 o! t( V" l! d8 }% k- B, y
  43.         //---- Enter your exception handling code here -----: `% H- p/ K: |. z1 o
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    - ]/ M5 @" q  G7 C
  45.     }2 c) m! m. ~7 w/ t+ s3 w, H
  46. }
    9 |: }$ Q  M0 Q& u: W* @% _
复制代码

, c$ T. C0 ^- d+ o+ p- i: e
4 P, b2 R8 Z9 n4 S0 c  L1 etreelist的创建,需要在dialogShown_cb()里面定义treelist的内容  C1 M, y- W/ I% p+ }( ?

$ m5 H- g! j9 o1 f+ n+ h7 @首先通过InsertColumn 定义列,有了列才能创建节点Node
4 b/ Y. C) F+ S* W, e1 e. k$ y% N
, h! f$ X5 K7 t& n这个顺序非常重要!
* [0 P7 V" e) h% p- x
. T; K, p0 t4 Z  p

treelist 树控件创建

treelist 树控件创建
8 n  L) r. q) I" O$ e
* N1 H" X. M0 `0 |
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了