|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 c. n/ X" Q! z; Y! w5 u
/ u9 T1 G8 K. N' J: K
/ h) J# [. f/ W; l" v9 k
创建一个选择feature的功能,当用户选择的是sphere的时候,让用户选择更改球的直径!( g3 C$ w6 e) ], g9 v; k7 v0 j
; H) h. `3 q/ I+ z, T9 i2 KSession *theSession = Session::GetSession();
$ y/ h+ a, _* s UI *theUI = UI ::GetUI();
E/ }! P# A: [ Part *workPart (theSession->Parts()->Work());
' D1 @3 Z' ~$ @
$ j3 S3 n# R3 t6 ]* Q' P; O0 {, H // initialize the select + D9 ]$ s( Z A, n$ p! [
std::vector <Selection::MaskTriple> masks(1);2 u: |9 w( Q- \/ L
Selection::MaskTriple mask;
$ n! r' Q& E; o8 ^5 K6 j6 V8 u mask.Type=UF_feature_type;3 r a( s& M5 n( o# b% U
mask.Subtype =0;6 J$ y* d* p" o) v
mask.SolidBodySubtype=0;+ J: Z$ P4 E' b- L7 M6 ~% S' q" D
masks.push_back(mask);+ ~0 @+ |# b1 m
//masks[0] = {{UF_feature_type,0,0}};- Q" i Z _0 l# k/ _* Q$ N4 @
TaggedObject *object;! W, f, {) K- n. @$ O3 l0 C
std::stringstream ss;
: k9 }& m8 M, T1 H/ m- F Point3d cursor;
& M2 |) }/ P& Y$ o! Y Selection::SelectionScope scope = Selection::SelectionScopeUseDefault;6 f" r% o; K c# }" H- M. Q7 h% K
Selection::SelectionAction action = Selection::SelectionActionClearAndEnableSpecific;
- A' v- e8 \. ^$ d2 z, A! [* @) P8 O Selection::Response res;
" B- k8 s! Y0 A7 y6 B* k Features::Feature * getFeature = NULL;
9 F- {" p, W% M3 b+ B& c( Q res = theUI->SelectionManager()->SelectTaggedObject("select a feature:","feature select",scope,action,false,false,masks,&object,&cursor);- Q" ^6 I9 M2 F8 [$ S2 c( R
if(res == Selection::ResponseObjectSelected || res == Selection::ResponseObjectSelectedByName)
8 J) B( X! {- r5 r6 F# T9 D {
+ }& ?; R! I2 N$ C% |& l- Q' a // get the information
* ]# c3 j+ n( H, e8 C, t getFeature = dynamic_cast<Features::Feature *>(object);1 D& D4 s) b% I/ J' T
; Y( s6 X1 q9 p7 ^) d* }) L
theSession->ListingWindow()->WriteLine("the select feature type is : " +getFeature->FeatureType() + "\n");
q* M- \( f% I1 t# I9 B! ^
! v5 c8 n! I/ H! F# D8 V6 O if (!strcmp(getFeature->FeatureType().GetUTF8Text(),"SPHERE"))
% L0 r. h' D. P5 s% C; G1 |$ d7 t {
( m; G# l" ]/ t% d$ C Features::Sphere *getSphere = dynamic_cast<Features::Sphere *>(getFeature); t- b$ w/ J$ p! U1 k
std::vector<Expression *> exp = getSphere->GetExpressions();
3 y# l, [* R6 `3 ~: [/ d ss << exp.size() <<endl;) L3 [3 h6 |) @1 A0 W. M" e0 ^
theSession->ListingWindow()->WriteLine("the expression number is : " + ss.str() );
7 x! M2 ]1 i+ P1 U for(unsigned int i =0 ; i< exp.size();i++)
$ i+ ~3 h$ x+ ~4 I; F {
0 W, c: M2 P; T+ [' y theSession->ListingWindow()->WriteLine("The expressions are : " + exp[i]->Equation()+"\n");1 D$ A4 J x/ L4 |$ Z; v6 E* W8 R
}5 J8 y# m% G G& q' m5 X
Session::UndoMarkId undomark = theSession->SetUndoMark(Session::MarkVisibilityVisible,"change the exp");
9 Y0 Q, T( @3 h m exp[0]->SetRightHandSide("400");
# | Q5 B% I/ d5 ^ theSession->UpdateManager()->DoUpdate(undomark);1 p* b: j* K( }' H. ^
theSession->ListingWindow()->WriteLine("The expressions are : " + exp[0]->Equation()+"\n");
+ z+ ?. |5 u7 ~, l1 i }
5 W9 P2 d: O+ J7 C' }, ~+ H( b }
, }' C" T; t) o; z; A- A" n/ r0 Y% s9 a8 A- L
! K# |4 ] F: y x9 U
|
|