|
本帖最后由 yuhuimoon 于 2015-2-2 14:40 编辑 0 e8 w: O/ y( p( Q4 m% J E
3 [& s. H4 H7 `! {
测试代码是ug自带的范例ufd_ui_select_with_single.c,如下所示。3 I; x6 q5 z2 P5 n6 ]+ |3 d. r
35行中的UF_UI_select_with_single_dialog()是弹出对话框用于交互选择当前建模环境中的对象。
; o Z. j" L# G! x# D |9 kdebUG调试时,发现可以跟踪进入到代码56行init_proc()回调函数中并且也能执行到70行的return (UF_UI_SEL_SUCCESS);
) v) P" c& D& s; u+ P" f. c, k但是没有弹出对象选择对话框,而是弹出了一个默认对话框(这个对话框我没有创建过)如下图所示,不知道是什么原因,恳请指教。
, ^9 O8 Z$ b' x4 J" r! X; z, q
3 x# S$ d5 _$ Z! J- I1 |* O
( j n( @' P) A5 K
4 y( f* P) U$ |# z. {- ' ^2 g* V* v, a5 o
- #include <stdio.h>
7 ^6 J9 ^% i8 e7 {5 J2 B: i% h L - #include <uf.h>' l8 ~: N3 `& E( x- c
- #include <uf_ui.h>/ O0 i8 F7 V+ |( {# e, {% P
- #include <uf_object_types.h>, M" @# v1 \! P3 I' B
- #include <uf_disp.h>
- P# M8 ?2 M/ Q
2 e) p. R" h$ ?) N* F- static int init_proc(UF_UI_selection_p_t select,
+ _" ^" i9 i; @" w1 \, ^/ h; r - void *user_data);' I5 f; w" Q6 h% e/ J' ?" D
8 ]6 L* O3 {5 j- #define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
" A1 S6 g5 |" y8 ^- Y2 d - % n( W& Y+ p0 w- B
- static int report( char *file, int line, char *call, int irc)+ @9 |7 _; ?+ D+ C
- {
5 {$ T$ T0 B0 k+ O, h0 Z, l - if (irc)# G4 ]0 Y7 L& [2 {5 @" v2 H3 s1 D
- {- V- _6 D) W( p3 X6 u
- char messg[133];% _0 I3 G7 u+ r' _+ ` Z6 k# d6 L
- printf("%s, line %d: %s\n", file, line, call);
9 b! ?& D$ l4 A! p3 A - (UF_get_fail_message(irc, messg)) ?
* I* O6 H+ D8 s5 o- J9 g3 t" G - printf(" returned a %d\n", irc) :% J4 W, X$ n/ `
- printf(" returned error %d: %s\n", irc, messg);* ^) o/ e/ e' w
- }
: ~7 s# Q! H1 r8 j5 W- g - return(irc);
& G6 d% `; n: X) v - }
1 d! i! L$ t7 Q/ v1 \
x1 v6 f" W; N% ^- static void do_ugopen_api(void)
; G& a- }5 [, W) n - {
$ s% @) D1 K; O3 y G3 ?8 G: S - char cue[] = "cue message";
* k& ~) }$ J z1 m" R0 `2 ? - char title[] = "dialog title";
- b6 K$ Z; d: i$ q9 h3 Q - int response;. o- `3 c: q" u; F
- tag_t object, view;
. I0 S0 u. @- q$ J: r - double cursor[3];
: m& e9 h5 I1 e: l4 l* u, j( e1 | - 0 B+ g0 l# u& w; R; V" s
- : j) |1 {, E9 J) Q
- if(!UF_CALL(UF_UI_select_with_single_dialog(cue,title,: I$ \8 W) T* ^" [7 n( E
- UF_UI_SEL_SCOPE_NO_CHANGE, init_proc, NULL,+ I% |" H- G5 Z
- &response, &object, cursor, &view))); c7 E! ~/ e, y6 v% e, Y2 \
- {
" h: S( u8 E' o! f' |6 L1 k, h - if (response == UF_UI_OBJECT_SELECTED || ! |* e4 ` a, M1 p$ d
- response == UF_UI_OBJECT_SELECTED_BY_NAME)7 L5 _: X6 N h2 E) F/ O" B
- {: V0 v- P! L# {+ U: D. j
- printf("object tag = %d\n", object);
- r3 V$ F( G) _5 X6 ^ - if (response == UF_UI_OBJECT_SELECTED)
6 F0 z) y% ?" j H! x - {$ n1 }$ Z; x9 N5 L; ^+ c3 \4 J
- printf("view = %d\n", view);$ x. C0 H; E0 `; c
- printf("cursor position = %f %f %f\n",
" b* d& I e) I9 |' s) }% h - cursor[0], cursor[1], cursor[2]);1 c6 X+ g/ t" P, w- t+ R
- }
8 Q3 a% b( D6 \' ` - }: |& j& I9 d1 `7 ]1 H, v' K( ]
- /* unhighlight selected object */
2 }& ^7 o! M$ U5 _4 o; m% N - UF_DISP_set_highlight(object,0);+ G" m6 g9 u P
- }0 s M. b5 j( i* p9 K5 G/ ^
- }3 I/ {$ _1 {& T% Q3 C0 x
- , Q: x6 }5 I0 J: F, `; }
- /* selection initialization procedure */" E+ y& H4 N! E( l' _" @+ A% m
- static int init_proc(8 Z7 i' M% n7 Q% E3 Q! E
- UF_UI_selection_p_t select,
y* s/ h4 T) R R ]4 w - void* user_data)
, Q& P; S) I0 Z2 l- q - {+ C% U2 g# x) D1 O9 l
- int num_triples = 2;1 M7 J$ h0 Y* ]
- UF_UI_mask_t mask_triples[] = {
, i1 X6 @ B% C7 s - UF_line_type, 0, 0,
5 F) l; x2 J2 u( ]8 w8 Y! ]* U - UF_solid_type, 0, UF_UI_SEL_FEATURE_ANY_EDGE};
. v+ g% J0 U l% U, } - r% c9 V( c% O/ X0 s- Y
- /* enable only lines and edges */6 I5 p) s3 K- x$ }
- if((UF_CALL(UF_UI_set_sel_mask(select,
$ K# n/ Y8 k" r! q9 \ - UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,
. ]8 X3 d$ P8 o2 I: ]- { - num_triples, mask_triples))) == 0)& ~+ N _8 m# G: {
- {
* C; t9 d' T/ O, r' e - return (UF_UI_SEL_SUCCESS);$ B/ A5 o* m: G1 g
- }& b' q. e$ M% q6 p
- else+ n8 L- N1 v3 K( r6 @. {+ y
- {% w3 i( f0 e1 `% x
- return (UF_UI_SEL_FAILURE);
m5 \. A! K+ U" ]+ q - }
' y( u& c+ J# C! v1 X9 J - }2 v) z0 M1 p+ F! t: r
- /*ARGSUSED*/
1 [# R& \4 ?* A8 [7 U% K0 z, K - void ufusr(char *param, int *retcode, int param_len)
6 c* n% m# `0 T H$ L, ^ - {
1 p. g/ N. L* I! `0 B - if (!UF_CALL(UF_initialize()))
1 H6 N: J5 A+ k* t& w5 ~ - {
) m2 \, S# Y5 O/ }3 A - do_ugopen_api();) j/ k5 n; A2 b8 p) K! ?2 m
- UF_CALL(UF_terminate());
/ m# C: q u: L- ?% X; S - }
. Z& y" n& g7 Q4 j - }: W/ u( X1 e/ U- J
& A+ M: a& X8 Z I) i- int ufusr_ask_unload(void)
4 z& j3 S/ J6 i' I; D0 W' ] - {
- o- p$ P& @0 _ - return (UF_UNLOAD_IMMEDIATELY);
( H! D. S/ |9 ~& k- A, b - }
复制代码
" b. A3 ]0 j! E6 t6 {" t/ a
, s7 L, u8 ]# h* U
. s2 ^& j7 Y! J g7 ] |
|