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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()
    8 R$ @# U4 t) \! G: F
  2. {/ g' m! }+ @7 G
  3.     try7 d* Q! d+ I2 x' k7 I" S* C1 ^
  4.     {4 c% D% {. \" a1 H7 b7 y* Q
  5.         //---- Enter your callback code here -----; ~, j  m& {8 h9 ]) A

  6. ' z: N; {( U  Q
  7.                                 
    0 D5 d4 T& ~3 @. p3 o+ K" a4 E
  8.                 tree_control0->InserTColumn(0,"Name",140);1 h0 k+ @, q" m4 t
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);
    " O$ M  m9 i- y) k+ `% L  }$ ~
  10.             tree_control0->InsertColumn(2," Up to Date",70);
    ' f7 X" r6 X. d3 X) |) ^- F

  11. " b8 }7 m6 ]  e7 `: f" Q
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);: J5 }/ W) ]1 e% w5 t! N9 M
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    1 m" U5 e  e! E- L& H
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);, t9 k4 G8 I4 z% I9 S% U/ i
  15. 0 p4 t4 y- y3 L0 {8 _
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);, w& y% f6 s8 p' t/ z4 X
  17. 4 R* e) Y# J4 f) L2 c# w# K6 Y
  18.                 // create historymode( p. s9 Q' {% ?5 {7 L* y7 u, Y
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    / ^, f2 v* B& n8 u, v) q
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);0 s% ]) ^) ^2 ]  M* s0 k: q; a
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);5 v! Y. x. p% F
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);; t. s0 N/ V2 q) s" ]
  23.                 tree_control0->SetSortRootNodes(false);3 X/ N5 [. m0 t+ B" ~  ^0 T
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);0 v, |; k1 k) N$ w7 @
  25.                 // get all the features with values / @6 Z( e. {0 G. b2 g7 Z
  26. 5 h. g0 j" A# Y2 Y2 {
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();8 i5 i, l. r. V5 b, t3 |
  28.                 // insert the features9 [9 o! v, d: w; V) u4 ], l
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)$ K  h1 u! P+ m) x; G
  30.                 {
    5 Z0 Z7 `) |( d! K& [3 F8 {; n
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());1 v7 L9 s# D4 W! g
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);; w1 e0 R2 Z! x1 M1 t2 X
  33.                         + |- y' D/ X! Y0 @( j
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    3 R3 `. G& [5 z8 ?2 w% E
  35.                         featureNode->SetColumnDisplayText(2,"check");
    4 b! `, v; d, m0 O+ z9 W0 c/ M
  36. ( v9 \8 S9 m: P* @: M
  37.                 }
      E" }' S7 }3 T, R
  38.         - X8 Y7 p' [* n3 u( S
  39. 9 t3 p$ ]% u3 i! X. B4 r
  40.     }
    2 K0 J4 b/ N7 f3 g/ _6 u1 Q
  41.     catch(exception& ex)" t$ V: \( }+ g/ \$ D
  42.     {/ E, t# d! m& b; G2 C% `
  43.         //---- Enter your exception handling code here -----
    2 g! ?2 C2 F* B* h+ d; O$ n3 u
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());! f6 b& |' `* h1 M. b
  45.     }0 ^  Q* k1 Z' x( ]2 g: t+ f1 `
  46. }! e8 ]1 {! P# f0 s: M/ V
复制代码
# {4 V! L* ]' e! E
, x! B8 t/ M& S# o2 i
treelist的创建,需要在dialogShown_cb()里面定义treelist的内容
  l8 E+ N) Y3 d5 V/ _0 _" M, v/ e9 X; U% S& Y" A  w7 X
首先通过InsertColumn 定义列,有了列才能创建节点Node- F- |' Y* A, \1 F
2 C; [2 V# o- S& i6 Y
这个顺序非常重要!
* k! u8 U4 |; P3 h1 O
8 R  a$ }! F! Q5 ?: ?7 B

treelist 树控件创建

treelist 树控件创建
3 x. b: M1 o2 w, {0 i

. Y9 q4 a' G8 I! N
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了