|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' _1 z4 x- J# V6 x9 F
/*****************************************************************************. u* a$ s! B5 I. U- ]8 m
**
6 d, J! m/ ~5 y** createfilebox.cpp
4 ^4 X& s! w, t1 W**$ k* e6 J- M( x
** Description:
" Y; n' c |1 y \* `** Contains Unigraphics entry points for the application.
1 F) e* a2 U2 Q+ A7 i7 M3 [% {**
" T$ f/ c" B. n8 v*****************************************************************************/
, T7 u: w. _! Z8 \- J5 D/* Include files */" F% Y1 N7 F4 O2 H
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
2 r! I g* ?/ i. C- ^" s# include <strstream>8 }2 ]1 K. G- M2 B, q5 V( `4 K0 \
# include <iostream>; I3 n6 L# H n3 x
using std: strstream;
L- f* Y' J' k. N using std::endl;
, W" `. w2 y( `+ s1 }7 y; Y( s using std::ends;
) c: p4 F) O7 q, }& v/ T1 l0 r using std::cerr;
! \9 P9 T2 R5 w#else
8 y/ l2 h% W5 ^- ~2 M) |# include <strstream.h>0 k5 I6 J: Z2 S
# include <iostream.h>) {# a' I* u b" L
#endif
/ a. e4 M. r/ a! x N8 y X#include <uf.h>* W/ A, [0 W% f1 K* M' \
#include <uf_ui.h>1 `- p9 A6 S9 l) `
#include <uf_exit.h>$ R b8 s5 b1 u: E8 V( }
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))" \% `! u. L* i% Z# c
static int report_error( char *file, int line, char *call, int irc)8 n5 e) x( L( X, }# ~
{
3 r5 N, t) S$ `2 A* [6 ^ if (irc)
. c$ l3 u; G( W" I$ C7 o {+ J$ C$ l& T4 A! I5 C
char err[133],
# b8 S1 n. K- i) V5 i msg[133];1 P7 L4 {3 ?; G# d# c. G3 i) J
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ", I% F$ a" Q$ v% S+ B7 Z3 v
irc, line, file);
2 L( Q% a* c4 b, m UF_get_fail_message(irc, err);
; [. F5 B" a! h" V- X i, F% Y UF_print_syslog(msg, FALSE);
8 K4 b8 c6 T+ M. u3 H UF_print_syslog(err, FALSE);/ I- c3 y( o$ @+ w+ K: L' Q
UF_print_syslog("\n", FALSE);
* h# ?! N( k" G) o9 d, A UF_print_syslog(call, FALSE);/ V- F& b# M% O/ B) _9 U9 {
UF_print_syslog(";\n", FALSE);: X B1 `% Q4 x# Z( `! ~1 w
if (!UF_UI_open_listing_window())
3 l! k L: h4 m/ V' e9 ^% m: [( { {5 q1 w2 K* E! c; P0 a% J2 ^* |
UF_UI_write_listing_window(msg);
5 \: Q A; x$ b# x3 R: N: d6 { UF_UI_write_listing_window(err);
/ { r3 s( |, i+ \$ V" h UF_UI_write_listing_window("\n");5 L4 b6 O8 v6 ?( l3 p
UF_UI_write_listing_window(call);
- h7 i8 }2 t) q/ U! y UF_UI_write_listing_window(";\n");
" s& s5 V; p: ^: N( k0 s }
) U, M/ e% I0 v _- B7 _4 c }! P* G% R& x% m A, ]
return(irc);
8 y! h0 L9 Z1 O$ c% l% C}
0 }" C. y3 x( i1 `: b' l* {& z6 V5 V3 N: I7 G/ p5 Z4 Y
/*****************************************************************************( H0 r1 ^! n( p0 l/ o1 V6 G- k
** Activation Methods2 s% {8 y) b _8 R
*****************************************************************************/ E3 l4 t' f- G* s. t/ p1 ]( Z
/* Explicit Activation2 Q0 E' e- I9 Z& s5 L2 F
** This entry point is used to activate the application explicitly, as in0 [7 W! U, Q' x. q8 n
** "File->Execute UG/Open->User Function..." */9 [2 z3 v$ |7 U
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
* i4 L# n D$ p2 D{# {+ L3 g7 r2 |3 r8 c3 S
/* Initialize the API environment */3 S& w1 h$ Y9 [# N
char prompt_string[]="open file";
9 U8 l, j- W" C( D0 P char title_string[] = "select file";
1 }3 ~! y) g4 T char filter_string[] = "*.prt";5 ?6 }. U: B+ N/ D' L. Y- o- R$ A
char default_name[] = "my file";1 X% k. S0 Y2 O# \6 a
char filename[256];
% V; f, r2 l7 w# q int response;& |7 N6 d' w; H: m; M
if( UF_CALL(UF_initialize()) ) ; P3 t9 E; `& r3 J% J" Z
{
' P' \) x- v- p2 G! D, U$ M3 u7 d /* Failed to initialize */! e5 ?: A7 j7 o& y" ~: c; H7 w& A
return;8 G( A( C1 @+ N; ^2 c# Q# y: e
}
2 Y2 \. m6 Z9 N4 V: h 9 x" O2 r- s( X3 j- Y
/* TODO: Add your application code here */
! [8 P/ @3 K. Q* V- ?- Q+ w UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox/ Q; T; u0 ^5 r/ T
/* Terminate the API environment */
! Q0 s/ u1 N3 L7 ^. ? UF_CALL(UF_terminate());9 Y0 y+ N" N9 [$ J+ J. d. E
}, u& B9 `/ B) _0 R3 c" G
/*****************************************************************************7 v# k/ l+ E, a3 R- }; {
** Utilities
2 U- H" R( w6 B*****************************************************************************/
4 |# h& `* c9 |3 G# @$ r0 s/* Unload Handler
1 H7 o0 c# K- }9 m# J6 j) m! A# C' O** This function specifies when to unload your application from Unigraphics.
4 w! p7 o; b: K* I, Z( ^* a6 g2 S0 W** If your application registers a callback (from a MenuScript item or a4 s( ^& H H: ~* H& U
** User Defined Object for example), this function MUST return" J. ^7 B9 G6 H6 A ^6 ]
** "UF_UNLOAD_UG_TERMINATE". */. A/ `" i3 z) w7 C
extern int ufusr_ask_unload( void )
4 C& x$ R+ \7 r. f" c{' K, v) t) [' t5 b) P7 c s
return( UF_UNLOAD_IMMEDIATELY );* \; X1 s0 R& a% k/ n* h
}- W8 b! z- V: }: S4 i. |
! q( a' M; \3 D. d; R
|
-
|