|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
5 q7 q+ o, J4 A4 \/*****************************************************************************
5 k/ V& G _- \/ \) z& `6 a* z**( G) b" l' N4 ], E
** createfilebox.cpp# G+ w: L; Q; `( r7 t3 ?
**! C* J6 K3 Q5 E" |
** Description:
0 v2 x. E. J4 F l! |- _, R** Contains Unigraphics entry points for the application.: R, N' |" j: e: o q8 ^* r
**: V5 U! g* b8 f% h: _9 ?
*****************************************************************************/
" F" ~$ a/ x m" q" P$ ]/* Include files */
7 p* y5 T1 v3 s# o4 I! b3 m4 ?#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
9 F9 _' C+ N( G. M: a' Q# M& v" n# include <strstream>
: y- I! D ]) o/ \# include <iostream>) S- T( W* k+ x% G
using std: strstream;# ^; x( P, i. r2 h5 c; s
using std::endl; . W/ p" H& I0 y7 [* w* n
using std::ends;
: c& a( `- t) O4 E' Q using std::cerr;
, } Y$ T' n* Q6 w#else
) F, p& E$ W4 \; m# Z* P# include <strstream.h>, T, \9 \/ n- W7 [' h) A; }
# include <iostream.h>
' b$ O$ v0 X1 n0 J#endif) J2 U/ P: T& Q' j; l' R
#include <uf.h>
% S: e6 s+ |0 d: X6 e- p$ m& }" g#include <uf_ui.h>: s5 ^, ^% G( Q' i8 y2 A6 f
#include <uf_exit.h>
7 z; O( o y* d6 r#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))7 b, J9 z ~2 o4 X5 F2 c# ^
static int report_error( char *file, int line, char *call, int irc)1 y# }9 H2 D7 g/ x# |+ P- E
{
. b, U) }% I- a: W5 u" M6 F if (irc)' l( _* B0 {" U5 E1 h9 j
{4 m. Y+ w: X" z( _ E' b
char err[133],
( h& _& B& X. u: J; U4 J0 b msg[133];
+ Q ?8 j: c+ x, E% ]$ E sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
" c) R+ p6 Y3 b- X; {( c- J irc, line, file);
* ?0 X3 P9 v2 {9 b6 p0 A/ O UF_get_fail_message(irc, err);
5 A1 A6 Q2 U7 E+ `8 q; e: A UF_print_syslog(msg, FALSE);
. a+ z3 d4 Q9 f0 q1 ^ UF_print_syslog(err, FALSE);$ o0 D# d% R% x* ]7 {7 q0 G/ j9 _
UF_print_syslog("\n", FALSE);" y/ L: K2 A5 d
UF_print_syslog(call, FALSE);
6 R, R9 Z) t3 D6 D9 t UF_print_syslog(";\n", FALSE);/ |9 Q4 @4 [4 M' O* n" Q
if (!UF_UI_open_listing_window())- H1 o \) a: g3 k
{, g4 k! Q. ?# v+ O8 J4 f' P
UF_UI_write_listing_window(msg);" ?1 W( r# p D4 P5 X( E+ G( L
UF_UI_write_listing_window(err);! W! Q/ ^' D' m) L$ }7 ^& L
UF_UI_write_listing_window("\n");, o; ?& |" }: s+ K" s
UF_UI_write_listing_window(call);
( N8 Q& J) V2 a5 X* _ UF_UI_write_listing_window(";\n");
3 L0 s8 q7 {( Q }
9 Z! }; c9 z/ t+ Z0 a3 X }
) J8 F+ a2 @5 i; S$ q2 |# y; T return(irc);
2 \' j) }1 S$ l0 e% B0 O* Q# ~}
6 w$ d# c7 R, Q$ c/ V
2 \9 i$ N) Y3 {5 R4 G# ^6 v- \/*****************************************************************************
1 R+ ?6 V9 N; p) ~2 z4 a$ h2 J** Activation Methods h3 I. Y2 g* F; [4 [0 q6 K
*****************************************************************************/& n/ n% I" q( P/ ?
/* Explicit Activation( q2 ^6 J6 T6 @$ |1 n& X1 j% b! \
** This entry point is used to activate the application explicitly, as in
) E5 J+ x. f! w** "File->Execute UG/Open->User Function..." */; O- Q `6 S1 G w
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
: k5 C% ?+ _- h2 v1 {, o{6 K. z( }0 L5 T7 O
/* Initialize the API environment */! J9 T5 b" B0 s2 H B3 _, V
char prompt_string[]="open file";
7 {, _" C3 V1 ^ char title_string[] = "select file";
( D$ X% x7 E/ V7 M5 j: @8 ^4 z/ r% ? char filter_string[] = "*.prt";
5 d5 k; h8 y& n* \/ c; ^8 e char default_name[] = "my file";
3 [! u) t9 i, e7 ]& n; q: F char filename[256];
3 d# P( v2 v+ T7 k# V int response;) k0 D3 H# s$ M8 P. Z8 g, D( a
if( UF_CALL(UF_initialize()) ) . k" G" u% w8 t ~# o, E/ h l5 D
{
* A. O& {, D4 Z3 \5 T% @! [ /* Failed to initialize */
/ ]9 X# C" d7 a8 R- M+ _ return;
" i+ d- ]0 D% _1 U }8 x! {4 Z- M1 U7 |5 u d
4 i8 A. h! L8 M: m3 ? _( v8 T4 F /* TODO: Add your application code here */& x" F8 ]% ]( H' A+ h0 N% y% n' v
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
) n! g6 k" Q+ e- S- c: v /* Terminate the API environment */6 `- K; `0 {5 K ]3 m& t) j& X/ o
UF_CALL(UF_terminate());* z1 e7 o( M- B. n+ Z1 P2 M
}! m+ L7 V0 [* j# l& s
/*****************************************************************************) t* l0 ?% k+ b( O, q5 E
** Utilities
, o* y( h. @5 a*****************************************************************************/
_+ b) w6 _, K: {6 v% ~1 o8 c/* Unload Handler b+ x; x0 G& E: C
** This function specifies when to unload your application from Unigraphics.
1 ?( ]" {3 g# M** If your application registers a callback (from a MenuScript item or a
$ Q1 F! X1 L: I' Q- @** User Defined Object for example), this function MUST return
, c2 j0 B* C: V0 ?4 v7 m** "UF_UNLOAD_UG_TERMINATE". */
5 f; _5 A- V+ u D& _' Vextern int ufusr_ask_unload( void )
0 ]+ ?5 J& c+ a; |/ ]( I* m' Y) \{1 {# ~: Z- Z( F+ M# {
return( UF_UNLOAD_IMMEDIATELY );
1 E4 @/ H Q/ A( ^2 w}) T5 U! F4 k0 j( w: w
; e& W: [, c0 n# G |
-
|