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

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

[复制链接]

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

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

admin 楼主

2014-2-12 19:13:34

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

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

x
  1. void tree::dialogShown_cb(). ]7 b, k$ }$ ?' ?: `. X
  2. {# H& l) R- B6 s$ f! n' y- x
  3.     try
    ; s9 m$ Z' [) F9 \4 m0 Q/ v
  4.     {' {+ v0 k& C( m7 ?" z
  5.         //---- Enter your callback code here -----
    : S" W# U1 u2 \! J0 N
  6. ! p' L+ z' R0 V; h* u0 h0 o
  7.                                 
    ! g/ e3 ]. g  W" H  t9 e/ M
  8.                 tree_control0->InserTColumn(0,"Name",140);
    . Z, u* b' e% [- ^  y4 x. {7 a
  9.                 tree_control0->InsertColumn(1,"Feature Type",90);- a$ {8 M# e: b* ]9 u
  10.             tree_control0->InsertColumn(2," Up to Date",70);
    / }# j/ b' ^* @* I$ E( U
  11. " J8 l7 v0 D: ^! o7 d. V. W* y
  12.                 tree_control0->SetColumnResizePolicy(0,Tree::ColumnResizePolicyConstantWidth);" B6 k3 ?& j+ T- c: \+ i) a
  13.                 tree_control0->SetColumnResizePolicy(1,Tree::ColumnResizePolicyConstantWidth);# M0 F  Y" D4 q' G
  14.                 tree_control0->SetColumnResizePolicy(2,Tree::ColumnResizePolicyConstantWidth);
    / C4 _& ?7 V& C- I3 ^9 R# }
  15.   V( k8 ~9 o: O
  16.                 tree_control0->SetColumnDisplayType(2,Tree::ColumnDisplayIcon);
    9 t- n+ b- a/ n0 G
  17. 1 p. j2 w/ [4 ^) x2 G: Z
  18.                 // create historymode- }& Y4 x8 m3 p5 w: G, U6 u0 }' k
  19.                 historyModeNode = createInsertParentNode(this->tree_control0,"History Mode" ,NULL,nodeIcons[0],nodeIcons[0],Tree::NodeInsertOptionAlwaysFirst);
    " d2 N3 D9 q4 N. ^+ L; N
  20.                 viewNode = createInsertParentNode(this->tree_control0,"Model Views" ,historyModeNode,nodeIcons[1],nodeIcons[1],Tree::NodeInsertOptionLast);$ p# C- v* l  y; Z) h6 M7 P
  21.                 camerasNode = createInsertParentNode(this->tree_control0,"Cameras" ,viewNode,nodeIcons[2],nodeIcons[2],Tree::NodeInsertOptionLast);
    0 ~. C- I. r  ?( c: P5 Y4 e) H
  22.                 modelhistoryNode = createInsertParentNode(this->tree_control0,"Model History" ,camerasNode,nodeIcons[3],nodeIcons[3],Tree::NodeInsertOptionAlwaysLast);
    : A4 o! u. y  |- \
  23.                 tree_control0->SetSortRootNodes(false);* s5 a1 w0 E( O  N9 U3 w" Z
  24.                 modelhistoryNode->Expand(Node::ExpandOptionExpand);
    ! s* _1 g# @4 y5 s
  25.                 // get all the features with values * @( [6 C- f, ~) o
  26. 2 f# {3 T6 P) W; Y1 L, A
  27.                 std::vector <Features::Feature *> nodeFeatures = getfeatures();
    2 K" b1 U" @; e3 X+ U& b! J
  28.                 // insert the features
    4 t. K8 {7 p* O' U
  29.                 for(int i = 0 ; i < nodeFeatures.size();++i)1 N9 H$ |" [3 e% [  {" A; O
  30.                 {3 y+ H- s' A) \# ~
  31.                         Node *featureNode = tree_control0->CreateNode(nodeFeatures[i]->GetFeatureName());) a. s5 o* A9 T; f8 z' ~" g; @7 J
  32.                         tree_control0->InsertNode(featureNode,modelhistoryNode,NULL,Tree::NodeInsertOptionLast);
    " T- m# m" ?# W( d3 L3 B
  33.                         ! p0 D% Q7 a) M1 m4 B8 @+ n" f7 L
  34.                         featureNode->SetColumnDisplayText(1,        nodeFeatures[i]->FeatureType());
    ( D% M& l/ V0 l8 S  E( P
  35.                         featureNode->SetColumnDisplayText(2,"check");
    ' G& ?1 w# M  r& f3 e9 c6 J: Y- s3 t

  36. 6 S9 w: `, W$ J6 j  g" V# I/ K
  37.                 }' t. L% d4 C& R  V
  38.           o" |8 i( u# c6 R8 Z6 Y" ^) K% P

  39. 8 h$ q* {6 {/ ?" C( D- r
  40.     }' P( P9 s6 U0 ]- c4 k
  41.     catch(exception& ex). p5 J& i9 Y- P# N; {+ r
  42.     {
    : {8 k: I" F' ~; g" ~1 s/ ?
  43.         //---- Enter your exception handling code here -----
    ( |2 N! t6 L8 }3 v4 M1 T3 w
  44.         tree::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    : m8 A5 \. d( _3 m" |' u" h9 e
  45.     }& n3 K8 q# i  u! y& N& S# ?
  46. }& t+ R% G- h7 h1 l; ?4 f9 B0 h
复制代码
5 ^8 f& A4 j5 ?  _& J

3 g- f2 _1 T4 z5 u; z  dtreelist的创建,需要在dialogShown_cb()里面定义treelist的内容
( a8 L! {+ ?  A8 t
0 P" [1 p+ l# N' s# J, e+ y5 v首先通过InsertColumn 定义列,有了列才能创建节点Node
! d% a5 s" t# b$ T5 N4 z( B) l& h, H, h% r' ^- h! u+ _
这个顺序非常重要!
/ W) m; Z  B0 a5 r! W# x5 }- ~; j: O" M" S. a

treelist 树控件创建

treelist 树控件创建
. t1 s0 s/ }5 M- ]7 R

2 U$ q9 w" z. g; \
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了