源代码:
; F9 K9 E. c! M: o
% [7 [' J, F: h: b7 J//////////////////////////////////////////////////////////////////////////////
( v" ]- k. T4 G% |) ~ t//
1 {0 X0 ^7 J/ u7 ?' S// add_view.cpp. G7 F' X2 b% B/ |% _
//3 q1 y% U) V9 s( ~- |6 B7 ^
// Description:
$ u7 ^9 @8 }/ z) O// Contains Unigraphics entry points for the application.3 r* P. b1 F2 @# N$ C1 F
//
6 E+ j3 J# p3 r# p) }$ ]) Y7 h//////////////////////////////////////////////////////////////////////////////& l$ g9 w0 ]) m% N
. @% s5 |# D3 n) |# o3 ]% a
// Include files
6 R7 G: W9 I, G' i( ?#include <uf.h>7 U% D) D3 [3 z9 ~# G& T
#include <uf_exit.h>0 o' q5 X ^' n4 t8 p$ d
#include <uf_ui.h>
2 X! H5 c S& h; ?#include <uf_draw.h>" o; R% S5 Y$ e2 Q/ H$ S; h1 F- ~
4 ?" H9 U$ W0 [0 O; g8 ? W#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
) d3 {# X5 i, z( W" \" L4 Q% O0 D# include <strstream>. y! y8 {' b8 L* ?9 z
# include <iostream>
' d# ?* a* R! G% `0 x' B( X7 Q using std: strstream;
# g, ?5 F W+ ^: d! K! N using std::endl;
$ ^2 V; V0 ?5 Q! \2 K using std::ends;
5 D6 b3 ]" o4 D; h1 b using std::cerr;5 a a2 {- U- Q$ l6 `
#else" y2 R0 h: ]6 r+ A$ N& q; N
# include <strstream.h>
$ E5 E0 w+ X+ r2 R: g' ~# include <iostream.h>" `% }5 h% |$ Y
#endif
, x2 T4 l0 g6 t#include "add_view.h", |7 D6 V9 X- p' O) M
C% j. h' N. n, U//----------------------------------------------------------------------------: O6 N0 w" ^9 d& o. O: M; [
// Activation Methods v# A5 v2 i" w
//----------------------------------------------------------------------------
8 h2 U% d. Y' q5 C+ I9 t' p9 w* V% L+ Z
// Unigraphics Startup
: ]5 L$ s: I6 G/ N! M. f% A// This entry point activates the application at Unigraphics startup
5 u# a4 O4 f2 S$ Z0 Bextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
- ~; v9 L$ z/ s6 ]9 S. w{2 _1 n# c* E$ C
/* Initialize the API environment */( f1 a9 q# z- B( n4 F+ `0 C
int errorCode = UF_initialize();
0 r0 \/ Y/ |( d) E8 h3 ^2 g
* W7 U5 M5 E+ B6 n; h# P8 N if ( 0 == errorCode )
* h: ?$ {* j3 A" u3 S {
) Y8 }( ^3 a B /* TODO: Add your application code here */
5 \+ v4 P- c4 K8 c [9 f6 u9 Z: P6 @* Y4 V
const char *dwg_name="SHT1";
: r" y1 e( [* T' u9 \0 W- B- | const char *view_name="TOP";
* y$ o0 Q$ ^; f7 J' z double reference_pt[2]={500,500};/ t: Z, U0 _" m9 w, m
int view_status=0;
1 @' @( a N+ v
7 f5 ?3 w& }! v; U3 n) v; [ uc6481(dwg_name,view_name,reference_pt,view_status);4 _$ B1 D) j+ H% D4 I: |# F
* y+ p6 H3 `& T7 ?$ f/ O, d /* Terminate the API environment */
; `5 k( I7 s- a3 b6 S errorCode = UF_terminate();
7 k' F2 Q' J/ s* A }
' ^+ I x3 c |- N3 E3 \0 G# e/ }9 R* l! x @# p
/* Print out any error messages */0 j, E( n6 U- z! V
PrintErrorMessage( errorCode );4 L' |* K/ `5 @9 {6 {, |
}& g! X/ E8 V* H3 ?& D( K7 z+ F
9 d2 a! u) J0 U1 p/ e//----------------------------------------------------------------------------
, l/ }) f- L) h- s e: [/ m// Utilities
" F% U, L0 z: N' D5 G//----------------------------------------------------------------------------7 H5 g; h, g, o; h5 ]
2 p5 o. E; \, x/ K5 O6 U3 {
// Unload Handler6 ]+ ^6 K& m$ \% U
// This function specifies when to unload your application from Unigraphics.9 ] s' `' S6 w3 u0 l0 L
// If your application registers a callback (from a MenuScript item or a
: G0 N" U9 O" h+ G, { E9 c) s) Z// User Defined Object for example), this function MUST return
! `; P: y' _" I( p0 G/ j6 \# m// "UF_UNLOAD_UG_TERMINATE".; z6 G# O3 d4 X$ b2 s1 B) E
extern "C" int ufusr_ask_unload( void )
3 K( @$ U4 i7 E& F! k+ q{
- u/ v2 u# E) d3 {$ ?" w; v( a5 k return( UF_UNLOAD_UG_TERMINATE );1 w& N% [7 k4 C% K' | \: E* O
}
; {5 u# M4 g, Z% f6 w
, X7 y0 l# B- T7 w/ v9 E- m' a/* PrintErrorMessage
# a5 A0 H5 n5 X, g: ~**$ h+ t& S1 o! |# }& |" I) U/ ~. n
** Prints error messages to standard error and the Unigraphics status3 _% v( {+ \1 `* M: r! Y+ e' L
** line. */
: X' e8 l2 \5 z- m1 rstatic void PrintErrorMessage( int errorCode )
E( k. V6 r Q( z5 ^9 A9 n{
# t' j( F9 e% b- P0 Y; c if ( 0 != errorCode )
, ~* S; w+ k3 V: }; G- H6 I6 T# y {$ o8 p" o# [4 b0 x v7 ]
/* Retrieve the associated error message */
% g2 f; L/ h/ y/ x% P: l% c char message[133];+ i- s2 e9 T) y0 U& ]% \
UF_get_fail_message( errorCode, message );" I/ j. ]! Z; d% n: \! O
( _8 h0 Z2 _- R /* Print out the message */$ N5 _' Y( k+ } K
UF_UI_set_status( message );
) z' I0 s$ X; }: k% o" r* v4 I
( y1 A# l0 q/ o" U // Construct a buffer to hold the text.
% U3 S/ Y/ I- d4 d ostrstream error_message;
7 [' q& Z4 r+ |" w7 I: n9 I: y+ F+ n0 b& y7 Y9 N5 v
// Initialize the buffer with the required text.
9 V. L" T% ~/ a/ P error_message << endl
( {* N6 v6 K2 Z8 i h9 ? << "Error:" << endl& q6 n- h, E% _9 y
<< message( d- I! e" h A
<< endl << endl << ends; z* i- l6 _3 M" X
7 x: Z% Q5 k5 p$ A$ F* R; e
// Write the message to standard error
/ V8 |+ e' o* ]) S6 n cerr << error_message.str();
# X$ t5 J+ l& `0 n/ X0 G( c }. j* T% L; Y0 F" X
} |