00001 #ifndef _MCW_MEMPLOT_HEADER_
00002 #define _MCW_MEMPLOT_HEADER_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <X11/Intrinsic.h>
00013 #include <string.h>
00014 #include <stdio.h>
00015 #include <math.h>
00016 #include <stdlib.h>
00017
00018 #ifdef HAVE_XDBE
00019 # include <X11/extensions/Xdbe.h>
00020
00021 # ifdef MAIN_COXPLOT_FILE
00022 int use_xdbe = -1 ;
00023 # else
00024 extern int use_xdbe ;
00025 # endif
00026
00027 extern void init_XDBE(Display *) ;
00028 extern Window getwin_from_XDBE( Display * , Drawable ) ;
00029 #else
00030 # define getwin_from_XDBE(dd,ww) (ww)
00031 #endif
00032
00033 #undef MAX
00034 #define MAX(a,b) (((a)<(b)) ? (b) : (a))
00035
00036 #undef MIN
00037 #define MIN(a,b) (((a)>(b)) ? (b) : (a))
00038
00039 #ifndef VOID_FUNC
00040 #define VOID_FUNC
00041 typedef void void_func() ;
00042 #endif
00043
00044
00045
00046 typedef struct {
00047 int nxyline , nxyline_all ;
00048 float aspect ;
00049 float * xyline ;
00050 char ident[256] ;
00051 int insert_at ;
00052 } MEM_plotdata ;
00053
00054
00055
00056 #define INC_MEMPLOT 64
00057 #define EXP_MEMPLOT 1.1
00058 #define NXY_MEMPLOT 6
00059
00060 #define INIT_MEMPLOT(name,id) \
00061 do{ (name) = (MEM_plotdata *) malloc(sizeof(MEM_plotdata)) ; \
00062 (name)->nxyline = 0 ; \
00063 (name)->nxyline_all = INC_MEMPLOT ; \
00064 (name)->xyline = (float *) malloc(sizeof(float)*NXY_MEMPLOT*INC_MEMPLOT) ; \
00065 strncpy( (name)->ident, (id), 255 ) ; (name)->ident[255] = '\0' ; \
00066 (name)->aspect = 1.3 ; (name)->insert_at = -1 ; \
00067 } while(0)
00068
00069
00070
00071 #define ADDTO_MEMPLOT(name,x1,y1,x2,y2,col,th) \
00072 do{ int nn , ll=(name)->insert_at ; \
00073 if( ll >= 0 && ll < (name)->nxyline ){ \
00074 nn = NXY_MEMPLOT * ll ; \
00075 (name)->xyline[nn++] = (x1) ; (name)->xyline[nn++] = (y1) ; \
00076 (name)->xyline[nn++] = (x2) ; (name)->xyline[nn++] = (y2) ; \
00077 (name)->xyline[nn++] = (col); (name)->xyline[nn++] = (th) ; break ; \
00078 } \
00079 if( (name)->nxyline == (name)->nxyline_all ){ \
00080 nn = (name)->nxyline_all = EXP_MEMPLOT * (name)->nxyline_all + INC_MEMPLOT ; \
00081 (name)->xyline = (float *) realloc( (name)->xyline , sizeof(float)*NXY_MEMPLOT*nn ) ; \
00082 } \
00083 nn = NXY_MEMPLOT * (name)->nxyline ; \
00084 (name)->xyline[nn++] = (x1) ; (name)->xyline[nn++] = (y1) ; \
00085 (name)->xyline[nn++] = (x2) ; (name)->xyline[nn++] = (y2) ; \
00086 (name)->xyline[nn++] = (col); (name)->xyline[nn++] = (th) ; (name)->nxyline ++ ; \
00087 } while(0)
00088
00089
00090
00091 #define DESTROY_MEMPLOT(name) \
00092 do{ if( (name) != NULL ){ \
00093 if( (name)->xyline != NULL ) free( (name)->xyline ) ; \
00094 free( (name) ) ; (name) = NULL ; } \
00095 } while(0)
00096
00097
00098
00099 #define TRUNC_MEMPLOT(name,num) \
00100 do{ if( (num) < (name)->nxyline ) (name)->nxyline = (num); } while(0)
00101
00102 #define MEMPLOT_X1(name,ii) ((name)->xyline[NXY_MEMPLOT*ii])
00103 #define MEMPLOT_Y1(name,ii) ((name)->xyline[NXY_MEMPLOT*ii+1])
00104 #define MEMPLOT_X2(name,ii) ((name)->xyline[NXY_MEMPLOT*ii+2])
00105 #define MEMPLOT_Y2(name,ii) ((name)->xyline[NXY_MEMPLOT*ii+3])
00106 #define MEMPLOT_COL(name,ii) ((name)->xyline[NXY_MEMPLOT*ii+4])
00107 #define MEMPLOT_TH(name,ii) ((name)->xyline[NXY_MEMPLOT*ii+5])
00108
00109 #define MEMPLOT_NLINE(name) ((name)->nxyline)
00110 #define MEMPLOT_IDENT(name) ((name)->ident)
00111 #define MEMPLOT_NAME MEMPLOT_IDENT
00112 #define MEMPLOT_ASPECT(name) ((name)->aspect)
00113
00114
00115
00116 #define THCODE_RECT 1
00117 #define THCODE_CIRC 2
00118 #define THCODE_OPAC 3
00119 #define THCODE_INVALID 666
00120
00121
00122
00123
00124 #define ZO_TO_TFS(x) ((int)(255.99*(x)))
00125 #define TFS_TO_ZO(y) ((y)/255.0f)
00126
00127 #define RGB_TO_COL(r,g,b) ( (ZO_TO_TFS(r)<<16) | (ZO_TO_TFS(g)<<8) | (ZO_TO_TFS(b)) )
00128
00129 #define COL_TO_RRR(cc) TFS_TO_ZO( (((int)(cc)) & 0xff0000) >> 16 )
00130 #define COL_TO_GGG(cc) TFS_TO_ZO( (((int)(cc)) & 0x00ff00) >> 8 )
00131 #define COL_TO_BBB(cc) TFS_TO_ZO( (((int)(cc)) & 0x0000ff) )
00132
00133
00134
00135 typedef struct {
00136 int classKRH ;
00137 int depth ;
00138
00139 int ncolors ;
00140 unsigned char * rr , * gg , * bb ;
00141
00142 unsigned long rrmask , ggmask , bbmask ;
00143 int rrshift, ggshift, bbshift;
00144 } X11_colordef ;
00145
00146 #define FREE_X11_colordef(cd) \
00147 do{ if( (cd) != NULL ){ \
00148 if( (cd)->rr != NULL ){ \
00149 free((cd)->rr) ; free((cd)->gg) ; free((cd)->bb) ; } \
00150 free((cd)) ; (cd) = NULL ; } } while(0)
00151
00152
00153
00154 extern MEM_plotdata * find_memplot( char * ) ;
00155 extern int create_memplot( char * , float ) ;
00156 extern int set_active_memplot( char * ) ;
00157 extern MEM_plotdata * get_active_memplot(void) ;
00158 extern void delete_active_memplot(void) ;
00159 extern void delete_memplot( MEM_plotdata * ) ;
00160 extern void plotline_memplot( float , float , float , float ) ;
00161 extern void set_color_memplot( float , float , float ) ;
00162 extern void set_thick_memplot( float ) ;
00163 extern float get_thick_memplot(void) ;
00164 extern int nline_active_memplot(void) ;
00165 extern void plotrect_memplot( float,float,float,float ) ;
00166 extern void plotcirc_memplot( float,float,float ) ;
00167 extern int create_memplot_surely( char *, float ) ;
00168 extern void set_opacity_memplot( float ) ;
00169 extern float get_opacity_memplot(void) ;
00170
00171 extern MEM_plotdata * copy_memplot( MEM_plotdata * ) ;
00172 extern void append_to_memplot( MEM_plotdata *,MEM_plotdata * ) ;
00173 extern void scale_memplot( float,float,float,float,float,MEM_plotdata * );
00174 extern MEM_plotdata * clip_memplot( float,float,float,float , MEM_plotdata * ) ;
00175
00176 extern void cutlines_memplot( int,int,MEM_plotdata * ) ;
00177 extern void insert_at_memplot( int , MEM_plotdata * ) ;
00178 #define insert_atend_memplot(mm) insert_at_memplot(-1,mm)
00179
00180 #define MRI_ROT_0 1
00181 #define MRI_ROT_90 2
00182 #define MRI_ROT_180 4
00183 #define MRI_ROT_270 8
00184 #define MRI_FLMADD 128
00185
00186 extern void flip_memplot( int , int , MEM_plotdata * ) ;
00187
00188
00189
00190 extern void memplot_to_postscript( char * , MEM_plotdata * ) ;
00191
00192 #define memplot_to_ps(fn) memplot_to_postscript( (fn) , get_active_memplot() ) ;
00193
00194
00195
00196 extern unsigned long rgb_to_pixel( unsigned char , unsigned char ,
00197 unsigned char , X11_colordef * ) ;
00198
00199 extern X11_colordef * get_X11_colordef( Display * , Window ) ;
00200
00201 #define MEMPLOT_FREE_ASPECT 1
00202 #define MEMPLOT_ERASE 2
00203
00204 extern void memplot_to_X11_sef( Display * , Window ,
00205 MEM_plotdata * , int,int,int ) ;
00206
00207 extern void set_memplot_X11_box( int,int,int,int ) ;
00208
00209 extern void set_X11_background( Display * , Window ,
00210 unsigned char , unsigned char , unsigned char ) ;
00211
00212 #define memplot_to_X11(d,w) \
00213 memplot_to_X11_sef( (d),(w) , get_active_memplot() , 0,0,0 )
00214
00215 #define memplot_to_X11_free(d,w) \
00216 memplot_to_X11_sef( (d),(w) , get_active_memplot() , 0,0,1 )
00217
00218 typedef struct {
00219 Widget top , dial , wtf , drawing , form ;
00220 int valid ;
00221 MEM_plotdata * mp ;
00222 void * userdata ;
00223 void_func * killfunc ;
00224
00225 #ifdef HAVE_XDBE
00226 int have_xdbe ;
00227 XdbeBackBuffer buf_xdbe ;
00228 #endif
00229 } MEM_topshell_data ;
00230
00231 #define MTD_PLOTDATA(mpcb) ((mpcb)->mp)
00232 #define MTD_KILLFUNC(mpcb) ((mpcb)->killfunc)
00233 #define MTD_VALID(mpcb) ((mpcb)->valid)
00234 #define MTD_USERDATA(mpcb) ((mpcb)->userdata)
00235 #define MTD_remove_killfunc(mpcb) ((mpcb)->killfunc = NULL)
00236
00237 #define MTD_replace_plotdata(mpcb,mpnew) \
00238 do{ delete_memplot((mpcb)->mp) ; (mpcb)->mp = (mpnew) ; } while(0)
00239
00240 extern MEM_topshell_data * memplot_to_topshell(Display *,MEM_plotdata *,void_func *) ;
00241 extern void plotkill_topshell( MEM_topshell_data * ) ;
00242 extern void redraw_topshell( MEM_topshell_data * ) ;
00243
00244 #define memplot_to_shell(d) memplot_to_topshell( (d),get_active_memplot(),1 )
00245
00246
00247
00248 #define TSP_SEPARATE_YBOX 1
00249 #define TSP_SEPARATE_YSCALE 2
00250
00251 extern void plot_ts_xypush( int , int ) ;
00252 extern void plot_ts_xfix( int,int , float,float ) ;
00253 extern void plot_ts_yfix( int,int , float,float ) ;
00254
00255 extern void plot_ts_lab( Display *,
00256 int,float *, int,float **,
00257 char *,char *,char *,char ** , void_func * ) ;
00258
00259 #define plot_ts(a,b,c,d,e) plot_ts_lab((a),(b),(c),(d),(e),NULL,NULL,NULL,NULL,NULL)
00260
00261 extern MEM_topshell_data * plot_ts_init( Display *, float, float,
00262 int, float, float,
00263 char *, char *, char *, char ** , void_func * ) ;
00264
00265 extern void plot_ts_addto( MEM_topshell_data *, int,float *, int,float ** ) ;
00266
00267 extern MEM_plotdata * plot_ts_mem( int,float *, int,int,float **,
00268 char *,char *,char *,char ** ) ;
00269
00270
00271
00272 extern MEM_topshell_data * plot_strip_init( Display * , int , float ,
00273 int , float , float ,
00274 char * , char * ,
00275 char * , char ** , void_func * ) ;
00276
00277 extern void plot_strip_addto( MEM_topshell_data * , int , float ** ) ;
00278
00279 extern void plot_strip_clear( MEM_topshell_data * ) ;
00280
00281
00282
00283 extern void zzmpco_( float * , float * , float * ) ;
00284 extern void zzmpli_( float * , float * , float * , float * ) ;
00285
00286
00287
00288 extern void ps_move( int , int ) ;
00289 extern void ps_line( int , int , int , int ) ;
00290 extern void ps_cont( int , int ) ;
00291 extern void ps_point( int , int ) ;
00292 extern void ps_label( char * ) ;
00293 extern void ps_arc( int , int , int , int , int , int ) ;
00294 extern void ps_circle( int , int , int ) ;
00295 extern void ps_erase( void ) ;
00296 extern void ps_linemod( char * ) ;
00297 extern void ps_space( int , int , int , int ) ;
00298 extern int ps_openpl( char * ) ;
00299 extern void ps_closepl( void ) ;
00300 extern void ps_setrgb( float , float , float ) ;
00301 extern void ps_setwidth( float ) ;
00302 extern void ps_rect( int,int,int,int) ;
00303
00304
00305
00306 #include "f2c.h"
00307 #undef complex
00308
00309 extern int color_(integer *ncol);
00310 extern int fcolor_( real *cr, real *cg, real *cb );
00311 extern int curve_(real *x, real *y, integer *n);
00312 extern int frame_(void);
00313 extern int frstpt_(real *x, real *y);
00314 extern int labmod_(integer *ifmtx, integer *ifmty, integer *numx, integer *numy, integer *jsizx, integer *jsizy, integer *ixdec, integer *iydec, integer *ixor);
00315 extern int line_(real *x1, real *y1, real *x2, real *y2);
00316 extern int memplt_(real *aspect);
00317 extern int perim_(integer *mbx, integer *mlx, integer *mby, integer *mly);
00318 extern int periml_(integer *mbx, integer *mlx, integer *mby, integer *mly);
00319 extern int perimm_(integer *mbx, integer *mlx, integer *mby, integer *mly, integer *ilab);
00320 extern int phdot_(real *x1, real *y1);
00321 extern int phline_(real *x1, real *y1, real *x2, real *y2);
00322 extern int point_(real *x, real *y);
00323 extern int points_(real *x, real *y, integer *n, integer *ichar, integer *ipen);
00324 extern int pwrit_(real *x, real *y, char *ch, integer *nch, integer *isiz, integer *ior, integer *icent, ftnlen ch_len);
00325 extern int pwritf_(real *x, real *y, char *ch, integer *nch, integer *isiz, integer *ior, integer *icent, ftnlen ch_len);
00326 extern integer lastnb_(char *cline, ftnlen cline_len);
00327 extern int zzstro_(char *ch, integer *nch, integer *nstr, real *xstr, real *ystr, logical *lbstr, ftnlen ch_len);
00328 extern int zzconv_(char *chin, integer *nchin, char *chout, integer *nchout, ftnlen chin_len, ftnlen chout_len);
00329 extern int set_(real *xobj1, real *xobj2, real *yobj1, real *yobj2, real *xsub1, real *xsub2, real *ysub1, real *ysub2, integer *ltype);
00330 extern int setdsh_(integer *nd, real *xld);
00331 extern int setfrm_(real *xobj1, real *xobj2, real *yobj1, real *yobj2);
00332 extern int setlin_(integer *ntype);
00333 extern int setw_(real *x1, real *y1, real *x2, real *y2);
00334 extern int srface_(real *x, real *y, real *z__, integer *m, integer *mx, integer *nx, integer *ny, real *s, real *stereo);
00335 extern int srfpl_(integer *n, real *px, real *py);
00336 extern int clset_(real *z__, integer *mx, integer *nx, integer *ny, real *chi, real *clo, real *cinc, integer *nla, integer *nlm, real *cl, integer *ncl, integer *icnst, integer *ioffp, real *spval, real *bigest);
00337 extern int ctcell_(real *z__, integer *mx, integer *nx, integer *ny, integer *m, integer *i0, integer *j0);
00338 extern int draws_(integer *mx1, integer *my1, integer *mx2, integer *my2, integer *idraw, integer *imark);
00339 extern int setr_(real *xmin, real *xmax, real *ymin, real *ymax, real *zmin, real *zmax, real *r0);
00340 extern int trn32s_(real *x, real *y, real *z__, real *xt, real *yt, real *zt, integer *iflag);
00341 extern int srfabd_(void);
00342 extern int tick4_(integer *lmajx, integer *lminx, integer *lmajy, integer *lminy);
00343 extern int vector_(real *x, real *y);
00344 extern int zzaxxx_(real *x1, real *x2, real *y, integer *iside, integer *ilab);
00345 extern int zzaxyy_(real *x, real *y1, real *y2, integer *iside, integer *ilab);
00346 extern int zzchar_(char *ch, real *xp, real *yp, real *ct, real *st, ftnlen ch_len);
00347 extern int zzclip_(real *x1in, real *y1in, real *x2in, real *y2in);
00348 extern int zzlabl_(real *val, char *cout, integer *nchar, ftnlen cout_len);
00349 extern int zzlgin_(real *xt, real *pwrten, integer *nlog);
00350 extern int zzline_(real *x1, real *y1, real *x2, real *y2);
00351 extern int zzlinx_(real *x1, real *x2, real *y, integer *majrx, real *tmaj, integer *minrx, real *tmin);
00352 extern int zzliny_(real *x, real *y1, real *y2, integer *majry, real *tmaj, integer *minry, real *tmin);
00353 extern int zzlogx_(real *x1, real *x2, real *y, integer *ndec, real *tmaj, real *tmin);
00354 extern int zzlogy_(real *x, real *y1, real *y2, integer *ndec, real *tmaj, real *tmin);
00355 extern int zzperi_(integer *ilab);
00356 extern int zzphph_(real *x1, real *y1, real *x2, real *y2);
00357 extern int zzphys_(real *x, real *y);
00358
00359
00360
00361 extern void plotpak_curve( float * x , float * y , int n ) ;
00362 extern void plotpak_frame(void) ;
00363 extern void plotpak_frstpt( float x , float y ) ;
00364 extern void plotpak_labmod( int jsizx , int jsizy ) ;
00365 extern void plotpak_line( float x1 , float y1 , float x2 , float y2 ) ;
00366 extern void plotpak_perim( int mbx , int mlx , int mby , int mly ) ;
00367 extern void plotpak_periml( int mbx , int mlx , int mby , int mly ) ;
00368 extern void plotpak_perimm( int mbx , int mlx , int mby , int mly , int ilab ) ;
00369 extern void plotpak_phdot( float x1 , float y1 ) ;
00370 extern void plotpak_phline( float x1 , float y1 , float x2 , float y2 ) ;
00371 extern void plotpak_point( float x1 , float y1 ) ;
00372 extern void plotpak_points( float *x , float *y , int n , int ipen ) ;
00373 extern void plotpak_pwrit( float x , float y , char * ch , int isiz , int ior , int icent ) ;
00374 extern void plotpak_pwritf( float x , float y , char * ch , int isiz , int ior , int icent ) ;
00375 extern void plotpak_set( float xo1,float xo2 , float yo1,float yo2 ,
00376 float xs1,float xs2 , float ys1,float ys2 , int code ) ;
00377 extern void plotpak_setdsh( int nd , float * xd ) ;
00378 extern void plotpak_setfrm( float xo1,float xo2 , float yo1,float yo2 ) ;
00379 extern void plotpak_setlin( int code ) ;
00380 extern void plotpak_setw( float xo1,float xo2 , float yo1,float yo2 ) ;
00381 extern void plotpak_tick4( int mx, int lx , int my , int ly ) ;
00382 extern void plotpak_vector( float x , float y ) ;
00383
00384 extern void plotpak_srface( float *, float *, float *, int,int, float,float ) ;
00385
00386 extern void plotpak_getset( float *xo1,float *xo2 , float *yo1,float *yo2 ,
00387 float *xs1,float *xs2 , float *ys1,float *ys2 ) ;
00388
00389
00390
00391 extern void plotpak_zzphys( float x1 , float y1 , float *x2 , float *y2 ) ;
00392 extern void plotpak_unphys( float x1 , float y1 , float *x2 , float *y2 ) ;
00393
00394
00395
00396 #ifdef PLOTPAK_COMMONS
00397 # define EXT
00398 #else
00399 # define EXT extern
00400 #endif
00401
00402 EXT struct {
00403 real xpgmin, ypgmin, xpgmax, ypgmax, xclbot, yclbot, xcltop, ycltop, xbot,
00404 ybot, xtop, ytop, xmin, ymin, xmax, ymax;
00405 integer ixcoor, iycoor;
00406 real alphxx, betaxx, alphyy, betayy, tmajx, tminx, tmajy, tminy;
00407 integer majrx, minrx, majry, minry, isizx, isizy;
00408 real xphold, yphold;
00409 } zzzplt_;
00410
00411 EXT struct {
00412 real xphmax, yphmax;
00413 integer ixpmax, iypmax;
00414 real xpscal, ypscal;
00415 integer iflip, nplotr;
00416 char cfile[64];
00417 } zzpltr_;
00418
00419 EXT struct {
00420 integer ndash;
00421 real xldash[8], xid;
00422 } zzdash_;
00423
00424 #endif