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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb()
    0 `% a- J& g8 u1 a  a5 Y
  2. {3 a* F% v  s9 G) T1 k+ ^5 D
  3.     try& ^. V6 {4 t5 P
  4.     {$ F% U9 a: z5 @
  5.         //---- Enter your callback code here -----% D! E$ e- |7 [3 {" j$ t
  6. 2 [" k8 ?: u  j4 K
  7.                                 
    $ M, m! u3 J: h& s+ p
  8.                 tree_control0->InserTColumn(0,"Name",140);
    . C5 g) ?' o* E$ C4 ?( T9 D7 d+ R1 r
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);: _3 O+ f* M8 d0 p, w# p" P
  10.             tree_control0->InsertColumn(2," Up to Date",70);# `% G% q! [! H* `8 `
  11. : ^6 P3 l; m2 y
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);
    2 s. R. I7 o, U
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);
    " Y& T" v( n1 \; @  Z; N* h0 x
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
    # L! v( x9 r$ {
  15. / D6 J6 k7 y* o9 a5 F8 O
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);( T+ M# W# J9 f: K
  17. ( U6 T, U/ ~' H& F3 B/ X1 y
  18.                 // create historymode* J( o  f3 X/ x, V6 V: A: }+ \
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);8 }# O4 m- ?$ `
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);" t8 t# d! A' J5 N; n9 ?
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);# O. D0 q% ^: `5 ~4 m# V
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);
    ' ~  p4 t! l  q$ Q
  23.                 tree_control0->SetSortRootNodes(false);7 r, m, `3 ]' e
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    " Z4 f0 {! P9 l: a- }/ L
  25.                 // get all the features with values
    : e# ?) v! B& |4 b0 V2 A; l# y
  26. " I/ G9 o4 f3 e7 {7 d3 W# U2 Z2 e- H
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();6 y- c; m4 C, b+ X* R" q- {
  28.                 // insert the features
    % O& w7 d, f2 J+ s: b. f/ x
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)
    ; y3 J" J# @  u  T) Q
  30.                 {
    0 o, _$ f% R7 L
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());
    ; F4 {5 z7 ?0 {
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
    . i& I, e& N+ P! M' q: ~4 J, i; \
  33.                         
    % [& a) B0 _! [: w  A+ i% M( u
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    4 ~, K& h  s, n& T; J1 w
  35.                         featureNode->SetColumnDisplayText(2,"check");
    ! p& u. L1 _" b2 {) {
  36. ! q! @8 Z: {2 U
  37.                 }
    + U7 x- _7 ]; w8 y; B
  38.         2 H& f7 L  h3 [1 v5 |, f" _9 C" k% `
  39. # M6 Q8 ?: Q' m, L* e( j7 z
  40.     }
    4 Z5 D# D  S1 e& }, `6 k1 r) H
  41.     catch(exception& ex)
    $ {( A. [% E6 P6 O4 p4 d# P( l( Q6 C
  42.     {. N4 Z: C! T: Z* Q) j$ _1 W) @
  43.         //---- Enter your exception handling code here -----; z& q  o- z$ o) o0 G+ W
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());. Y$ V0 G: ~0 o$ a+ D
  45.     }, F* D5 w* o# X4 p
  46. }0 F5 c5 ?8 O. ]" L& i! o# R
复制代码
( W, f; m+ _/ r( C. i

! B) |2 ^5 N* n6 h9 y( Htreelist的创建,需要在dialogShown_cb()里面定义treelist的内容2 v% V8 d/ ~8 M$ ^7 v- S" a. R

1 p$ c$ m7 x; ]7 A/ M8 k& M9 e首先通过InsertColumn 定义列,有了列才能创建节点Node
' P7 H' k: l& P& l) e4 _3 b' _- l' w
这个顺序非常重要!
  J1 _1 D. N% _; Q: z/ h# w
% c* D& Y/ |5 s2 r; J9 V; a3 j( {

treelist 树控件创建

treelist 树控件创建
9 s- {1 P. j! h
( m4 q6 V) N: H  ]) A: e6 |. 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二次开发专题模块培训报名开始啦

    我知道了