Actual source code: drawimpl.h

  1: /*
  2:        Abstract data structure and functions for graphics.
  3: */

  5: #if !defined(PETSCDRAWIMPL_H)
  6: #define PETSCDRAWIMPL_H

  8: #include <petsc/private/petscimpl.h>
  9: #include <petscdraw.h>

 11: PETSC_EXTERN PetscBool PetscDrawRegisterAllCalled;
 12: PETSC_EXTERN PetscErrorCode PetscDrawRegisterAll(void);

 14: struct _PetscDrawOps {
 15:   PetscErrorCode (*setdoublebuffer)(PetscDraw);
 16:   PetscErrorCode (*flush)(PetscDraw);
 17:   PetscErrorCode (*line)(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
 18:   PetscErrorCode (*linesetwidth)(PetscDraw,PetscReal);
 19:   PetscErrorCode (*linegetwidth)(PetscDraw,PetscReal*);
 20:   PetscErrorCode (*point)(PetscDraw,PetscReal,PetscReal,int);
 21:   PetscErrorCode (*pointsetsize)(PetscDraw,PetscReal);
 22:   PetscErrorCode (*string)(PetscDraw,PetscReal,PetscReal,int,const char[]);
 23:   PetscErrorCode (*stringvertical)(PetscDraw,PetscReal,PetscReal,int,const char[]);
 24:   PetscErrorCode (*stringsetsize)(PetscDraw,PetscReal,PetscReal);
 25:   PetscErrorCode (*stringgetsize)(PetscDraw,PetscReal*,PetscReal*);
 26:   PetscErrorCode (*setviewport)(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
 27:   PetscErrorCode (*clear)(PetscDraw);
 28:   PetscErrorCode (*rectangle)(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int,int);
 29:   PetscErrorCode (*triangle)(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int);
 30:   PetscErrorCode (*ellipse)(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
 31:   PetscErrorCode (*getmousebutton)(PetscDraw,PetscDrawButton*,PetscReal *,PetscReal *,PetscReal*,PetscReal*);
 32:   PetscErrorCode (*pause)(PetscDraw);
 33:   PetscErrorCode (*beginpage)(PetscDraw);
 34:   PetscErrorCode (*endpage)(PetscDraw);
 35:   PetscErrorCode (*getpopup)(PetscDraw,PetscDraw*);
 36:   PetscErrorCode (*settitle)(PetscDraw,const char[]);
 37:   PetscErrorCode (*checkresizedwindow)(PetscDraw);
 38:   PetscErrorCode (*resizewindow)(PetscDraw,int,int);
 39:   PetscErrorCode (*destroy)(PetscDraw);
 40:   PetscErrorCode (*view)(PetscDraw,PetscViewer);
 41:   PetscErrorCode (*getsingleton)(PetscDraw,PetscDraw*);
 42:   PetscErrorCode (*restoresingleton)(PetscDraw,PetscDraw*);
 43:   PetscErrorCode (*save)(PetscDraw);
 44:   PetscErrorCode (*getimage)(PetscDraw,unsigned char[][3],unsigned int*,unsigned int*,unsigned char*[]);
 45:   PetscErrorCode (*setcoordinates)(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
 46:   PetscErrorCode (*arrow)(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
 47:   PetscErrorCode (*coordinatetopixel)(PetscDraw,PetscReal,PetscReal,int*,int*);
 48:   PetscErrorCode (*pixeltocoordinate)(PetscDraw,int,int,PetscReal*,PetscReal*);
 49:   PetscErrorCode (*pointpixel)(PetscDraw,int,int,int);
 50:   PetscErrorCode (*boxedstring)(PetscDraw,PetscReal,PetscReal,int,int,const char[],PetscReal*,PetscReal*);
 51: };

 53: struct _p_PetscDraw {
 54:   PETSCHEADER(struct _PetscDrawOps);
 55:   PetscReal           pause;       /* sleep time after a synchronized flush */
 56:   PetscReal           port_xl,port_yl,port_xr,port_yr;
 57:   PetscReal           coor_xl,coor_yl,coor_xr,coor_yr;
 58:   PetscReal           currentpoint_x[20],currentpoint_y[20];
 59:   PetscReal           boundbox_xl,boundbox_yl,boundbox_xr,boundbox_yr; /* need to have this for each current point? */
 60:   PetscInt            currentpoint;
 61:   PetscDrawMarkerType markertype;
 62:   char                *title;
 63:   char                *display;
 64:   PetscDraw           popup;
 65:   int                 x,y,h,w;
 66:   char                *savefilename;
 67:   char                *saveimageext;
 68:   char                *savemovieext;
 69:   PetscInt            savefilecount;
 70:   PetscBool           savesinglefile;
 71:   PetscInt            savemoviefps;
 72:   char                *savefinalfilename;
 73:   PetscBool           saveonclear; /* save a new image for every PetscDrawClear() called */
 74:   PetscBool           saveonflush; /* save a new image for every PetscDrawFlush() called */
 75:   void                *data;
 76: };

 78: /* Contains the data structure for plotting several line
 79:  * graphs in a window with an axis. This is intended for line
 80:  * graphs that change dynamically by adding more points onto
 81:  * the end of the X axis.
 82:  */
 83: struct _p_PetscDrawLG {
 84:   PETSCHEADER(int);
 85:   PetscErrorCode (*destroy)(PetscDrawLG);
 86:   PetscErrorCode (*view)(PetscDrawLG,PetscViewer);
 87:   int            len,loc;
 88:   PetscDraw      win;
 89:   PetscDrawAxis  axis;
 90:   PetscReal      xmin,xmax,ymin,ymax,*x,*y;
 91:   int            nopts,dim,*colors;
 92:   PetscBool      use_markers;
 93:   char           **legend;
 94: };
 95: #define PETSC_DRAW_LG_CHUNK_SIZE 100

 97: struct _p_PetscDrawAxis {
 98:   PETSCHEADER(int);
 99:   PetscReal      xlow,ylow,xhigh,yhigh;                    /* User - coord limits */
100:   PetscErrorCode (*ylabelstr)(PetscReal,PetscReal,char**);/* routines to generate labels */
101:   PetscErrorCode (*xlabelstr)(PetscReal,PetscReal,char**);
102:   PetscErrorCode (*xticks)(PetscReal,PetscReal,int,int*,PetscReal*,int);
103:   PetscErrorCode (*yticks)(PetscReal,PetscReal,int,int*,PetscReal*,int);
104:                                            /* location and size of ticks */
105:   PetscDraw win;
106:   int       ac,tc,cc;                     /* axis,tick, character color */
107:   char      *xlabel,*ylabel,*toplabel;
108:   PetscBool hold;
109: };

111: PETSC_INTERN PetscErrorCode PetscADefTicks(PetscReal,PetscReal,int,int*,PetscReal*,int);
112: PETSC_INTERN PetscErrorCode PetscADefLabel(PetscReal,PetscReal,char**);
113: PETSC_INTERN PetscErrorCode PetscAGetNice(PetscReal,PetscReal,int,PetscReal*);
114: PETSC_INTERN PetscErrorCode PetscAGetBase(PetscReal,PetscReal,int,PetscReal*,int*);

116: PETSC_INTERN PetscErrorCode PetscStripe0(char*);
117: PETSC_INTERN PetscErrorCode PetscStripAllZeros(char*);
118: PETSC_INTERN PetscErrorCode PetscStripTrailingZeros(char*);
119: PETSC_INTERN PetscErrorCode PetscStripInitialZero(char*);
120: PETSC_INTERN PetscErrorCode PetscStripZeros(char*);
121: PETSC_INTERN PetscErrorCode PetscStripZerosPlus(char*);

123: struct _p_PetscDrawBar {
124:   PETSCHEADER(int);
125:   PetscErrorCode (*destroy)(PetscDrawSP);
126:   PetscErrorCode (*view)(PetscDrawSP,PetscViewer);
127:   PetscDraw      win;
128:   PetscDrawAxis  axis;
129:   PetscReal      ymin,ymax;
130:   int            numBins;
131:   PetscReal      *values;
132:   int            color;
133:   char           **labels;
134:   PetscBool      sort;
135:   PetscReal      sorttolerance;
136: };

138: struct _p_PetscDrawSP {
139:   PETSCHEADER(int);
140:   PetscErrorCode (*destroy)(PetscDrawSP);
141:   PetscErrorCode (*view)(PetscDrawSP,PetscViewer);
142:   int            len,loc;
143:   PetscDraw      win;
144:   PetscDrawAxis  axis;
145:   PetscReal      xmin,xmax,ymin,ymax,*x,*y;
146:   int            nopts,dim;
147: };
148: #define PETSC_DRAW_SP_CHUNK_SIZE 100

150: #endif /* PETSCDRAWIMPL_H */