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

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

[复制链接]

2014-2-13 14:47:51 3537 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! x  d5 y! a, D' L$ g- E
  2.             tree_control0->InsertColumn(2,"Status",100);4 b; \) \  R- x% F- }5 Y
  3. * U) ?  ]5 ?+ u" Y
  4.                 & ^  ]* \- j+ c! H" R& g2 _- z3 A
  5.                 7 h4 k4 w3 d0 O% a
  6.                 // get asembly name
      q. ~' b1 v  p3 V5 T8 H

  7. & n: j$ v6 [  @1 D5 L
  8.                 BasePart *displayBasepart = theSession->Parts()->BaseDisplay();. f  h# y/ k: S/ A3 _" N
  9.                 Part *workpart = theSession->Parts()->Work();
    1 C: e4 c% r% F/ {9 \0 Y2 x
  10.                 // get rootcomponent
    # o; f8 u% p2 a: z
  11.                 Assemblies::Component *rootcomponent = displayBasepart->ComponentAssembly()->RootComponent();
    ( ^  ^% ?4 S; f: E
  12.                 if(rootcomponent)) p  R4 Z& r+ k0 u# r
  13.                 {
    - F  p' @. z+ H: H$ t% g) S
  14.                         Node *parentNode= tree_control0->CreateNode(rootcomponent->DisplayName());
    3 V) o% ~; b. O4 y( u: ~
  15.                         tree_control0->InsertNode(parentNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);
    7 P' f! W. T1 e
  16.                         parentNode->SetColumnDisplayText(2,loadStatus(rootcomponent));
    / F3 j8 u% p; a8 u+ @, g
  17.                         getcompoents(parentNode,rootcomponent);3 c$ K4 ~- d) _+ ~. x
  18.                   9 t9 p7 I* H4 K
  19.                
    - f1 W- a' x3 p0 Q) a
  20.                 }1 M7 P( v; b. J9 ?0 Y% I
  21. $ C- W% D# r+ `' _7 n2 O- e
  22.                 else
    8 K: `5 L- q4 w
  23.                 {
    & @/ @5 O. y9 j( x2 p
  24.                         Node *newNode = tree_control0->CreateNode(workpart->Leaf());1 ?5 ?5 `' o" j- _. s( e4 u" M# N
  25.                         newNode->SetDisplayIcon("piecepart");
    # H9 K5 D+ b" f8 S6 Z
  26.                         newNode->SetSelectedIcon("piecepart");
    ! W# k* o' \  T* B2 U3 S
  27.                         tree_control0->InsertNode(newNode,NULL,NULL,Tree::NodeInsertOptionAlwaysFirst);' f( a0 L; ?$ Y6 t7 x. ^
  28.                         newNode->SetColumnDisplayText(2,"loaded piecepart");# \# R7 ?* i+ X( C
  29.                         delete newNode;
      Y+ S* Z: \. `5 s! B) r6 b. U
  30.                         newNode = NULL;4 I3 @) O* B* f' ]3 v0 ^  B% C0 d, {
  31.                
    / |" {' }6 d. e* Q0 F' k8 x/ K0 U
  32.                 }
    # C3 ^9 H9 f; A+ }$ q$ I
  33. 7 ?' _# U$ H" Y  b$ G* Y' q" E8 M# F% }
  34.                 1 B) z1 s- N6 x. I7 v5 N6 e5 K
  35.         }0 i( i8 m/ ^7 f1 g: o
  36.         * G) v  ^2 ^0 G3 z" E
  37.         * \- T: P5 {+ L2 S; B

  38. # ~& _8 j- O. B& ~! [' C

  39. ; Z+ C- X8 l8 t" s4 x
  40. Node * PNTDemo::createInsertNode(Node *pNode,NXString name,NXString geticon); n* j3 r+ a( z2 u3 _
  41. {
    . h- B% R* W4 V2 A
  42.         Node *getNode = tree_control0->CreateNode(name);& G( x% ~7 o. \$ B+ B
  43.         getNode->SetDisplayIcon(geticon);$ Y, _% Q5 a9 X! o- ~9 B2 ^
  44.         getNode->SetSelectedIcon(geticon);
    8 J" G6 ^% P$ e3 a( j7 p4 Z
  45.         tree_control0->InsertNode(getNode,pNode,NULL,Tree::NodeInsertOptionLast);
    9 v2 C0 ^# h0 }2 p
  46.         return getNode;
      X; T; n7 B* ~6 r& M% {

  47. 7 N. k, Q+ c: Z* Y0 ?
  48. }+ n- |/ H2 d* c. s/ r! M. C/ k
  49. 6 F/ ], P% h- R, C. e1 t
  50. NXString PNTDemo::loadStatus(Assemblies::Component *component)
    0 L( h" B0 X! a0 I4 s
  51. {
    * V% w, }- S- H8 I# k
  52.          Part *part =dynamic_cast<Part*>(component->Prototype());
    ; Z2 \& v0 `6 X7 p4 g6 j( Z% T+ J
  53.          if(part==NULL_TAG)2 m- G+ ~" q5 W  `! G8 s2 `9 S
  54.          {
    6 A: A: Q; K5 y6 a  [
  55.            return "Not Loaded";
    2 C4 s: G, f8 t# `- x
  56.          }
    + R. S+ q, k  K2 O! b/ `$ I. F
  57.          else3 Q& {4 }. O" C5 Z2 a! h
  58.          {
    - p1 a' L: m7 y$ j5 P+ W6 z# u
  59.          if(part->IsFullyLoaded())6 n$ t3 E/ [# w' k
  60.                  return "Fully Loaded";( L2 j" t2 }1 J2 L
  61.          else
    $ }  P& e2 J2 r! e4 n; j1 [' S$ ^
  62.                  return "Partially Loaded";
    ( f% ~; S# u6 R  M) A
  63.        
    3 ?) [; l* Z( K& y- Z" O. f3 r  f
  64.          }
    & \" g1 L; r* P8 s
  65. }
    # a1 }8 q! Z& E* _( v
  66. void PNTDemo::getcompoents(Node *parentNode,Assemblies::Component *root)" S3 `; u+ s" x
  67. {
    3 M; G0 J, A$ X8 a9 ]0 O8 p, r+ j
  68.    ( j/ a  n1 g; R
  69.            vector <Assemblies::Component *> children = root->GetChildren();
    ; h) g& J$ }3 M& d3 }
  70.            for(int i = 0 ; i < children.size(); i ++); S3 z! I# H- s. o% L$ }
  71.            {+ }, T" n) G7 L) L
  72.                    Assemblies::Component *com = children[i];  z- B& S# P  S8 T
  73.                    Node *newNode = createInsertNode(parentNode,com->DisplayName(),"assembly");
    5 O6 m# Z& _" C3 Y9 S( u' h
  74.                    newNode->SetColumnDisplayText(2,loadStatus(com));, i; Z% D  v  T( [
  75.                    getcompoents(newNode,com);# Q) t% c1 q- _4 S+ B  M
  76.                         1 z+ h2 U/ ^9 I7 ]+ j# W" W/ s
  77.            }% t) _1 U  L+ V2 t+ d. w  e
  78.    . Y" f6 _; j1 V+ w! V
  79. 4 V  }1 c7 h& Y
  80. ( b6 U) I# J! A
  81. }
复制代码
: h2 L, o7 l( R" B$ d% z1 ?
模拟装配导航器treelist代码分享--树控件的使用
. a3 b) Y3 e) x8 ?- K
6 v& Z8 y: d/ \' e3 A
7 k  s6 {$ U8 I# Y1 m; z* v/ Y0 ^% w5 O8 h
3 ^; {0 F3 }8 J0 _  A# M& a+ B& m
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了