PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()
    ) G' x6 l3 X% g
  2. {
    # m% h) o- ^4 `" |9 D; p
  3.     try' `, Q0 e' u$ G3 k
  4.     {  x6 l- {5 p. y' t
  5.         //---- Enter your callback code here -----; O6 G! \+ H  c
  6. * @/ u$ V, O! e
  7.                                 
    7 c1 E  `  r8 z9 n* C& ?% H% S( D* b
  8.                 tree_control0->InserTColumn(0,"Name",140);
    % e, P! |0 R, R0 v8 c' h
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    ! Z) F0 E. `) D1 ~7 S  T
  10.             tree_control0->InsertColumn(2," Up to Date",70);: u6 |8 d5 l& V4 ?

  11. 6 l% u$ g9 O- p0 O7 o$ i7 `
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);: t" n  v9 s, @; c$ Z; @+ q2 P" k
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);7 F6 o' E/ |; R3 T, w8 Z1 a
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);/ D2 d# B; O9 T9 z# n

  15. * a: x8 f) E& [1 M" r- i
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    ( Q! S/ q& p2 c! L$ k$ d" J

  17. 1 R# r8 B# F; N! |6 x
  18.                 // create historymode
    2 x, p9 n( h6 E- }
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);4 T% v1 w. b& ^6 i
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    - E- Q0 M0 J+ t" N3 I' S
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);, G. t. C# l+ X6 {2 k) ~2 V
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);5 t. E" Z' T' Z9 b& H
  23.                 tree_control0->SetSortRootNodes(false);* d6 D  P9 L& _! L
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    + O* |( k; s- e; ^: H9 C
  25.                 // get all the features with values , Z3 E( z8 f  G3 ^
  26. ( }" p; I5 r6 w# l' l
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();" s  A, `& A; N7 g8 r/ r9 x% p6 Q
  28.                 // insert the features  S/ R- i2 X! v3 V3 l7 a; J
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)9 d/ ^  o- D2 F3 i  g9 H
  30.                 {/ i& A( ]5 J% t& B, a3 A
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
      ~; R) @' @  ]7 [* e: J. g
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);9 g% ^. v& c4 d2 A* c. L) ?
  33.                         7 f% p6 o) m! n
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    7 B& ~0 [$ f8 p7 R* p* g! v
  35.                         featureNode->SetColumnDisplayText(2,"check");8 d* h# U# v! ]2 r, ?9 q

  36. ( a+ F  }% k0 U  K! r# \+ q0 Y" I1 {" h
  37.                 }6 t6 }+ y5 n$ S& {3 a, n
  38.         ( P8 D1 I) q9 f+ N( z
  39. 9 r( M0 }2 p3 w# y8 v) ?/ D  M- {
  40.     }0 L1 ~5 n: ~! K6 B* C
  41.     catch(exception& ex)* W* H1 p; f* J4 Z1 Q
  42.     {
    3 y  Q# b; L* p/ j8 ]' Q' H
  43.         //---- Enter your exception handling code here -----+ _. Y; H5 G$ ~
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());! [1 L4 U+ H+ _9 E" f
  45.     }
    9 U% u' h$ `" e# W' k  h/ R) t
  46. }
    ; W* R9 _& K9 K7 y% ?
复制代码
6 \) ?" H2 w1 M
& W* B" {; v/ ?2 z! i' x( R
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容
4 T/ G$ L% d8 h  N, J8 v: j
$ A2 ^+ g( h4 F首先通过InsertColumn 定义列,有了列才能创建节点Node
' v, z0 G9 X! B1 }/ B8 i2 u/ Y; E( ]
  A: n* V% b- v9 z- B9 |" D0 I这个顺序非常重要!6 T4 Z9 h4 L/ Q0 p+ k- u' L0 V

% M) ?8 E; k( V3 I5 D+ L8 g+ v5 e

treelist 树控件创建

treelist 树控件创建
7 Q0 L. ^$ o& A, q5 g6 b! e/ v
9 r. m+ z! Y, F& L
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了