1 #ifndef _MCW_MEMPLOT_HEADER_
2 #define _MCW_MEMPLOT_HEADER_
3 
4 /*****************************************************************************
5    Major portions of this software are copyrighted by the Medical College
6    of Wisconsin, 1994-2000, and are released under the Gnu General Public
7    License, Version 2.  See the file README.Copyright for details.
8 ******************************************************************************/
9 
10 /*---------------- Header for in-memory adaptation of PLOTPAK ---------------*/
11 
12 #include <X11/Intrinsic.h>
13 #include <string.h>
14 #include <stdio.h>
15 #include <math.h>
16 #include <stdlib.h>
17 #include "mrilib.h"
18 #ifdef HAVE_XDBE
19 #  include <X11/extensions/Xdbe.h>
20 
21 #  ifdef MAIN_COXPLOT_FILE
22       int use_xdbe = -1 ;
23 #  else
24       extern int use_xdbe ;
25 #  endif
26 
27    extern void init_XDBE(Display *) ;
28    extern Window getwin_from_XDBE( Display * , Drawable ) ;
29    extern int  get_XDBE_suspension(int) ; /* 01 May 2012 */
30    extern void set_XDBE_suspension(int) ;
31 #else
32 #  define getwin_from_XDBE(dd,ww) (ww)
33 #  define get_XDBE_suspension(qq) (1)
34 #  define set_XDBE_suspension(qq) /*nada*/
35 #endif
36 
37 #undef  MAX
38 #define MAX(a,b) (((a)<(b)) ? (b) : (a))
39 
40 #undef  MIN
41 #define MIN(a,b) (((a)>(b)) ? (b) : (a))
42 
43 #ifndef HOTCOLOR
44 #define HOTCOLOR(ww,ss)                                                        \
45   { char * xdef = XGetDefault(XtDisplay(ww),"AFNI","hotcolor") ;               \
46     if( xdef == NULL ) xdef = getenv("AFNI_hotcolor") ;                        \
47     if( xdef == NULL ) xdef = getenv("AFNI_HOTCOLOR") ;                        \
48     if( xdef == NULL ) xdef = XGetDefault(XtDisplay(ww),"AFNI","background") ; \
49     (ss) = (xdef != NULL) ? (xdef) : ("gray40") ; }
50 #endif
51 
52 #ifndef BGCOLOR_ARG
53 #define BGCOLOR_ARG(str) \
54   XtVaTypedArg , XmNbackground , XmRString , (str) , strlen(str)+1
55 #endif
56 
57 #ifndef VOID_FUNC
58 #define VOID_FUNC
59 typedef void void_func() ;
60 #endif
61 
62 #ifndef floatfix
63 #ifdef isfinite
64 # define floatfix(x) if( !isfinite(x) ) (x) = 0.0f ; else
65 #else
66 # define floatfix(x) if( !finite(x) ) (x) = 0.0f ; else
67 #endif
68 #endif
69 
70 /*----- data structure to hold a plot -----*/
71 
72 typedef struct {
73    int nxyline , nxyline_all ;
74    float aspect ;
75    float * xyline ;
76    char ident[256] ;
77    int insert_at ;    /* 15 Nov 2001 */
78 } MEM_plotdata ;
79 
80 /* macros to manipulate a plot */
81 
82 #define INC_MEMPLOT 64
83 #define EXP_MEMPLOT 1.2
84 #define NXY_MEMPLOT 6
85 
86 #define INIT_MEMPLOT(name,id)                                                    \
87   do{ (name) = (MEM_plotdata *) malloc(sizeof(MEM_plotdata)) ;                   \
88       (name)->nxyline = 0 ;                                                      \
89       (name)->nxyline_all = INC_MEMPLOT ;                                        \
90       (name)->xyline = (float *) malloc(sizeof(float)*NXY_MEMPLOT*INC_MEMPLOT) ; \
91       strncpy( (name)->ident, (id), 255 ) ; (name)->ident[255] = '\0' ;          \
92       (name)->aspect = 1.3 ; (name)->insert_at = -1 ;                            \
93   } while(0)
94 
95 /* put a line at the end of the plot [15 Nov 2001: maybe in the middle]  */
96 
97 #define ADDTO_MEMPLOT(name,x1,y1,x2,y2,col,th)                                             \
98   do{ int nn , ll=(name)->insert_at ;                                                      \
99       if( ll >= 0 && ll < (name)->nxyline ){                                               \
100          nn = NXY_MEMPLOT * ll ;                                                           \
101          (name)->xyline[nn++] = (x1) ; (name)->xyline[nn++] = (y1) ;                       \
102          (name)->xyline[nn++] = (x2) ; (name)->xyline[nn++] = (y2) ;                       \
103          (name)->xyline[nn++] = (col); (name)->xyline[nn++] = (th) ; break ;               \
104       }                                                                                    \
105       if( (name)->nxyline == (name)->nxyline_all ){                                        \
106         nn = (name)->nxyline_all = EXP_MEMPLOT * (name)->nxyline_all + INC_MEMPLOT ;       \
107         (name)->xyline = (float *)realloc( (name)->xyline, sizeof(float)*NXY_MEMPLOT*nn ); \
108         if( nn > 999999 ){                                                                 \
109           double qq=log10((double)nn) ;                                                    \
110           if( qq-(int)qq < 0.08 )                                                          \
111             fprintf(stderr,"** WARNING: in memory plot exceeds %d elements!\n",nn) ;       \
112       } }                                                                                  \
113       nn = NXY_MEMPLOT * (name)->nxyline ;                                                 \
114       (name)->xyline[nn++] = (x1) ; (name)->xyline[nn++] = (y1) ;                          \
115       (name)->xyline[nn++] = (x2) ; (name)->xyline[nn++] = (y2) ;                          \
116       (name)->xyline[nn++] = (col); (name)->xyline[nn++] = (th) ; (name)->nxyline ++ ;     \
117   } while(0)
118 
119 /* this is fatal */
120 
121 #define DESTROY_MEMPLOT(name)                                  \
122   do{ if( (name) != NULL ){                                    \
123          if( (name)->xyline != NULL ) free( (name)->xyline ) ; \
124          free( (name) ) ; (name) = NULL ; }                    \
125   } while(0)
126 
127 /* 14 Nov 2001: cut off the end of a plot */
128 
129 #define TRUNC_MEMPLOT(name,num)                                         \
130   do{ if( (num) < (name)->nxyline ) (name)->nxyline = (num); } while(0)
131 
132 #define MEMPLOT_X1(name,ii)  ((name)->xyline[NXY_MEMPLOT*ii])    /* from x */
133 #define MEMPLOT_Y1(name,ii)  ((name)->xyline[NXY_MEMPLOT*ii+1])  /* from y */
134 #define MEMPLOT_X2(name,ii)  ((name)->xyline[NXY_MEMPLOT*ii+2])  /* to x   */
135 #define MEMPLOT_Y2(name,ii)  ((name)->xyline[NXY_MEMPLOT*ii+3])  /* to y    */
136 #define MEMPLOT_COL(name,ii) ((name)->xyline[NXY_MEMPLOT*ii+4])  /* color    */
137 #define MEMPLOT_TH(name,ii)  ((name)->xyline[NXY_MEMPLOT*ii+5])  /* thickness */
138 
139 #define MEMPLOT_NLINE(name)  ((name)->nxyline)                /* number of lines */
140 #define MEMPLOT_IDENT(name)  ((name)->ident)                  /* identifier string */
141 #define MEMPLOT_NAME         MEMPLOT_IDENT
142 #define MEMPLOT_ASPECT(name) ((name)->aspect)                 /* aspect ratio */
143 
144  /*-- thickness codes < 0 are special instructions --*/
145 
146 #define THCODE_RECT       1  /* 21 Mar 2001: rectangle from (x1,y1)..(x2,y2) */
147 #define THCODE_CIRC       2  /* 10 Mar 2002: circle at (x1,y1), radius x2 */
148 #define THCODE_OPAC       3  /* 22 Jul 2004: set opacity of further drawing to x1 */
149 #define THCODE_BALL       4
150 #define THCODE_FRECT      5  /* 24 Apr 2012: filled rectangle */
151 #define THCODE_INVALID  666
152 
153 /* convert (r,g,b) in [0,1]**3 into a single number, and vice-versa */
154 /* acronyms: ZO == Zero-to-One;  TFS == initials of 256 spelled out */
155 
156 #define ZO_TO_TFS(x) ((int)(255.99*(x)))    /* produces a number from 0 .. 255   */
157 #define TFS_TO_ZO(y) ((y)/255.0f)           /* produces a number from 0.0 .. 1.0 */
158 
159 #define RGB_TO_COL(r,g,b) ( (ZO_TO_TFS(r)<<16) | (ZO_TO_TFS(g)<<8) | (ZO_TO_TFS(b)) )
160 
161 #define COL_TO_RRR(cc) TFS_TO_ZO( (((int)(cc)) & 0xff0000) >> 16 )
162 #define COL_TO_GGG(cc) TFS_TO_ZO( (((int)(cc)) & 0x00ff00) >>  8 )
163 #define COL_TO_BBB(cc) TFS_TO_ZO( (((int)(cc)) & 0x0000ff)       )
164 
165 /*----- stuff for plotting into an X11 window -----*/
166 
167 typedef struct {
168    int classKRH ;    /* type of colormap: PseudoColor and TrueColor are OK */
169    int depth ;
170 
171    int ncolors ;  /* This stuff for PseudoColor */
172    unsigned char * rr , * gg , * bb ;
173 
174    unsigned long rrmask , ggmask , bbmask ;   /* This stuff for TrueColor */
175    int           rrshift, ggshift, bbshift;
176 } X11_colordef ;
177 
178 #define FREE_X11_colordef(cd)                                    \
179   do{ if( (cd) != NULL ){                                        \
180          if( (cd)->rr != NULL ){                                 \
181             free((cd)->rr) ; free((cd)->gg) ; free((cd)->bb) ; } \
182          free((cd)) ; (cd) = NULL ; } } while(0)
183 
184 /*----- prototypes -----*/
185 
186 #ifdef  __cplusplus
187 extern "C" {
188 #endif
189 
190 extern MEM_plotdata * find_memplot( char * ) ;
191 extern int            create_memplot( char * , float ) ;
192 extern int            set_active_memplot( char * ) ;
193 extern MEM_plotdata * get_active_memplot(void) ;
194 extern void           delete_active_memplot(void) ;
195 extern void           delete_memplot( MEM_plotdata * ) ;
196 extern void           plotline_memplot( float , float , float , float ) ;
197 extern void           set_color_memplot( float , float , float ) ;
198 extern void           set_thick_memplot( float ) ;
199 extern float          get_thick_memplot(void) ;
200 extern void           plot_ts_dohist(int) ;                         /* 10 Jun 2014 */
201 extern void           plot_ts_noline( int ) ;
202 extern int            nline_active_memplot(void) ;
203 extern void           plotrect_memplot( float,float,float,float ) ; /* 21 Mar 2001 */
204 extern void           plotfrect_memplot( float,float,float,float) ; /* 24 Apr 2012 */
205 extern void           plotcirc_memplot( float,float,float ) ;       /* 10 Mar 2002 */
206 extern void           plotball_memplot( float,float,float ) ;
207 extern int            create_memplot_surely( char *, float ) ;      /* 20 Sep 2001 */
208 extern void           set_opacity_memplot( float ) ;                /* 22 Jul 2004 */
209 extern float          get_opacity_memplot(void) ;
210 extern void           plot_ts_do_naked  (int) ;                     /* 14 Sep 2018 */
211 
212 extern MEM_plotdata * copy_memplot( MEM_plotdata * ) ; /*-- 26 Feb 2001 --*/
213 extern void           append_to_memplot( MEM_plotdata *,MEM_plotdata * ) ;
214 extern void           scale_memplot( float,float,float,float,float,MEM_plotdata * );
215 extern MEM_plotdata * clip_memplot( float,float,float,float , MEM_plotdata * ) ;
216 
217 extern void           cutlines_memplot( int,int,MEM_plotdata * ) ; /* 15 Nov 2001 */
218 extern void           insert_at_memplot( int , MEM_plotdata * ) ;
219 #define insert_atend_memplot(mm) insert_at_memplot(-1,mm)
220 
221 #define MRI_ROT_0   1  /* codes for various rotations */
222 #define MRI_ROT_90  2  /* [do not change these unless */
223 #define MRI_ROT_180 4  /*  mrilib.h is changed also!] */
224 #define MRI_ROT_270 8
225 #define MRI_FLMADD  128
226 
227 extern void flip_memplot( int , int , MEM_plotdata * ) ; /* 30 Aug 2001 */
228 
229 /*-- draw to a PostScript file: see also plot_ps.c --**/
230 
231 extern void memplot_to_postscript( char * , MEM_plotdata * ) ;
232 
233 #define memplot_to_ps(fn) memplot_to_postscript( (fn) , get_active_memplot() ) ;
234 
235 /*-- draw to an X11 window --*/
236 
237 extern unsigned long rgb_to_pixel( unsigned char , unsigned char ,
238                                    unsigned char , X11_colordef * ) ;
239 
240 extern X11_colordef * get_X11_colordef( Display * , Window ) ;
241 
242 #define MEMPLOT_FREE_ASPECT 1  /* masks for memplot_to_X11_sef() */
243 #define MEMPLOT_ERASE       2
244 
245 void memplot_XDrawLines_set_substitute( void (*msf)() ) ;  /* 30 Aug 2021 */
246 void * memplot_XDrawLines_get_substitute(void) ;
247 
248 extern void memplot_to_X11_sef( Display * , Window ,
249                                 MEM_plotdata * , int,int,int ) ;
250 
251 extern void   memplot_to_X11_set_substitute( void (*msf)() ) ;  /* 30 Apr 2012 */
252 extern void * memplot_to_X11_get_substitute( void ) ;
253 
254 extern void drawable_geom( Display *dpy , Drawable ddd ,      /* 30 Apr 2012 */
255                            int *width , int *height , int *depth ) ;
256 
257 extern void set_memplot_X11_box( int,int,int,int ) ;  /* 26 Feb 2001 */
258 
259 extern void set_X11_background( Display * , Window ,
260                                 unsigned char , unsigned char , unsigned char ) ;
261 
262 extern void set_memplot_X11_rectfill( int ) ;  /* 26 Oct 2005 */
263 
264 #define memplot_to_X11(d,w) \
265    memplot_to_X11_sef( (d),(w) , get_active_memplot() , 0,0,0 )
266 
267 #define memplot_to_X11_free(d,w) \
268    memplot_to_X11_sef( (d),(w) , get_active_memplot() , 0,0,1 )
269 
270 extern void set_memplot_RGB_box( int xbot, int ybot, int xtop, int ytop ) ;
271 
272 extern void memplot_to_RGB_sef( MRI_IMAGE *im , MEM_plotdata *mp ,
273                                 int start , int end , int freee    ) ;
274 
275 extern float_quad memplot_bbox( MEM_plotdata *mp ) ;    /* 19 Aug 2021 */
276 
277 extern void memplot_to_jpg( char * , MEM_plotdata * ) ; /* 05 Dec 2007 */
278 extern void memplot_to_png( char * , MEM_plotdata * ) ;
279 extern void memplot_to_pnm( char * , MEM_plotdata * ) ; /* 06 Jan 2015 */
280 
281 extern void memplot_to_mri_set_dothick( int ) ;         /* 30 Apr 2012 */
282 extern void memplot_to_mri_set_dofreee( int ) ;         /* 30 Apr 2012 */
283 
284 typedef struct {
285    Widget top , dial , wtf , drawing , form, clonebut ;
286    int valid ;
287    MEM_plotdata * mp ;
288    void * userdata ;
289    void_func * killfunc ;
290 #ifdef HAVE_XDBE
291    int            have_xdbe ;
292    XdbeBackBuffer buf_xdbe ;
293 #endif
294 
295    void (* clonebut_user_cb)(void *data); /* for SUMA */
296    int cloned; /* for SUMA */
297 } MEM_topshell_data ;
298 
299 #define MTD_PLOTDATA(mpcb)        ((mpcb)->mp)
300 #define MTD_KILLFUNC(mpcb)        ((mpcb)->killfunc)
301 #define MTD_VALID(mpcb)           ((mpcb)->valid)
302 #define MTD_USERDATA(mpcb)        ((mpcb)->userdata)
303 #define MTD_remove_killfunc(mpcb) ((mpcb)->killfunc = NULL)
304 
305 #define MTD_replace_plotdata(mpcb,mpnew) \
306   do{ delete_memplot((mpcb)->mp) ; (mpcb)->mp = (mpnew) ; } while(0)
307 
308 extern MEM_topshell_data * memplot_to_topshell(Display *,MEM_plotdata *,void_func *) ;
309 extern MEM_topshell_data * suma_memplot_to_topshell( Display *dpy,
310                                          MEM_plotdata *mp, void_func *kfun );
311 extern void plotkill_topshell( MEM_topshell_data * ) ;
312 extern void redraw_topshell( MEM_topshell_data * ) ;
313 extern void set_wintitle_memplot( char *s );
314 extern void memplot_topshell_setsaver( char * ,
315                                        void (*)(char *,MEM_plotdata *) ) ;
316 
317 #define memplot_to_shell(d) memplot_to_topshell( (d),get_active_memplot(),1 )
318 
319 /*-- plot time series --*/
320 
321 #define TSP_SEPARATE_YBOX    1
322 #define TSP_SEPARATE_YSCALE  2
323 #define TSP_SEPARATE_XAXIS   4
324 
325 extern void plot_ts_xypush( int , int ) ;
326 extern void plot_ts_dobox ( float ) ;
327 extern void plot_ts_xfix( int,int , float,float ) ;                /* 22 Jul 2003 */
328 extern void plot_ts_yfix( int,int , float,float ) ;
329 
330 extern void plot_ts_set_aspect( float asp ) ;                      /* 03 May 2018 */
331 extern void plot_ts_do_perim  ( int   dp  ) ;
332 
333 extern void plot_ts_add_vbox( int,float,float,float,float,float ); /* 24 Apr 2012 */
334 
335 extern void plot_ts_add_rbox( int ygr ,
336                               float x1,float y1 , float x2,float y2,float y3 ,
337                               float rr,float gg,float bb,
338                               float r2,float g2,float b2 ) ;       /* 29 Jan 2017 */
339 
340 extern void plot_ts_add_tlin( int ygr ,                            /* 19 Sep 2017 */
341                               float x1,float y1 , float x2,float y2,
342                               float rr,float gg,float bb, int dcode ) ;
343 
344 extern void plot_ts_add_sepx( int lx , float *x ) ;                /* 21 Oct 2013 */
345 extern void plot_ts_clear_sepx(void) ;
346 extern void plot_ts_fetch_sepx( int *ns , int **ls , float ***sx ) ;
347 extern void plot_ts_setdash( int ndash , int *code ) ;
348 
349 extern void plot_ts_setcolors( int, float *, float *, float * ) ;  /* 23 Nov 2007 */
350 extern void plot_ts_setTHIK( float thk ) ;                         /* 26 Nov 2007 */
351 extern void plot_ts_setthik( float thk ) ;                         /* 02 May 2012 */
352 #define plot_ts_setthick plot_ts_setthik /* for clumsy typists */
353 #define plot_ts_sethik   plot_ts_setthik
354 #define plot_ts_sethick  plot_ts_setthik
355 extern void plot_ts_setthik_12( int n1, int n2, float thk ) ;      /* 04 Mar 2013 */
356 
357 extern void plot_ts_lab( Display *,
358                          int,float *, int,float **,
359                          char *,char *,char *,char ** , void_func * ) ;
360 
361 extern MEM_plotdata * plot_ts_ebar( int nx , float *x , float *y , float *ey ,
362                                     char *lab_xxx , char *lab_yyy , char *lab_top ) ;
363 
364 extern void plot_ts_ebar_win( Display *,
365                               int,float *,float *,float *,char *,char *,char *,
366                               void_func * ) ;
367 
368 #define plot_ts(a,b,c,d,e) plot_ts_lab((a),(b),(c),(d),(e),NULL,NULL,NULL,NULL,NULL)
369 
370 extern MEM_topshell_data * plot_ts_init( Display *, float, float,
371                                          int, float, float,
372                                          char *, char *, char *, char ** , void_func * ) ;
373 
374 extern void plot_ts_addto( MEM_topshell_data *, int,float *, int,float ** ) ;
375 
376 extern MEM_plotdata * plot_ts_mem( int,float *, int,int,float **,
377                                    char *,char *,char *,char ** ) ;
378 
379 /*-- 15 Nov 2001: routines for strip plot --*/
380 
381 extern MEM_topshell_data * plot_strip_init( Display * , int , float ,
382                                             int , float , float ,
383                                             char * , char * ,
384                                             char * , char ** , void_func * ) ;
385 
386 extern void plot_strip_addto( MEM_topshell_data * , int , float ** ) ;
387 
388 extern void plot_strip_clear( MEM_topshell_data * ) ;
389 
390 /*-- routines in this library that will be called from PLOTPAK --*/
391 
392 extern void zzmpco_( float * , float * , float * ) ;
393 extern void zzmpli_( float * , float * , float * , float * ) ;
394 
395 /*-- ps_plot.c routines --*/
396 
397 extern void ps_move( int , int ) ;               /* move current position     */
398 extern void ps_line( int , int , int , int ) ;   /* draw a line from a to b   */
399 extern void ps_cont( int , int ) ;               /* draw a line from current  */
400 extern void ps_point( int , int ) ;              /* draw a point              */
401 extern void ps_label( char * ) ;                 /* draw a string (Courier)   */
402 extern void ps_arc( int , int , int , int , int , int ) ;  /* draw an arc     */
403 extern void ps_circle( int , int , int ) ;                 /* draw a circle   */
404 extern void ps_erase( void ) ;                             /* new page        */
405 extern void ps_linemod( char * ) ;                         /* line styles     */
406 extern void ps_space( int , int , int , int ) ;            /* set plot space  */
407 extern int  ps_openpl( char * ) ;                          /* open plot file  */
408 extern void ps_closepl( void ) ;                           /* close plot file */
409 extern void ps_setrgb( float , float , float ) ;           /* set color */
410 extern void ps_setwidth( float ) ;                         /* set linewidth */
411 extern void ps_rect( int,int,int,int) ;                    /* filled rectangle */
412 
413 #ifdef  __cplusplus
414 }
415 #endif
416 
417 /*-- routines from PLOTPAK, after running through f2c --*/
418 
419 #include "f2c.h"
420 #undef complex
421 
422 #ifdef  __cplusplus
423 extern "C" {
424 #endif
425 
426 extern int color_(integer *ncol);
427 extern int fcolor_( real *cr, real *cg, real *cb );
428 extern int curve_(real *x, real *y, integer *n);
429 extern int frame_(void);
430 extern int frstpt_(real *x, real *y);
431 extern int labmod_(integer *ifmtx, integer *ifmty, integer *numx, integer *numy, integer *jsizx, integer *jsizy, integer *ixdec, integer *iydec, integer *ixor);
432 extern int line_(real *x1, real *y1, real *x2, real *y2);
433 extern int memplt_(real *aspect);
434 extern int perim_(integer *mbx, integer *mlx, integer *mby, integer *mly);
435 extern int periml_(integer *mbx, integer *mlx, integer *mby, integer *mly);
436 extern int perimm_(integer *mbx, integer *mlx, integer *mby, integer *mly, integer *ilab);
437 extern int phdot_(real *x1, real *y1);
438 extern int phline_(real *x1, real *y1, real *x2, real *y2);
439 extern int point_(real *x, real *y);
440 extern int points_(real *x, real *y, integer *n, integer *ichar, integer *ipen);
441 extern int pwrit_(real *x, real *y, char *ch, integer *nch, integer *isiz, integer *ior, integer *icent, ftnlen ch_len);
442 extern int pwritf_(real *x, real *y, char *ch, integer *nch, integer *isiz, integer *ior, integer *icent, ftnlen ch_len);
443 extern integer lastnb_(char *cline, ftnlen cline_len);
444 extern int zzstro_(char *ch, integer *nch, integer *nstr, real *xstr, real *ystr, logical *lbstr, ftnlen ch_len);
445 extern int zzconv_(char *chin, integer *nchin, char *chout, integer *nchout, ftnlen chin_len, ftnlen chout_len);
446 extern int set_(real *xobj1, real *xobj2, real *yobj1, real *yobj2, real *xsub1, real *xsub2, real *ysub1, real *ysub2, integer *ltype);
447 extern int setdsh_(integer *nd, real *xld);
448 extern int setfrm_(real *xobj1, real *xobj2, real *yobj1, real *yobj2);
449 extern int setlin_(integer *ntype);
450 extern int setw_(real *x1, real *y1, real *x2, real *y2);
451 extern int srface_(real *x, real *y, real *z__, integer *m, integer *mx, integer *nx, integer *ny, real *s, real *stereo);
452 extern int srfpl_(integer *n, real *px, real *py);
453 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);
454 extern int ctcell_(real *z__, integer *mx, integer *nx, integer *ny, integer *m, integer *i0, integer *j0);
455 extern int draws_(integer *mx1, integer *my1, integer *mx2, integer *my2, integer *idraw, integer *imark);
456 extern int setr_(real *xmin, real *xmax, real *ymin, real *ymax, real *zmin, real *zmax, real *r0);
457 extern int trn32s_(real *x, real *y, real *z__, real *xt, real *yt, real *zt, integer *iflag);
458 extern int srfabd_(void);
459 extern int tick4_(integer *lmajx, integer *lminx, integer *lmajy, integer *lminy);
460 extern int vector_(real *x, real *y);
461 extern int zzaxxx_(real *x1, real *x2, real *y, integer *iside, integer *ilab);
462 extern int zzaxyy_(real *x, real *y1, real *y2, integer *iside, integer *ilab);
463 extern int zzchar_(char *ch, real *xp, real *yp, real *ct, real *st, ftnlen ch_len);
464 extern int zzclip_(real *x1in, real *y1in, real *x2in, real *y2in);
465 extern int zzlabl_(real *val, char *cout, integer *nchar, ftnlen cout_len);
466 extern int zzlgin_(real *xt, real *pwrten, integer *nlog);
467 extern int zzline_(real *x1, real *y1, real *x2, real *y2);
468 extern int zzlinx_(real *x1, real *x2, real *y, integer *majrx, real *tmaj, integer *minrx, real *tmin);
469 extern int zzliny_(real *x, real *y1, real *y2, integer *majry, real *tmaj, integer *minry, real *tmin);
470 extern int zzlogx_(real *x1, real *x2, real *y, integer *ndec, real *tmaj, real *tmin);
471 extern int zzlogy_(real *x, real *y1, real *y2, integer *ndec, real *tmaj, real *tmin);
472 extern int zzperi_(integer *ilab);
473 extern int zzphph_(real *x1, real *y1, real *x2, real *y2);
474 extern int zzphys_(real *x, real *y);
475 
476 /*-- Versions that are easier to call from C: --*/
477 
478 extern void plotpak_curve( float * x , float * y , int n ) ;
479 extern void plotpak_frame(void) ;
480 extern void plotpak_frstpt( float x , float y ) ;
481 extern void plotpak_labmod( int jsizx , int jsizy ) ;
482 extern void plotpak_line( float x1 , float y1 , float x2 , float y2 ) ;
483 extern void plotpak_perim( int mbx , int mlx , int mby , int mly ) ;
484 extern void plotpak_periml( int mbx , int mlx , int mby , int mly ) ;
485 extern void plotpak_perimm( int mbx , int mlx , int mby , int mly , int ilab ) ;
486 extern void plotpak_phdot( float x1 , float y1 ) ;
487 extern void plotpak_phline( float x1 , float y1 , float x2 , float y2 ) ;
488 extern void plotpak_point( float x1 , float y1 ) ;
489 extern void plotpak_points( float *x , float *y , int n , int ipen ) ;
490 extern void plotpak_pwrit( float x , float y , char * ch , int isiz , int ior , int icent ) ;
491 extern void plotpak_pwritf( float x , float y , char * ch , int isiz , int ior , int icent ) ;
492 extern void plotpak_pwritf_phys( float x , float y , char * ch , int isiz , int ior , int icent ) ;
493 extern void plotpak_set( float xo1,float xo2 , float yo1,float yo2 ,
494                          float xs1,float xs2 , float ys1,float ys2 , int code ) ;
495 extern void plotpak_setdsh( int nd , float * xd ) ;
496 extern void plotpak_setfrm( float xo1,float xo2 , float yo1,float yo2 ) ;
497 extern void plotpak_setlin( int code ) ;
498 extern void plotpak_setw( float xo1,float xo2 , float yo1,float yo2 ) ;
499 extern void plotpak_tick4( int mx, int lx , int my , int ly ) ;
500 extern void plotpak_vector( float x , float y ) ;
501 
502 extern void plotpak_srface( float *, float *, float *, int,int, float,float ) ;
503 
504 extern void plotpak_getset( float *xo1,float *xo2 , float *yo1,float *yo2 ,
505                             float *xs1,float *xs2 , float *ys1,float *ys2  ) ;
506 
507 /* 20 Nov 2001: routines to convert between user and memplot coords */
508 
509 extern void plotpak_zzphys( float x1 , float y1 , float *x2 , float *y2 ) ;
510 extern void plotpak_unphys( float x1 , float y1 , float *x2 , float *y2 ) ;
511 
512 /* 02 Dec 2015 */
513 
514 extern int find_color_name( char *cnam, float *rr, float *gg, float *bb ) ;
515 
516 /*----- Commons from PLOTPAK -----*/
517 
518 #ifdef PLOTPAK_COMMONS
519 #  define EXT  /* nada */
520 #else
521 #  define EXT extern
522 #endif
523 
524 typedef struct {
525     real xpgmin, ypgmin, xpgmax, ypgmax, xclbot, yclbot, xcltop, ycltop, xbot,
526              ybot, xtop, ytop, xmin, ymin, xmax, ymax;
527     integer ixcoor, iycoor;
528     real alphxx, betaxx, alphyy, betayy, tmajx, tminx, tmajy, tminy;
529     integer majrx, minrx, majry, minry, isizx, isizy;
530     real xphold, yphold;
531 } zzzplt_type ;
532 
533 EXT zzzplt_type zzzplt_ ;
534 
535 typedef struct {
536     real xphmax, yphmax;
537     integer ixpmax, iypmax;
538     real xpscal, ypscal;
539     integer iflip, nplotr;
540     char cfile[64];
541 } zzpltr_type ;
542 
543 EXT zzpltr_type zzpltr_ ;
544 
545 typedef struct {
546     integer ndash;
547     real xldash[8], xid;
548 } zzdash_type ;
549 
550 EXT zzdash_type zzdash_ ;
551 
552 #ifdef  __cplusplus
553 }
554 #endif
555 
556 #endif
557