Actual source code: drawimpl.h
1: /*
2: Abstract data structure and functions for graphics.
3: */
5: #ifndef 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: PetscErrorCode (*setvisible)(PetscDraw, PetscBool);
52: };
54: struct _p_PetscDraw {
55: PETSCHEADER(struct _PetscDrawOps);
56: PetscReal pause; /* sleep time after a synchronized flush */
57: PetscReal port_xl, port_yl, port_xr, port_yr;
58: PetscReal coor_xl, coor_yl, coor_xr, coor_yr;
59: PetscReal currentpoint_x[20], currentpoint_y[20];
60: PetscReal boundbox_xl, boundbox_yl, boundbox_xr, boundbox_yr; /* need to have this for each current point? */
61: PetscInt currentpoint;
62: PetscDrawMarkerType markertype;
63: char *title;
64: char *display;
65: PetscDraw popup;
66: int x, y, h, w;
67: char *savefilename;
68: char *saveimageext;
69: char *savemovieext;
70: PetscInt savefilecount;
71: PetscBool savesinglefile;
72: PetscInt savemoviefps;
73: char *savefinalfilename;
74: PetscBool saveonclear; /* save a new image for every PetscDrawClear() called */
75: PetscBool saveonflush; /* save a new image for every PetscDrawFlush() called */
76: void *data;
77: };
79: /* Contains the data structure for plotting several line
80: * graphs in a window with an axis. This is intended for line
81: * graphs that change dynamically by adding more points onto
82: * the end of the X axis.
83: */
84: struct _p_PetscDrawLG {
85: PETSCHEADER(int);
86: PetscErrorCode (*destroy)(PetscDrawLG);
87: PetscErrorCode (*view)(PetscDrawLG, PetscViewer);
88: int len, loc;
89: PetscDraw win;
90: PetscDrawAxis axis;
91: PetscReal xmin, xmax, ymin, ymax, *x, *y;
92: int nopts, dim, *colors;
93: PetscBool use_markers;
94: char **legend;
95: };
96: #define PETSC_DRAW_LG_CHUNK_SIZE 100
98: struct _p_PetscDrawAxis {
99: PETSCHEADER(int);
100: PetscReal xlow, ylow, xhigh, yhigh; /* User - coord limits */
101: PetscErrorCode (*ylabelstr)(PetscReal, PetscReal, char **); /* routines to generate labels */
102: PetscErrorCode (*xlabelstr)(PetscReal, PetscReal, char **);
103: PetscErrorCode (*xticks)(PetscReal, PetscReal, int, int *, PetscReal *, int);
104: PetscErrorCode (*yticks)(PetscReal, PetscReal, int, int *, PetscReal *, int);
105: /* location and size of ticks */
106: PetscDraw win;
107: int ac, tc, cc; /* axis,tick, character color */
108: char *xlabel, *ylabel, *toplabel;
109: PetscBool hold;
110: };
112: PETSC_INTERN PetscErrorCode PetscADefTicks(PetscReal, PetscReal, int, int *, PetscReal *, int);
113: PETSC_INTERN PetscErrorCode PetscADefLabel(PetscReal, PetscReal, char **);
114: PETSC_INTERN PetscErrorCode PetscAGetNice(PetscReal, PetscReal, int, PetscReal *);
115: PETSC_INTERN PetscErrorCode PetscAGetBase(PetscReal, PetscReal, int, PetscReal *, int *);
117: PETSC_INTERN PetscErrorCode PetscStripe0(char *);
118: PETSC_INTERN PetscErrorCode PetscStripAllZeros(char *);
119: PETSC_INTERN PetscErrorCode PetscStripTrailingZeros(char *);
120: PETSC_INTERN PetscErrorCode PetscStripInitialZero(char *);
121: PETSC_INTERN PetscErrorCode PetscStripZeros(char *);
122: PETSC_INTERN PetscErrorCode PetscStripZerosPlus(char *);
124: struct _p_PetscDrawBar {
125: PETSCHEADER(int);
126: PetscErrorCode (*destroy)(PetscDrawSP);
127: PetscErrorCode (*view)(PetscDrawSP, PetscViewer);
128: PetscDraw win;
129: PetscDrawAxis axis;
130: PetscReal ymin, ymax;
131: int numBins;
132: PetscReal *values;
133: int color;
134: char **labels;
135: PetscBool sort;
136: PetscReal sorttolerance;
137: };
139: struct _p_PetscDrawSP {
140: PETSCHEADER(int);
141: PetscErrorCode (*destroy)(PetscDrawSP);
142: PetscErrorCode (*view)(PetscDrawSP, PetscViewer);
143: int len, loc;
144: PetscDraw win;
145: PetscDrawAxis axis;
146: PetscReal xmin, xmax, ymin, ymax, *x, *y;
147: PetscReal zmax, zmin, *z;
148: int nopts, dim;
149: PetscBool colorized;
150: };
151: #define PETSC_DRAW_SP_CHUNK_SIZE 100
153: #endif /* PETSCDRAWIMPL_H */