Actual source code: petscdraw.h

  1: /*
  2:   Interface to the PETSc graphics
  3: */
  4: #if !defined(PETSCDRAW_H)
  5: #define PETSCDRAW_H
  6: #include <petscsys.h>
  7: #include <petscdrawtypes.h>

  9: /* SUBMANSEC = Sys */

 11: PETSC_EXTERN PetscClassId PETSC_DRAW_CLASSID;

 13: PETSC_EXTERN PetscFunctionList PetscDrawList;
 14: PETSC_EXTERN PetscErrorCode PetscDrawInitializePackage(void);
 15: PETSC_EXTERN PetscErrorCode PetscDrawFinalizePackage(void);
 16: PETSC_EXTERN PetscErrorCode PetscDrawRegister(const char[],PetscErrorCode(*)(PetscDraw));

 18: PETSC_EXTERN PetscErrorCode PetscDrawGetType(PetscDraw,PetscDrawType*);
 19: PETSC_EXTERN PetscErrorCode PetscDrawSetType(PetscDraw,PetscDrawType);
 20: PETSC_EXTERN PetscErrorCode PetscDrawCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
 21: PETSC_EXTERN PetscErrorCode PetscDrawSetOptionsPrefix(PetscDraw,const char[]);
 22: PETSC_EXTERN PetscErrorCode PetscDrawSetFromOptions(PetscDraw);
 23: PETSC_EXTERN PetscErrorCode PetscDrawSetSave(PetscDraw,const char[]);
 24: PETSC_EXTERN PetscErrorCode PetscDrawSetSaveMovie(PetscDraw,const char[]);
 25: PETSC_EXTERN PetscErrorCode PetscDrawSetSaveFinalImage(PetscDraw,const char[]);
 26: PETSC_EXTERN PetscErrorCode PetscDrawView(PetscDraw,PetscViewer);
 27: PETSC_EXTERN PetscErrorCode PetscDrawViewFromOptions(PetscDraw,PetscObject,const char[]);

 29: /*
 30:    Number of basic colors in the draw routines, the others are used
 31:    for a uniform colormap.
 32: */
 33: #define PETSC_DRAW_BASIC_COLORS 33

 35: #define PETSC_DRAW_ROTATE          -1         /* will rotate through the colors, start with 2 */
 36: #define PETSC_DRAW_WHITE            0
 37: #define PETSC_DRAW_BLACK            1
 38: #define PETSC_DRAW_RED              2
 39: #define PETSC_DRAW_GREEN            3
 40: #define PETSC_DRAW_CYAN             4
 41: #define PETSC_DRAW_BLUE             5
 42: #define PETSC_DRAW_MAGENTA          6
 43: #define PETSC_DRAW_AQUAMARINE       7
 44: #define PETSC_DRAW_FORESTGREEN      8
 45: #define PETSC_DRAW_ORANGE           9
 46: #define PETSC_DRAW_VIOLET          10
 47: #define PETSC_DRAW_BROWN           11
 48: #define PETSC_DRAW_PINK            12
 49: #define PETSC_DRAW_CORAL           13
 50: #define PETSC_DRAW_GRAY            14
 51: #define PETSC_DRAW_YELLOW          15

 53: #define PETSC_DRAW_GOLD            16
 54: #define PETSC_DRAW_LIGHTPINK       17
 55: #define PETSC_DRAW_MEDIUMTURQUOISE 18
 56: #define PETSC_DRAW_KHAKI           19
 57: #define PETSC_DRAW_DIMGRAY         20
 58: #define PETSC_DRAW_YELLOWGREEN     21
 59: #define PETSC_DRAW_SKYBLUE         22
 60: #define PETSC_DRAW_DARKGREEN       23
 61: #define PETSC_DRAW_NAVYBLUE        24
 62: #define PETSC_DRAW_SANDYBROWN      25
 63: #define PETSC_DRAW_CADETBLUE       26
 64: #define PETSC_DRAW_POWDERBLUE      27
 65: #define PETSC_DRAW_DEEPPINK        28
 66: #define PETSC_DRAW_THISTLE         29
 67: #define PETSC_DRAW_LIMEGREEN       30
 68: #define PETSC_DRAW_LAVENDERBLUSH   31
 69: #define PETSC_DRAW_PLUM            32
 70: #define PETSC_DRAW_MAXCOLOR       256

 72: /*MC

 74:    PetscDrawRealToColor - Maps a real value within an interval to a color.
 75:    The color is an integer value in the range [PETSC_DRAW_BASIC_COLORS to 255]
 76:    that can be passed to various drawing routines.

 78:    Synopsis:
 79: #include <petscdraw.h>
 80:    int PetscDrawRealToColor(PetscReal value,PetscReal min,PetscReal max)

 82:    Not Collective

 84:    Input Parameters:
 85: +  value - value to map within the interval [min,max]
 86: .  min - lower end of interval
 87: -  max - upper end of interval

 89:    Notes:
 90:     Values outside the interval [min,max] are clipped.

 92:    Level: intermediate

 94: .seealso: `PetscDrawPointPixel()`, `PetscDrawPoint()`, `PetscDrawLine()`, `PetscDrawTriangle()`, `PetscDrawRectangle()`

 96: M*/
 97: static inline int PetscDrawRealToColor(PetscReal value,PetscReal min,PetscReal max)
 98: {
 99:   value = PetscClipInterval(value,min,max);
100:   return PETSC_DRAW_BASIC_COLORS + (int)((255-PETSC_DRAW_BASIC_COLORS)*(value-min)/(max-min));
101: }

103: PETSC_EXTERN PetscErrorCode PetscDrawOpenX(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);

105: #define PETSC_DRAW_FULL_SIZE    -3
106: #define PETSC_DRAW_HALF_SIZE    -4
107: #define PETSC_DRAW_THIRD_SIZE   -5
108: #define PETSC_DRAW_QUARTER_SIZE -6

110: PETSC_EXTERN PetscErrorCode PetscDrawOpenImage(MPI_Comm,const char[],int,int,PetscDraw*);
111: PETSC_EXTERN PetscErrorCode PetscDrawOpenNull(MPI_Comm,PetscDraw *);
112: PETSC_EXTERN PetscErrorCode PetscDrawDestroy(PetscDraw*);
113: PETSC_EXTERN PetscErrorCode PetscDrawIsNull(PetscDraw,PetscBool *);

115: PETSC_EXTERN PetscErrorCode PetscDrawGetPopup(PetscDraw,PetscDraw*);
116: PETSC_EXTERN PetscErrorCode PetscDrawScalePopup(PetscDraw,PetscReal,PetscReal);

118: PETSC_EXTERN PetscErrorCode PetscDrawCheckResizedWindow(PetscDraw);
119: PETSC_EXTERN PetscErrorCode PetscDrawResizeWindow(PetscDraw,int,int);
120: PETSC_EXTERN PetscErrorCode PetscDrawGetWindowSize(PetscDraw,int*,int*);
121: PETSC_EXTERN PetscErrorCode PetscDrawPixelToCoordinate(PetscDraw,int,int,PetscReal*,PetscReal*);
122: PETSC_EXTERN PetscErrorCode PetscDrawCoordinateToPixel(PetscDraw,PetscReal,PetscReal,int*,int*);

124: PETSC_EXTERN PetscErrorCode PetscDrawIndicatorFunction(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int,PetscErrorCode (*)(void*,PetscReal,PetscReal,PetscBool*),void*);

126: PETSC_EXTERN PetscErrorCode PetscDrawLine(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
127: PETSC_EXTERN PetscErrorCode PetscDrawArrow(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
128: PETSC_EXTERN PetscErrorCode PetscDrawLineSetWidth(PetscDraw,PetscReal);
129: PETSC_EXTERN PetscErrorCode PetscDrawLineGetWidth(PetscDraw,PetscReal*);

131: /*E
132:     PetscDrawMarkerType - How a "mark" is indicate in a figure

134:    Level: intermediate

136: $  PETSC_MARKER_CROSS - a small pixel based x symbol or the character x if that is not available
137: $  PETSC_MARKER_PLUS - a small pixel based + symbol or the character + if that is not available
138: $  PETSC_MARKER_CIRCLE - a small pixel based circle symbol or the character o if that is not available
139: $  PETSC_MARKER_POINT - the make obtained with PetscDrawPoint()

141: .seealso: `PetscDrawMarker()`, `PetscDrawSetMarkerType()`
142: E*/
143: typedef enum {PETSC_DRAW_MARKER_CROSS, PETSC_DRAW_MARKER_POINT,PETSC_DRAW_MARKER_PLUS,PETSC_DRAW_MARKER_CIRCLE} PetscDrawMarkerType;
144: PETSC_EXTERN const char *const PetscDrawMarkerTypes[];

146: PETSC_EXTERN PetscErrorCode PetscDrawMarker(PetscDraw,PetscReal,PetscReal,int);
147: PETSC_EXTERN PetscErrorCode PetscDrawSetMarkerType(PetscDraw,PetscDrawMarkerType);
148: PETSC_EXTERN PetscErrorCode PetscDrawGetMarkerType(PetscDraw,PetscDrawMarkerType*);

150: PETSC_EXTERN PetscErrorCode PetscDrawPoint(PetscDraw,PetscReal,PetscReal,int);
151: PETSC_EXTERN PetscErrorCode PetscDrawPointPixel(PetscDraw,int,int,int);
152: PETSC_EXTERN PetscErrorCode PetscDrawPointSetSize(PetscDraw,PetscReal);

154: PETSC_EXTERN PetscErrorCode PetscDrawRectangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int,int);
155: PETSC_EXTERN PetscErrorCode PetscDrawTriangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int);
156: PETSC_EXTERN PetscErrorCode PetscDrawEllipse(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
157: PETSC_EXTERN PetscErrorCode PetscDrawTensorContourPatch(PetscDraw,int,int,PetscReal*,PetscReal*,PetscReal,PetscReal,PetscReal*);
158: PETSC_EXTERN PetscErrorCode PetscDrawTensorContour(PetscDraw,int,int,const PetscReal[],const PetscReal[],PetscReal *);

160: PETSC_EXTERN PetscErrorCode PetscDrawString(PetscDraw,PetscReal,PetscReal,int,const char[]);
161: PETSC_EXTERN PetscErrorCode PetscDrawStringCentered(PetscDraw,PetscReal,PetscReal,int,const char[]);
162: PETSC_EXTERN PetscErrorCode PetscDrawStringBoxed(PetscDraw,PetscReal,PetscReal,int,int,const char[],PetscReal*,PetscReal*);
163: PETSC_EXTERN PetscErrorCode PetscDrawStringVertical(PetscDraw,PetscReal,PetscReal,int,const char[]);
164: PETSC_EXTERN PetscErrorCode PetscDrawStringSetSize(PetscDraw,PetscReal,PetscReal);
165: PETSC_EXTERN PetscErrorCode PetscDrawStringGetSize(PetscDraw,PetscReal*,PetscReal*);

167: PETSC_EXTERN PetscErrorCode PetscDrawSetViewPort(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
168: PETSC_EXTERN PetscErrorCode PetscDrawGetViewPort(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
169: PETSC_EXTERN PetscErrorCode PetscDrawSplitViewPort(PetscDraw);

171: PETSC_EXTERN PetscErrorCode PetscDrawSetCoordinates(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
172: PETSC_EXTERN PetscErrorCode PetscDrawGetCoordinates(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);

174: PETSC_EXTERN PetscErrorCode PetscDrawSetTitle(PetscDraw,const char[]);
175: PETSC_EXTERN PetscErrorCode PetscDrawAppendTitle(PetscDraw,const char[]);
176: PETSC_EXTERN PetscErrorCode PetscDrawGetTitle(PetscDraw,const char *[]);

178: PETSC_EXTERN PetscErrorCode PetscDrawSetPause(PetscDraw,PetscReal);
179: PETSC_EXTERN PetscErrorCode PetscDrawGetPause(PetscDraw,PetscReal*);
180: PETSC_EXTERN PetscErrorCode PetscDrawPause(PetscDraw);
181: PETSC_EXTERN PetscErrorCode PetscDrawSetDoubleBuffer(PetscDraw);
182: PETSC_EXTERN PetscErrorCode PetscDrawClear(PetscDraw);
183: PETSC_EXTERN PetscErrorCode PetscDrawFlush(PetscDraw);
184: PETSC_EXTERN PetscErrorCode PetscDrawSave(PetscDraw);
185: PETSC_EXTERN PetscErrorCode PetscDrawSaveMovie(PetscDraw);
186: PETSC_EXTERN PetscErrorCode PetscDrawBOP(PetscDraw);
187: PETSC_EXTERN PetscErrorCode PetscDrawEOP(PetscDraw);

189: PETSC_EXTERN PetscErrorCode PetscDrawSetDisplay(PetscDraw,const char[]);
190: PETSC_EXTERN PetscErrorCode PetscDrawGetSingleton(PetscDraw,PetscDraw*);
191: PETSC_EXTERN PetscErrorCode PetscDrawRestoreSingleton(PetscDraw,PetscDraw*);

193: PETSC_EXTERN PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw,PetscReal*,PetscReal*);
194: PETSC_EXTERN PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw,PetscReal,PetscReal);
195: PETSC_EXTERN PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw,PetscReal,PetscReal);
196: PETSC_EXTERN PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw);
197: PETSC_EXTERN PetscErrorCode PetscDrawGetBoundingBox(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);

199: /*E
200:     PetscDrawButton - Used to determine which button was pressed

202:    Level: intermediate

204: .seealso: `PetscDrawGetMouseButton()`
205: E*/
206: typedef enum { PETSC_BUTTON_NONE = 0,
207:                PETSC_BUTTON_LEFT,PETSC_BUTTON_CENTER,PETSC_BUTTON_RIGHT,
208:                PETSC_BUTTON_WHEEL_UP,PETSC_BUTTON_WHEEL_DOWN,
209:                PETSC_BUTTON_LEFT_SHIFT,PETSC_BUTTON_CENTER_SHIFT,PETSC_BUTTON_RIGHT_SHIFT } PetscDrawButton;

211: PETSC_EXTERN PetscErrorCode PetscDrawGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);

213: PETSC_EXTERN PetscErrorCode PetscDrawZoom(PetscDraw,PetscErrorCode (*)(PetscDraw,void *),void *);

215: /*S
216:      PetscDrawViewPorts - Subwindows in a PetscDraw object

218:    Level: intermediate

220: .seealso: `PetscDrawViewPortsCreate()`, `PetscDrawViewPortsSet()`
221: S*/
222: typedef struct {
223:   PetscInt  nports;
224:   PetscReal *xl;
225:   PetscReal *xr;
226:   PetscReal *yl;
227:   PetscReal *yr;
228:   PetscDraw draw;
229:   PetscReal port_xl,port_yl,port_xr,port_yr;   /* original port of parent PetscDraw */
230: } PetscDrawViewPorts;
231: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreate(PetscDraw,PetscInt,PetscDrawViewPorts**);
232: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreateRect(PetscDraw,PetscInt,PetscInt,PetscDrawViewPorts**);
233: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsDestroy(PetscDrawViewPorts*);
234: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsSet(PetscDrawViewPorts*,PetscInt);

236: PETSC_EXTERN PetscClassId PETSC_DRAWAXIS_CLASSID;

238: PETSC_EXTERN PetscErrorCode PetscDrawAxisCreate(PetscDraw,PetscDrawAxis*);
239: PETSC_EXTERN PetscErrorCode PetscDrawAxisDestroy(PetscDrawAxis*);
240: PETSC_EXTERN PetscErrorCode PetscDrawAxisDraw(PetscDrawAxis);
241: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLimits(PetscDrawAxis,PetscReal,PetscReal,PetscReal,PetscReal);
242: PETSC_EXTERN PetscErrorCode PetscDrawAxisGetLimits(PetscDrawAxis,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
243: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetHoldLimits(PetscDrawAxis,PetscBool);
244: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetColors(PetscDrawAxis,int,int,int);
245: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLabels(PetscDrawAxis,const char[],const char[],const char[]);

247: PETSC_EXTERN PetscClassId PETSC_DRAWLG_CLASSID;

249: PETSC_EXTERN PetscErrorCode PetscDrawLGCreate(PetscDraw,PetscInt,PetscDrawLG*);
250: PETSC_EXTERN PetscErrorCode PetscDrawLGDestroy(PetscDrawLG*);
251: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoint(PetscDrawLG,const PetscReal*,const PetscReal*);
252: PETSC_EXTERN PetscErrorCode PetscDrawLGAddCommonPoint(PetscDrawLG,const PetscReal,const PetscReal*);
253: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoints(PetscDrawLG,PetscInt,PetscReal**,PetscReal**);
254: PETSC_EXTERN PetscErrorCode PetscDrawLGDraw(PetscDrawLG);
255: PETSC_EXTERN PetscErrorCode PetscDrawLGSave(PetscDrawLG);
256: PETSC_EXTERN PetscErrorCode PetscDrawLGView(PetscDrawLG,PetscViewer);
257: PETSC_EXTERN PetscErrorCode PetscDrawLGReset(PetscDrawLG);
258: PETSC_EXTERN PetscErrorCode PetscDrawLGSetDimension(PetscDrawLG,PetscInt);
259: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDimension(PetscDrawLG,PetscInt*);
260: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLegend(PetscDrawLG,const char *const*);
261: PETSC_EXTERN PetscErrorCode PetscDrawLGGetAxis(PetscDrawLG,PetscDrawAxis*);
262: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDraw(PetscDrawLG,PetscDraw*);
263: PETSC_EXTERN PetscErrorCode PetscDrawLGSetUseMarkers(PetscDrawLG,PetscBool);
264: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLimits(PetscDrawLG,PetscReal,PetscReal,PetscReal,PetscReal);
265: PETSC_EXTERN PetscErrorCode PetscDrawLGSetColors(PetscDrawLG,const int[]);
266: PETSC_EXTERN PetscErrorCode PetscDrawLGSetOptionsPrefix(PetscDrawLG,const char[]);
267: PETSC_EXTERN PetscErrorCode PetscDrawLGSetFromOptions(PetscDrawLG);

269: PETSC_EXTERN PetscClassId PETSC_DRAWSP_CLASSID;

271: PETSC_EXTERN PetscErrorCode PetscDrawSPCreate(PetscDraw,int,PetscDrawSP*);
272: PETSC_EXTERN PetscErrorCode PetscDrawSPDestroy(PetscDrawSP*);
273: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoint(PetscDrawSP,PetscReal*,PetscReal*);
274: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoints(PetscDrawSP,int,PetscReal**,PetscReal**);
275: PETSC_EXTERN PetscErrorCode PetscDrawSPDraw(PetscDrawSP,PetscBool);
276: PETSC_EXTERN PetscErrorCode PetscDrawSPSave(PetscDrawSP);
277: PETSC_EXTERN PetscErrorCode PetscDrawSPReset(PetscDrawSP);
278: PETSC_EXTERN PetscErrorCode PetscDrawSPGetDimension(PetscDrawSP,int*);
279: PETSC_EXTERN PetscErrorCode PetscDrawSPSetDimension(PetscDrawSP,int);
280: PETSC_EXTERN PetscErrorCode PetscDrawSPGetAxis(PetscDrawSP,PetscDrawAxis*);
281: PETSC_EXTERN PetscErrorCode PetscDrawSPGetDraw(PetscDrawSP,PetscDraw*);
282: PETSC_EXTERN PetscErrorCode PetscDrawSPSetLimits(PetscDrawSP,PetscReal,PetscReal,PetscReal,PetscReal);
283: PETSC_EXTERN PetscErrorCode PetscDrawLGSPDraw(PetscDrawLG,PetscDrawSP);
284: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPointColorized(PetscDrawSP,PetscReal*,PetscReal*,PetscReal*);

286: PETSC_EXTERN PetscClassId PETSC_DRAWHG_CLASSID;

288: PETSC_EXTERN PetscErrorCode PetscDrawHGCreate(PetscDraw,int,PetscDrawHG*);
289: PETSC_EXTERN PetscErrorCode PetscDrawHGDestroy(PetscDrawHG*);
290: PETSC_EXTERN PetscErrorCode PetscDrawHGAddValue(PetscDrawHG,PetscReal);
291: PETSC_EXTERN PetscErrorCode PetscDrawHGDraw(PetscDrawHG);
292: PETSC_EXTERN PetscErrorCode PetscDrawHGSave(PetscDrawHG);
293: PETSC_EXTERN PetscErrorCode PetscDrawHGView(PetscDrawHG,PetscViewer);
294: PETSC_EXTERN PetscErrorCode PetscDrawHGReset(PetscDrawHG);
295: PETSC_EXTERN PetscErrorCode PetscDrawHGGetAxis(PetscDrawHG,PetscDrawAxis*);
296: PETSC_EXTERN PetscErrorCode PetscDrawHGGetDraw(PetscDrawHG,PetscDraw*);
297: PETSC_EXTERN PetscErrorCode PetscDrawHGSetLimits(PetscDrawHG,PetscReal,PetscReal,int,int);
298: PETSC_EXTERN PetscErrorCode PetscDrawHGSetNumberBins(PetscDrawHG,int);
299: PETSC_EXTERN PetscErrorCode PetscDrawHGSetColor(PetscDrawHG,int);
300: PETSC_EXTERN PetscErrorCode PetscDrawHGCalcStats(PetscDrawHG, PetscBool);
301: PETSC_EXTERN PetscErrorCode PetscDrawHGIntegerBins(PetscDrawHG, PetscBool);

303: PETSC_EXTERN PetscClassId PETSC_DRAWBAR_CLASSID;

305: PETSC_EXTERN PetscErrorCode PetscDrawBarCreate(PetscDraw,PetscDrawBar*);
306: PETSC_EXTERN PetscErrorCode PetscDrawBarSetData(PetscDrawBar,PetscInt,const PetscReal[],const char *const*);
307: PETSC_EXTERN PetscErrorCode PetscDrawBarDestroy(PetscDrawBar*);
308: PETSC_EXTERN PetscErrorCode PetscDrawBarDraw(PetscDrawBar);
309: PETSC_EXTERN PetscErrorCode PetscDrawBarSave(PetscDrawBar);
310: PETSC_EXTERN PetscErrorCode PetscDrawBarSetColor(PetscDrawBar,int);
311: PETSC_EXTERN PetscErrorCode PetscDrawBarSetLimits(PetscDrawBar,PetscReal,PetscReal);
312: PETSC_EXTERN PetscErrorCode PetscDrawBarSort(PetscDrawBar,PetscBool,PetscReal);
313: PETSC_EXTERN PetscErrorCode PetscDrawBarSetFromOptions(PetscDrawBar);
314: PETSC_EXTERN PetscErrorCode PetscDrawBarGetAxis(PetscDrawBar,PetscDrawAxis*);
315: PETSC_EXTERN PetscErrorCode PetscDrawBarGetDraw(PetscDrawBar,PetscDraw*);

317: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetCmap(const char[],int,unsigned char[],unsigned char[],unsigned char[]);
318: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetGamma(PetscReal);

320: /*
321:     Handling of X11 I/O window resizing, window closing and errors in parallel
322: */
323: #if PetscDefined(HAVE_X) && PetscDefined(HAVE_SETJMP_H)
324: #include <setjmp.h>

326: PETSC_EXTERN jmp_buf PetscXIOErrorHandlerJumpBuf;
327: PETSC_EXTERN void    PetscXIOErrorHandlerJump(void *);
328: PETSC_EXTERN_TYPEDEF typedef void (*PetscXIOErrorHandler)(void *);
329: PETSC_EXTERN PetscXIOErrorHandler PetscSetXIOErrorHandler(PetscXIOErrorHandler);

331: /*MC
332:     PetscDrawCollectiveBegin - Begins a set of draw operations

334:    Collective

336:    Synopsis:
337: #include <petscdraw.h>
338:     PetscErrorCode PetscDrawCollectiveBegin(PetscDraw draw)

340:     Collective

342:   Input Parameters:
343: .   draw - the draw object

345:   Notes:
346:     This is a macro that handles its own error checking, it does not return an error code.

348:     The set of operations needs to be ended by a call to PetscDrawCollectiveEnd().

350:     X windows draw operations that are enclosed by these routines handle correctly resizing or closing of
351:     the window without crashing the program.

353:   Developer Notes:
354:     This only applies to X windows and so should have a more specific name such as PetscDrawXCollectiveBegin()

356:   Level: advanced

358: .seealso: `PetscDrawCollectiveEnd()`
359: M*/
360: #define PetscDrawCollectiveBegin(draw) do {                                                 \
361:   jmp_buf                       _Petsc_jmpbuf;                                                 \
362:   volatile PetscXIOErrorHandler _Petsc_xioerrhdl = PETSC_NULLPTR;                                       \
363:   PetscBool                     _Petsc_isdrawx,_Petsc_xioerr,_Petsc_xioerr_local=PETSC_FALSE;  \
364:   PetscObjectTypeCompare((PetscObject)(draw),PETSC_DRAW_X,&_Petsc_isdrawx);           \
365:   if (_Petsc_isdrawx) {                                                                        \
366:   PetscMemcpy(&_Petsc_jmpbuf,&PetscXIOErrorHandlerJumpBuf,sizeof(_Petsc_jmpbuf));     \
367:   _Petsc_xioerrhdl = PetscSetXIOErrorHandler(PetscXIOErrorHandlerJump);                        \
368:   if (setjmp(PetscXIOErrorHandlerJumpBuf)) {                                                   \
369:     _Petsc_xioerr_local = PETSC_TRUE;                                                          \
370:     do {                                                                                       \
371:       PetscDrawCollectiveEnd(draw);                                                            \
372:     }                                                                                          \
373:   }                                                                                            \
374:   do {} while (0)

376: /*MC
377:     PetscDrawCollectiveEnd - Ends a set of draw operations begun with PetscDrawCollectiveBegin()

379:    Collective

381:    Synopsis:
382: #include <petscdraw.h>
383:     PetscErrorCode PetscDrawCollectiveEnd(PetscDraw draw)

385:     Collective

387:   Input Parameters:
388: .   draw - the draw object

390:   Notes:
391:     This is a macro that handles its own error checking, it does not return an error code.

393:     X windows draw operations that are enclosed by these routines handle correctly resizing or closing of
394:     the window without crashing the program.

396:   Developer Notes:
397:     This only applies to X windows and so should have a more specific name such as PetscDrawXCollectiveEnd()

399:   Level: advanced

401: .seealso: `PetscDrawCollectiveBegin()`
402: M*/
403: #define PetscDrawCollectiveEnd(draw)                                                           \
404:   if (_Petsc_isdrawx) {                                                                        \
405:     (void)PetscSetXIOErrorHandler(_Petsc_xioerrhdl);                                           \
406:     PetscMemcpy(&PetscXIOErrorHandlerJumpBuf,&_Petsc_jmpbuf,sizeof(PetscXIOErrorHandlerJumpBuf)); \
407:     MPI_Allreduce(&_Petsc_xioerr_local,&_Petsc_xioerr,1,MPIU_BOOL,MPI_LOR,PetscObjectComm((PetscObject)(draw))); \
408:     if (_Petsc_xioerr) {                                                                       \
409:       PetscDrawSetType((draw),PETSC_DRAW_NULL);                                       \
410:       return 0;                                                                  \
411:     }                                                                                          \
412:   }                                                                                            \
413:   } while (0)

415: #else
416: #define PetscDrawCollectiveBegin(draw)
417: #define PetscDrawCollectiveEnd(draw)
418: #endif /* PetscDefined(HAVE_X) && PetscDefined(HAVE_SETJMP_H) */

420: #endif /* PETSCDRAW_H */