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

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

[复制链接]

2014-2-13 14:47:51 3517 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. N* _3 M4 u" m) m/ i- O
  2.             tree_control0->InsertColumn(2,"Status",100);
    3 g  V# v# Q  e2 F
  3. ; g9 O" g, e9 Y( ?5 v  p3 J' t
  4.                
    ( G  h$ w1 W: p& q) A5 t# e% B
  5.                 / I" ~, H. o- s8 f; l7 \; B
  6.                 // get asembly name$ _8 r# O, r- @0 h- Z) H& P% H
  7.   H6 N  y. W4 x) U5 F: X
  8.                 BasePart *displayBasepart = theSession->Parts()->BaseDisplay();
    ; Z; v* P8 |8 z0 l' u
  9.                 Part *workpart = theSession->Parts()->Work();
      L6 ~2 c* y* v* h
  10.                 // get rootcomponent
    / F. J' X8 \5 g7 ]! e0 }
  11.                 Assemblies::Component *rootcomponent = displayBasepart->ComponentAssembly()->RootComponent();1 j  p/ m* G# q. j5 h6 F
  12.                 if(rootcomponent)5 L0 I' f; L- [& \
  13.                 {8 g6 U% ^  O9 \+ Y4 t* Y8 S" f
  14.                         Node *parentNode= tree_control0->CreateNode(rootcomponent->DisplayName());+ F$ A0 s( [' Y; T$ t/ I
  15.                         tree_control0->InsertNode(parentNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);+ N; t( E2 [& |$ ~; [
  16.                         parentNode->SetColumnDisplayText(2,loadStatus(rootcomponent));
    . y4 K" B! a8 R5 `0 X' k5 Z2 K
  17.                         getcompoents(parentNode,rootcomponent);6 G# ~) |+ f! h
  18.                   * ]$ s  _" c5 k; K- {& k0 d
  19.                 0 M' x; A# q, P" y) f- v( Z
  20.                 }2 Z8 W# U8 `3 Y* l# {' Q

  21. : A* m" H' {; X4 e$ ?* l
  22.                 else6 ~; c  `, ^6 v2 l$ T
  23.                 {* l9 B& e2 V8 h
  24.                         Node *newNode = tree_control0->CreateNode(workpart->Leaf());4 i- R9 Y- S3 L  ^6 N
  25.                         newNode->SetDisplayIcon("piecepart");- E& w4 O# t7 h4 i" H5 a. ^
  26.                         newNode->SetSelectedIcon("piecepart");6 c/ s  _7 l5 o; {, Z! p9 z" h
  27.                         tree_control0->InsertNode(newNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
    ; y" E5 v" S8 ]4 |  p
  28.                         newNode->SetColumnDisplayText(2,"loaded piecepart");- z+ z4 y1 K# b& e
  29.                         delete newNode;
    : ?8 F1 W% }& X" ^2 K! ]
  30.                         newNode = NULL;
    5 p' B- q" P6 w2 K; b
  31.                
    0 |3 u7 A1 F" T% Q" ~8 V: s! ?% y
  32.                 }# `5 v" X  [+ ^2 F& ^" f
  33. 9 g% ]6 w( t. b! U* i
  34.                 1 i9 s+ Z! ^& ]5 ]9 R8 F
  35.         }
    ) k7 Z$ n% ], Z5 e4 z
  36.        
    1 R$ ]" h8 J6 K" y9 x$ x3 T% P: L& O
  37.         0 Q5 n, h9 B6 a$ W8 e, G7 R
  38. 2 L; g- {0 ~: l8 N% N9 t0 G

  39. ( x; U4 A$ A- }
  40. Node * PNTDemo::createInsertNode(Node *pNode,NXString name,NXString geticon)
    3 }+ g( t0 }0 e& w' ?
  41. {4 M. K! T- {0 d
  42.         Node *getNode = tree_control0->CreateNode(name);
    $ Y- z5 c7 T3 T# ?
  43.         getNode->SetDisplayIcon(geticon);
    % ~6 x; \' R# d0 w& v" O+ X  i
  44.         getNode->SetSelectedIcon(geticon);
    ( j# }1 ?4 ?; v+ s# n- u7 M
  45.         tree_control0->InsertNode(getNode,pNode,NULL,Tree::NodeInsertOptionLast);
    2 i3 N7 w& ~  }0 b) a! J% E* |3 I
  46.         return getNode;5 A2 F- l# p2 p4 z5 X9 R6 n
  47. + n- T" j, v& h7 ]) g+ r! w
  48. }% z7 v' s1 C8 t, k
  49. " V8 O8 R# i' I( }9 w! z" r" O
  50. NXString PNTDemo::loadStatus(Assemblies::Component *component)6 j2 W3 r3 ~$ v* [: w
  51. {
    3 T" y; }9 H8 t7 E0 Q4 X1 O
  52.          Part *part =dynamic_cast<Part*>(component->Prototype());9 ^- s) Z, r% B& v
  53.          if(part==NULL_TAG)& e+ f+ o9 l  c4 R! g1 G
  54.          {" {- A. s3 N4 s9 F
  55.            return "Not Loaded";
    ; a3 _6 ]8 _# ]- [, p% Z+ v* u
  56.          }
    2 N4 A3 i8 O) ^- |
  57.          else
    / F2 a2 Y( B1 `8 X6 \. H
  58.          {
    / S$ A8 ]! ^8 q' x3 }7 }7 Z
  59.          if(part->IsFullyLoaded())) E; P" }+ U8 w4 S' r
  60.                  return "Fully Loaded";
    ) v: e. u, i" x
  61.          else( H4 @$ _7 g+ y0 \/ u& D
  62.                  return "Partially Loaded";
    ; c4 q, a+ k9 {9 }- L
  63.         + l8 P. |) e0 h  {8 n' e0 f
  64.          }) J5 P) V  E9 X0 K
  65. }
    & I- z/ i7 ~9 q/ g
  66. void PNTDemo::getcompoents(Node *parentNode,Assemblies::Component *root)
    1 v0 _( A$ ]6 M( K/ e
  67. {
      J, `0 S/ k- x
  68.    8 n7 A- x! Q0 e
  69.            vector <Assemblies::Component *> children = root->GetChildren();1 {% r  }0 G6 p- L6 E! y
  70.            for(int i = 0 ; i < children.size(); i ++)" M$ K9 K. ?1 V. @8 \3 Y) J2 b( M
  71.            {% [6 U# |' y" p: b' h
  72.                    Assemblies::Component *com = children[i];
    1 i5 Q4 K) S5 ^) g& ~, w
  73.                    Node *newNode = createInsertNode(parentNode,com->DisplayName(),"assembly");
    , {" w+ G2 |/ B* u  w& t/ ]
  74.                    newNode->SetColumnDisplayText(2,loadStatus(com));
    + L' @" H1 p6 X! a) [
  75.                    getcompoents(newNode,com);
    ) D2 }) `$ Q( L7 R, E7 g
  76.                         5 P# i! `5 f* \
  77.            }
    . ~: ?2 W8 a  a! v  P; Q
  78.    8 J* X3 K5 k# l6 s* L) p

  79. 3 L. y; K! w9 Z7 r& u3 b
  80. " O: C% y/ G$ C3 j' [
  81. }
复制代码

4 ?* b& `: Q$ D% c8 V# X模拟装配导航器treelist代码分享--树控件的使用
/ ~: d0 E9 G- g, |+ \5 J
5 }3 s% D( I+ q4 ~! [; I) B' z% F, P! p) k) H5 i

/ G" Y1 M& ?# p& X( r# H  l# o8 T$ u( [
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了