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

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

[复制链接]

2014-2-13 14:47:51 3508 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);
    9 k# A$ A/ a* q$ d
  2.             tree_control0->InsertColumn(2,"Status",100);
    % @7 B" v# A$ a0 h. W5 o' r
  3. ( @5 ^' x/ Z$ q$ X- Q
  4.                
    + b( z  R& p" X$ W! U3 ?
  5.                 , A; g6 ]' A* v5 ^6 Y9 g
  6.                 // get asembly name
    1 n# t  s" I! V. u) f8 M2 ~

  7. ! B7 K/ E! ?# s) c( G
  8.                 BasePart *displayBasepart = theSession->Parts()->BaseDisplay();7 a* r7 ~6 Z0 d5 [6 U- ]8 w
  9.                 Part *workpart = theSession->Parts()->Work();
    8 j2 a  J' l2 J3 Q* ?' ], ?+ c
  10.                 // get rootcomponent
    * r! B2 `% u" ]+ s2 f
  11.                 Assemblies::Component *rootcomponent = displayBasepart->ComponentAssembly()->RootComponent();  `9 [3 _# V/ W2 t; U
  12.                 if(rootcomponent)
    - M# Q$ G2 w: Q# Z
  13.                 {
    4 H5 V" l( }* ?. f2 ~5 y
  14.                         Node *parentNode= tree_control0->CreateNode(rootcomponent->DisplayName());
    ) w' o. L. ?! {
  15.                         tree_control0->InsertNode(parentNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
    : {8 w' s0 W/ L& T5 Z$ J8 t
  16.                         parentNode->SetColumnDisplayText(2,loadStatus(rootcomponent));: U: T- M  u* ]5 D' w
  17.                         getcompoents(parentNode,rootcomponent);
    6 a7 P8 z( D2 ?# c4 w
  18.                   ! E2 E' r2 M/ {4 O9 }
  19.                 0 J" A) [" ]/ `$ y
  20.                 }
    & @2 _8 f1 X- i0 v) @4 ~1 U
  21. 4 P3 n" P0 P6 T) g7 ]: }+ v
  22.                 else
      S$ L& T7 `7 w* ~1 a
  23.                 {. j0 ?6 J, u- _$ D
  24.                         Node *newNode = tree_control0->CreateNode(workpart->Leaf());& ]% ]& Y& b4 l5 r
  25.                         newNode->SetDisplayIcon("piecepart");
    6 G- ^- Q, J) p0 v9 J' x
  26.                         newNode->SetSelectedIcon("piecepart");
    " ]7 n' U# G1 K$ w7 e7 O
  27.                         tree_control0->InsertNode(newNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);( K# {' n7 Z, t0 L
  28.                         newNode->SetColumnDisplayText(2,"loaded piecepart");
    * `. r9 L2 ^7 s% p/ W
  29.                         delete newNode;
    8 K) D1 K6 O1 a$ ?& Y
  30.                         newNode = NULL;
      L" S- L+ W7 j7 e
  31.                
    0 V. l# A' ~" L- Q: Q+ \
  32.                 }5 L' i$ f$ i3 y6 A) O) X/ S- M

  33. + I% |& f, R- c9 N& l& m3 ^" }
  34.                 4 `) c' q9 u6 ^4 F" @0 S$ w4 o6 M6 d
  35.         }
    $ ~" K' B$ f% j, ^0 a" I9 I
  36.         ; I3 j3 ^; v' E+ J8 V6 W% V8 R
  37.         0 k( p4 D- t3 R
  38. 1 U5 b! C3 A$ C! f' o4 r

  39. ! u. q7 z! |4 }* h+ Y1 R! E
  40. Node * PNTDemo::createInsertNode(Node *pNode,NXString name,NXString geticon), Y0 p+ Q# K- r# w1 W* u) e
  41. {
    ' f* b. b% D  O# c, W& W
  42.         Node *getNode = tree_control0->CreateNode(name);
    5 X# D: P1 i9 r% _+ s( @* r
  43.         getNode->SetDisplayIcon(geticon);
    1 y: {1 W, Z% L# j
  44.         getNode->SetSelectedIcon(geticon);9 g0 \# ?% p% N0 K5 P6 ?
  45.         tree_control0->InsertNode(getNode,pNode,NULL,Tree::NodeInsertOptionLast);
    6 a( B. V, c% o! A6 J
  46.         return getNode;4 O/ B8 U+ a3 m2 V* g3 \
  47. , n" y7 E1 z% }! x+ L5 G
  48. }
    * |) _2 i! G, ?# \6 h

  49. 3 Z5 \6 r- a2 `7 \, d# I
  50. NXString PNTDemo::loadStatus(Assemblies::Component *component); j* \% l+ y6 ?) C& U0 M
  51. {
    " T3 J6 p- w4 q7 r: T. s: q. H
  52.          Part *part =dynamic_cast<Part*>(component->Prototype());
    3 i5 J2 n$ y9 _* J) u1 E( Y! |
  53.          if(part==NULL_TAG)
    4 |7 p. V; q+ J, z
  54.          {
    / g: U  G: Z* P2 Q& z- P
  55.            return "Not Loaded";
    , B$ ?) t' U# x0 x
  56.          }9 I$ x; V4 u8 @! {
  57.          else
    : w8 A# E8 n: f
  58.          {1 r7 `2 z- v( B
  59.          if(part->IsFullyLoaded())' a' f" y% W: {" X# g7 g0 Q) P1 {& J
  60.                  return "Fully Loaded";' l; [0 y- H$ E; S! Z! \
  61.          else" \+ }# E2 H" i! `& M& u4 f
  62.                  return "Partially Loaded";
      x, y6 ]3 z" h& Y' B3 [  J+ C
  63.         9 J( f. y/ O$ B4 M
  64.          }
    # h+ X3 }2 U1 q/ ^+ O' D' |$ y
  65. }
    ; b/ L( F9 M3 O
  66. void PNTDemo::getcompoents(Node *parentNode,Assemblies::Component *root)3 |! ^( e: A3 G- c* i' t
  67. {9 [4 J4 I% c6 m" |) Y7 H
  68.    
    % F  J4 M9 P' U8 E! J1 P
  69.            vector <Assemblies::Component *> children = root->GetChildren();
      p$ k8 U( Q% C; }
  70.            for(int i = 0 ; i < children.size(); i ++)5 r' @/ k9 c* G4 a/ k8 [. j
  71.            {/ I  ]& \1 ~8 G& q
  72.                    Assemblies::Component *com = children[i];
    * y! x: o4 |4 T! y. s; `
  73.                    Node *newNode = createInsertNode(parentNode,com->DisplayName(),"assembly");
    2 O9 {- D7 @! M4 w
  74.                    newNode->SetColumnDisplayText(2,loadStatus(com));- M6 e9 }" @6 Z" `8 |5 A' V3 i
  75.                    getcompoents(newNode,com);) L) u1 e3 X% v) f4 `: q; B
  76.                        
    - i( w! Y3 z; ~- n
  77.            }
    ( g4 H1 m1 m- _
  78.    0 G2 Z2 z) x: S7 ~" ?

  79. 3 z# E1 U' n% Q0 C  b
  80. # ]7 }' h/ g$ v
  81. }
复制代码
; C% W& {. r) S/ x
模拟装配导航器treelist代码分享--树控件的使用7 Z. l8 s; i: J4 Y  m: j  Q6 p' Z

! Q7 H* b% M3 ^, M
$ k6 f0 l( Z$ p3 m; j; Y- ^0 b( J2 D5 `+ x
" r! [0 Z- K7 O& e
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了