源玛:
6 e$ \, j4 q' d" L1 \6 G6 L# j& B: U* A
//////////////////////////////////////////////////////////////////////////////. ~8 Q* {/ n% `1 { l; ?6 l/ E
// \$ {4 ]2 G5 |6 G' i- `$ Z
// create_oper.cpp- d! L, a# Q9 v1 M
//9 E# N' O) m" Q6 [. z; [; e
// Description:) T' Y8 z( j8 T
// Contains Unigraphics entry points for the application.+ J0 }2 i% Z- A4 R" }% n
//
; s' A: v; O' E j7 M: v) Q//////////////////////////////////////////////////////////////////////////////
V1 F; [- U6 e2 Y0 C. [
( T z* e" u y! A// Include files
# p. N) v6 P4 n: z, i1 q#include <uf.h>5 [6 b2 r. N% T4 W
#include <uf_exit.h>
. B1 s: s! l- B& ]6 N% W' M7 g#include <uf_ui.h>: U* k: s' S* A
#include <uf_oper.h>
2 z( \. e6 Z& M* D4 s2 L/ l$ Y#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )- _2 u- k& Z; M g7 w0 L; }
# include <strstream>
; R3 t/ ~9 Y7 I$ V2 ]4 q1 l# include <iostream>
; V4 ?4 O: ], k1 s using std:strstream;
4 l0 F j! |& k# F using std::endl;
6 }" @# Z, w6 x- [ e O% U) r using std::ends;
; o; [) [! b, |7 ~. l$ J( } using std::cerr;% o( U2 h- i. j1 ~. Y
#else/ z9 v& U: M6 v2 [! z! M
# include <strstream.h>
0 L4 h9 }3 }7 E- o( t# include <iostream.h>8 u0 y$ j3 C1 e8 s7 v1 ~' S
#endif- O5 P7 X& y" S7 Q' `+ v9 J$ V
#include "create_oper.h"8 p# @ o+ k+ j2 D/ A. i0 n
# L4 Q. g7 _9 }% t7 ?9 N
//----------------------------------------------------------------------------
( v# Q7 p3 [2 R" o// Activation Methods
' {7 {! N' C2 P//----------------------------------------------------------------------------, h( @" O3 s }, A3 T: O) k
2 S4 _7 v5 c% U- l2 u$ c// Unigraphics Startup+ Q$ B. T4 x R# H& l# n
// This entry point activates the application at Unigraphics startup4 L( ?4 i2 g5 v" b' S8 U0 q
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )# ^4 Z% o( x2 M
{1 {9 B/ n: u6 F5 l' z
/* Initialize the API environment */
2 e, _) K9 p1 L, K! S int errorCode = UF_initialize();
2 W8 {3 v1 \' k* q4 t4 C# F
9 l& X; b5 l2 u if ( 0 == errorCode )
- t1 s5 z, k3 x/ s, K {* G9 U- E1 U8 J" u
/* TODO: Add your application code here */( m2 a$ b9 }. N+ F
$ ~! r7 w# `5 }) T" A char *type_name="mill_planar";
4 d9 Z$ \9 b! @' q" A; f. m char *subtype_name="FACE_MILLING_AREA";
, ^$ K* t% D8 [8 {8 d$ ~' D tag_t oper_tag;
+ V% S+ L( I3 V P1 C
" u, W: {: ~6 `4 [) y UF_OPER_create(type_name,subtype_name,&oper_tag);
& a- U, S; A. O, G- ^# L2 P( s2 V
/ i- g1 ^7 s0 K+ D3 O* V: }5 r1 _2 U' h$ E5 c
% i7 W0 d3 d2 h$ R0 p2 p# i9 b: W& [) ~1 |# @0 Y8 G4 c
/* Terminate the API environment */
, |. L- n6 X; w- x: Q4 x! i6 h- n, C errorCode = UF_terminate();, ]' }5 [ y" N: _; f8 ]
}7 H( q6 q' T* V5 l9 u
( _, i) f& f1 i. d2 t /* Print out any error messages */
( B1 j: x) K( p! [5 x PrintErrorMessage( errorCode );
1 z3 {5 s, J! {/ X! X% z}# z. a' z5 w. H) |7 x4 z' I5 O
/ n4 E: i2 T# |- G! H L
//----------------------------------------------------------------------------: d7 Z- |2 P' W
// Utilities
, ^1 l* Z4 t, B$ \7 W6 R//----------------------------------------------------------------------------+ R. v% v& F9 Q7 L) L. i9 E$ n
3 ~5 _% _; p/ r m7 \5 T* P// Unload Handler6 M0 D1 }7 V8 S3 J$ K3 R7 l1 x
// This function specifies when to unload your application from Unigraphics.
2 D! d! u8 a: x C( S% y// If your application registers a callback (from a MenuScript item or a- Y7 f/ q3 m7 a1 d3 C+ [9 h+ K. k
// User Defined Object for example), this function MUST return
$ K/ a S4 e6 ?' s+ H# p// "UF_UNLOAD_UG_TERMINATE".
" i c. m' z6 Lextern "C" int ufusr_ask_unload( void )% d8 X4 w+ ?7 `% h$ O- j1 R
{' I, w7 w( |0 l8 l& ^6 m1 ?
return( UF_UNLOAD_UG_TERMINATE );5 l; d4 v/ ^& t8 J; `
}
- @ o5 |5 y& q9 {4 V
N0 _7 x9 d8 b! c) {/* PrintErrorMessage. [0 L9 Z; N, Y m- S) O3 ~
**
' K, `( F% s6 P** Prints error messages to standard error and the Unigraphics status3 E4 X+ l- r; P
** line. */
# S) A8 F) [, f. T0 |) d$ Dstatic void PrintErrorMessage( int errorCode )5 {% p# E& b3 _" t
{
- b, A5 x7 _9 l7 g" M! m Q* v if ( 0 != errorCode )+ R% T- K: M/ J* @
{4 y4 ?9 @4 ?/ S0 V% @0 X5 M
/* Retrieve the associated error message */9 w8 Y- b g4 h8 }
char message[133];+ J# q1 @6 r% a8 F
UF_get_fail_message( errorCode, message );
: s r2 [& e) ?. W! f
" V4 p# W0 C: S4 R' [& A& f2 I& u /* Print out the message */
/ y/ `) _; N6 q, w% P h2 c UF_UI_set_status( message );1 ~+ W6 Y3 f8 [& E& p$ r/ i
) y- I: ?+ s! X* ^" D) G // Construct a buffer to hold the text.) u' }7 ^# s! {' A
ostrstream error_message;
" T0 T0 ]& s& c$ a; y$ r9 A6 U; _( X. @" R; v. d" F
// Initialize the buffer with the required text.
% |+ D. d, N! [( U; Q! ~+ U error_message << endl1 Q' |+ S. ?+ A. Q
<< "Error:" << endl7 N7 u( `5 g( G5 c, X7 Y* Y. j5 P
<< message0 E* m |* a. w9 j1 W8 w4 ?
<< endl << endl << ends;
0 F. k& D, _+ |( M
. {2 h3 j2 C0 w, Y' b; P' s3 Z // Write the message to standard error
1 O: o" D6 h% |" c8 I cerr << error_message.str();3 m2 f& {& j. T; i
}* g9 z: E- n* i% l6 \ |- [. E
} |