源代码:) c% z6 y {# u8 k+ h) x5 c4 c4 p; m
- O4 a0 ?1 J5 |) ?2 P( ]//////////////////////////////////////////////////////////////////////////////1 e! [* d" z; N6 W7 K' X
//5 p% r: |0 [( F) a2 X9 { F
// add_view.cpp
+ Z9 f& t4 H/ C4 k% G# ]! a) r//
: i# d) Y* R! K2 P% o5 S7 ~- v// Description:, r! j7 b- r/ h
// Contains Unigraphics entry points for the application.
" G Q' S. V( T& w& _8 P9 o& i//3 p2 J7 K0 C# I/ S% B6 R$ l
//////////////////////////////////////////////////////////////////////////////
% m& X* w. Z. @ J/ w7 W
$ i9 t5 i: r& I% X* K, B// Include files6 R% e5 u. f8 E) s) g, @( O
#include <uf.h>
( m1 i# Y! ^% I+ T2 W |#include <uf_exit.h>! ]! h2 m+ C! b
#include <uf_ui.h>! T6 p( o. K. A4 g4 Z2 R. v
#include <uf_draw.h>9 F0 y8 g- F. J' d7 r, q/ a" L
+ `. @5 `7 l+ b6 p#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
" M, {9 z1 m( C. P% E) c5 u c5 L# include <strstream>
7 k- J0 E9 w" E# include <iostream> s# S) h7 W! ?8 z
using std:strstream;
9 K/ L* \* O8 ?/ _6 ^% O) W( U7 U using std::endl; ! j5 g a3 T( F, S
using std::ends;, ?' E/ e+ U# J/ Z% k6 j7 _: A
using std::cerr;9 q* n0 q6 y1 B$ N$ r
#else5 v& x+ z" I% ~( _
# include <strstream.h>
; f( R2 X( ?6 d; X% v' ~# include <iostream.h>/ L$ W6 p0 o9 j% F! T5 L
#endif
8 \: | c: ?' |6 C#include "add_view.h"4 ?4 V& f& o% d% m6 D
5 j. V: P* E$ s. i4 D! U: P$ a) R2 W: C//----------------------------------------------------------------------------* Z: p1 w0 X) X4 \" y5 n
// Activation Methods
# e* E2 z3 n% y0 Y. m# p//----------------------------------------------------------------------------
5 V' n v) E8 K: [/ \
+ P& z. c3 p( S9 l2 p// Unigraphics Startup( f; O- G# ^: O7 c5 R
// This entry point activates the application at Unigraphics startup
. ?- Q# R- A5 V3 z6 E- ^extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )$ y- c' ~- A: M( ]) u
{% Q0 z# D" L6 S' l' G
/* Initialize the API environment */3 x3 m6 D; l* u3 ^+ ^
int errorCode = UF_initialize();' y& R# [0 w4 G% J. `8 O: r
7 m5 y: h/ D" g+ _% p, w* l1 {
if ( 0 == errorCode )- _0 V" S4 n3 N" q! _3 X+ V, w
{
8 O3 X( H# ~- Q2 w& l/ i. n5 n /* TODO: Add your application code here */3 p' d# l# F/ J/ o& @2 q
P2 ~' b! J3 [6 o- D% { const char *dwg_name="SHT1";
, F( \2 o k7 u" L# n' y const char *view_name="TOP";
2 r" g7 W* G# }- W double reference_pt[2]={500,500};+ \. S( C: l" a8 {; \) R
int view_status=0;" D* m6 V Y% b% |5 O
3 k! N" P& O/ C3 B& Z' T uc6481(dwg_name,view_name,reference_pt,view_status);
3 V4 O7 C5 l) W5 c2 e2 [9 f
' \5 t, a! V. B& N9 @4 p /* Terminate the API environment */. E8 e1 Z# e z) ?2 C% c! |6 g
errorCode = UF_terminate();# Y# z' U1 M! x3 e/ }& w
}7 | J/ _2 }" V
5 k9 T4 X% H- s- Q4 O: [9 ?, Y
/* Print out any error messages */ L0 {/ U; w/ e3 V# D, J4 d
PrintErrorMessage( errorCode );+ r9 F/ {2 Y# W
}( t8 ?& W6 X7 f6 @. K. o
' Y) h$ F# b0 i ?//----------------------------------------------------------------------------; G6 x' j) [# V- N
// Utilities
' R+ N8 ]# t& T1 s//----------------------------------------------------------------------------
* S0 a3 m( M' O) B
$ D" ?6 L8 z. I1 k; z+ C// Unload Handler6 {$ x% P0 j S
// This function specifies when to unload your application from Unigraphics.
0 q( @2 K7 I w" s// If your application registers a callback (from a MenuScript item or a
p) m4 i. U k- I5 H+ A- ^// User Defined Object for example), this function MUST return4 C8 M0 M7 ?; G8 x! _
// "UF_UNLOAD_UG_TERMINATE".
, d( ]2 J0 L: `4 e4 pextern "C" int ufusr_ask_unload( void )1 E9 i; X2 W3 o3 I; y, n
{
; k, v) \ B! j J1 q return( UF_UNLOAD_UG_TERMINATE );
0 D Z- \1 H( R% s}$ k. G; \$ F0 N, ~- i
4 s2 v& V$ H) e2 m# D+ `/* PrintErrorMessage/ s% M* z) e1 q8 Y: |8 N& d
**2 Z& i1 D4 n) @* J& X3 H1 l
** Prints error messages to standard error and the Unigraphics status
7 d$ M* T- l' m' ^** line. */7 t o( [% l) {6 u
static void PrintErrorMessage( int errorCode )' x' ?$ r: w0 _4 L" T
{4 y0 a! Y/ b( s8 q9 t( {- g
if ( 0 != errorCode )- T$ F; a# J+ G
{( i- r4 ~1 J y) F: K {2 G f0 @, y
/* Retrieve the associated error message */, h/ j' p3 J5 V
char message[133];
; ~" I& T2 ^& Y- Y, U8 i5 }: } UF_get_fail_message( errorCode, message );$ R& e' w0 y# p+ R- W
9 I. n, y* O' ~ /* Print out the message */% {( Y$ D/ W/ T9 W" H- d8 t- f
UF_UI_set_status( message );
- p- o/ g9 C" @, O& |" H+ L# W% H
6 b* v. \, J1 f5 d3 K m // Construct a buffer to hold the text.
( {7 q9 c6 e1 R+ B1 U ostrstream error_message;! X3 ?2 D6 r1 u* q
$ r6 Q9 I8 M% ^% W4 M# _8 r0 N
// Initialize the buffer with the required text.+ l2 R/ k. P2 @7 i# y: ^9 s
error_message << endl
+ z% N' a% I8 \; M* s$ A ? << "Error:" << endl
8 m/ A; _/ ^ w3 ~ << message
# l8 k5 \' g5 n: r8 u/ E+ F << endl << endl << ends;
, q0 N; I ^" ^2 V6 ~9 u- h+ d2 O9 q \0 L; W8 q5 Z J- E
// Write the message to standard error
: m, g& u" ], r7 P, S' S cerr << error_message.str();. E2 l& u+ A' G3 \- i8 k
}
& ]. s, Z+ d- F9 t7 l$ l} |