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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()& f3 ]- h) h, Y
  2. {8 d& j/ E) Y. X0 `. s4 Q( d
  3.     try, F" E( c; x. T# U" Y, E7 x
  4.     {
    3 u( e; e$ Y, [& Z
  5.         //---- Enter your callback code here -----
    ; N) c. J8 m1 ^. W' T& l1 F! }

  6. " }, L3 C% [; b. ?! |
  7.                                 ) d% h" `! I- E0 ~4 l. `
  8.                 tree_control0->InserTColumn(0,"Name",140);
    8 \% b5 |; Y  f  `9 P" K# S. d
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    9 r$ D+ e$ J  ?/ Y# H/ Z
  10.             tree_control0->InsertColumn(2," Up to Date",70);
    9 D6 B+ `; T) [# }

  11. $ R# c; p- g" o
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);6 D  x3 A: y2 w* J  K6 k% h" m
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);( B( O3 s; `7 `1 U9 `# |) K# d
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);8 V( s! t8 N+ h* [2 m  l

  15. + a; n: |& Q5 d5 L" S$ C
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    ) I1 h+ \; ]' e& c: S8 o' Y8 L

  17. 7 G* l# }3 H4 ^: [7 `' K7 w' ?
  18.                 // create historymode
    ( e' q" Y/ G" \  R1 V: a
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    3 S7 F4 p( G6 K
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);
    ) S* q- Z% }" w2 y
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);$ x- |; D2 {- q- O/ ~% I% S8 k- A/ i
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);! `9 U" S7 ~2 G! z5 T
  23.                 tree_control0->SetSortRootNodes(false);
    - h8 R% P( d5 W8 r- e9 u
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    3 M: t2 L; C4 q& u9 F# r
  25.                 // get all the features with values 8 d& Y6 I, i3 b; l

  26. 9 I( X/ X9 ?8 A5 Q
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();$ U! G/ k3 V0 Y7 s8 I! [1 g# g
  28.                 // insert the features# f6 ~0 j  v8 E% X
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)& S5 H% o! `4 j+ a4 T) S0 `; Q
  30.                 {8 E+ p! d* q& J; B0 i: N/ T5 I
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    ; ?! \9 [2 d4 w+ l
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
    8 n3 F6 p0 \! W4 H$ x
  33.                         ; q; Y: b9 U# p; w6 f
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    * U4 g, D  h9 m3 e* _
  35.                         featureNode->SetColumnDisplayText(2,"check");+ R; G( w0 H4 r6 e

  36. ( {: i9 W* R' g" w, L' @( D
  37.                 }+ R& D* H; ]0 R& s" N( C
  38.         + \3 ?$ @1 W/ s+ E% Z# I/ G( x

  39. " l: r  }& x! s, ]7 [
  40.     }
    9 j  a3 M$ _/ n- u( M
  41.     catch(exception& ex)& W8 g9 h5 m* Y
  42.     {
    / q: R1 N+ j$ V; o, B8 N" ]( B
  43.         //---- Enter your exception handling code here ------ Z& }. u5 |* t) `( H
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    4 w9 n: O. A. f* R& V
  45.     }. N0 R! b- c8 G. }0 x
  46. }
    " C) }1 L5 t- j2 v2 S( H
复制代码
; P2 _% ^) z+ h0 b
. s5 G" s' ]1 z- @# k+ S" A, o
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容
' [& Q4 ]' T/ u7 ?: e. i$ b+ o' x7 W. D5 a6 M. B+ Y
首先通过InsertColumn 定义列,有了列才能创建节点Node  G& l" T/ g  M8 ?  o! a: T( H
) J6 X1 o# r! U3 C) d
这个顺序非常重要!( d. w( l( @% P" A
: K6 {. y- s7 q4 p) {9 R

treelist 树控件创建

treelist 树控件创建
  R! R8 W; ?+ d8 O4 @) }
/ z3 V( w: v" L- O
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了