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

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

[复制链接]

2014-2-13 14:47:51 3515 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);
    6 o7 G+ B" ~; {0 y( h; F5 P) M
  2.             tree_control0->InsertColumn(2,"Status",100);
    6 M, a" R% G! H) @2 u- i

  3. - ]7 c0 U% j7 c+ {5 h& X  }
  4.                
    ! d1 k2 o$ M- R* A2 ~
  5.                
    + D( \4 h: A" c4 }) Z/ \5 s
  6.                 // get asembly name# j$ v/ }5 L8 `+ `/ R# f. G, s

  7. , D! y+ k2 @  i, O; k3 |% p
  8.                 BasePart *displayBasepart = theSession->Parts()->BaseDisplay();
    " L# N/ w+ R  g* N; F' Q1 g
  9.                 Part *workpart = theSession->Parts()->Work();
    . e" e" u0 u. N# [( O- W! D
  10.                 // get rootcomponent
    ) j8 R; d$ B( H
  11.                 Assemblies::Component *rootcomponent = displayBasepart->ComponentAssembly()->RootComponent();" h* S/ @( ~. B5 W$ g6 m8 o. J( c
  12.                 if(rootcomponent)/ _! o. N" j! m: @9 l' t" G& i
  13.                 {
    . w& [& p7 i& t% P& P
  14.                         Node *parentNode= tree_control0->CreateNode(rootcomponent->DisplayName());
    " A5 ]" m0 n$ v* L0 j6 x
  15.                         tree_control0->InsertNode(parentNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);8 ~* @, A( w0 p9 B* @, n) a3 }, H
  16.                         parentNode->SetColumnDisplayText(2,loadStatus(rootcomponent));! s: K/ f  Q: K4 x0 S
  17.                         getcompoents(parentNode,rootcomponent);9 `' C" @( _. H( A& }; l& N
  18.                   
    % Z- N' N  i6 M2 e% g; R' V# `
  19.                
    6 q  p1 @: v, p3 X8 D, t# z) `
  20.                 }& n1 J% Y8 G# e  k7 R
  21. - ~' e& I( }$ l* T8 ?
  22.                 else' f% W4 M7 u- x! n$ c3 [
  23.                 {
    9 ~) Y: ^6 N' R6 Z7 f* d  {
  24.                         Node *newNode = tree_control0->CreateNode(workpart->Leaf());3 E- K9 J3 B- y$ s; n1 l4 ~
  25.                         newNode->SetDisplayIcon("piecepart");8 O' w0 r0 q4 o) ]
  26.                         newNode->SetSelectedIcon("piecepart");& p7 P  i% K4 f- {' Q5 i+ d! L" v
  27.                         tree_control0->InsertNode(newNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
    & P, N! b8 e: a1 @
  28.                         newNode->SetColumnDisplayText(2,"loaded piecepart");% z8 G- J% Z! Q8 E6 m) u
  29.                         delete newNode;/ q0 G5 |1 _% F4 H; \1 |8 C; M
  30.                         newNode = NULL;# Y, u7 V1 _" ^& P' N
  31.                 # k4 n! W' X8 \% o
  32.                 }
    3 J9 }$ L5 `2 @0 @, w- E

  33. : y1 W. M- r% @3 D' @8 p9 _
  34.                
    6 `% r( C( {% y( h' x! n
  35.         }
    " A( s  a9 F7 ]9 h. y
  36.        
    0 F& j6 ]( U8 G- y9 T3 H
  37.         / ~1 ~1 Z- N, d7 _

  38. 6 Q: [( }4 Y1 T6 e
  39. - J$ _2 T( V3 T* E" ?- n# E( _
  40. Node * PNTDemo::createInsertNode(Node *pNode,NXString name,NXString geticon)& ?1 g; y4 \! V) ~" o- t
  41. {
    : J" E+ R9 j7 W+ F0 J+ ^4 E7 y
  42.         Node *getNode = tree_control0->CreateNode(name);
    . A( x, P" `- P# B) i! u5 G" ]
  43.         getNode->SetDisplayIcon(geticon);
    $ U( j2 v* G7 E6 C" p$ J# c( ~6 h* m
  44.         getNode->SetSelectedIcon(geticon);
    ; Y) _2 f9 {  K% C' j
  45.         tree_control0->InsertNode(getNode,pNode,NULL,Tree::NodeInsertOptionLast);
    2 K% K& R- W/ j9 T; f
  46.         return getNode;
    8 |9 v  i/ }3 _" n; ?0 Y$ i" `
  47. / B, f/ x, e% e4 H! e% S6 W
  48. }
    7 Z  g0 P+ m( L  M

  49. # j5 G& G) i6 @4 d) ~/ n
  50. NXString PNTDemo::loadStatus(Assemblies::Component *component)! A( v3 \, Y7 O
  51. {
    1 v) H1 U- \+ D% D
  52.          Part *part =dynamic_cast<Part*>(component->Prototype());3 P; F' r! t& }
  53.          if(part==NULL_TAG)
    % \% f  T3 y% R6 Y# H
  54.          {
    1 b6 q1 {9 b3 e9 V. U1 H
  55.            return "Not Loaded";, w! l# L! ], C5 @- Q# h' q
  56.          }
    9 I! k4 u: K- Z" o, z' e: t
  57.          else- b/ T% g8 N3 e+ ?' o
  58.          {/ ?/ u% d5 t- Y+ L8 q
  59.          if(part->IsFullyLoaded())
    " _7 X8 Z9 p9 [; S& {+ c; A
  60.                  return "Fully Loaded";
    ' p$ e3 z0 v/ e  L) w% x. ~
  61.          else
    0 i' H+ H* k4 H# I6 X, [
  62.                  return "Partially Loaded";0 N- ?# U* ~5 y- W: O! _- T/ Q
  63.         2 Z" \# g0 O1 g6 d, X
  64.          }
    3 L8 w, f; h8 ?8 h, Z
  65. }
    7 ^7 k9 h, T# E0 C. C  @" ?* U
  66. void PNTDemo::getcompoents(Node *parentNode,Assemblies::Component *root)
    ; S* H! n- x! C
  67. {6 [+ |6 _4 E6 R6 q8 ^
  68.    ( S) m( l0 M5 Q
  69.            vector <Assemblies::Component *> children = root->GetChildren();
    2 H$ B* u5 q& j
  70.            for(int i = 0 ; i < children.size(); i ++)4 c) m- X4 s  j8 r' C
  71.            {7 }: t' U( x! q% a1 Q
  72.                    Assemblies::Component *com = children[i];; u/ X& J( q, n/ {* |
  73.                    Node *newNode = createInsertNode(parentNode,com->DisplayName(),"assembly");9 U5 q$ O" g4 A1 _8 a
  74.                    newNode->SetColumnDisplayText(2,loadStatus(com));, L6 @5 _. W" {; X  t$ A* s& R
  75.                    getcompoents(newNode,com);  p1 C  P( \1 M
  76.                        
    ( t( k% w) M! q& [' k& Y) O
  77.            }
    5 g. @$ k7 z# z& A, G
  78.    
    $ w, C, C4 ]/ [$ S! R
  79. 3 w7 N: h* a+ u' F( ^
  80. , A. z+ c/ f) s9 Q1 G$ |$ F8 Y
  81. }
复制代码
4 G, c* r. ?* R( m
模拟装配导航器treelist代码分享--树控件的使用
, M0 E# B5 K+ T3 _$ k  }7 C
' v, Q  `5 e9 a7 [; ]' b# L! I/ q% \3 r% e

3 P5 u/ T; T6 Z1 H3 h  ~- A$ a6 Y, W; B; Z% e+ n. u3 Y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了