|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 |6 |9 V _: R9 X3 T
/*****************************************************************************
. A! P6 M1 ^3 q5 j6 }2 ]**! C( a( ^' L; C1 e
** createfilebox.cpp
; k: I& s4 a0 D; j**
/ p% e L1 a, x( E- K7 Z** Description:4 @ w d$ w' D7 V9 z# Z% i
** Contains Unigraphics entry points for the application.
2 u- M, s) A% Q/ W) n**
( ^. k7 i6 l) S# q& ~" A*****************************************************************************/9 V% J W; X+ ?5 F0 f/ [- ]
/* Include files */
) B; Q4 I4 b; k( K/ i- j5 J#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )* H$ N; f, w. a, P
# include <strstream>
5 A# y9 D9 q/ i! Y3 ~, V+ U# include <iostream>
) }* d, \6 N, n; z' { using std: strstream;' x3 M" y" h* j
using std::endl;
* W. ~$ G) E0 y' ?% T using std::ends;4 p# R3 z B' Y, }2 ~
using std::cerr;
( K! g4 a! _3 K& n9 h#else4 Q9 t+ f7 ` E0 A8 f
# include <strstream.h>$ ?" L4 ^% Z$ M* a. W B B: k
# include <iostream.h>0 O( y" B& v' K- }
#endif$ [- E4 U1 O' A# e% [. {6 J2 I
#include <uf.h>
5 V- X) i2 p9 D& _- j# f#include <uf_ui.h>6 ` m& o5 d* l- V5 n
#include <uf_exit.h>
8 \" i+ W9 `4 f2 P& x#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))- R% \. H1 O' [ y& l+ n, ]
static int report_error( char *file, int line, char *call, int irc)
, U8 M7 _( B$ X: ]3 z{
" b# E2 l6 I0 v# Q0 Q if (irc)1 u# G" x9 ]: u% w& ]; C
{* S4 _3 B r$ k7 g; `
char err[133],5 G! `* f% L' Z+ W/ |
msg[133];6 X/ U' i: L/ E* n P+ N9 s6 E8 A
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",9 {; @7 m9 a4 ^) k
irc, line, file);- N; F6 r- A: L6 J2 H3 B7 N
UF_get_fail_message(irc, err);
8 {' v2 Z0 v) z+ W8 m T UF_print_syslog(msg, FALSE);& p) t) F; g# v
UF_print_syslog(err, FALSE);* E- I, r. [3 M H3 v+ E5 y5 x
UF_print_syslog("\n", FALSE);
- m( |0 Y* {8 | f UF_print_syslog(call, FALSE);
5 C& w/ r. G, r& t2 z- H" d UF_print_syslog(";\n", FALSE);
" m) U) B' q) I3 L6 s% |5 d# } if (!UF_UI_open_listing_window())( }; r& g; e$ ?
{6 N5 ^% c& _) b! F
UF_UI_write_listing_window(msg);8 n- }% |1 v. {; R
UF_UI_write_listing_window(err);
1 I5 e' Z6 @: E; A4 {" M UF_UI_write_listing_window("\n");+ i& J1 _3 @9 U! W# I& b' T
UF_UI_write_listing_window(call);& }5 {; p" \0 a+ K9 I/ q
UF_UI_write_listing_window(";\n");" q+ K {+ ?; Q0 _9 V0 z9 G: \
}
- I8 b0 B4 I) c8 F! C/ A6 D }
. W9 m4 d B9 n- k/ D/ m4 i; W5 u return(irc);) o2 z6 t5 s: v; R) T$ D8 _# Y( x9 M3 n
}
" o/ \/ N, C7 Q8 J; y: l, p
% ?# `' |, h2 ?5 h: |" |/*****************************************************************************
% Y0 r3 N! \$ @/ R& O** Activation Methods" W% s) t& W+ N) {: p5 X
*****************************************************************************/- `7 _3 u2 R. {- M
/* Explicit Activation. N( T3 i1 Q; {7 Z
** This entry point is used to activate the application explicitly, as in; c8 Q% J' n5 t) I1 I
** "File->Execute UG/Open->User Function..." */+ L5 n1 R' `2 v* G, ^: Q8 p
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
4 p, m) h# s& h# ~& @{
8 u5 P9 V- S5 E( R7 N! t /* Initialize the API environment */7 [. N6 R8 v2 C+ q% T; o+ o6 P$ f
char prompt_string[]="open file";
' \( C* \6 m( k' M- L6 K- T7 D/ V char title_string[] = "select file";
& U* y6 }. ^* |* R char filter_string[] = "*.prt";
4 G1 G) z! w' G$ |1 W8 {+ s9 h char default_name[] = "my file";
& n4 k$ w+ X% m- w( [0 Y: Y( o char filename[256];- I; v0 P4 C% c: n
int response;- S& Z# J4 a# R( ?/ s
if( UF_CALL(UF_initialize()) )
! P3 p8 R5 q( |8 p! x {
6 Q" D0 C/ x+ N% r /* Failed to initialize */ ~' a9 \' f2 g
return;( I" m4 q0 _7 j
}
# O+ T- y/ H3 E- X4 R) U; m
$ U# l' E: V( @4 X( L /* TODO: Add your application code here */ W% |+ i. `/ \4 c9 o) I
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
+ R% _+ }' {$ @) M0 E8 { /* Terminate the API environment */
' K' V c9 V* {) R/ J7 R. u, ^' G UF_CALL(UF_terminate());
2 w y. v' l" y3 L7 K& v; h# ?9 H}6 v: F$ e3 B7 ~8 \1 B7 P& @# Z+ w
/*****************************************************************************9 E* H; c( q* k5 l3 ~) P' ~
** Utilities* O7 V0 H5 t/ U/ M/ a) j
*****************************************************************************/
1 q6 o9 c3 i& m, u9 l; i( N/ F j/* Unload Handler( h9 o" r! s% k5 _& x v; l+ r
** This function specifies when to unload your application from Unigraphics.: M2 F4 Q) F# r |& v" m/ [- Z
** If your application registers a callback (from a MenuScript item or a& A2 e0 D5 p! f( A" k a( \
** User Defined Object for example), this function MUST return
3 D: a9 l: H; P1 w: }: g- [: k** "UF_UNLOAD_UG_TERMINATE". */
6 j. T7 K' G! |9 e$ P. w$ x$ i; aextern int ufusr_ask_unload( void )$ {5 U# O; }- L q- ~
{
/ y8 ?5 f2 G9 r* K. M return( UF_UNLOAD_IMMEDIATELY );+ q4 j M5 h* f% Z! N' m
}
2 F8 i9 z% g; b% H+ I
' s" e& x# n2 ~( e |
-
|