|
& L: P# K( l6 }, w9 j3 j
/* Include files */$ d6 }. e4 N# z. ]
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )8 [/ e7 g6 h: ^" G
# include <strstream>
2 C( g1 ?( u4 G7 a7 [+ o# include <iostream>
$ t% n# }9 g8 p& ] using std: strstream;
: z9 m" q1 s) `) M using std::endl;
2 w; f9 f' A( x9 O$ R1 y& z using std::ends;0 r# v" G% O, {' ?/ t
using std::cerr;
g |) g( ~. b0 `1 O#else- S( p3 h4 s) M
# include <strstream.h>
! o; ^* F2 q* P9 D) A/ z4 `# include <iostream.h>
* l; D6 ?" F3 ^- y9 {#endif7 z2 z6 E+ |( q. L/ U% L
#include <uf.h>) h& }8 }' Q! v& M
#include <uf_ui.h>
; v2 Z' z a) E9 U& b4 ]; Z#include <uf_exit.h>4 O: |) i" `$ w: a- c8 {2 x
#include <uf_layer.h> e# W7 b0 Z0 h7 `
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
4 e4 I- m1 q( z! k* m
/ D2 t. B4 j! f& Y2 O: y) s7 Rstatic int report_error( char *file, int line, char *call, int irc)6 P# r' S8 ^( z% X$ p# s1 Y8 N
{
! P4 X6 X9 Y5 d+ m# } if (irc)
, ~' I% X; X) B3 P* C {) ?- j- _0 P3 k: ]$ S
char err[133],
8 J7 W* a. R. j1 a3 {; q msg[133];$ k7 \8 T3 N. a4 S! h
/ F( w$ b2 h, ^6 I sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
( N' F# d0 g, Z( G8 | irc, line, file);
$ V/ m" d+ L3 [ UF_get_fail_message(irc, err);
0 n+ `; K( @% a6 Q
" M2 |& C& \, ]9 D" G0 k UF_print_syslog(msg, FALSE);5 e- J% g/ u; Q0 o2 p
UF_print_syslog(err, FALSE);
* f( l1 G, A% d6 b8 R y. s UF_print_syslog("\n", FALSE);
6 r+ M2 ~' b" B8 ` UF_print_syslog(call, FALSE);
' O3 H& `/ Q: L7 R' K7 b/ L( e6 T6 b UF_print_syslog(";\n", FALSE);% r- b! \( a6 h2 s* k% Q* f: D; Y
: C/ j/ N) G$ C if (!UF_UI_open_listing_window()) X8 |' L5 K' n
{
; G5 x7 o! Y6 D6 O1 y UF_UI_write_listing_window(msg);
! d9 C3 p* z9 ]! l# L' ^ UF_UI_write_listing_window(err);; j2 l5 h1 j g3 _6 P8 C
UF_UI_write_listing_window("\n");9 U7 I j* V6 ~) i9 q6 o
UF_UI_write_listing_window(call);
9 R; X7 B. n2 v3 h- g UF_UI_write_listing_window(";\n");
4 K) U" w4 A! Z2 z }) R0 B* ^3 B7 Z; L B4 Z
}
) O/ Z; D1 G0 {% c& o( \' ^- R& H( V/ s" k: F4 D& r
return(irc);
* a: o$ A) S7 _+ {}4 ~0 l% s% _3 C; M
5 u' x4 c+ s! P/ @2 b) F
G6 |! x! e7 V% q" Y
/* "File->Execute UG/Open->User Function..." */+ o1 O |8 U+ O* T& U
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
1 ~7 F( [. B" c9 q8 w{
# B$ h" k# E* [& l: t) \2 ` /* Initialize the API environment */4 A# S7 h3 {& V. z) @( O
if( UF_CALL(UF_initialize()) ) ) o. b T0 {! _5 e6 x: K+ C
{
1 h) j$ y2 d) i# e& w/ @ /* Failed to initialize */
0 m5 f; R7 z- `: {6 T* }6 Q return;& p. q0 s# D7 E* I9 A( a' ]
}
% @9 v7 x% _7 b N4 g) b
0 h9 W d6 y8 I /* TODO: Add your application code here *// i: ~2 |" x% Z/ f: }
9 ~$ h4 J, _: s% y7 d
int layer_number=10;- [/ x9 g w5 u- N& K
int layer_status =
* {, _ a! u5 \ // UF_LAYER_WORK_LAYER ;//设置工作图层
# d- I; |8 c' }- {" i//UF_LAYER_ACTIVE_LAYER ;//设置可选图层
: c8 J: F }9 A" g( W q//UF_LAYER_REFERENCE_LAYER ;//设置只见图层$ b1 @( k2 z9 S9 l' \8 h+ O$ f, X
UF_LAYER_INACTIVE_LAYER; //设置不可选不可见活动图层
1 g$ Q+ n* S& a7 W! z1 w
) w5 ]1 [' p& h" A; `1 q UF_LAYER_set_status( layer_number, layer_status);+ n, m0 o" O `1 Z
! x* X z+ `. ^4 o
/* Terminate the API environment */
. l P2 ?. q- A) c1 N/ f2 `/ W UF_CALL(UF_terminate());( z, j8 ^' T7 s4 F
}
2 |' A e @2 d% f* b* a
: C9 s- `& T4 C8 g/ |/*****************************************************************************1 e4 B7 f) g: |# R) f$ }& u( h
** Utilities! R1 |- c5 e% c# ~5 i
*****************************************************************************/) w9 ^( B; H9 j! M
% Y8 u# s8 k' C2 g
extern int ufusr_ask_unload( void )
5 B4 h% m! ~2 H" A Z" n; H+ `{
( S6 Z, e* v% I; h4 ]' o return( UF_UNLOAD_IMMEDIATELY );
. m, p. H, U" U}1 G9 i, d O D1 N0 ]
) p L( s+ T8 L2 B/ @ |
|