|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
" e# c9 P9 h/ B4 j/ @# U! @' c
) r5 H, ~7 u) |' w创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!8 W+ V; r. T( p9 n) y
0 w5 _* ?) K6 i6 Z+ A. dSession *theSession = Session::GetSession();
, D6 n7 X8 B5 M) v" e UI *theUI = UI ::GetUI();
4 a9 G h, z2 i& E1 H# J Part *workPart (theSession->Parts()->Work());* o, d; d8 z1 |1 w* B
$ _' p; j, s& t3 ?0 T1 s Y) ^
// initialize the select
A# R4 C4 V* S, A std::vector <Selection::MaskTriple> masks(1);/ W" H' E. t1 P' Z1 O% k
Selection::MaskTriple mask;
. B3 P7 m7 n- n% w mask.Type=UF_feature_type;
4 H6 |" }. k9 y; h) u$ m mask.Subtype =0;: H T4 k# {# I# l' f1 D, W7 p
mask.SolidBodySubtype=0;
" S) o6 Y( ~+ V3 q0 g0 | masks.push_back(mask);
3 H' ^- @! \' E/ ]: r2 o) r" C //masks[0] = {{UF_feature_type,0,0}};. r1 l7 }. P% r% K1 K' d
TaggedObject *object;
1 |. e( _" a. [& x! ]2 \ std::stringstream ss;
. Y4 h! R+ U; a Point3d cursor;3 \! g z. E3 s% b6 t
Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;* A( r ]$ ^, ?9 o y% l
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
& D4 x; K9 c' q- { e Selection::Response res;
2 d$ t) l( A- i9 I* u: d; J Features::Feature * getFeature = NULL;9 O" O5 |& D- t O0 f' u8 o
res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);) F+ M5 a% q& _7 v. z8 Q9 W
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName): U9 g/ R: H! _) e D, X, o0 C
{# X! ^2 [* w- e2 @0 F M2 [3 @
// get the information
6 f% ^$ d: a/ G4 W5 X, ] getFeature = dynamic_cast<Features::Feature *>(object);& T- a+ h. @5 ?( x8 }7 d4 b9 }! t+ r
5 w/ F- ] ~6 L' l4 t4 {, u4 _ theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");8 A/ k- Z7 I1 q/ S; g
5 Z/ O& v% R. Y! c if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))7 S& ~% c5 f0 A+ P4 g
{
j/ K8 `- ?4 L! w4 U Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature);
2 q' j7 p7 W$ g& P) M7 E. c4 [, i e std::vector<Expression *> exp = getSphere->GetExpressions();
7 A6 q# ~2 M$ a& |* R5 _, V ss << exp.size() <<endl;
8 t A1 d7 O( E/ O theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );; Z+ m5 R1 e) G2 T6 K+ e
for(unsigned int i =0 ; i< exp.size();i++)1 |* M' ^, Q3 L% r* V
{ $ n1 c7 r( {/ @; O
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");: A9 V, y5 P2 p- B7 B- z
}
9 J7 q. J* p l Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
' h, _0 t1 S: E exp[0]->SetRightHandSide("400");
! }6 Q+ ^5 X& d* p& z theSession->UpdateManager()->DoUpdate(undomark);' \- g4 [* W: Z. J( v7 l- m
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");- X) z7 i& y5 ]3 F* \7 S0 d+ Y
}4 F; P1 I% }( Z1 K5 B
}9 m& K* b, U- j5 J
- w! u: o; J- m+ {- K, s
' I; m: z H3 w) O |
|