源代码:
& c3 Z, A- J+ P$ r
5 ~ Y5 Q f6 T" P, F% \5 L//////////////////////////////////////////////////////////////////////////////
5 `3 D7 [! f/ U5 d9 j. Q//
D2 d9 \/ A8 \' b4 v" v" q// add_view.cpp! L4 m% n/ [7 @4 I& _- L4 @
//
4 [2 P6 J) y8 |# {2 n// Description:
/ a( d) Y* b2 W// Contains Unigraphics entry points for the application.
; u" F, @5 c& h; T4 Y//
/ o0 [, c. E1 s5 X# g5 \( N//////////////////////////////////////////////////////////////////////////////
# [1 F9 a0 R' G1 G, _& x/ @( F( I, H6 M: Q6 u/ B; _# w3 k( a
// Include files
. e5 i4 Z0 g: ` r#include <uf.h>+ r( Z/ X+ e2 T s) M
#include <uf_exit.h>& {& k/ p0 m- D, h! P7 g
#include <uf_ui.h>! H( o, Y/ V/ L
#include <uf_draw.h> l: K* j' Q( Y% x
# r7 N( T8 @, y8 a5 h
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
3 ^+ o) r7 I. F! J! E% _, ]# include <strstream>
0 W' J2 L0 d ]) n% J# include <iostream>) a! l1 C$ T: M& E: D! z% z% v- |( y" q
using std: strstream;) Q! x6 ^1 x0 l" s
using std::endl;
2 R0 P+ L6 X( S& y* S# d using std::ends;" p* W \1 w# @9 G1 T* Q
using std::cerr;
, e# J0 S0 \/ o2 _* |#else
/ M: \6 A, q7 `' U1 h9 Y# include <strstream.h># g' _1 j8 ~4 g6 i7 o8 r0 F- t
# include <iostream.h>
' q g3 W( j `7 u9 X- c% P3 K#endif
' z8 d8 e) E) J! |#include "add_view.h"9 z0 a/ Y5 U) @3 ^
0 F3 p0 P$ }$ x3 `" i
//----------------------------------------------------------------------------+ }' M. _/ d5 ^2 U
// Activation Methods+ ^9 b7 q B% @) P* c
//----------------------------------------------------------------------------0 R4 ? K) ?3 W& x
* i; I4 N# m# S; ~5 T4 ]- {// Unigraphics Startup' ]* ~% x- Z; a& `* i
// This entry point activates the application at Unigraphics startup
. X% P. H! Y- H) sextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
' t; P: F* d, x2 d{" i! g7 [1 {* f$ ]- i3 ~ F/ ^4 Z
/* Initialize the API environment */
$ V. f$ a+ r M: } int errorCode = UF_initialize();
- o# F4 t3 e2 U4 L3 s9 `' r+ I
& `* L9 Z: j8 @5 n7 u0 b" S2 C/ c if ( 0 == errorCode )
0 ]3 N! u. `/ E; w; R {9 p# D, N$ u9 b$ | L
/* TODO: Add your application code here */' Y7 L ?9 x+ Y$ r1 f. a
- b" u6 L! Y% I1 [4 z1 ` const char *dwg_name="SHT1";
+ @+ e- M" s$ s+ V* k6 H const char *view_name="TOP";6 \& D/ k9 j' r
double reference_pt[2]={500,500};
, }! `* _, w) _5 x& v; V" j int view_status=0;
8 x9 V. s2 D5 \ r T( ~; z: S7 g$ R9 x6 ?% ? ?7 @' s, _1 ^
uc6481(dwg_name,view_name,reference_pt,view_status);
9 @. C0 O% }6 U2 X" y5 a9 i
. G' g+ z6 f6 _2 _( R3 T /* Terminate the API environment */
3 [, Y# L$ X3 ~+ W& [3 n( U errorCode = UF_terminate();
) P7 ?; t( E! D3 O# `8 W \* d( Y1 d }* p( P" l8 d& m' G3 r6 [9 O
9 k& Z4 s' r8 w- ~- I' l
/* Print out any error messages */
- J: {; {9 b& n: I* ^7 U; [ PrintErrorMessage( errorCode );
8 r; b0 `2 N8 h2 @( R}
1 S7 A* a( T2 K. A3 z/ ^) W: [! H. |9 v% a" q- F8 p9 t
//----------------------------------------------------------------------------
5 `/ `% B* |* [5 d1 w// Utilities
" r5 _+ N9 M3 n) Z//----------------------------------------------------------------------------2 C1 p0 U# F$ A6 d G4 i9 g( c) D) m
}5 T8 }0 V) [% i
// Unload Handler! H# O! X9 s% k* Z
// This function specifies when to unload your application from Unigraphics.4 V, W5 W6 d: b- }5 U# B5 x
// If your application registers a callback (from a MenuScript item or a
) {+ v9 o7 N4 u8 D3 H) W' }) r1 y// User Defined Object for example), this function MUST return2 e$ x6 V" |! X; |% B
// "UF_UNLOAD_UG_TERMINATE".. l& j7 R% L2 j6 `% j
extern "C" int ufusr_ask_unload( void ); |. g& l r! L7 r% ?* y
{; ?# ~/ e* O; [, s8 b; T1 g
return( UF_UNLOAD_UG_TERMINATE );/ |9 f* j" x/ y* [
}1 w: {; w" r5 d# i
( {* K- O6 A+ T
/* PrintErrorMessage$ I H4 I; v) B7 V# N. m4 d
**7 j r7 x. ]; `
** Prints error messages to standard error and the Unigraphics status
, D' U% _6 _% @" ~: ?& |** line. */
* o$ B( ^+ ~) m: ystatic void PrintErrorMessage( int errorCode )% \# a R7 K1 M- [2 N' P
{
$ j1 f- n5 |: R( A, r if ( 0 != errorCode )
0 t3 V4 F1 [( W$ X6 h {
; d ]$ C& _8 s9 r1 F) p ] /* Retrieve the associated error message */* x4 |- j4 i7 D9 A
char message[133];
1 c+ q* h/ C# Q6 S( I0 B4 B6 ? UF_get_fail_message( errorCode, message );: E3 r4 }& J/ |4 u1 L2 r
& L: ^$ K- J& y6 x7 N /* Print out the message */5 u/ G! L% V$ t. v0 j% Z
UF_UI_set_status( message );
$ F9 V1 `3 L0 K
/ b5 \2 I7 {/ l. g! Z- Q // Construct a buffer to hold the text.6 O$ R" q$ X, ]3 W. `4 D- c; A
ostrstream error_message;
! Q. O$ P0 C7 Z( h8 m
7 f3 W: U. ^% H [! h // Initialize the buffer with the required text.
6 _ s: a. _2 H: T H6 s error_message << endl
: Y! }: ~( y# e- J9 H << "Error:" << endl
& D8 P2 H2 D/ c5 f; u9 J: | << message3 K' O2 _+ `) o* {" S* k
<< endl << endl << ends;5 b# E% Y/ C0 x( z" G0 [" Z
' v1 h4 D' M% S! w# P // Write the message to standard error7 Q3 i9 q; G r
cerr << error_message.str();
: z ?% I2 P" L4 q6 y* H }1 l; ?3 i5 R$ X" _& w, @; W
} |