|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
" w9 Z$ R6 ~+ w" _0 f7 Y/*****************************************************************************4 E/ {! f- f6 C
**3 l% K* l: [" m1 s5 `. O" ~( `8 E
** createfilebox.cpp
' M3 v m, D2 ]6 ~ R**
4 U1 E9 r4 B4 G+ h** Description:
6 X9 @& z4 F2 ?% R** Contains Unigraphics entry points for the application. ^) N' W; }7 ^- n) u3 Y- {
**
! S* ?" k5 g8 H; V- h ]*****************************************************************************/( e& M" t: E5 H; c+ R
/* Include files */' o& R4 g. n/ \* _4 x9 m" I
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# \6 B; X7 c i( {2 E" @7 Y6 s S5 k3 j! p# include <strstream>9 x( }3 g u$ H3 n+ A# [
# include <iostream>
* W' A" X/ `- O using std: strstream;
7 u) n, b* W V2 K0 y! r using std::endl; 7 i% f7 K: s( I. p' W6 S7 [
using std::ends;4 i$ e: y8 q9 b/ A
using std::cerr;; f5 X7 j# O. x8 M7 h) T
#else
5 J! Q% m3 }$ O" j5 J, f# include <strstream.h>/ F" i3 C2 ]5 w8 e, j' H$ O
# include <iostream.h>( L# s$ t v& p9 d) M) M1 w# a
#endif. P H4 [; d1 R7 B8 I. p6 i9 d
#include <uf.h>
. v7 D! X$ ?, t) O#include <uf_ui.h>0 [1 _9 Y+ C* ~
#include <uf_exit.h>
3 O7 N% q# c5 B; p+ T#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))5 U5 b! {+ U3 l3 W; m3 t
static int report_error( char *file, int line, char *call, int irc)
7 }2 f2 O" M( m% h& `# ?9 s; S{$ O! C! p C& R$ m: v
if (irc)0 H4 T' I; _: d3 [ a9 M' t
{
+ w6 ^6 u3 p8 K+ N5 L7 K char err[133],& ^* M7 Y E/ I+ C
msg[133];& F0 ^" a6 d, q9 H, Y- X7 ` \
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",; `& b/ R v5 N6 u2 G! z
irc, line, file);
- X, K7 V; c) t% O9 R UF_get_fail_message(irc, err);
4 ~, F& ?2 O: V8 w- |4 ?8 O+ L" l: d UF_print_syslog(msg, FALSE);: G* `0 D2 ~$ U6 B, E
UF_print_syslog(err, FALSE);
4 L, t& ~% K0 r0 i9 U E$ { UF_print_syslog("\n", FALSE);
! k. }' W% B5 d) B1 | UF_print_syslog(call, FALSE);5 z! f1 K0 t- N5 e1 l3 s" v2 G+ _
UF_print_syslog(";\n", FALSE);
S7 q' _6 w6 L6 @$ r0 K, Q if (!UF_UI_open_listing_window())
9 Q2 N( X5 a. E/ D {. i6 c* g9 I0 J* k
UF_UI_write_listing_window(msg);
* x0 J+ @, g9 n6 B1 z. ?4 @; Y2 p UF_UI_write_listing_window(err);
' u% m( b1 {+ D2 _; E UF_UI_write_listing_window("\n");9 V; S9 g O; ~6 r# H& t
UF_UI_write_listing_window(call);: z7 W0 L' Z+ j" o, B
UF_UI_write_listing_window(";\n");/ Q: W3 ?& G% ^
}% p+ g6 c" ?% e7 L
}' _: _/ q* I4 H6 }6 u! S
return(irc);5 c+ a- d3 u" T
}
1 n* p$ A o2 t1 E4 o! N
$ z& H1 e$ Q% c6 ~2 {/*****************************************************************************
* E, k- }# f* C** Activation Methods; O$ |+ m- Z1 |# p, W; ?8 [. Z
*****************************************************************************/
' A' D) z- E: C8 B; m! [# ]/* Explicit Activation% Z- a2 o6 q# ^2 `
** This entry point is used to activate the application explicitly, as in0 S$ Y5 V( b& b
** "File->Execute UG/Open->User Function..." */
% J5 y7 |; G& U2 Qextern DllExport void ufusr( char *parm, int *returnCode, int rlen )
4 c) q' p' M. _! E{* ^' v3 X( A. ^/ X" }1 X9 @7 O; P
/* Initialize the API environment */
& ]% q& |; o7 @( }3 X char prompt_string[]="open file";" y; D0 ~( H* u: O* y) f
char title_string[] = "select file";
3 M% }& @6 F4 \0 s4 c char filter_string[] = "*.prt";1 W7 M0 C3 A) c, V# G" S
char default_name[] = "my file";, b, D2 i( i4 U8 X" u4 I# u9 i' x3 d" K
char filename[256];
: g8 }& j# v. ]8 i1 t int response;
- R8 b: j9 I9 A/ T& C$ V if( UF_CALL(UF_initialize()) ) 6 B0 M2 ^7 u/ p/ ?5 V) C+ h9 l
{
; w! X4 G# k% ?; X% W3 O9 }# j /* Failed to initialize */+ d5 u' T# e6 ?. \1 A
return;
0 b: ^, Z+ U" ~3 v" A }
. u5 S" f$ i; M9 o; s- s M6 b+ _ # f+ D5 C: J' D) G" W9 S4 P+ X' N
/* TODO: Add your application code here */8 ]9 [" ]/ `& k M* P
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox1 ]' O4 w- c4 i4 a) S4 `
/* Terminate the API environment */
7 r$ |, ?( |6 o4 v9 z UF_CALL(UF_terminate());' ?( w0 r u5 p" @) x& C/ F0 d0 ?
}
$ a# U" l, n; l1 v& Q/ T" @* I/*****************************************************************************
7 H& a' r* N' e" E& f** Utilities* R! ]3 ^7 ^ c2 X( }; |0 W% v9 F4 \
*****************************************************************************/$ ^" n: f. B+ ^9 ]& E8 s. h! |4 g
/* Unload Handler
0 W* P) Z+ S7 ]$ E N' k' [** This function specifies when to unload your application from Unigraphics.
$ g1 o" h) S2 z% g/ v2 s. I5 @3 h** If your application registers a callback (from a MenuScript item or a( p3 C _' _8 Q- x- `
** User Defined Object for example), this function MUST return) O; Y% F1 @$ M! Y- t
** "UF_UNLOAD_UG_TERMINATE". */
5 |8 y* @; p0 g1 bextern int ufusr_ask_unload( void )' r$ _% [8 A* _) i% d
{
2 b: P- Q3 m; M; `( D return( UF_UNLOAD_IMMEDIATELY );
5 { A( v+ Z/ A% a7 I2 O V}4 c! K8 t( ~* P
/ c1 {* X4 L; l& R" f
|
-
|