Actual source code: petscdraw.h
petsc-3.6.4 2016-04-12
1: /*
2: Interface to the PETSc graphics
3: */
6: #include <petscsys.h>
7: #include <petscdrawtypes.h>
9: PETSC_EXTERN PetscClassId PETSC_DRAW_CLASSID;
11: PETSC_EXTERN PetscFunctionList PetscDrawList;
12: PETSC_EXTERN PetscErrorCode PetscDrawInitializePackage(void);
13: PETSC_EXTERN PetscErrorCode PetscDrawRegister(const char[],PetscErrorCode(*)(PetscDraw));
15: PETSC_EXTERN PetscErrorCode PetscDrawGetType(PetscDraw,PetscDrawType*);
16: PETSC_EXTERN PetscErrorCode PetscDrawSetType(PetscDraw,PetscDrawType);
17: PETSC_EXTERN PetscErrorCode PetscDrawCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
18: PETSC_EXTERN PetscErrorCode PetscDrawSetFromOptions(PetscDraw);
19: PETSC_EXTERN PetscErrorCode PetscDrawSetSave(PetscDraw,const char*,PetscBool);
20: PETSC_EXTERN PetscErrorCode PetscDrawSetSaveFinalImage(PetscDraw,const char*);
21: PETSC_EXTERN PetscErrorCode PetscDrawView(PetscDraw,PetscViewer);
22: PETSC_STATIC_INLINE PetscErrorCode PetscDrawViewFromOptions(PetscDraw A,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,obj,name);}
24: /*
25: Number of basic colors in the draw routines, the others are used
26: for a uniform colormap.
27: */
28: #define PETSC_DRAW_BASIC_COLORS 33
30: #define PETSC_DRAW_ROTATE -1 /* will rotate through the colors, start with 2 */
31: #define PETSC_DRAW_WHITE 0
32: #define PETSC_DRAW_BLACK 1
33: #define PETSC_DRAW_RED 2
34: #define PETSC_DRAW_GREEN 3
35: #define PETSC_DRAW_CYAN 4
36: #define PETSC_DRAW_BLUE 5
37: #define PETSC_DRAW_MAGENTA 6
38: #define PETSC_DRAW_AQUAMARINE 7
39: #define PETSC_DRAW_FORESTGREEN 8
40: #define PETSC_DRAW_ORANGE 9
41: #define PETSC_DRAW_VIOLET 10
42: #define PETSC_DRAW_BROWN 11
43: #define PETSC_DRAW_PINK 12
44: #define PETSC_DRAW_CORAL 13
45: #define PETSC_DRAW_GRAY 14
46: #define PETSC_DRAW_YELLOW 15
48: #define PETSC_DRAW_GOLD 16
49: #define PETSC_DRAW_LIGHTPINK 17
50: #define PETSC_DRAW_MEDIUMTURQUOISE 18
51: #define PETSC_DRAW_KHAKI 19
52: #define PETSC_DRAW_DIMGRAY 20
53: #define PETSC_DRAW_YELLOWGREEN 21
54: #define PETSC_DRAW_SKYBLUE 22
55: #define PETSC_DRAW_DARKGREEN 23
56: #define PETSC_DRAW_NAVYBLUE 24
57: #define PETSC_DRAW_SANDYBROWN 25
58: #define PETSC_DRAW_CADETBLUE 26
59: #define PETSC_DRAW_POWDERBLUE 27
60: #define PETSC_DRAW_DEEPPINK 28
61: #define PETSC_DRAW_THISTLE 29
62: #define PETSC_DRAW_LIMEGREEN 30
63: #define PETSC_DRAW_LAVENDERBLUSH 31
64: #define PETSC_DRAW_PLUM 32
66: PETSC_EXTERN PetscErrorCode PetscDrawOpenX(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
67: PETSC_EXTERN PetscErrorCode PetscDrawOpenGLUT(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
69: #define PETSC_DRAW_FULL_SIZE -3
70: #define PETSC_DRAW_HALF_SIZE -4
71: #define PETSC_DRAW_THIRD_SIZE -5
72: #define PETSC_DRAW_QUARTER_SIZE -6
74: PETSC_EXTERN PetscErrorCode PetscDrawOpenNull(MPI_Comm,PetscDraw *);
75: PETSC_EXTERN PetscErrorCode PetscDrawDestroy(PetscDraw*);
76: PETSC_EXTERN PetscErrorCode PetscDrawIsNull(PetscDraw,PetscBool *);
78: PETSC_EXTERN PetscErrorCode PetscDrawGetPopup(PetscDraw,PetscDraw*);
79: PETSC_EXTERN PetscErrorCode PetscDrawCheckResizedWindow(PetscDraw);
80: PETSC_EXTERN PetscErrorCode PetscDrawResizeWindow(PetscDraw,int,int);
82: PETSC_EXTERN PetscErrorCode PetscDrawScalePopup(PetscDraw,PetscReal,PetscReal);
84: PETSC_EXTERN PetscErrorCode PetscDrawPixelToCoordinate(PetscDraw,PetscInt,PetscInt,PetscReal*,PetscReal*);
85: PETSC_EXTERN PetscErrorCode PetscDrawCoordinateToPixel(PetscDraw,PetscReal,PetscReal,PetscInt*,PetscInt*);
87: PETSC_EXTERN PetscErrorCode PetscDrawIndicatorFunction(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int,PetscErrorCode (*)(void*,PetscReal,PetscReal,PetscBool*),void*);
89: PETSC_EXTERN PetscErrorCode PetscDrawLine(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
90: PETSC_EXTERN PetscErrorCode PetscDrawArrow(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
91: PETSC_EXTERN PetscErrorCode PetscDrawLineSetWidth(PetscDraw,PetscReal);
92: PETSC_EXTERN PetscErrorCode PetscDrawLineGetWidth(PetscDraw,PetscReal*);
94: /*E
95: PetscDrawMarkerType - How a "mark" is indicate in a figure
97: Level: intermediate
99: $ PETSC_MARKER_CROSS - a small pixel based x symbol or the character x if that is not available
100: $ PETSC_MARKER_PLUS - a small pixel based + symbol or the character + if that is not available
101: $ PETSC_MARKER_CIRCLE - a small pixel based circle symbol or the character o if that is not available
102: $ PETSC_MARKER_POINT - the make obtained with PetscDrawPoint()
104: .seealso: PetscDrawMarker(), PetscDrawSetMarkerType()
105: E*/
106: typedef enum {PETSC_DRAW_MARKER_CROSS, PETSC_DRAW_MARKER_POINT,PETSC_DRAW_MARKER_PLUS,PETSC_DRAW_MARKER_CIRCLE} PetscDrawMarkerType;
107: PETSC_EXTERN const char *const PetscDrawMarkerTypes[];
109: PETSC_EXTERN PetscErrorCode PetscDrawMarker(PetscDraw,PetscReal,PetscReal,int);
110: PETSC_EXTERN PetscErrorCode PetscDrawSetMarkerType(PetscDraw,PetscDrawMarkerType);
111: PETSC_EXTERN PetscErrorCode PetscDrawGetMarkerType(PetscDraw,PetscDrawMarkerType*);
113: PETSC_EXTERN PetscErrorCode PetscDrawPoint(PetscDraw,PetscReal,PetscReal,int);
114: PETSC_EXTERN PetscErrorCode PetscDrawPointPixel(PetscDraw,PetscInt,PetscInt,int);
115: PETSC_EXTERN PetscErrorCode PetscDrawPointSetSize(PetscDraw,PetscReal);
117: PETSC_EXTERN PetscErrorCode PetscDrawRectangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int,int);
118: PETSC_EXTERN PetscErrorCode PetscDrawTriangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int);
119: PETSC_EXTERN PetscErrorCode PetscDrawEllipse(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
120: PETSC_EXTERN PetscErrorCode PetscDrawTensorContourPatch(PetscDraw,int,int,PetscReal*,PetscReal*,PetscReal,PetscReal,PetscReal*);
121: PETSC_EXTERN PetscErrorCode PetscDrawTensorContour(PetscDraw,int,int,const PetscReal[],const PetscReal[],PetscReal *);
123: PETSC_EXTERN PetscErrorCode PetscDrawString(PetscDraw,PetscReal,PetscReal,int,const char[]);
124: PETSC_EXTERN PetscErrorCode PetscDrawStringCentered(PetscDraw,PetscReal,PetscReal,int,const char[]);
125: PETSC_EXTERN PetscErrorCode PetscDrawStringBoxed(PetscDraw,PetscReal,PetscReal,int,int,const char[],PetscReal*,PetscReal*);
126: PETSC_EXTERN PetscErrorCode PetscDrawStringBoxedSize(PetscDraw,const char[],PetscReal*,PetscReal*);
127: PETSC_EXTERN PetscErrorCode PetscDrawStringVertical(PetscDraw,PetscReal,PetscReal,int,const char[]);
128: PETSC_EXTERN PetscErrorCode PetscDrawStringSetSize(PetscDraw,PetscReal,PetscReal);
129: PETSC_EXTERN PetscErrorCode PetscDrawStringGetSize(PetscDraw,PetscReal*,PetscReal*);
131: PETSC_EXTERN PetscErrorCode PetscDrawSetViewPort(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
132: PETSC_EXTERN PetscErrorCode PetscDrawGetViewPort(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
133: PETSC_EXTERN PetscErrorCode PetscDrawSplitViewPort(PetscDraw);
135: PETSC_EXTERN PetscErrorCode PetscDrawSetCoordinates(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
136: PETSC_EXTERN PetscErrorCode PetscDrawGetCoordinates(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
138: PETSC_EXTERN PetscErrorCode PetscDrawSetTitle(PetscDraw,const char[]);
139: PETSC_EXTERN PetscErrorCode PetscDrawAppendTitle(PetscDraw,const char[]);
140: PETSC_EXTERN PetscErrorCode PetscDrawGetTitle(PetscDraw,char **);
142: PETSC_EXTERN PetscErrorCode PetscDrawSetPause(PetscDraw,PetscReal);
143: PETSC_EXTERN PetscErrorCode PetscDrawGetPause(PetscDraw,PetscReal*);
144: PETSC_EXTERN PetscErrorCode PetscDrawPause(PetscDraw);
145: PETSC_EXTERN PetscErrorCode PetscDrawSetDoubleBuffer(PetscDraw);
146: PETSC_EXTERN PetscErrorCode PetscDrawFlush(PetscDraw);
147: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedFlush(PetscDraw);
148: PETSC_EXTERN PetscErrorCode PetscDrawClear(PetscDraw);
149: PETSC_EXTERN PetscErrorCode PetscDrawSave(PetscDraw);
150: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedClear(PetscDraw);
151: PETSC_EXTERN PetscErrorCode PetscDrawBOP(PetscDraw);
152: PETSC_EXTERN PetscErrorCode PetscDrawEOP(PetscDraw);
154: PETSC_EXTERN PetscErrorCode PetscDrawSetDisplay(PetscDraw,const char[]);
155: PETSC_EXTERN PetscErrorCode PetscDrawGetSingleton(PetscDraw,PetscDraw*);
156: PETSC_EXTERN PetscErrorCode PetscDrawRestoreSingleton(PetscDraw,PetscDraw*);
158: PETSC_EXTERN PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw,PetscReal*,PetscReal*);
159: PETSC_EXTERN PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw,PetscReal,PetscReal);
160: PETSC_EXTERN PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw,PetscReal,PetscReal);
161: PETSC_EXTERN PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw);
162: PETSC_EXTERN PetscErrorCode PetscDrawGetBoundingBox(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
164: /*E
165: PetscDrawButton - Used to determine which button was pressed
167: Level: intermediate
169: .seealso: PetscDrawGetMouseButton(), PetscDrawSynchronizedGetMouseButton()
170: E*/
171: typedef enum {PETSC_BUTTON_NONE,PETSC_BUTTON_LEFT,PETSC_BUTTON_CENTER,PETSC_BUTTON_RIGHT,PETSC_BUTTON_LEFT_SHIFT,PETSC_BUTTON_CENTER_SHIFT,PETSC_BUTTON_RIGHT_SHIFT} PetscDrawButton;
173: PETSC_EXTERN PetscErrorCode PetscDrawGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);
174: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);
176: PETSC_EXTERN PetscErrorCode PetscDrawZoom(PetscDraw,PetscErrorCode (*)(PetscDraw,void *),void *);
178: /*S
179: PetscDrawViewPorts - Subwindows in a PetscDraw object
181: Level: intermediate
183: Concepts: graphics
185: .seealso: PetscDrawViewPortsCreate(), PetscDrawViewPortsSet()
186: S*/
187: typedef struct {
188: PetscInt nports;
189: PetscReal *xl;
190: PetscReal *xr;
191: PetscReal *yl;
192: PetscReal *yr;
193: PetscDraw draw;
194: PetscReal port_xl,port_yl,port_xr,port_yr; /* original port of parent PetscDraw */
196: } PetscDrawViewPorts;
197: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreate(PetscDraw,PetscInt,PetscDrawViewPorts**);
198: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreateRect(PetscDraw,PetscInt,PetscInt,PetscDrawViewPorts**);
199: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsDestroy(PetscDrawViewPorts*);
200: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsSet(PetscDrawViewPorts*,PetscInt);
202: PETSC_EXTERN PetscClassId PETSC_DRAWAXIS_CLASSID;
204: PETSC_EXTERN PetscErrorCode PetscDrawAxisCreate(PetscDraw,PetscDrawAxis *);
205: PETSC_EXTERN PetscErrorCode PetscDrawAxisDestroy(PetscDrawAxis*);
206: PETSC_EXTERN PetscErrorCode PetscDrawAxisDraw(PetscDrawAxis);
207: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLimits(PetscDrawAxis,PetscReal,PetscReal,PetscReal,PetscReal);
208: PETSC_EXTERN PetscErrorCode PetscDrawAxisGetLimits(PetscDrawAxis,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
209: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetHoldLimits(PetscDrawAxis,PetscBool );
210: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetColors(PetscDrawAxis,int,int,int);
211: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLabels(PetscDrawAxis,const char[],const char[],const char[]);
213: PETSC_EXTERN PetscClassId PETSC_DRAWLG_CLASSID;
215: PETSC_EXTERN PetscErrorCode PetscDrawLGCreate(PetscDraw,PetscInt,PetscDrawLG *);
216: PETSC_EXTERN PetscErrorCode PetscDrawLGDestroy(PetscDrawLG*);
217: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoint(PetscDrawLG,const PetscReal*,const PetscReal*);
218: PETSC_EXTERN PetscErrorCode PetscDrawLGAddCommonPoint(PetscDrawLG,const PetscReal,const PetscReal*);
219: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoints(PetscDrawLG,PetscInt,PetscReal**,PetscReal**);
220: PETSC_EXTERN PetscErrorCode PetscDrawLGDraw(PetscDrawLG);
221: PETSC_EXTERN PetscErrorCode PetscDrawLGView(PetscDrawLG,PetscViewer);
222: PETSC_EXTERN PetscErrorCode PetscDrawLGReset(PetscDrawLG);
223: PETSC_EXTERN PetscErrorCode PetscDrawLGSetDimension(PetscDrawLG,PetscInt);
224: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDimension(PetscDrawLG,PetscInt*);
225: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLegend(PetscDrawLG,const char *const*);
226: PETSC_EXTERN PetscErrorCode PetscDrawLGGetAxis(PetscDrawLG,PetscDrawAxis *);
227: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDraw(PetscDrawLG,PetscDraw *);
228: PETSC_EXTERN PetscErrorCode PetscDrawLGSetUseMarkers(PetscDrawLG,PetscBool);
229: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLimits(PetscDrawLG,PetscReal,PetscReal,PetscReal,PetscReal);
230: PETSC_EXTERN PetscErrorCode PetscDrawLGSetColors(PetscDrawLG,const int*);
231: PETSC_EXTERN PetscErrorCode PetscDrawLGSetFromOptions(PetscDrawLG);
233: PETSC_EXTERN PetscClassId PETSC_DRAWSP_CLASSID;
235: PETSC_EXTERN PetscErrorCode PetscDrawSPCreate(PetscDraw,int,PetscDrawSP *);
236: PETSC_EXTERN PetscErrorCode PetscDrawSPDestroy(PetscDrawSP*);
237: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoint(PetscDrawSP,PetscReal*,PetscReal*);
238: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoints(PetscDrawSP,int,PetscReal**,PetscReal**);
239: PETSC_EXTERN PetscErrorCode PetscDrawSPDraw(PetscDrawSP,PetscBool);
240: PETSC_EXTERN PetscErrorCode PetscDrawSPReset(PetscDrawSP);
241: PETSC_EXTERN PetscErrorCode PetscDrawSPSetDimension(PetscDrawSP,int);
242: PETSC_EXTERN PetscErrorCode PetscDrawSPGetAxis(PetscDrawSP,PetscDrawAxis *);
243: PETSC_EXTERN PetscErrorCode PetscDrawSPGetDraw(PetscDrawSP,PetscDraw *);
244: PETSC_EXTERN PetscErrorCode PetscDrawSPSetLimits(PetscDrawSP,PetscReal,PetscReal,PetscReal,PetscReal);
245: PETSC_EXTERN PetscErrorCode PetscDrawLGSPDraw(PetscDrawLG,PetscDrawSP);
247: PETSC_EXTERN PetscClassId PETSC_DRAWHG_CLASSID;
249: PETSC_EXTERN PetscErrorCode PetscDrawHGCreate(PetscDraw,int,PetscDrawHG *);
250: PETSC_EXTERN PetscErrorCode PetscDrawHGDestroy(PetscDrawHG*);
251: PETSC_EXTERN PetscErrorCode PetscDrawHGAddValue(PetscDrawHG,PetscReal);
252: PETSC_EXTERN PetscErrorCode PetscDrawHGDraw(PetscDrawHG);
253: PETSC_EXTERN PetscErrorCode PetscDrawHGView(PetscDrawHG,PetscViewer);
254: PETSC_EXTERN PetscErrorCode PetscDrawHGReset(PetscDrawHG);
255: PETSC_EXTERN PetscErrorCode PetscDrawHGGetAxis(PetscDrawHG,PetscDrawAxis *);
256: PETSC_EXTERN PetscErrorCode PetscDrawHGGetDraw(PetscDrawHG,PetscDraw *);
257: PETSC_EXTERN PetscErrorCode PetscDrawHGSetLimits(PetscDrawHG,PetscReal,PetscReal,int,int);
258: PETSC_EXTERN PetscErrorCode PetscDrawHGSetNumberBins(PetscDrawHG,int);
259: PETSC_EXTERN PetscErrorCode PetscDrawHGSetColor(PetscDrawHG,int);
260: PETSC_EXTERN PetscErrorCode PetscDrawHGCalcStats(PetscDrawHG, PetscBool );
261: PETSC_EXTERN PetscErrorCode PetscDrawHGIntegerBins(PetscDrawHG, PetscBool );
263: PETSC_EXTERN PetscClassId PETSC_DRAWBAR_CLASSID;
265: PETSC_EXTERN PetscErrorCode PetscDrawBarCreate(PetscDraw,PetscDrawBar*);
266: PETSC_EXTERN PetscErrorCode PetscDrawBarSetData(PetscDrawBar,PetscInt,const PetscReal[],const char *const *);
267: PETSC_EXTERN PetscErrorCode PetscDrawBarDestroy(PetscDrawBar*);
268: PETSC_EXTERN PetscErrorCode PetscDrawBarDraw(PetscDrawBar);
269: PETSC_EXTERN PetscErrorCode PetscDrawBarSetColor(PetscDrawBar,int);
270: PETSC_EXTERN PetscErrorCode PetscDrawBarSetLimits(PetscDrawBar,PetscReal,PetscReal);
271: PETSC_EXTERN PetscErrorCode PetscDrawBarSort(PetscDrawBar,PetscBool,PetscReal);
272: PETSC_EXTERN PetscErrorCode PetscDrawBarSetFromOptions(PetscDrawBar);
273: PETSC_EXTERN PetscErrorCode PetscDrawBarGetAxis(PetscDrawBar,PetscDrawAxis*);
274: PETSC_EXTERN PetscErrorCode PetscDrawBarGetDraw(PetscDrawBar,PetscDraw*);
276: /*
277: PetscViewer routines that allow you to access underlying PetscDraw objects
278: */
279: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDraw(PetscViewer,PetscInt,PetscDraw*);
280: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseAdd(PetscViewer,PetscInt);
281: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseSet(PetscViewer,PetscInt);
282: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawLG(PetscViewer,PetscInt,PetscDrawLG*);
283: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawAxis(PetscViewer,PetscInt,PetscDrawAxis*);
285: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetCmapHue(unsigned char *,unsigned char *,unsigned char *,int);
286: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetGamma(PetscReal);
288: #endif