PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()1 `  K: W  N: c4 L
  2. {
    * O$ M# c! a8 ~, P( K- b8 B1 g& @% I
  3.     try
    3 v  A& i$ R# Y# ?# D- j
  4.     {
    ( t1 X3 [9 U1 n5 Q( _% O, \1 S
  5.         //---- Enter your callback code here -----
    0 s! @. g. a7 b* q  Y4 Z

  6. , d$ r, H1 I1 q
  7.                                 / W# t! {- E. `
  8.                 tree_control0->InserTColumn(0,"Name",140);  f5 y2 a5 u$ B  n4 p
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);. I. R3 T, X5 j
  10.             tree_control0->InsertColumn(2," Up to Date",70);% v# h! e* U2 t) x% E$ D
  11. ! U! L2 K' Q3 ^
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);. ^9 R, l$ s0 \4 P& S9 }  W
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    + U$ X5 V  q/ ~$ S1 |
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);( M, v  e' t7 _# Q/ {- U
  15. 5 R- I% i% d$ P8 G" {6 d  j
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    2 f) t* f. v7 G8 Q4 x# z
  17. ! J% I. M' A  [; C6 _
  18.                 // create historymode: X0 Q& L! Z; U" \+ w4 C
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    0 I4 X4 A% U) ^1 W
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    2 T8 e. X  z$ s) x  Q
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);3 K+ J% ]5 [! M
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);
    2 X( P4 O$ m4 `$ ^9 T( M
  23.                 tree_control0->SetSortRootNodes(false);
      F; C/ [& A5 t5 e9 e
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);4 u& B. T5 e7 F# I) H( k
  25.                 // get all the features with values
    / V' b$ [9 ?& x% h2 M0 I. |
  26. 7 ^( c: X, q! V: ?4 q5 K  g% G/ m
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();
    3 h* [8 S2 H, T2 F: B: M' G
  28.                 // insert the features
    / T* a0 \* n5 G3 @
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)' ~+ C% C' ^. Z8 d0 h. h( `
  30.                 {
    " I. [3 y3 s2 h
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    : j6 H. ]( k" n( S  i
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
    " |& ~, d1 l/ ?4 g1 m, X
  33.                         0 D$ w" ~7 _( ^) u
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    & M: `/ g% i' g2 z
  35.                         featureNode->SetColumnDisplayText(2,"check");& m3 N# h+ ]6 F. N2 @" F

  36.   q1 S, K- M# e6 I- u
  37.                 }5 i7 x! \. P* n% F% L; p
  38.         
    % C3 Z* S/ p  M: m2 V  K2 j9 i

  39. 6 q' W4 {4 t3 n8 q" N% h% [
  40.     }: k% y- H/ t  s3 T
  41.     catch(exception& ex)
    / B, _# N6 G9 O, i, _4 N
  42.     {7 a. P1 Q4 U* s  A. X
  43.         //---- Enter your exception handling code here -----8 c* s" E5 b! P% [, }
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());3 D- S5 ?- d- T1 X: U1 a4 v* @
  45.     }
    + P, G& q  j+ w, m5 B( s
  46. }: `) k# D. e& ]. `
复制代码
1 A7 ?6 P. m/ f2 e4 E/ w! {3 \- F

2 [# c# ^4 Q2 H1 ~+ w# Y5 G1 X/ E/ Ltreelist的创建,需要在dialogShown_cb()里面定义treelist的内容% K; K' o6 c8 [
7 {% w* ?+ U9 N9 ~
首先通过InsertColumn 定义列,有了列才能创建节点Node: I- d7 n' ?, W! Y9 x, L7 M9 y" W
( W1 e) }2 ^2 M) X. X
这个顺序非常重要!
0 c) g$ J8 `* w8 m0 O/ h& W/ l5 i  _+ s" B8 T1 t8 u

treelist 树控件创建

treelist 树控件创建
* ^9 [9 R7 F' L. k
  t! ?( o1 J3 X# g  l# x/ k
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了