源代码:
( G. N" J& n- O4 [9 P* Q% B! R7 f6 f8 d: \* \4 y
//////////////////////////////////////////////////////////////////////////////- Y' s- k9 r% r$ C$ ]- @
//
9 e* i( }& `$ Q6 |" U9 _: N// add_view.cpp
# `1 h9 Q0 n8 u5 R4 q- J8 l# m: R' V( {//
S3 a" M0 n! X4 C" u// Description:( C! e* }+ c+ e! }! m9 ]; A9 e, m
// Contains Unigraphics entry points for the application.
$ L e. b2 f5 B2 Y9 f//
# h' f% \1 K( \$ y% i7 k2 u3 K//////////////////////////////////////////////////////////////////////////////1 |# B2 |- c& K5 i" F( q/ k
3 O, m. E7 c) ]' T, l
// Include files+ P" ] x* N" T8 U8 u
#include <uf.h>
: d8 G& \* ?: ]: X- ~#include <uf_exit.h>
! F) }% ?0 b2 @& a" l#include <uf_ui.h>
. \- Y. m* Q5 g. s0 @) }6 x#include <uf_draw.h>" a2 X2 m3 h- }
/ m- r( F; L6 J% ]6 g# n- x6 I
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )0 C( b- T( B" x1 K" b
# include <strstream>
2 z' v2 O/ b2 C) b6 Y( y# include <iostream>/ P, m+ G; C7 f8 r/ M# _8 Q7 P
using std: strstream;
\1 _6 Q7 F9 G2 t8 a using std::endl;
) I5 X* K# M1 e0 ^ z; b using std::ends;. ~7 g& O" M+ F) T+ H, u
using std::cerr;
: j0 P3 u' @" C; P/ s#else+ _. G6 _# {; {! p; n, |5 p; c
# include <strstream.h>
0 w: ^& M3 z: e& }# include <iostream.h>6 z- E) \3 K1 F( ^
#endif) G' N5 [* ^$ j
#include "add_view.h"
+ Y! W3 O4 B6 N4 C7 K' P
. f0 R2 {; n6 m! _ O//----------------------------------------------------------------------------1 g1 M: u" g* f/ _& ?& J
// Activation Methods
( z5 z2 K. {+ C1 |; B- ~4 @! k//----------------------------------------------------------------------------% Q7 C7 d* B& p$ U, @, i l q
# k3 N( I7 Y" L ^// Unigraphics Startup% H# l8 l2 ~2 @3 y6 g
// This entry point activates the application at Unigraphics startup
- p# ~7 e [- J* D1 `* eextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )( u8 C' J P: a* w/ s/ A4 r- Q
{: u& m1 f( r, }3 i# Q2 u
/* Initialize the API environment */
- b" x% c* X, G" o0 `' ~ int errorCode = UF_initialize();0 H2 f8 m0 N. S. [
% E) w/ y% r+ |3 B( d
if ( 0 == errorCode ): `/ N) g% B, O: v+ x
{) B4 O. f z0 u6 s
/* TODO: Add your application code here */
) u8 D! t7 m& {' F
7 Z5 n8 r" Q8 J6 d const char *dwg_name="SHT1";6 O& [/ G" n3 u) t
const char *view_name="TOP";8 K3 c1 W- W, G$ Z( o, G
double reference_pt[2]={500,500};
; G' z( A$ Q8 h4 l4 n9 F int view_status=0;5 a( y1 a8 [( O4 Z* s8 K: C
& D" k% h) \. R8 {6 z uc6481(dwg_name,view_name,reference_pt,view_status);$ ^7 R3 {' w' G. r3 g& P
9 d H+ R9 r. w) q' Q7 p /* Terminate the API environment */& U6 [ V- }+ R9 X
errorCode = UF_terminate();
, f. X8 T5 b8 [) \3 T }3 B l9 y ]0 R& M5 T
x4 J6 f: T" x. Z /* Print out any error messages */* S! Z9 Q# X5 W
PrintErrorMessage( errorCode );
! J/ f9 ~9 `( c: b! N; u+ u" i2 d# Z}
" ~! U) N; I0 ]& O$ W# a# [% ]. h" u$ Z
//----------------------------------------------------------------------------
( M( Z2 }& \: d// Utilities
/ g: J9 m7 T- a+ q" L! e//----------------------------------------------------------------------------
) l( X% r+ ]2 e! B9 X b
; W) Y# m3 _) p0 ~5 u// Unload Handler
5 p* u+ `9 o; h; I) \" F& g// This function specifies when to unload your application from Unigraphics.
6 T0 _" N, T1 {/ q7 X9 y// If your application registers a callback (from a MenuScript item or a" _5 k# Y' x& X! X! K! w, c
// User Defined Object for example), this function MUST return3 ]( a/ c$ C2 I5 a5 U( X* \
// "UF_UNLOAD_UG_TERMINATE".8 W+ e% X5 c3 a( o; ~. E& o9 [% |
extern "C" int ufusr_ask_unload( void )
* G/ V! `+ z, o- c$ z{
# o/ C) E7 x! j. V/ I. G+ L0 M: t) T return( UF_UNLOAD_UG_TERMINATE );( E5 i) [' \5 |/ Q0 d- \
}! b' y% l2 Z2 e! ]0 s# r
& u2 Q3 r; L6 R% Z; ]$ d' k/* PrintErrorMessage- K# a6 g) D' ]5 D( J
**
8 E1 O4 c6 E3 W** Prints error messages to standard error and the Unigraphics status2 U4 b# S+ |# {0 l7 P4 f9 C
** line. */! X" ?# C8 M! ]- n7 r' l
static void PrintErrorMessage( int errorCode )
$ p$ f5 b) \# K6 e; {) @{ D0 s5 ~1 P0 W* U! M" ^1 B! R
if ( 0 != errorCode )- G* n! H" x7 c! ?" k# S( ]
{
/ C: ^4 t8 b2 J' j: s7 S# Q1 g /* Retrieve the associated error message */
2 J' w( _% o( n! \/ c char message[133];1 v+ z/ h: z) a- l. E& T9 |
UF_get_fail_message( errorCode, message );
7 T/ Y4 }9 e p! a& @! ]) ?
0 g( g% [+ X0 e1 ?7 \" r5 ^5 Z /* Print out the message *// W% Q& o4 k* z6 S8 e: P/ L* d. G$ h
UF_UI_set_status( message );! N1 A3 q9 ]( u, R
. _5 G* ^7 [8 V1 l: N3 ~: x
// Construct a buffer to hold the text.
3 l( ?2 o- z! o% v. l3 F# t ostrstream error_message;
3 s, R; Z9 X( ~! p/ A$ q" m* @; j+ Z; s1 f; i
// Initialize the buffer with the required text.
5 x- T% Q/ L) x1 \3 Z8 O0 |! O( Q9 Y error_message << endl
. j! r6 H8 L5 y7 e << "Error:" << endl% I0 }, M, O2 f. c* v. ?8 v a- ?
<< message* X. I( d$ {! N2 k
<< endl << endl << ends;
* W) F* ]! }- M/ R8 {8 O4 p2 O1 i* I, J- _! @# e- ^( z8 x
// Write the message to standard error3 y6 s2 M, O6 S0 m
cerr << error_message.str();
% q5 h8 H7 x4 O6 ~& v }! y* `# f( [ C3 X! o5 Q
} |