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

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

[复制链接]

2014-2-13 14:47:51 3535 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);
    0 p8 W% b: U* _7 T  y2 O% ~
  2.             tree_control0->InsertColumn(2,"Status",100);7 o* v4 L6 C8 E, }

  3. 5 t7 N8 i9 L+ N2 T5 u# T3 Q
  4.                 $ e' m# D# P5 N/ c7 \* R
  5.                 ) w/ c3 t' o1 V" M4 ~) `
  6.                 // get asembly name4 \) F4 ^9 w5 s

  7. 7 S6 j& @% O. S6 _3 ?
  8.                 BasePart *displayBasepart = theSession->Parts()->BaseDisplay();- {: {0 Y. `3 L% l% K
  9.                 Part *workpart = theSession->Parts()->Work();
    / `, y* H7 X  ?8 _# p' `
  10.                 // get rootcomponent
    1 h$ G4 f2 n) f1 k
  11.                 Assemblies::Component *rootcomponent = displayBasepart->ComponentAssembly()->RootComponent();
    ! Q( Q6 E3 ^8 Z2 b2 R* [8 g
  12.                 if(rootcomponent)& M$ D+ r" Q# S
  13.                 {. N0 \8 @& q9 d& s( _! N
  14.                         Node *parentNode= tree_control0->CreateNode(rootcomponent->DisplayName());) P3 {0 B# f2 H! ]" t0 o' H
  15.                         tree_control0->InsertNode(parentNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
    , R; p: Z) m% W, s  Q
  16.                         parentNode->SetColumnDisplayText(2,loadStatus(rootcomponent));2 D( K+ q2 G4 d* t: x* L& ~" V) t
  17.                         getcompoents(parentNode,rootcomponent);
    % C6 t3 W" J. ^/ }5 V1 C
  18.                   . i/ h# O9 v3 \
  19.                
    7 v; \# }0 ]0 ~# U3 X, Q
  20.                 }
    # U0 r# m3 o0 O
  21.   s  l& M, N0 z2 k5 ?$ c
  22.                 else
    % _9 \# X* y) e$ O8 r: [
  23.                 {
      A  d, i; M. E
  24.                         Node *newNode = tree_control0->CreateNode(workpart->Leaf());% A" g4 X( [6 Y0 h& b* r) @
  25.                         newNode->SetDisplayIcon("piecepart");. K% V; f. z( C" B0 z" h! R
  26.                         newNode->SetSelectedIcon("piecepart");
    . E" F6 b: z9 a" ?* T( v
  27.                         tree_control0->InsertNode(newNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);7 _+ i" J# k' C" e3 K* o) }3 g
  28.                         newNode->SetColumnDisplayText(2,"loaded piecepart");
    ) _6 I) ~# n4 W" s: m  l
  29.                         delete newNode;+ [: r& Z# Z5 ~5 b" E& }
  30.                         newNode = NULL;- d6 \' Q2 V* C# J' ^
  31.                 9 Z8 `  S# S' [2 @2 K
  32.                 }9 [* e7 ]) @$ l( _* g
  33. 5 g9 [1 L3 Z3 ^" c( f) e
  34.                
    * F' Q+ S7 X3 M; U6 }
  35.         }+ D. B. T3 A" O4 w) L2 V
  36.        
    $ w; Z# t: r8 q% G) o9 B: x4 G
  37.        
    ' N  A, p# N+ `( ?
  38. 8 H# N0 r6 S2 M8 C  \
  39. & h; o1 M! c/ m- B# `5 Z8 k
  40. Node * PNTDemo::createInsertNode(Node *pNode,NXString name,NXString geticon)
      I! W. X$ D7 N6 `+ T& M
  41. {7 ^( J, z: l3 b" p* p
  42.         Node *getNode = tree_control0->CreateNode(name);3 D5 W6 @% A; D" U
  43.         getNode->SetDisplayIcon(geticon);
    * v9 l5 J& z9 k9 a( A. V
  44.         getNode->SetSelectedIcon(geticon);
    3 {' L& S1 b% B0 F" k; h' T
  45.         tree_control0->InsertNode(getNode,pNode,NULL,Tree::NodeInsertOptionLast);% a  w6 e  M8 J0 j9 F9 s7 w6 B! Y
  46.         return getNode;
    - D6 d# R1 w* \# N
  47. % V. _" l! K% {6 |, Q0 y
  48. }* |$ w: R3 i  X5 [) v" q
  49. 4 L7 Z1 g' }1 D* A. }7 a1 S# f: N
  50. NXString PNTDemo::loadStatus(Assemblies::Component *component)
    2 q1 l, X8 R4 B1 n
  51. {# W8 t/ \4 x, |" f
  52.          Part *part =dynamic_cast<Part*>(component->Prototype());4 C: x1 X8 G8 G" }
  53.          if(part==NULL_TAG)
    " P2 y+ V! K' W, n; k
  54.          {  K2 V3 ]$ B% i% }
  55.            return "Not Loaded";
      L/ I  ?- W' o* F1 g( ^4 S9 ~( d
  56.          }
    - W+ _( k. u6 G7 r' m# c8 Z
  57.          else+ g, f8 w9 H  A/ S
  58.          {
    ; E- N" U/ x. ?9 C5 \
  59.          if(part->IsFullyLoaded())
    2 P# H2 u+ I  k0 }2 s( R' f. @
  60.                  return "Fully Loaded";- h5 ?5 {1 X3 J$ i( ?5 U% o# D
  61.          else  Y* h0 S1 L+ X: I; a" U# }2 m8 w
  62.                  return "Partially Loaded";  G$ a- C+ z2 Z! `/ f( p' G$ F
  63.        
    / |0 j0 D' [3 h* d6 ?% Z
  64.          }% I* P& i7 f2 w2 V$ n/ d1 R
  65. }
    ( R1 F: i! ^6 h0 E4 ~" O0 u0 I/ }
  66. void PNTDemo::getcompoents(Node *parentNode,Assemblies::Component *root)! W- s1 R$ u. V' T
  67. {
    4 w! T# Y+ D* z% J5 h0 ?
  68.    : L' w% I0 i& q- J
  69.            vector <Assemblies::Component *> children = root->GetChildren();
    $ b6 }" d: }5 B7 m
  70.            for(int i = 0 ; i < children.size(); i ++)4 y# d& W* K! o2 F" N
  71.            {
    * {0 y  T: c$ |
  72.                    Assemblies::Component *com = children[i];
    4 B) r) U4 _1 ^
  73.                    Node *newNode = createInsertNode(parentNode,com->DisplayName(),"assembly");
    ; G' [& s1 B: R8 {! l- k
  74.                    newNode->SetColumnDisplayText(2,loadStatus(com));  V: u& w, s. _# r
  75.                    getcompoents(newNode,com);  e0 w4 j$ {# N7 O
  76.                         0 `# R! a& ]& z$ h: z
  77.            }
    # ~4 A5 a$ ?2 i0 M% k
  78.    9 N0 w$ S4 {. H' B+ C. l3 M

  79. 7 O) Y, E7 W. e

  80. % K2 k8 g0 [# r# H+ M+ v+ S
  81. }
复制代码
( _  n/ X7 B9 O
模拟装配导航器treelist代码分享--树控件的使用
# a( T$ s# [) v+ ]: H/ E* ]8 Q8 f9 \8 }

/ E2 ]9 \! Z& B: W( H* q% J  L9 w1 x5 u% G4 ]: S! U
% N3 K8 U% G5 r3 Z2 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二次开发专题模块培训报名开始啦

    我知道了