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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()
    6 R% b5 X  [; N* q, `0 \9 ?
  2. {% d0 e5 [% N( M1 w, O1 V
  3.     try
    , N% X1 c9 u9 H2 q
  4.     {
    , q7 Z3 R" A. `
  5.         //---- Enter your callback code here -----
    6 R# _, n4 w: x, E
  6. 6 A0 P1 `( `- X+ w
  7.                                 
      Y/ k3 t! p- V  M5 ^3 H2 M4 u! Z: X
  8.                 tree_control0->InserTColumn(0,"Name",140);
    : a9 k0 B( P/ C+ H
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    . c6 f: A6 D! q6 H
  10.             tree_control0->InsertColumn(2," Up to Date",70);: d; m+ S; }0 I; x5 o' Q, z+ A, J

  11. , K5 a6 I4 d) e
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);7 A8 m6 s+ V) `) W/ [7 K
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    & k9 {( M* @* E7 x9 B/ l9 a! t
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);0 I/ \; I( R. G

  15. / g+ {- W) ~6 y# I# G
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);8 ]% |9 B; j/ M% k' Z3 `; `

  17. 1 h/ ?5 f( @3 Y1 ~  v* T# P9 W7 u
  18.                 // create historymode
    " G, ^6 P  l6 L
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);: d# D6 Y  D0 w' s& b
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);9 ~# p& f; O' u3 q: j1 a) L- |
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);
    & ]0 Z$ C. Q( e) j% ^0 `! t
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);
    5 w6 h+ }* g: l7 B; f: v
  23.                 tree_control0->SetSortRootNodes(false);! U9 z( y" ?, a4 \3 d1 v9 [. ]
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    8 x* a! i# [: O8 F+ r
  25.                 // get all the features with values
    0 c7 Y+ O# P5 U3 p8 ~7 y) s
  26. # d8 y  z- d+ m: z1 j: m, r
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();$ ~; }$ g6 D3 H9 B0 g6 [0 I( Y1 H
  28.                 // insert the features- K8 c4 @5 t- T, [
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)" i) f. l2 [+ _
  30.                 {, d) e+ g! T1 q4 T1 o* f1 z* b
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    # n4 O. n" v+ q# G3 D4 X2 Z
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);! h, E6 |3 p% [8 ]  I! |# H
  33.                         8 x2 n( g( e: |2 A$ ^
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());' U3 Q8 O  R' G+ }5 o4 @9 B) G
  35.                         featureNode->SetColumnDisplayText(2,"check");
    ; S1 J8 x6 e7 X4 v5 r, p2 v

  36. ! O  n8 b8 p; ^9 Q: t  N
  37.                 }- F/ r  G* l" h+ }# i
  38.         ; B  s$ m0 J7 L3 z5 w! R. ^& P

  39. 8 Q6 A5 |9 s, v: W: h# n1 `' M
  40.     }+ F7 {+ W% A% S" H. _! i! B
  41.     catch(exception& ex)5 Y  I4 r" @# \: D7 D8 M2 o
  42.     {
    7 L7 c4 p! z% v" J! j% S
  43.         //---- Enter your exception handling code here -----
    2 A% R- z: ^0 c" D4 y' @& n
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    ! R: P, D; a; t
  45.     }
    ' d! d/ ~1 [0 M) H  G+ y, T
  46. }
    : f7 r' K8 x% z. i3 d! I" X! W
复制代码

* `, N8 \/ j& ?0 ^2 Z- o( }8 g, L0 r1 G0 M8 W) F( C' X+ U: l
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容! v1 \! j( i6 J" w8 T$ k
! s& M9 W; H6 n. q+ T
首先通过InsertColumn 定义列,有了列才能创建节点Node; L' q8 [% D" |3 \# l' ]+ J

. X, F( T6 K3 H这个顺序非常重要!
* `% U$ ~, ^! V; q; w7 _7 a( L& ?* E, v1 `

treelist 树控件创建

treelist 树控件创建
0 v9 F. l: D8 z1 I( S* }( L

# j* `, {, I- J
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了