PLM之家PLMHome-工业软件与AI结合践行者

[二次开发源码] 模拟装配导航器treelist代码分享--树控件的使用

[复制链接]

2014-2-13 14:47:51 3553 0

admin 发表于 2014-2-13 14:47:51 |阅读模式

admin 楼主

2014-2-13 14:47:51

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

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

x
  1.                 tree_control0->InserTColumn(1,"AssemblyName",180);
    . B+ I2 r  x) |0 h
  2.             tree_control0->InsertColumn(2,"Status",100);# v+ ]9 G! U: R

  3. + ~/ k" |, l/ k) J& u
  4.                 5 D# S2 H0 I; s0 @' \% T  f) V
  5.                 ' Q6 c8 }, P9 [- `
  6.                 // get asembly name6 P# s: \' i* X( D

  7. 0 P0 Y! q! j8 I0 v" \) i
  8.                 BasePart *displayBasepart = theSession->Parts()->BaseDisplay();0 r: i6 S, V! e6 w% W2 t
  9.                 Part *workpart = theSession->Parts()->Work();3 p3 C- y* E% j- A2 I+ u
  10.                 // get rootcomponent
    2 `9 m6 F, g: k$ Q
  11.                 Assemblies::Component *rootcomponent = displayBasepart->ComponentAssembly()->RootComponent();) F+ C' I; |4 [' w# j5 h
  12.                 if(rootcomponent)' ?" e# |8 L! v) G$ a
  13.                 {
    8 [* g8 C+ B8 M1 X7 f3 X
  14.                         Node *parentNode= tree_control0->CreateNode(rootcomponent->DisplayName());) I! r, [5 Z3 v  o& Q. A$ a4 Q3 ?
  15.                         tree_control0->InsertNode(parentNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
    6 @9 Y5 ?" C/ V4 S* P  {: d0 t
  16.                         parentNode->SetColumnDisplayText(2,loadStatus(rootcomponent));
    7 g; T' f9 H5 x" g: s  @- ~
  17.                         getcompoents(parentNode,rootcomponent);  d; H. w. i. S0 c6 Y0 j% y
  18.                   
      A. G) n; F' L( e, F; w- ~- x
  19.                 ! ]) f" ?) T# u7 o* J8 C
  20.                 }" B/ M  ?3 N& g, Z- y
  21. 8 n; w2 h- G' o8 i" c5 X
  22.                 else0 k3 l% F, y  s6 f' F/ U
  23.                 {5 V+ t* K5 I' q+ O% V5 S6 L4 Q
  24.                         Node *newNode = tree_control0->CreateNode(workpart->Leaf());
    # P" p/ i5 q# s) U" A; ^+ Q
  25.                         newNode->SetDisplayIcon("piecepart");" x1 T8 r5 y& V. }; o% ^
  26.                         newNode->SetSelectedIcon("piecepart");8 h2 v; G* `- O# {6 J/ k
  27.                         tree_control0->InsertNode(newNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
    ; u- H6 ?5 z5 j$ R- G( E3 N
  28.                         newNode->SetColumnDisplayText(2,"loaded piecepart");
    - \4 ^% m5 g  H4 i0 c( M. G( l' v
  29.                         delete newNode;
    0 J2 v6 I& F6 A! L7 f3 @
  30.                         newNode = NULL;
    7 J7 @4 |9 _' O$ c. @+ s
  31.                 , t$ @' X7 ?5 p' X  o2 ?! z
  32.                 }
    . t8 ?; r. ^$ `+ _- {

  33. # K/ T; ~/ R$ }: m- c
  34.                 * r; Z3 w1 V$ V- ]$ E1 W2 `: E0 V" T# s
  35.         }% j  f/ d8 I( h8 R
  36.        
    9 A( o7 L  a: c8 C  H; V2 V/ u
  37.         ! [1 H% s8 d! Z8 v( |8 J
  38. 5 O1 u( t5 P' u

  39. . h8 M( [3 [- X- e/ [
  40. Node * PNTDemo::createInsertNode(Node *pNode,NXString name,NXString geticon)3 B6 K# u1 z9 ?3 A* q1 S& o
  41. {
    * m) \/ F+ d: Z' J
  42.         Node *getNode = tree_control0->CreateNode(name);9 B+ g' d8 s6 D' U3 j
  43.         getNode->SetDisplayIcon(geticon);6 r# }, y* d1 c. v- L
  44.         getNode->SetSelectedIcon(geticon);- e$ e. d3 |6 ~, Q: [
  45.         tree_control0->InsertNode(getNode,pNode,NULL,Tree::NodeInsertOptionLast);
    4 G9 ?# n4 L  X7 [" k- f
  46.         return getNode;" X/ C4 c! H2 X" {
  47. : z# s9 N0 S* v5 S
  48. }+ P& X5 b" _0 g" a5 |3 z
  49. , e+ T. a& l- \6 \+ D" ~
  50. NXString PNTDemo::loadStatus(Assemblies::Component *component)
    0 |) L2 e7 _' u! F8 n
  51. {5 K* R; {0 B4 k7 u  E0 K7 q' t1 J
  52.          Part *part =dynamic_cast<Part*>(component->Prototype());
    ; e) Y& z3 ]" @/ i$ m) I# ]
  53.          if(part==NULL_TAG)
    " F6 o. j0 }/ f6 e& r$ f
  54.          {
    + {4 P% S/ `. {, ?+ H/ e0 j
  55.            return "Not Loaded";
    / j+ p3 x1 x0 f2 h( v5 \
  56.          }
    ' Z, S, \: @: S
  57.          else: _6 I- q6 U1 K# c; k
  58.          {
    . c& ]3 P9 j+ W% i* t
  59.          if(part->IsFullyLoaded())4 @9 c& V. b- ?+ G
  60.                  return "Fully Loaded";; R0 l0 j) D- c/ V4 }' _' B
  61.          else
    ) E  G+ m! }: u: A. j$ x( H* n
  62.                  return "Partially Loaded";+ Z) \) B- E( D9 f
  63.         2 y+ ]7 z6 m9 H# M* D; @
  64.          }
    / O; Z6 t5 L7 Y. d, [+ F7 ]" w4 H  y
  65. }
    ( m/ _; U) b; ]% {0 M
  66. void PNTDemo::getcompoents(Node *parentNode,Assemblies::Component *root)
    * p5 M0 X) c3 v7 P
  67. {
    : h' R  h# Q" k9 b4 K' F
  68.    
    # l+ Y  K. s: Q: _) P. K0 d3 `
  69.            vector <Assemblies::Component *> children = root->GetChildren();
    $ G- l2 u' A: b% r# n
  70.            for(int i = 0 ; i < children.size(); i ++)
    # M1 b; o7 K0 I0 S9 k' G
  71.            {# E3 [) O1 d" f$ g
  72.                    Assemblies::Component *com = children[i];
    $ ~. P4 _1 U7 H  F9 Y7 Y, q$ K) s" }
  73.                    Node *newNode = createInsertNode(parentNode,com->DisplayName(),"assembly");1 M/ x1 j5 i( i1 H9 o/ {  y
  74.                    newNode->SetColumnDisplayText(2,loadStatus(com));3 Z- p- H6 v8 a) ]
  75.                    getcompoents(newNode,com);
    5 f9 b% [2 A7 z! ?0 v: X
  76.                         3 D; r$ T! r7 G
  77.            }
    2 h0 Q1 ^1 `" ~# Y" [
  78.    ' l1 c2 c6 r! g; W& n
  79. % D) A/ l$ W- r7 {) T) W* K8 ^

  80. " Q6 Y$ b3 A  E6 b
  81. }
复制代码
9 J% W7 h1 ?9 ~1 t( h4 l. C
模拟装配导航器treelist代码分享--树控件的使用( `9 R: q; j6 {: E0 d% G

; d! J" K& B  n
' s5 X- H: G& @% m# S2 _3 m. ^0 \% l  r" C/ A: ^' \. M8 v) q; w
/ s& d0 b. G. c, z9 s
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了