查看: 8067|回复: 0

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

[复制链接]

2477

主题

1280

回帖

8万

积分

管理员

PLM之家站长

积分
82265
QQ
发表于 2014-2-12 19:13:34 | 显示全部楼层 |阅读模式

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

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

×
  1. void tree::dialogShown_cb()
    # \8 O, a2 G6 V
  2. {1 {+ b4 d0 M* Y, G2 l
  3.     try! g' T4 D1 d5 Q8 l/ }3 X# y8 j7 j
  4.     {" Q. u# s  l, u3 e0 W+ _
  5.         //---- Enter your callback code here -----$ f: z& H) j  i: X2 E' R

  6. 0 h( e8 s) v/ D: ?8 y# `
  7.                                 ; Q3 h. D' X5 h( X
  8.                 tree_control0->InserTColumn(0,"Name",140);
    ( a6 H2 v8 e3 X
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);" Z1 M& x8 |8 b5 d: `  R+ `+ B
  10.             tree_control0->InsertColumn(2," Up to Date",70);3 I  C. ?" a9 Y/ u, q
  11. + G4 ]8 t# r/ g( a* {0 l+ [
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
    / t$ U  T2 P9 l7 X2 m8 K
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    ( v( [  q: y% r+ i; Y* [$ A
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);( r3 j( ~* K0 H6 i0 ^
  15. 7 k& J4 }7 {  e" s8 Q3 F( d
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    ; y' o* X. {# Q1 d5 E# S9 d
  17. % n& U7 ]' F1 J$ V$ _
  18.                 // create historymode' `* P9 g0 f9 K- S+ x3 N
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    . f- W- N+ ?3 u. v- o! l; d, V
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    # y% H1 W8 J( M, w
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);) Y( c* V* K# ~  W
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);
    6 h" S. S8 Y2 g3 _: t
  23.                 tree_control0->SetSortRootNodes(false);
    + q7 O4 x. j7 k, ^9 `) i/ @
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);# V. H# d; x( p/ Y% j4 J0 o
  25.                 // get all the features with values ; z/ g* r: T; A

  26. , w! x9 O; A/ O0 A3 v' v0 P
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();
    ) w# a7 C0 z* ?# p- l/ k
  28.                 // insert the features
    1 C5 i$ P. b& C8 T& J. N5 \
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)0 y$ g! N) j+ v( I+ Q3 W. E# O; R
  30.                 {
    + L# L/ ~7 G" X9 G( w5 O
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());% h. G  J. x4 W# a5 b+ k
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);0 |; e) f/ y: T/ j( R6 ~) e
  33.                         # [2 G1 P' H' P1 \7 Z
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    3 J6 W& N* t9 H4 F9 ]
  35.                         featureNode->SetColumnDisplayText(2,"check");) I6 c* e- J' b: R0 I0 H; T

  36. 5 e+ Z& x1 ~! L& |
  37.                 }0 E& ]# h) z% ~7 n% D
  38.         - W: E' k& l" o2 N

  39. * [, ?0 h! {4 u1 G
  40.     }: J& m( L) s7 Z2 [& g) d* R
  41.     catch(exception& ex)& j0 T" I  N' M7 W
  42.     {* x) P& A3 R# d5 \9 U! \
  43.         //---- Enter your exception handling code here -----
    8 @& n6 C+ `, B6 d/ i9 x7 s
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());( V. j+ E( K. m5 P* R4 U
  45.     }5 K/ l/ [" d( J; h) c
  46. }9 t7 r  b' o( x) J# q% ~
复制代码
( }& {5 ?5 k5 _, m. W! X8 M

& r' d" r' ?7 A7 i9 [8 I( itreelist的创建,需要在dialogShown_cb()里面定义treelist的内容6 M4 L. s3 Z7 X9 ^2 s5 s
# X$ X3 e% s. S
首先通过InsertColumn 定义列,有了列才能创建节点Node
, |- ^& ?1 Q" i8 Y
- U- Q* W( @) {0 x- e& d5 O& C这个顺序非常重要!1 q% ?. A1 T: u. c7 @

* k" U# N* d( e3 j% f6 B) M

treelist 树控件创建

treelist 树控件创建

% f1 m6 l4 ^; y, ^+ N
0 Z  C/ g2 i9 b' U% S3 a
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部