|
依然是菜鸟求助, C) x" c" {5 Q* p, D# U
我用UIStyler建立了一个按钮,那如何实现:点击该按钮后可以用鼠标选择一曲线,然后获得它的中点,我的程序如下,但是似乎总是死循环。, y6 q8 D( D; h% b
int GP_action_0_act_cb ( int dialog_id,
' V* D5 \4 i6 e) v void * client_data," y% z" A3 X8 I0 b6 l
UF_STYLER_item_value_type_p_t callback_data)
: _- q+ ?4 H% K0 p6 y2 Q( y{
2 a' s- s. l( u# h! j- [ /* Make sure User Function is available. */
( L' Z3 V3 d0 E% {7 _ if ( UF_initialize() != 0)
3 P7 X5 S1 M" w; O. W q return ( UF_UI_CB_CONTINUE_DIALOG );" Z- k1 v& v0 r2 P- q
' N" t* q7 z' g2 O0 H+ l
/* ---- Enter your callback code here ----- */, s- e3 j0 Z/ r9 ~) ?
char message[133];
- v, X: B8 [1 C" U1 Qmessage[0]='\0';5 I3 t! H5 g( E+ Q+ h2 |1 B
strcpy(message, "请选择一条曲线");* e I$ u2 k! t1 w
UF_UI_selection_options_t opts;0 e2 s, v* j' n$ ^3 a0 V7 {3 v2 q1 J _
UF_UI_mask_t mask;% ~3 w8 M$ F. C; I2 Q
int response;
$ i% }: e8 O* ?8 w; Wtag_t object, view;* A" q9 s! u" P
double cursor[3];
' [2 Y# G4 J A! h8 h, eint unhighlight=0;1 l3 D* j5 f8 }9 J% Q) V
7 U- J% r3 | G
# Z8 q3 N# F/ F2 z! w
0 p: ^; C) G' A2 _UF_initialize();
$ H5 g" E) I7 n+ R* N2 Z4 O/ eopts.other_options=0;' h) R7 ~" X. d* C' a
opts.reserved=NULL;
& C7 g7 [4 i; G2 J3 {opts.num_mask_triples=1;
, j3 J1 l- A3 v8 P6 p1 Yopts.mask_triples=&mask;+ L; H0 [0 U' H. ?0 \5 x1 U
) B: G- z) a& `: B$ x. w' V
opts.mask_triples->object_type=UF_spline_type;- C. [2 z9 ^0 [4 r: `+ u8 n$ {- a/ a
opts.mask_triples->object_subtype=0;
* c% b7 O0 o( {+ i0 Uopts.mask_triples->solid_type=0;
# a7 S2 a8 m; L! \; J3 ?
1 A6 D% h& X u; y& ~opts.scope=UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY;
" B& G* @8 \: U ]0 J }8 W8 ~9 kdouble port[3];
% o% q3 V! _2 z% I- w) p
. G- g- T, w% q4 f; p. S9 t( m% e6 A1 R D8 O& |
do{int irc=UF_UI_select_single(message, &opts, &response, &object, cursor, &view);}) j$ L! K% ^* v0 \# Z6 u
9 z* i# P+ Y1 W, A( [6 Ywhile (!(response==UF_UI_OBJECT_SELECTED));
4 T# f* d9 C/ C# u5 qif (response!=UF_UI_OBJECT_SELECTED)1 ` o- \4 A. _% g2 h
{
: W' n' K3 ?; K6 J( ?/ L6 _uc1601("No Curve Selected",1);
' d# E. i% i8 `& c1 sUF_terminate ();
; |$ v0 C& X. l5 ^$ m) xreturn (UF_UI_CB_CONTINUE_DIALOG);
( y4 ~3 e) S. p: \( ]} 3 z* z+ {4 A8 V( R$ T# n2 p2 [9 w
' D; P9 |9 E- s% z* [+ s% {5 [
1 v9 d$ l6 @) v. ]int ret=UF_MODL_ask_curve_props(object,0.5,port,NULL,NULL,NULL,NULL,NULL);! e+ f; Z9 ?+ @9 R! r+ k+ Q
char message2[133];
" d) `5 s E+ k" e. `" A8 e/ ? message2[0]='\0';. t, `7 ]& d- X- g
sprintf (message2, "曲线中点坐标为:%f,%f,%f",port[0],port[1],port[2]);
3 v' b) ^% u; M' | uc1601(message2,1);
/ f3 ^% U9 x2 F% B/ s2 w- H& m; U+ t: G8 [: @. H; y% ^/ [
. m. ^7 q" Y( m$ [
1 W5 \1 D! Z! e
UF_terminate ();
2 W" N5 ~ _* B4 \- [ |$ |return (UF_UI_CB_CONTINUE_DIALOG);2 b p5 t7 M; v. y
} |
|