|
/*=============================================================================
" C3 F& }4 _1 ^/ F. @6 c7 R# O WARNING!! This file is overwritten by the UIStyler each time the Styler - ?9 [ C# }5 x8 q' ]
file is saved.% D& Y% X: X( ?2 L: X) w$ D
2 O( Z; I# R5 @, `$ z6 ~
, u9 d( r) U4 }/ h3 K" X Filename: ZGEAR_template.c; j* J; I. |/ {0 ^! i' l
' Z& ?9 _8 @# s' g1 @+ W- }" R
This file was generated by the NX User Interface Styler2 G& V5 J3 J) t, O3 t5 H
Created by: Administrator
5 [+ l+ J: o5 N! [3 `- ^ Version: NX 4' d8 B$ k, q/ C; f
Date: 03-19-10+ U& p( y" m, r8 V* l5 Q
Time: 14:14
# \/ H% v# r' k2 J7 a) x
1 C+ Q: n7 m4 ? ?6 V This template file is overwritten each time the UIStyler dialog is
" O4 ~0 ~3 I8 f% l2 ]9 S saved. Any modifications to this file will be lost.
4 b* @4 t# ^4 A1 m, N, H8 E==============================================================================*/# y( Y7 `3 V0 M9 m
( i3 e4 H7 J# j% m9 B {3 F: F8 h, H* ^
, S9 q% l1 ]1 J+ a) a9 y# ]/*==============================================================================
! g; f! C- B5 j Purpose: This TEMPLATE file contains C source and static structures to
5 P& Q) K1 C2 X guide you in the construction of your NX Open application dialog. ' J- l7 T# X# `- X8 l4 ^, n0 Z
The generation of your dialog file (.dlg extension) is the first step towards
0 ?3 x, D/ z0 n2 z dialog construction within Unigraphics. You must now create a ugOpen
; Y# R# o! d( O' f* F) b* C application that utilizes this file (.dlg). + h- I6 t. W+ U# x8 j5 F
* i! _$ c5 L. o4 l6 H; p8 \6 s( x( _9 K The information in this file provides you with the following: + V" u1 e$ k# S5 H6 E0 N
' u1 B. r' p7 E c% E
1. Help on the use of the functions, UF_MB_add_styler_actions and * A' r: z' s# k6 B0 m1 ~7 ?5 H
UF_STYLER_create_dialog in your NX Open application. These functions
, P# d/ C, i7 n$ p will load and display your UIStyler dialog in Unigraphics.
; ]7 w) i/ M7 j+ Z/ J
% P: g8 o. F8 e5 c* E- Q9 } An example of the function, UF_MB_add_styler_actions to associate your D/ n$ Z& w% ]3 n8 v
dialog to the menubar is shown below (Search on Example 1). 6 B8 C0 G1 Z5 |0 m& T5 r
1 N7 P% U1 m% d2 h( e/ ] An example of a invoking a dialog from a callback utilizing
; W# k1 p# `3 |3 p3 j, _ UF_STYLER_create_dialog is also shown below (Search for Example 2).
5 k( h, \! x. x5 ?. s& P- L + ]+ [+ k' R2 X1 V' _5 F/ D
An example of a user exit utilizing UF_STYLER_create_dialog is also ) _/ E( o1 a% m6 ]7 m+ w! [
shown below (Search for Example 3). / J2 `$ |3 M3 {1 o
: S; j F2 R0 [6 y" B% D 2. The callback structure: --- ZGEAR_cbs ---
: J2 Q8 N: q. W This structure is VERY important if you have callbacks associated with ; \( z2 I+ y ?3 p G' Y& T
your dialog. It correlates the dialog items in your dialog with the ) n8 Z: a4 S5 D! H) D) p
callback functions you must supply. You should not modify this
) w8 q5 M9 d! @) k9 ]4 M( L structure since it MUST match up to the information stored in your
, p8 ]) _! n" G% F dialog file (.dlg). Any attempt to do so will cause an error while
1 U0 v8 v& i& V# i' Z3 _( W: P constructing your dialog. If you wish to modify the association of
! p t1 K( R1 K4 D5 L4 d your callbacks to your dialog, please reload your dialog file (.dlg) into
: \) g4 n7 @- V the UIStyler and regenerate your files.
$ Y S+ P8 Q/ h( E' Q$ x You do not need to be concerned about this structure, simply pass it as 9 N9 {% R) u! I0 e% \# f' l
an argument to the function, UF_STYLER_create_dialog along with your
M/ N3 f1 p h- W* D dialog file (.dlg).
: H" X# z( O- r7 f1 h
6 s( @ _! m/ z) e( E5 J0 } Example 1 displays the actual call you may make for this particular
( Q0 W- U0 ~& y0 D, J/ t dialog. + C! }/ E; h2 K& `$ _9 x
; {' F# N& ^3 o1 }
3. The empty callback functions (stubs) associated with your dialog items " ~0 Z- ~; t: q2 N
have also been placed in this file. These empty functions have been
- Q. H* E/ c, A4 B7 h+ h created simply to start you along with your coding requirements. 8 _4 }9 |" e- i; X
The function name, argument list and possible return values have already
T; q) y& d, q" Q/ E/ E+ @ been provided for you.
9 b+ y4 k( f4 v
1 d6 B9 `: f6 |' m5 TNOTE: Each callback must be wrappered with the functions UF_initialize() " R, |4 v' h( I Q0 N* m6 m
and UF_terminate(). ) G5 D W5 E0 l0 L
# A9 F8 S \: C5 M0 Y7 @, Y
==============================================================================*/
* E! b: u+ F5 J8 L; e; L% ]
+ w0 Y5 u8 b% q9 o9 Y+ }! ^4 _! @) _ q
1 w$ ]# F P3 |9 y4 S
/* These include files are needed for the following template code. */
$ s* _; W3 l7 A6 q; i; |#include <stdio.h> 5 O" ?5 t A6 D
#include <uf.h>
8 C* w% Y, m& ]) D4 r9 C) l#include <uf_defs.h>
7 x A- I8 d5 Z9 W5 Z" b#include <uf_exit.h>
* f- z. Q6 _ c u' w+ _#include <uf_ui.h>+ c+ a6 R* x+ q% X! H# b
#include <uf_styler.h>
8 J" t1 S' |! v! r#include <uf_mb.h> ' b% y1 j( ~ X7 }$ ^0 N- @: p
#include <stdlib.h>
5 Y1 _( F5 `" V& Y/ n2 _' J' {#include <uf_modl_expressions.h>
" `* h- I4 e( w# S. m: {#include <uf_part.h>8 q$ P1 g8 V7 Z; u7 [7 N0 K. W7 j* u
#include <uf_modl.h>
% X0 A+ [2 z& A#include "ZGEAR.h"
( I4 a, X6 p- K' ^( r#define ZGEAR_CB_COUNT ( 3 + 1 ) /* Add 1 for the terminator */
( u, h( M8 t5 g) h' i 2 O7 N3 X0 ]% [; w2 m- b$ ?( c& `
/*--------------------------------------------------------------------------, d" A, d# P' u: x6 x6 ?
The following structure defines the callback entries used by the
4 @ t3 N3 d2 k' R) G2 \8 nstyler file. This structure MUST be passed into the user function, 6 c, w: O0 U s8 D& e
UF_STYLER_create_dialog along with SPLINE_CB_COUNT. 1 }$ p; i5 l5 Q$ Y7 S- J
--------------------------------------------------------------------------*/1 A& g& M7 S' [9 l; h" O
static UF_STYLER_callback_info_t ZGEAR_cbs[ZGEAR_CB_COUNT] = ( m1 G4 Y( K# {* u) K
{
# n+ w4 o! Y2 N! C5 p+ d5 V O {UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB , 0, ZGEAR_constructor},
* C' V6 b$ M) u% f {UF_STYLER_DIALOG_INDEX, UF_STYLER_DESTRUCTOR_CB , 0, ZGEAR_destructor},
1 O% S* a9 s1 a% `: q {UF_STYLER_DIALOG_INDEX, UF_STYLER_OK_CB , 0, ZGEAR_ok}," Q" d' A! [' o! [( p
{UF_STYLER_DIALOG_INDEX, UF_STYLER_CANCEL_CB , 0, ZGEAR_cancel},
0 y" {1 F! W: q2 |$ {! X- m {UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }
0 L. c3 o# @8 r! n& @& o# N3 I$ x};
! C- I8 `, f$ Bstatic UF_MB_styler_actions_t actions[] = {8 u1 l9 \ N# R6 ~0 O6 X
{ "ZGEAR.dlg", NULL, ZGEAR_cbs , UF_MB_STYLER_IS_NOT_TOP },
" f( Z+ q2 U1 Q. `5 ?2 N. L { NULL, NULL, NULL, 0 } /* This is a NULL terminated list */' y5 H' m% L6 [5 k f0 f$ r
}; Z& \) l7 e+ q# w
7 W( Y# N" h5 X7 J! V; J9 [- S
7 E" k( x1 g) J% d* n/ ~
+ k9 W! z: `, U6 b$ j8 e" \% @( E \; w" Z
( g2 C- x6 Z' }- u4 |+ F& r
' c0 [- q8 O% L: P% ?0 M
' F/ G3 R5 @+ J# g! c$ G8 M# y/ L/ Z% U2 F7 k7 P
5 G: f5 f( C+ E8 n3 L# b/*---------------- MENUBAR HOOKUP HELP Example -------------------
% _; W, K) ?# O; [, k- y& eTo launch this dialog from a Unigraphics menubar, you must follow * |* R8 g; L) a) Q
the steps below./ D' y* @2 ?1 T$ u3 Z5 b
1) Add the following lines to your MenuScript file in order to
" z' I$ N$ ~$ n! G8 g associate a menu bar button with your dialog. In this 5 o' S i9 M6 K( x
example, a cascade menu will be created and will be / S! X; m' `" w" S+ p
located just before the Help button on the main menubar. # p. B6 X a7 L/ d" ~( D
The button, ZGEAR_BTN is set up to launch your dialog and 0 P4 G: N' Z9 m3 u1 E1 I+ l1 h2 D! y
will be positioned as the first button on your pulldown menu.
* F( l M# A/ x6 s/ J8 ?0 u If you wish to add the button to an existing cascade, simply
3 R, |$ k( R" ]* h% v2 n6 O add the 3 lines between MENU LAUNCH_CASCADE and END_OF_MENU , _* B( f) ?* V% L$ @' X
to your menuscript file.
! ^% ]# ?( U. h) n) \. }
% ]; s" v( v! `8 g- {! ^ The MenuScript file requires an extension of ".men".- [6 a: }! f- ~, h
Make sure that you add the extension to the file and place 2 Z# _# s' J, I! j
the file in your startup directory:
6 m3 D7 A7 I# [+ o, t4 x, q# \ $UGII_USER_DIR/startup or " _2 L; H$ g1 h& j
$UGII_SITE_DIR/startup or - J7 ^, \7 N. F
$UGII_VENDOR_DIR/startup directory- [0 O x1 T# T& g$ X
) {7 ~) F( \- T t) I
, A: o1 q; w& t
Move the contents between the dashed lines to your Menuscript file.8 }" r S! K! a, w& g+ z& ]
! ----------------------------------------------------------------
! ~6 V# ?) o+ z. K4 k; | VERSION 120( E9 r. e( e/ k, O
. O1 b. @* _8 l3 Y% q EDIT UG_GATEWAY_MAIN_MENUBAR/ r z. E8 d/ Z2 C3 C, S
u6 d7 K3 O0 Z6 J BEFORE UG_HELP
0 k! U7 q" J9 z CASCADE_BUTTON UISTYLER_DLG_CASCADE_BTN9 J" O/ [/ d1 M8 K! N8 @( a+ N. ]! i- y
LABEL Dialog Launcher! K* n( G) J! M4 x
END_OF_BEFORE1 x! b5 t8 ^6 K7 G/ J, y. ?
5 q5 U) p+ S' j- e9 n$ l
MENU UISTYLER_DLG_CASCADE_BTN3 L2 f9 C' U& v; }
BUTTON ZGEAR_BTN4 X8 s) o. m/ ^1 v3 i1 T
LABEL Display ZGEAR dialog+ _: o7 o: b8 v# ~
ACTIONS ZGEAR.dlg4 _- u' X0 x$ a' K4 m7 M, g
END_OF_MENU
6 w; B6 k5 R; t4 W! ---------------------------------------------------------------2 Y1 u& G) X% u# D4 G) w; o7 n
! K' z5 s: |) m1 Q! G- U# c# Z+ J: @0 ^
2) Issue a call to the function, UF_MB_add_styler_actions from the ufsta0 g" F7 I! m) A! O0 w7 n# C" C
user exit as shown below. To use this call, remove the conditional 9 ~9 {( S% H- |6 s' W9 U
definitions: #ifdef MENUBAR_COMMENTED_OUT 5 [# k( c0 q+ u' ~" Y" t
#endif MENUBAR_COMMENTED_OUT
) Q( L- e$ ^% I. ?, i) z
+ m+ Z+ ]0 U n' q, Y( T The static structure, actions, will allow you to associate ALL of your
/ ?5 \8 |) q/ ^; m4 d* u: I, \ dialogs and callback functions to the menubar at once. For example, if you " B2 U! j' B- c. B( M
wish to have 10 dialogs associated to 10 different buttons on the menubar,; [. l2 ^% m8 Y5 O
you may enter each dialog and callback list into the actions structure. Make
' h3 E9 H" W) j; e- z; A sure that you have created a corresponding button in your MenuScript file. O5 b( X3 }! d! Y3 F
0 s2 [: E: }* M
You may also have separate shared libraries, each with a ufsta user exit! ^! J: q4 D' R! ]
for each individual dialog.
) n( a I$ z8 q$ y4 B/ J) |* O% k" S! a r+ ^ I
9 A9 r1 t: B1 ~
3) Place your compiled and linked ufsta user function in
, A9 d: y2 i* \ $UGII_USER_DIR/startup or 0 P7 d4 B! ^0 r0 b* D1 S. t' Q
$UGII_SITE_DIR/startup or
% h. E* P8 u; @# w- z; R, c4 C3 k $UGII_VENDOR_DIR/startup directory.
B# v- T Q: k2 s! t5 `1 R 1 ?: Z% P& Y3 v* h9 b! o6 y+ @2 b
NOTE: The user function must contain the proper extension .so, .sl or .dll $ c* S+ w/ P4 c# U9 o
to make ensure that it is recognized by the MenuScript. If it does not
& _2 p; O E8 [+ D" S- { have the proper extension, it will NOT be recognized by MenuScript.
! V# p( [ {5 u6 h+ x; F8 X8 {
' q% N Q& u2 H9 Y) g4 G9 V Y t) r
The action name you have provided in your MenuScript must correspond to
8 \% w0 O2 l+ z) C8 b to the dialog name provided in the action structure. This MUST match inorder
0 Y3 a4 S: W; Y& S to bind your dlg file to your MenuScript button.
7 h. x5 I4 b3 W2 }% D4 v v0 K8 L- e9 K* L6 v+ T2 ?
, M/ L9 ^8 E8 `+ I, w, `
4) Copy your UIStyler dialog file to the proper directory.$ l0 r) R2 A& H0 f; L' X: X
All dialog files (.dlg) must be located in
. }9 u7 B& P3 ]0 R; }/ W $UGII_USER_DIR/application or 7 g x1 _) N7 ]9 {& m! G* X
$UGII_SITE_DIR/application or
: N H) Y; E" v3 b$ b+ v $UGII_VENDOR_DIR/application directory5 i+ T- k6 h, X; c8 i( U+ \, G6 o9 f
. p5 J. O* W# t
6 y$ g, B& c9 Q9 p! P; m6 G$ z/ m" n g: C5 t- P! X8 S
8 d& }( m5 P1 W P) t0 m `
------------------------------------------------------------*/, j+ t7 ~2 I4 S5 l, `; V9 |$ _5 U2 g
//#ifdef MENUBAR_COMMENTED_OUT
2 g V: D) q' j5 m1 x% yextern void ufsta (char *param, int *retcode, int rlen)5 R6 W8 Y" O) i% O( E6 l8 a
{
; A! Z/ X) H6 J+ I# q { int error_code;3 N5 d* O+ H7 E" X% `' |$ C
5 u0 g9 Z+ ^1 ~9 x+ G/ m if ( (UF_initialize()) != 0) + D' ~- R4 Z1 x# e
return;1 ?) v3 h9 f b
7 {( e4 Y* ?9 |, ~ if ( (error_code = UF_MB_add_styler_actions ( actions ) ) != 0 )' D. x3 N& Y" K% l. C% s L/ |
{/ `7 \; q9 u7 X! D7 {7 c( E2 C4 V+ ~
char fail_message[133];4 x* ]: |) U$ m4 x4 ?
& m8 z) ]0 u9 v& v, b UF_get_fail_message(error_code, fail_message);
# p" q6 G* F/ w+ D( x printf ( "%s\n", fail_message ); + t# o' Y. ?2 W3 F" D& C
}
1 ^+ B( y* H3 }' }( ~2 }( X
3 @( e" v2 D5 |, \; ?$ `8 K3 a UF_terminate();
5 P3 L, e# ~! E4 g9 v5 R return;! J* {, B9 E9 T5 K$ R+ r
}
; L/ [5 k# ^ V2 Q//#endif /*MENUBAR_COMMENTED_OUT*/) M, u, r) r7 |8 h F; c% \4 U
, y( t+ l* ]! C5 H) o( A6 Y; D! z" j
5 i( \% F/ _7 e5 \
' L6 \. }3 {3 ^$ [1 ~9 t* J6 Y) v; ~. S' \
% J0 K9 c3 n# J: ?: Y+ v' v3 ~% c( ~" h$ e/*-------DIALOG CREATION FROM A CALLBACK HELP Example ----------* t4 K. E; I, e2 {9 T# s
If you wish to have this dialog displayed from the callback of # U! [% k4 _0 ~
another UIStyler dialog, you should: / v! }7 ]) V, }) [* ]8 @
3 F4 f* K$ I1 B" S1) Make sure that the callback of your UIStyler dialog is ; Q0 i$ E, Y/ Y% @) G# v' E
designated as a dialog building callback. ( t1 w- q, o/ }, g. ?* l- `9 @
2) Remove the conditional definitions:1 A) c# r9 l2 c* {6 s
#ifdef DISPLAY_FROM_CALLBACK ( E/ _' v6 K. Y: ^1 X: l: r
#endif DISPLAY_FROM_CALLBACK
: }* s/ [/ k( u. [ S7 u3) Your callback should issue a call to this function.
" r7 j: `. Q' @0 a4) You should also add the funcitonal prototype to your header file ; h" F; C5 [! D. v# I
(ZGEAR.h) and ensure that the file is properly included.
+ B3 {3 x+ {! w0 ]$ h8 o/ A
# ?* A* i$ T& O6 f6 b7 ?* T. a. u3 gAll dialog files must be located in
9 R, s6 O+ g) `, T3 K: y3 z+ \ $UGII_USER_DIR/application or
& s7 P; h/ H8 L1 h: s6 U/ b5 ?7 \ $UGII_SITE_DIR/application or _2 }- t Y+ T- c" j g
$UGII_VENDOR_DIR/application directory
" E8 g5 Y$ _5 K; y5 q1 r l--------------------------------------------------------------*/
" {; T0 F. s! h: o I4 s0 X0 H8 f2 y2 |' V
4 `# x5 l0 r' y' u: b5 l0 S#ifdef DISPLAY_FROM_CALLBACK
. Z4 W; T9 i z; M% Textern int <enter the name of your function> ( int *response )" N4 ^7 _2 D6 M
{
! i- t& u0 V r: z( z& x- j- z: O int error_code = 0;3 w2 D; N; O2 |/ C/ l6 A
" r" e9 W. X7 s6 Z, ^& @ if ( ( error_code = UF_initialize() ) != 0 )
6 R( R! B/ m9 u2 d. N2 n. _ return (0) ;
: x# F ^5 o; q5 g" l% m
3 d, n. K) y. ]: U. f7 n if ( ( error_code = UF_STYLER_create_dialog ( "ZGEAR.dlg",
) Z* r+ F, t. E( Y2 ^; m7 M( l ZGEAR_cbs, /* Callbacks from dialog */! a8 ^1 I( m1 u x8 }
ZGEAR_CB_COUNT, /* number of callbacks*/
5 f% s3 T" }/ ]/ n7 ] NULL, /* This is your client data */) U$ P2 |/ X" r2 t* {) d* @
response ) ) != 0 ) 5 b& w- C% `% o1 p6 \/ @
{
! \- Y& Q$ z0 P# q6 g; V char fail_message[133];
! @8 d2 \! A7 m. M2 Q3 k! G
/ f7 T$ F+ @; {0 p: u) s /* Get the user function fail message based on the fail code.*/5 t9 p! l4 D) W9 l: |3 J( k5 ?/ s' p
UF_get_fail_message(error_code, fail_message);7 y. o3 q% `! n' p
UF_UI_set_status (fail_message);
6 w+ }8 q4 r5 A9 s* W1 P printf ( "%s\n", fail_message ); . Z% @/ `" G- p/ n# F2 i
}' Q7 f7 R8 |* a- G, K: c3 B2 K* ?
- Y6 _3 e D* k% `. J
9 M& y0 p& W8 q" ~1 [ UF_terminate();
, f1 Y3 D7 P/ z7 _& i% N return (error_code);
' x8 f7 G& D; T7 c# b5 {3 |" [}+ ]0 J8 s# b4 ] s7 t6 p
#endif /* DISPLAY_FROM_CALLBACK */ ! _4 g9 Z/ w$ i" q# r* t
! Z- `* \, _& l$ t
! }) b% H0 g: O! ^+ ~3 O# j, m" `; v, d% O7 c
# n$ K7 q" D) f5 y/*-------DIALOG CREATION FROM A USER EXIT HELP Example --------- k( U1 `( x) r- F" b5 q5 x
To create this dialog from a user exit, you must invoke a 3 K7 @) d' Z% h! a. E- v
call to the NX Open API, UF_STYLER_create_dialog. An example ; Z% V0 w. l' J5 w3 h/ d
is shown below. * u- n0 `( G5 J% V9 e$ q0 d5 y& C. B9 O
1 k: N: L' Q1 K5 L: `All dialog files must be located in & m4 o/ ] f2 H
$UGII_USER_DIR/application or
4 u- t ]+ i% W& @$ e% w1 Q $UGII_SITE_DIR/application or , \8 g( V- P J9 \, u+ @
$UGII_VENDOR_DIR/application directory
z& S9 T% g: f- z/ s3 |2 g( u2 q# o0 C
1) Remove the conditional definitions:
2 @% [% H6 S3 [) ?7 | #ifdef DISPLAY_FROM_USER_EXIT ! R# f- W# f+ i+ R$ ^
#endif DISPLAY_FROM_USER_EXIT : T* C& T/ M9 {, S( J8 I- w* M
2) Add a user exit to the function name below, for example, ufusr.0 B$ P6 n7 `8 g$ T/ j- V
3) Consider how your shared library will be unloaded. Take a look K. H2 r2 q- }7 O4 F U
at the generated function ufusr_ask_unload.0 h4 Z9 w- x& o
--------------------------------------------------------------*/7 q$ O* c4 z9 e) b& p6 A/ d1 e8 U5 R1 I
5 ^7 [, U$ Z2 A) H+ j#ifdef DISPLAY_FROM_USER_EXIT
& I! @7 Y R/ X3 n; yextern void <enter a valid user exit here> (char *param, int *retcode, int rlen)
! P7 J" b% S' ^- h. C7 L1 B2 ]{3 @9 S" }* a+ M/ [* |% D
int response = 0;0 Z) j: c: A6 l' b, n% u
int error_code = 0;. L/ ], J4 U9 q
/ e& W, S9 f( X# m! w
if ( ( UF_initialize() ) != 0 )
2 f- Y) y0 t' I; _" U" ^3 { return;7 J3 Z* S# Y8 k' x( W' L5 `
) l1 l2 W) e4 v8 U% t% g if ( ( error_code = UF_STYLER_create_dialog ( "ZGEAR.dlg",' f q( R6 r4 T; W) _1 x2 @( n, H
ZGEAR_cbs, /* Callbacks from dialog */
. E$ I" C7 o- u. o# y" v ZGEAR_CB_COUNT, /* number of callbacks*/$ J& A8 g; ]1 D: q/ X
NULL, /* This is your client data */
! x0 k3 |/ |1 a! X/ F6 q! l+ }+ S &response ) ) != 0 ) 0 n) x. d+ L t5 i, P0 n7 t7 p
{- |3 f% x0 Z2 x2 \* o# k2 o" _
char fail_message[133];
: J; O9 t8 @ @: {0 C: @& A, D+ u, j' H, D. c7 S3 o
/* Get the user function fail message based on the fail code.*/+ L W6 I7 J& V
UF_get_fail_message(error_code, fail_message);
4 i2 X4 y2 G$ M& F& v* @: \ UF_UI_set_status (fail_message);
& l, t( F1 z+ k+ ~! Y/ F printf ( "%s\n", fail_message ); 2 f9 c; G" u% d1 ]3 M
}
% x5 K$ B8 ~ v
1 u. x, R$ ]8 @* @- U$ I( b7 F( e9 W- G* q
UF_terminate(); 6 q8 Q6 I. Q" P0 j9 }
return;8 Y( d! p& H$ e& B. }' @8 D9 Z
}2 g) v3 U8 @6 n3 h! u3 ?$ l
U* m" z6 s: G3 L1 h, f
}3 x; R5 W5 z; A) M
; m- Z E& G* S( H& P2 R" j
/ w+ H# E2 z9 b" W% w) f- U9 K2 m/*--------------------------------------------------------------------------
) @: n5 w# i3 f" X5 {This function specifies how a shared image is unloaded from memory 5 r( q! z; ^, T8 `2 J, d- ]% }% B6 Y
within Unigraphics. This function gives you the capability to unload an
8 L# T, d; K. l5 _internal NX Open application or user exit from Unigraphics. You can
2 l$ w# j1 j) w0 @ |specify any one of the three constants as a return value to determine 1 t2 A, |3 B6 l
the type of unload to perform: immediately after user function
9 {$ M. ?: k3 Lexecution, via an unload selection dialog, or when Unigraphics terminates : N1 v- ~# E7 l O1 v/ u
terminates. If you choose UF_UNLOAD_SEL_DIALOG, then you have the
8 W7 u! u# Q' Aoption to unload your image by selecting File->Utilities->Unload Shared 7 A4 s/ G2 j; a4 l- i( i
Image.
. M. g5 Y# _; e- f. X; y, R+ y. a+ T6 r
NOTE: A program which associates NX Open applications with the menubar
6 S5 d% Q& d4 k$ X0 I! Q, [2 F- QMUST NOT use this option since it will UNLOAD your NX Open application image0 \% T# Y" A" b2 W
--------
8 l" i2 Q( P# O9 r+ T+ Z( ufrom the menubar.
, ?4 }5 }6 k! K1 W3 t--------------------------------------------------------------------------*/) c; q9 U% a& i! u- e# t
1 ?: M7 ]5 C$ eextern int ufusr_ask_unload (void)
2 r [6 ~0 O5 k. K! E% v; s{+ g n' P2 L: g8 i% e( w1 C- H, U r
/* unload immediately after application exits*/
$ d+ `0 ?7 N+ E, D, N3 N7 K' ~ return ( UF_UNLOAD_IMMEDIATELY );0 j" q/ r3 h0 d5 C2 b
% _$ ?& O% k! s. \! t% P2 g /*via the unload selection dialog... */) E- P0 R2 W! W: c9 ?6 a
/*return ( UF_UNLOAD_SEL_DIALOG ); */4 V% ^. Q$ Q& P9 n3 A* {' {2 X
/*when UG terminates... */
6 q4 a+ S. f/ _+ n! U2 a2 _, D /*return ( UF_UNLOAD_UG_TERMINATE ); */% u& t# Q, ]- g9 |! `
}' W4 l! ~8 A1 h) D
) r' y ?- L. \* z
! b5 b% d7 b$ ?; w# b! R+ m" N& j7 J! N, Q+ M
/*--------------------------------------------------------------------------
; I8 E6 `5 f0 D: H! C" K; BYou have the option of coding the cleanup routine to perform any housekeeping: \5 {! l8 K4 u3 D' h" B, E5 a8 s* ~$ b
chores that may need to be performed. If you code the cleanup routine, it is7 [( D4 |! g: r! `) `" s
automatically called by Unigraphics.
/ l, i2 y/ x# i8 r1 X--------------------------------------------------------------------------*/- D( }$ o0 q4 ]( p6 W
extern void ufusr_cleanup (void)/ R2 r- g1 f* I& g
{7 i5 D( S) m& [! j7 {: h
return;
, u, w9 F! _6 g' b}
9 m8 I @& c+ h4 z3 s2 b( A#endif /* DISPLAY_FROM_USER_EXIT */ : Z( C7 e) y/ R* o: [
" J/ G K; P$ _3 y
$ L, [' b2 _) c$ T: z$ A1 G: w. O" }" u" D+ h3 J
' O6 l6 J4 U4 N* g* F
4 I0 q, X Y T5 i! E( Y
/ J$ t4 B* O V9 ^( B2 b/*-------------------------------------------------------------------------*/
# G* G6 K; u; Z/*---------------------- UIStyler Callback Functions ----------------------*// G4 l2 S) p; V! @; |) g
/*-------------------------------------------------------------------------*/
4 [5 t, F4 h! w5 R) G7 S& o
# t- C* g1 `1 Lint ZGEAR_constructor ( int dialog_id,
- b1 r1 S" f# F7 g* h+ D4 \ void * client_data,
6 w' N( `' w/ U6 M0 ~ UF_STYLER_item_value_type_p_t callback_data)/ L0 w; L @ t5 J% T6 C
{, b' p6 x" |3 V! V9 q2 I2 l) p! X) c. N
/* Make sure User Function is available. */
: G t) N6 J/ ?4 l if ( UF_initialize() != 0)
3 R7 F9 c$ a$ z0 H return ( UF_UI_CB_CONTINUE_DIALOG );# W- a+ T0 g, B; \: f! K: C, Z
* M9 D. E& o; `, S, [/ l4 E
/* ---- Enter your callback code here ----- */
$ t t1 y! O. R: A& l. Q2 \ char dir[100]; ' t+ P1 [" g8 B6 c
const char env[255]="UGII_USER_DIR";" N2 k4 @% n- P
char *basedir=NULL;
) {! h" W9 f' \- r7 w) C tag_t part;
* ?- V7 b' l9 J- A UF_PART_load_status_t error_status;
. z" m4 U* G. q# ~ basedir=getenv(env);# ?8 i% v/ ]# B+ W2 n4 D
# l& y, u9 t, E
strcpy(dir,basedir);
/ H& x5 E3 d0 w# `3 e% s5 i strcat(dir,"\\part\\ZGEAR_part.prt");. ~4 [" P3 j/ [! G0 T& o5 b% H% F% C
& Y9 W/ V. B6 b6 S* `! P! [ if(UF_PART_open(dir,&part,&error_status)!=0)
9 B `( f/ u- T/ z; _1 n$ ` {
# P, ?+ A! ^4 {7 Z& ?/ D UF_free_string_array(error_status.n_parts,error_status.file_names);
% V: O, j& S" K9 w UF_free(error_status.statuses);& R/ [; i Q* ~/ H0 N1 y
return(UF_UI_CB_CONTINUE_DIALOG);
9 E. J9 z5 ]# [& ~+ Q }* H9 l3 j& d& X; W `: U9 i7 c0 g
UF_free_string_array(error_status.n_parts,error_status.file_names);
7 @3 ]" I+ _1 q; ?" t) `& m& q* j UF_free(error_status.statuses);5 B. a& x: E! C* k7 n2 Z7 W& R
' O7 Z& ~ {+ n4 z. [; T! P4 e9 Y double arExpValue[5];
# g1 r4 X: r2 ?! G2 ^8 |. b
& q8 F8 p* E$ C$ z% b' T5 V UF_MODL_eval_exp("Z",&arExpValue[0]);, u! \( }# N+ [# k4 x$ o
UF_MODL_eval_exp("MN",&arExpValue[1]);
# L/ c9 F2 \) J2 p0 f UF_MODL_eval_exp("YLJ",&arExpValue[2]);
! a# |' M* \$ }$ I8 G, f UF_MODL_eval_exp("B",&arExpValue[3]);
. b% p9 n3 [4 j+ f% m [$ Y7 {0 G
* Q* Z) H3 g1 N" O: i4 Q9 B ( s e0 q3 K: z
UF_STYLER_item_value_type_t data_set;
# u Y( D+ W, z9 d I! `1 [# D2 r" ^
data_set.item_attr=UF_STYLER_VALUE;! V" ]! N- J H. C' w5 l
data_set.item_id=ZGEAR_Z;: d* a( l0 k, [* @. y; \
data_set.value.real=arExpValue[0]*2;4 E9 y" k3 E- E) \+ m( y+ d( P
UF_STYLER_set_value(dialog_id,&data_set);/ l* d0 f3 q+ c
UF_STYLER_free_value(&data_set);
1 j$ I4 s6 E( V! X$ o: X7 j
" i/ V; Z6 F8 z! s1 F5 z) e* T data_set.item_attr=UF_STYLER_VALUE;
# [; S% r" [& _4 R+ X data_set.item_id=ZGEAR_MN;
: [: Y9 Y# K1 A0 }6 U: Q data_set.value.real=arExpValue[1];# @# x; l2 e# n C( ~" N1 q6 x# T
UF_STYLER_set_value(dialog_id,&data_set);1 {$ V+ g0 ?8 Y+ n# \& I1 K
UF_STYLER_free_value(&data_set);+ p2 i' s( n2 I6 u
) F6 w" u2 g2 `( p) T2 [$ e" `6 p data_set.item_attr=UF_STYLER_VALUE;$ q" K% S& S% z
data_set.item_id=ZGEAR_YLJ;
) E6 {4 f% P9 V( O data_set.value.real=arExpValue[2];
. z7 A( N( O; j- x# S b! y0 X. S8 Z7 W0 r UF_STYLER_set_value(dialog_id,&data_set);5 ^8 s, r9 X+ f6 E
UF_STYLER_free_value(&data_set);
; p$ F: Z3 ?, E' n$ R" G, F" `& ~* B9 b( {8 M- }! |+ `
data_set.item_attr=UF_STYLER_VALUE;
8 y+ m: ~. k1 B+ W) d5 Q0 B; h data_set.item_id=ZGEAR_B;, B; i* Z/ j8 Z
data_set.value.integer=arExpValue[3];
5 n8 f" f# _4 x z UF_STYLER_set_value(dialog_id,&data_set);7 \3 ]5 G0 ?( [# [: b' U
UF_STYLER_free_value(&data_set);# p0 F9 l6 W( U5 P2 ?
/ l3 q( V2 ^' F8 Y1 g3 {+ e UF_terminate ();
5 v! ]* h2 ]+ _! J7 }% e8 ^8 m2 `& m7 N! Q4 `
/* Callback acknowledged, do not terminate dialog */6 p) j# d% f. k0 O
return (UF_UI_CB_CONTINUE_DIALOG); . O8 d. ?; m' c, ~# w
/* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */' ?1 _' U) [/ d! H+ v! n
/* for this callback type. You must continue dialog construction.*/5 l# h/ r! G) }
" ~) @- {1 ]; P$ R5 R2 O! w o} C: b1 U) ^. g5 F1 h; \) U1 i
' y m* ^1 y4 b3 X+ r9 \
. F+ J5 y6 J" U2 F
/* -------------------------------------------------------------------------
+ M( @/ m0 v; L! }7 U8 i" a * Callback Name: SPLINE_destructor
* G( }( z* a9 X% ~+ m* z; H * This is a callback function associated with an action taken from a- U v+ W( R+ q: K
* UIStyler object.
9 Y. z+ Y' M1 x' l% ~ *
. e) A4 O, U l3 e! c * Input: dialog_id - The dialog id indicate which dialog this callback
2 Z; i1 ?& K/ Z2 P! c$ k * is associated with. The dialog id is a dynamic,& J3 c x/ B% ~& l! c6 N5 W% h
* unique id and should not be stored. It is. y- B; S; M* d- ?
* strictly for the use in the NX Open API:8 y5 z' d- d9 D" W5 I
* UF_STYLER_ask_value(s) + Z& j- F7 f! Q% B
* UF_STYLER_set_value
* V# ]0 y9 X; C * client_data - Client data is user defined data associated
( l3 N6 V7 c* U4 Z& v * with your dialog. Client data may be bound
5 j, H. k! `) O * to your dialog with UF_MB_add_styler_actions
( y* p7 P; J( K6 \0 h6 E * or UF_STYLER_create_dialog. / v4 T& E/ {3 }* x0 \5 h
* callback_data - This structure pointer contains information& k. [5 m) E; s
* specific to the UIStyler Object type that
( r( \6 Z" h1 {; h * invoked this callback and the callback type.
% o2 j$ d& @+ M% y, [+ r * -----------------------------------------------------------------------*/# ~$ f V: N4 o+ W; m
int ZGEAR_destructor ( int dialog_id,
: }( [5 ~& u6 @* \- [ void * client_data,
9 ~6 S1 b1 C7 @( X. Q; E& G/ x UF_STYLER_item_value_type_p_t callback_data)6 k. Q/ V) a3 F
{4 w; r! Q: }3 T
/* Make sure User Function is available. */ ' x8 M, S9 S4 x( `0 J% d" d* K
if ( UF_initialize() != 0) 0 d% }/ z2 w" |
return ( UF_UI_CB_CONTINUE_DIALOG );, Q8 L2 K! t; j! I. F) q' x3 x" ]
2 P/ Z3 Q! K7 d' W& j! o$ B /* ---- Enter your callback code here ----- */
& P+ R! H( n: N( x f _" k
v/ o0 D+ D6 @: X; G+ K UF_terminate ();# g# z' P: n. f# v9 G9 ^$ p7 P% z V
$ S2 V6 b' J7 E* j2 G0 y /* Callback acknowledged, do not terminate dialog. */
! @, M. ]& H4 x8 `/ o /* A return value of UF_UI_CB_EXIT_DIALOG will not be accepted */
$ ^; H& n5 o; ]$ \/ j! K' i+ K. H /* for this callback type. You must continue dialog destruction*/
0 l+ x8 k" c: C$ T ~. d0 ? return (UF_UI_CB_CONTINUE_DIALOG);
) k n9 Q J/ q7 t u/ f4 A) {, {$ Y0 y- I
}7 |3 R9 e7 v' Q! F% ^ Q
9 M. t; I. D# W2 o; {- Z5 n
; ~; D B5 \9 R6 \/* -------------------------------------------------------------------------
* \1 f3 _6 n- h% v1 R% i * Callback Name: SPLINE_ok
* v/ I7 D4 z! ]1 n& b * This is a callback function associated with an action taken from a2 k2 D& i" Q' }" }+ n6 U. _
* UIStyler object.
6 h. T6 q0 j8 q" n% g% o *+ Q2 @1 x& S. b9 y
* Input: dialog_id - The dialog id indicate which dialog this callback: _- y1 k: P7 J8 k1 Q
* is associated with. The dialog id is a dynamic,; J0 Q" {. w" K; H! _6 z
* unique id and should not be stored. It is
) p/ M- Z, H u J( r3 n. r6 e * strictly for the use in the NX Open API:
/ x& }3 g; L5 @! j1 G * UF_STYLER_ask_value(s)
( P! S1 O) E& e. i6 x * UF_STYLER_set_value ( j- {9 U- T( Q A+ B" l' O6 e
* client_data - Client data is user defined data associated% \$ H6 `% X, v$ Z6 n( N
* with your dialog. Client data may be bound
, u+ z- [1 D! f& W, K * to your dialog with UF_MB_add_styler_actions4 G6 H3 | g( {6 j
* or UF_STYLER_create_dialog.
- P# |) J0 u& ?/ H9 n: b" r * callback_data - This structure pointer contains information& X( V1 j8 s- U, a4 d9 U
* specific to the UIStyler Object type that
9 c) {4 V, y, m' }8 Y5 B * invoked this callback and the callback type.) S8 Y- {# c2 e
* -----------------------------------------------------------------------*/4 v7 Z" f0 _- j& m( a
int ZGEAR_ok ( int dialog_id,4 i, F+ r. P- g0 w. W
void * client_data,
3 }/ ^4 d( j" V UF_STYLER_item_value_type_p_t callback_data)
, t8 ~, g) u+ [2 J{
0 l8 j( q' k8 W7 n# e. M /* Make sure User Function is available. */
8 D4 n" v m7 z' O3 @6 T+ t if ( UF_initialize() != 0)
" N; _5 e5 D" v$ W8 O6 P return ( UF_UI_CB_CONTINUE_DIALOG );
# d4 D% }8 l+ r9 E8 Y! D
- b3 f& p4 C9 V /* ---- Enter your callback code here ----- */
) S7 H/ D6 K* { k int Z;
$ ^: e w! ^5 C0 \# V double MN;
6 ^$ F4 S, {1 S' l8 I& I double YLJ;
% |, {6 v7 V3 Q double B; g. O- `* n0 R8 `* n6 b
& L+ y# Q3 q- M8 P+ k/ Y: n
; B+ U' K; l# B0 ?% q" T
char exps_string[5][20];
2 ^2 R- G# D; p B9 t' W0 S: k; J+ v% |7 B/ y
UF_STYLER_item_value_type_t data[5];
9 Y" N) j) M! v$ v7 g' l$ @
c9 \# P: I" f/ f data[0].item_attr=UF_STYLER_VALUE;
) W2 C1 q3 {4 j" `0 V( l data[0].item_id=ZGEAR_Z;
) m, \# T j: Z. @( j" ~ UF_STYLER_ask_value(dialog_id,&data[0]);
0 j& u( F/ z, ~& |% a) U' N5 f2 n' c+ p* X% l
data[1].item_attr=UF_STYLER_VALUE;2 G1 s8 K7 D b$ |' z* \% H
data[1].item_id=ZGEAR_MN;
4 A E7 h% H8 u UF_STYLER_ask_value(dialog_id,&data[1]);
$ C& j1 L1 r% t5 ?3 g& S' c k6 N
- x: `! Q; k8 B data[2].item_attr=UF_STYLER_VALUE;/ U/ P( g5 e9 C2 \! ~1 |
data[2].item_id=ZGEAR_YLJ;2 ]$ v% ]: q; D H/ C
UF_STYLER_ask_value(dialog_id,&data[2]);/ e |0 w. X4 u
v I6 c% L8 _
data[3].item_attr=UF_STYLER_VALUE;* n" [. e/ R& k4 x" J
data[3].item_id=ZGEAR_B;
5 x: i& w) X3 y1 S UF_STYLER_ask_value(dialog_id,&data[3]);
( H# `$ h/ O" L6 a: {$ c' y( Q. ~0 W5 m
) D+ C6 g0 F2 Z' u
' D- Y" v6 }9 B; Y0 {9 E# E
Z=data[0].value.real;1 d$ g7 _* `) J# X: Y7 U3 k# c
MN=data[1].value.real;
, Y+ b% ]4 O4 {3 l4 u; R9 V- r YLJ=data[2].value.real;: W. M4 ^$ j. I5 f2 C, G
B=data[3].value.integer;
% P* y8 G+ t/ ?' i6 @8 s+ H ' H' O) h5 i9 T; q# Q i; O
8 R3 J& x4 e1 _# W for(int i=0;i<5;i++)* U' G2 W8 ~% |4 d4 c y
{5 p U5 e! E `
UF_STYLER_free_value(&data[i]);
, s8 e8 w$ j! X; P }
4 Y& u1 J# L4 @. \# | ' n3 y9 C. d8 ?+ s+ t
if(Z==0||MN==0||YLJ==0||B==0)
& `4 Q4 m6 v) B9 J9 Z {& F7 C+ c2 n7 K
uc1601("对话框中的数值不能为零!",1);$ {1 x! [0 s4 ]! E8 H" I, z. v7 H3 k
return (UF_UI_CB_CONTINUE_DIALOG); & |) o- R" F+ g
}
d" D$ O/ Z" b
( E- R! a; [ M
+ Y3 I. M! ]2 H$ S5 t8 q6 u //修改表达式的值
/ D# _' O8 B k! ^$ n! `* s sprintf(exps_string[0],"Z=%D",Z);
* W7 n& t# _% Z4 Z, D9 i sprintf(exps_string[1],"MN=%f",MN);
2 d* b, f0 o* c1 l& m* O/ `2 G6 c sprintf(exps_string[2],"YLJ=%f",YLJ);
# K* \( q" \. U* g! L sprintf(exps_string[3],"B=%F",B);
1 W% `0 p$ h. q' }5 k, ?2 H; { ' p2 Q3 L! s/ o; _+ D
& m! J9 Q: c) J9 G/ g' r' g //更新模型/ E: j8 ~1 Q8 Z( f; p/ b& k
for(int j=0;j<4;j++)# ^& K% i& U0 \& q) h
{8 Q- _3 w3 j6 k
UF_MODL_edit_exp(exps_string[j]);
1 [ z- A! k |8 _7 U9 `3 t UF_MODL_update();7 H6 b! w0 G$ _) x
}
8 z8 r7 P3 J) A8 r y+ E6 Z
' o( Z; I8 [4 c g! d q- s5 ~ UF_terminate ();
0 ]% f; P; W/ o' ]3 y
4 _) }! v7 M2 U# j2 P$ T6 Q) u# { /* Callback acknowledged, terminate dialog */" N" b3 O5 w* i" t- I1 f$ f
/* It is STRONGLY recommended that you exit your */
2 V2 I0 s" T# _: w /* callback with UF_UI_CB_EXIT_DIALOG in a ok callback.*/
5 c& r1 O5 p( \3 j# O8 p- R: k' z /* return ( UF_UI_CB_EXIT_DIALOG ); */ |6 v- o8 Y0 h8 |& r' ~
return (UF_UI_CB_CONTINUE_DIALOG); $ ]; O8 x& l; @3 a
7 `5 {) V6 H; N$ d2 v1 W
}; z& k) R; L9 X$ {$ \
$ d& Z; N8 [# |$ o; n5 h
7 |5 F" P1 ~* q" @$ f. I( X# h/* -------------------------------------------------------------------------) W( j8 T5 _- v, p7 B$ S
* Callback Name: SPLINE_cancel
; c" B1 H# P' X) Y% | f * This is a callback function associated with an action taken from a( }& k6 |5 y# i8 b1 s, ?
* UIStyler object.
# v/ [! g0 O: y5 F; E+ o& K *; f4 }- S! _4 A" o6 K$ M* N
* Input: dialog_id - The dialog id indicate which dialog this callback; j m1 \$ e& s* S
* is associated with. The dialog id is a dynamic,% \' v! \) t: J
* unique id and should not be stored. It is' ~1 e1 g n# x' o& s: h9 Y
* strictly for the use in the NX Open API:
* D1 ]+ o& S# m8 N$ I) r1 L * UF_STYLER_ask_value(s) , ^7 }# N! X8 L5 W6 Q% r# a
* UF_STYLER_set_value : F2 X0 K+ _* k
* client_data - Client data is user defined data associated4 _8 V) E$ m/ w$ h0 l" \- L
* with your dialog. Client data may be bound% e# s% v. f. G* ?
* to your dialog with UF_MB_add_styler_actions6 J: ~% d( }$ E$ `" ^* ]$ v# }
* or UF_STYLER_create_dialog. / h& N2 k7 T; k* ~5 y- d( Z' c! W8 F) g
* callback_data - This structure pointer contains information. n% k, I: p/ m
* specific to the UIStyler Object type that 0 }6 K- S( C0 {+ u0 w
* invoked this callback and the callback type.& }3 W$ R' F+ v' X8 ~% u( ^5 o
* -----------------------------------------------------------------------*/
2 X% M3 [. R0 @/ Nint SPLINE_cancel ( int dialog_id,
& x O+ ?$ y9 [& v$ Q C9 \ void * client_data,
" m# ]3 |/ r! C( d4 H6 t UF_STYLER_item_value_type_p_t callback_data)( p1 ]& x+ E. \; n. B! s2 e
{1 g$ k- c; n P! X$ t
/* Make sure User Function is available. */
+ G4 k- s# H2 i- h) N: v1 D if ( UF_initialize() != 0)
e' V+ y- \ `2 | return ( UF_UI_CB_CONTINUE_DIALOG ); [/ j, @, c& [" H. c( Y, [
5 Z6 ~ k" `! [$ l. @( A /* ---- Enter your callback code here ----- */
. ^7 B$ a1 F9 I& \* U. H
$ S1 g$ O6 S/ h z UF_terminate ();
: g! U9 o$ y- o
9 _/ r" [% C: r5 \3 d# J /* Callback acknowledged, terminate dialog */ T( p, r& Z% \7 R
/* It is STRONGLY recommended that you exit your */
1 S" n& E8 H) } /* callback with UF_UI_CB_EXIT_DIALOG in a cancel call */
+ e7 g+ [+ F: F2 y' k /* back rather than UF_UI_CB_CONTINUE_DIALOG. */
+ X- g a A7 }: p2 i9 N2 b, q& o# g return ( UF_UI_CB_EXIT_DIALOG );
3 T; b+ Y% g7 G* z4 Z* g( @& m9 O+ E: Q& F2 @& s' r5 Q' v
} |
|