|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
" w5 T& V S% G2 W: _! t
" L% O# m% q6 q) e% {* w
6 W6 Z0 Y) M6 N' q( B% Y' R创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!0 s& u! _ z' J+ n
H& g1 f% @. R! YSession *theSession = Session::GetSession();
( {3 W! I/ N Y3 c UI *theUI = UI ::GetUI();3 ^6 j2 @3 S, z7 S8 |6 v% s
Part *workPart (theSession->Parts()->Work());
1 `2 s) J- ~& w$ c/ c+ g) v0 O: [. b) ^1 B+ e! Z( h5 q, o
// initialize the select
- A5 V" v( B# {6 V3 U$ n9 x# m0 D std::vector <Selection::MaskTriple> masks(1);% C* u! u* S8 E. S
Selection::MaskTriple mask;' ~* p& e- o/ e$ n7 L
mask.Type=UF_feature_type;/ R' ?3 e! d2 B, m3 M1 a
mask.Subtype =0;
1 Y5 Y' M9 l" m, | mask.SolidBodySubtype=0;0 m+ _5 Y: }& w
masks.push_back(mask);
0 @4 m* l( ~; K8 c1 X+ f' o //masks[0] = {{UF_feature_type,0,0}};
- o7 A) z5 D. w7 b TaggedObject *object;
+ h4 i' m, b' F6 u std::stringstream ss;
% O+ s j: f( C& a i. L6 F; V Point3d cursor;2 w- g' y( \( q1 f5 h' I, J
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;
$ v0 [: S6 f9 X. A) p Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
4 {$ [- G2 }% c" D3 j Selection::Response res;& l- L0 m0 R( h) u6 ?
Features::Feature * getFeature = NULL;9 }( _( m: @$ t0 d- }
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);+ M. \0 p. K2 r ^1 i8 Y
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName): x) ]+ h& c9 b B
{
$ J' j6 u4 l, V1 x // get the information
2 P$ @& U( z: p- P0 G: q9 N% w getFeature = dynamic_cast<Features::Feature *>(object);" d+ O; T% ^+ o6 c
% H, [% S% i, Q1 N% O theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");* X5 \$ B+ Y, D( ~; J
6 \8 D: W; p& r- q if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
+ P& u) @( e" c% \$ K {4 h- m- D, d) \
Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
5 H. }! z, ~- r5 M( k. i std::vector<Expression *> exp = getSphere->GetExpressions();( c) M' W! [( b9 l$ \8 @& ?) S
ss << exp.size() <<endl;
5 A! ~% G* B* \( z( I8 a4 y4 } theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
5 N7 k9 d0 O6 b for(unsigned int i =0 ; i< exp.size();i++)
: |7 j5 n& X, [6 V* x5 r { - c. V O5 e4 @4 j3 k
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");" D( r/ ?9 x% G
}8 R; h, J2 s- t5 L4 N' {' _
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
$ C. k) T/ ?* ~7 I" {) b2 U L exp[0]->SetRightHandSide("400");
1 c& Y. U5 B+ B/ P# S, h theSession->UpdateManager()->DoUpdate(undomark);
4 ]: O1 p" W' D' s% U8 H% u' E; ~ theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n"); _* w; P; A" ?$ L6 F
}
0 X$ a3 F- f+ o9 H1 e6 k x. W }" s, s: U1 g6 q# a; S
g. G0 u& @+ }! C& P
; D$ Z: q5 s4 q
|
|