|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 @- I+ | b0 G# [# q- M$ }" c+ O* C7 v7 Z$ \
" @6 K( |" _/ A1 k! o$ e
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!6 Q' z: P' M: g4 m; {" o8 x5 r# m
# f" Q' p7 W2 i8 USession *theSession = Session::GetSession();$ T$ I( `4 c9 `* t
UI *theUI = UI ::GetUI();
% F8 q+ Z1 E+ x& L Part *workPart (theSession->Parts()->Work());
6 T6 b" D; S* N- m8 W1 H" Y9 J
$ ^* t; _9 q* E8 P // initialize the select
" t8 L- s$ o- U8 Q- m3 q std::vector <Selection::MaskTriple> masks(1);
" f* L+ F* V/ B# h1 n Selection::MaskTriple mask;
$ N' n8 ~4 z% w" H9 f& G0 K. s mask.Type=UF_feature_type;, [8 G9 P! ?( T/ t8 y/ E" g$ r. B
mask.Subtype =0;# i: S8 ^" l4 b9 T: A; j$ m% B& E" }# _
mask.SolidBodySubtype=0;7 F6 P1 W5 Q8 }( v3 z
masks.push_back(mask);
5 s0 u6 I8 S+ J) J5 z) j //masks[0] = {{UF_feature_type,0,0}};
, C W2 w3 q: x$ k TaggedObject *object;
8 o' I, ?9 y. x std::stringstream ss;" x) d5 W$ k ?- O H. V
Point3d cursor;
0 } l9 u( H* i5 L7 G6 C3 ^5 Q1 } Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;) }* {4 b' v1 r* C( M
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;4 ?+ f% l% K- W( U- W" c0 y9 L$ |
Selection::Response res;! C( x' [6 n0 E. V7 Q$ R
Features::Feature * getFeature = NULL;9 v1 C A* Q: k0 [$ O1 f! }
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);0 M0 e) h4 X- t0 n0 m
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)7 s$ c% P( ~, E5 r9 j0 `' K
{
2 F* L3 r/ M% R- g% i1 q; X // get the information
2 y4 M# h* d, s% S. N getFeature = dynamic_cast<Features::Feature *>(object);
3 h W) m, E `. ]
% p P' a6 v: S# }7 X: I theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");1 R: A6 N" ^/ d9 ^1 i. X0 }
5 r4 D/ B7 _5 A, {* ` i if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
' l* r8 p6 b0 @* v ` {* v# I3 L& T$ j
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
' i$ A% N. }2 G0 T3 A5 }3 v1 ]+ ` std::vector<Expression *> exp = getSphere->GetExpressions();+ c- ?% p( f: [' i1 o2 W
ss << exp.size() <<endl;
* n( T% ?+ l! \/ t- K) I! o; K theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
$ Z7 d; \: A l for(unsigned int i =0 ; i< exp.size();i++)
, C% `3 J0 [0 x! |- w8 L { 5 D6 ] w( j9 h/ i; N
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");( J R. j3 h8 \' b! D
}7 |8 X3 H0 j' w2 `+ e% Y" x. H. l' }
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
1 Q" k* L# ]& c7 x. y7 e exp[0]->SetRightHandSide("400");
?" ]- Y2 v$ ]: I' u% ? theSession->UpdateManager()->DoUpdate(undomark);' H7 I: I v6 `# m" P
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");7 e$ p" I+ `# e2 O \
}
! h; ~1 g+ J3 d" K }
9 A6 @2 h; o* U$ Q3 w7 \* c
5 a! }) O6 x' E" }% S i$ d
+ A+ y9 d- h6 S" t/ Z |
|