Date: 2026-07-30T21:13:58+00:00

Actual source code: petscdraw.h

      1: /*
      2:   Interface to the PETSc graphics
      3: */
      4: #pragma once
      5: #include <petscsys.h>
      6: #include <petscdrawtypes.h>

      8: /* MANSEC = Sys */
      9: /* SUBMANSEC = Draw */

     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
     73:    PetscDrawRealToColor - Maps a real value within an interval to a color.
     74:    The color is an integer value in the range [`PETSC_DRAW_BASIC_COLORS` to 255]
     75:    that can be passed to various drawing routines.

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

     81:    Not Collective

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

     88:    Returns:
     89:    The result as integer

     91:    Level: intermediate

     93:    Note:
     94:    Values outside the interval [`min`, `max`] are clipped.

     96: .seealso: `PetscDraw`, `PetscDrawPointPixel()`, `PetscDrawPoint()`, `PetscDrawLine()`, `PetscDrawTriangle()`, `PetscDrawRectangle()`
     97: M*/
     98: static inline int PetscDrawRealToColor(PetscReal value, PetscReal min, PetscReal max)
     99: {
    100:   value = PetscClipInterval(value, min, max);
    101:   return PETSC_DRAW_BASIC_COLORS + (int)((255 - PETSC_DRAW_BASIC_COLORS) * (value - min) / (max - min));
    102: }

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

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

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

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

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

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

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

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

    135:    Values:
    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:    Level: intermediate

    143: .seealso: `PetscDraw`, `PetscDrawMarker()`, `PetscDrawSetMarkerType()`
    144: E*/
    145: typedef enum {
    146:   PETSC_DRAW_MARKER_CROSS,
    147:   PETSC_DRAW_MARKER_POINT,
    148:   PETSC_DRAW_MARKER_PLUS,
    149:   PETSC_DRAW_MARKER_CIRCLE
    150: } PetscDrawMarkerType;
    151: PETSC_EXTERN const char *const PetscDrawMarkerTypes[];

    153: PETSC_EXTERN PetscErrorCode PetscDrawMarker(PetscDraw, PetscReal, PetscReal, int);
    154: PETSC_EXTERN PetscErrorCode PetscDrawSetMarkerType(PetscDraw, PetscDrawMarkerType);
    155: PETSC_EXTERN PetscErrorCode PetscDrawGetMarkerType(PetscDraw, PetscDrawMarkerType *);

    157: PETSC_EXTERN PetscErrorCode PetscDrawPoint(PetscDraw, PetscReal, PetscReal, int);
    158: PETSC_EXTERN PetscErrorCode PetscDrawPointPixel(PetscDraw, int, int, int);
    159: PETSC_EXTERN PetscErrorCode PetscDrawPointSetSize(PetscDraw, PetscReal);

    161: PETSC_EXTERN PetscErrorCode PetscDrawRectangle(PetscDraw, PetscReal, PetscReal, PetscReal, PetscReal, int, int, int, int);
    162: PETSC_EXTERN PetscErrorCode PetscDrawTriangle(PetscDraw, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal, int, int, int);
    163: PETSC_EXTERN PetscErrorCode PetscDrawEllipse(PetscDraw, PetscReal, PetscReal, PetscReal, PetscReal, int);
    164: PETSC_EXTERN PetscErrorCode PetscDrawTensorContourPatch(PetscDraw, int, int, PetscReal *, PetscReal *, PetscReal, PetscReal, PetscReal *);
    165: PETSC_EXTERN PetscErrorCode PetscDrawTensorContour(PetscDraw, int, int, const PetscReal[], const PetscReal[], PetscReal *);

    167: PETSC_EXTERN PetscErrorCode PetscDrawString(PetscDraw, PetscReal, PetscReal, int, const char[]);
    168: PETSC_EXTERN PetscErrorCode PetscDrawStringCentered(PetscDraw, PetscReal, PetscReal, int, const char[]);
    169: PETSC_EXTERN PetscErrorCode PetscDrawStringBoxed(PetscDraw, PetscReal, PetscReal, int, int, const char[], PetscReal *, PetscReal *);
    170: PETSC_EXTERN PetscErrorCode PetscDrawStringVertical(PetscDraw, PetscReal, PetscReal, int, const char[]);
    171: PETSC_EXTERN PetscErrorCode PetscDrawStringSetSize(PetscDraw, PetscReal, PetscReal);
    172: PETSC_EXTERN PetscErrorCode PetscDrawStringGetSize(PetscDraw, PetscReal *, PetscReal *);

    174: PETSC_EXTERN PetscErrorCode PetscDrawSetViewPort(PetscDraw, PetscReal, PetscReal, PetscReal, PetscReal);
    175: PETSC_EXTERN PetscErrorCode PetscDrawGetViewPort(PetscDraw, PetscReal *, PetscReal *, PetscReal *, PetscReal *);
    176: PETSC_EXTERN PetscErrorCode PetscDrawSplitViewPort(PetscDraw);

    178: PETSC_EXTERN PetscErrorCode PetscDrawSetCoordinates(PetscDraw, PetscReal, PetscReal, PetscReal, PetscReal);
    179: PETSC_EXTERN PetscErrorCode PetscDrawGetCoordinates(PetscDraw, PetscReal *, PetscReal *, PetscReal *, PetscReal *);

    181: PETSC_EXTERN PetscErrorCode PetscDrawSetTitle(PetscDraw, const char[]);
    182: PETSC_EXTERN PetscErrorCode PetscDrawAppendTitle(PetscDraw, const char[]);
    183: PETSC_EXTERN PetscErrorCode PetscDrawGetTitle(PetscDraw, const char *[]);

    185: PETSC_EXTERN PetscErrorCode PetscDrawSetPause(PetscDraw, PetscReal);
    186: PETSC_EXTERN PetscErrorCode PetscDrawGetPause(PetscDraw, PetscReal *);
    187: PETSC_EXTERN PetscErrorCode PetscDrawPause(PetscDraw);
    188: PETSC_EXTERN PetscErrorCode PetscDrawSetDoubleBuffer(PetscDraw);
    189: PETSC_EXTERN PetscErrorCode PetscDrawClear(PetscDraw);
    190: PETSC_EXTERN PetscErrorCode PetscDrawFlush(PetscDraw);
    191: PETSC_EXTERN PetscErrorCode PetscDrawSave(PetscDraw);
    192: PETSC_EXTERN PetscErrorCode PetscDrawSaveMovie(PetscDraw);
    193: PETSC_EXTERN PetscErrorCode PetscDrawBOP(PetscDraw);
    194: PETSC_EXTERN PetscErrorCode PetscDrawEOP(PetscDraw);

    196: PETSC_EXTERN PetscErrorCode PetscDrawSetDisplay(PetscDraw, const char[]);
    197: PETSC_EXTERN PetscErrorCode PetscDrawGetSingleton(PetscDraw, PetscDraw *);
    198: PETSC_EXTERN PetscErrorCode PetscDrawRestoreSingleton(PetscDraw, PetscDraw *);

    200: PETSC_EXTERN PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw, PetscReal *, PetscReal *);
    201: PETSC_EXTERN PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw, PetscReal, PetscReal);
    202: PETSC_EXTERN PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw, PetscReal, PetscReal);
    203: PETSC_EXTERN PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw);
    204: PETSC_EXTERN PetscErrorCode PetscDrawGetBoundingBox(PetscDraw, PetscReal *, PetscReal *, PetscReal *, PetscReal *);

    206: PETSC_EXTERN PetscErrorCode PetscDrawSetVisible(PetscDraw, PetscBool);

    208: /*E
    209:    PetscDrawButton - Used to determine which button was pressed

    211:    Values:
    212: +  `PETSC_BUTTON_NONE`        - no button was pressed
    213: .  `PETSC_BUTTON_LEFT`        - the left button
    214: .  `PETSC_BUTTON_CENTER`      - the center button
    215: .  `PETSC_BUTTON_RIGHT`       - the right button
    216: .  `PETSC_BUTTON_WHEEL_UP`    - the wheel was moved up
    217: .  `PETSC_BUTTON_WHEEL_DOWN`  - the wheel was moved down
    218: .  `PETSC_BUTTON_LEFT_SHIFT`  - the left button and the shift key
    219: .  `PETSC_BUTTON_CENTER_SHIFT`- the center button and the shift key
    220: -  `PETSC_BUTTON_RIGHT_SHIFT` - the right button and the shift key

    222:    Level: intermediate

    224: .seealso: `PetscDraw`, `PetscDrawGetMouseButton()`
    225: E*/
    226: typedef enum {
    227:   PETSC_BUTTON_NONE,
    228:   PETSC_BUTTON_LEFT,
    229:   PETSC_BUTTON_CENTER,
    230:   PETSC_BUTTON_RIGHT,
    231:   PETSC_BUTTON_WHEEL_UP,
    232:   PETSC_BUTTON_WHEEL_DOWN,
    233:   PETSC_BUTTON_LEFT_SHIFT,
    234:   PETSC_BUTTON_CENTER_SHIFT,
    235:   PETSC_BUTTON_RIGHT_SHIFT
    236: } PetscDrawButton;

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

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

    242: /*S
    243:    PetscDrawViewPorts - Object representing subwindows in a `PetscDraw` object

    245:    Level: intermediate

    247: .seealso: `PetscDraw`, `PetscDrawViewPortsCreate()`, `PetscDrawViewPortsSet()`
    248: S*/
    249: typedef struct {
    250:   PetscInt   nports;
    251:   PetscReal *xl;
    252:   PetscReal *xr;
    253:   PetscReal *yl;
    254:   PetscReal *yr;
    255:   PetscDraw  draw;
    256:   PetscReal  port_xl, port_yl, port_xr, port_yr; /* original port of parent PetscDraw */
    257: } PetscDrawViewPorts;
    258: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreate(PetscDraw, PetscInt, PetscDrawViewPorts **);
    259: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreateRect(PetscDraw, PetscInt, PetscInt, PetscDrawViewPorts **);
    260: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsDestroy(PetscDrawViewPorts *);
    261: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsSet(PetscDrawViewPorts *, PetscInt);

    263: PETSC_EXTERN PetscClassId PETSC_DRAWAXIS_CLASSID;

    265: PETSC_EXTERN PetscErrorCode PetscDrawAxisCreate(PetscDraw, PetscDrawAxis *);
    266: PETSC_EXTERN PetscErrorCode PetscDrawAxisDestroy(PetscDrawAxis *);
    267: PETSC_EXTERN PetscErrorCode PetscDrawAxisDraw(PetscDrawAxis);
    268: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLimits(PetscDrawAxis, PetscReal, PetscReal, PetscReal, PetscReal);
    269: PETSC_EXTERN PetscErrorCode PetscDrawAxisGetLimits(PetscDrawAxis, PetscReal *, PetscReal *, PetscReal *, PetscReal *);
    270: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetHoldLimits(PetscDrawAxis, PetscBool);
    271: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetColors(PetscDrawAxis, int, int, int);
    272: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLabels(PetscDrawAxis, const char[], const char[], const char[]);

    274: PETSC_EXTERN PetscClassId PETSC_DRAWLG_CLASSID;

    276: PETSC_EXTERN PetscErrorCode PetscDrawLGCreate(PetscDraw, PetscInt, PetscDrawLG *);
    277: PETSC_EXTERN PetscErrorCode PetscDrawLGDestroy(PetscDrawLG *);
    278: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoint(PetscDrawLG, const PetscReal *, const PetscReal *);
    279: PETSC_EXTERN PetscErrorCode PetscDrawLGAddCommonPoint(PetscDrawLG, const PetscReal, const PetscReal *);
    280: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoints(PetscDrawLG, PetscInt, PetscReal **, PetscReal **);
    281: PETSC_EXTERN PetscErrorCode PetscDrawLGDraw(PetscDrawLG);
    282: PETSC_EXTERN PetscErrorCode PetscDrawLGSave(PetscDrawLG);
    283: PETSC_EXTERN PetscErrorCode PetscDrawLGView(PetscDrawLG, PetscViewer);
    284: PETSC_EXTERN PetscErrorCode PetscDrawLGReset(PetscDrawLG);
    285: PETSC_EXTERN PetscErrorCode PetscDrawLGSetDimension(PetscDrawLG, PetscInt);
    286: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDimension(PetscDrawLG, PetscInt *);
    287: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLegend(PetscDrawLG, const char *const *);
    288: PETSC_EXTERN PetscErrorCode PetscDrawLGGetAxis(PetscDrawLG, PetscDrawAxis *);
    289: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDraw(PetscDrawLG, PetscDraw *);
    290: PETSC_EXTERN PetscErrorCode PetscDrawLGSetUseMarkers(PetscDrawLG, PetscBool);
    291: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLimits(PetscDrawLG, PetscReal, PetscReal, PetscReal, PetscReal);
    292: PETSC_EXTERN PetscErrorCode PetscDrawLGSetColors(PetscDrawLG, const int[]);
    293: PETSC_EXTERN PetscErrorCode PetscDrawLGSetOptionsPrefix(PetscDrawLG, const char[]);
    294: PETSC_EXTERN PetscErrorCode PetscDrawLGSetFromOptions(PetscDrawLG);
    295: PETSC_EXTERN PetscErrorCode PetscDrawLGGetData(PetscDrawLG, PetscInt *, PetscInt *, const PetscReal *[], const PetscReal *[]);

    297: PETSC_EXTERN PetscClassId PETSC_DRAWSP_CLASSID;

    299: PETSC_EXTERN PetscErrorCode PetscDrawSPCreate(PetscDraw, int, PetscDrawSP *);
    300: PETSC_EXTERN PetscErrorCode PetscDrawSPDestroy(PetscDrawSP *);
    301: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoint(PetscDrawSP, PetscReal *, PetscReal *);
    302: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoints(PetscDrawSP, int, PetscReal **, PetscReal **);
    303: PETSC_EXTERN PetscErrorCode PetscDrawSPDraw(PetscDrawSP, PetscBool);
    304: PETSC_EXTERN PetscErrorCode PetscDrawSPSave(PetscDrawSP);
    305: PETSC_EXTERN PetscErrorCode PetscDrawSPReset(PetscDrawSP);
    306: PETSC_EXTERN PetscErrorCode PetscDrawSPGetDimension(PetscDrawSP, int *);
    307: PETSC_EXTERN PetscErrorCode PetscDrawSPSetDimension(PetscDrawSP, int);
    308: PETSC_EXTERN PetscErrorCode PetscDrawSPGetAxis(PetscDrawSP, PetscDrawAxis *);
    309: PETSC_EXTERN PetscErrorCode PetscDrawSPGetDraw(PetscDrawSP, PetscDraw *);
    310: PETSC_EXTERN PetscErrorCode PetscDrawSPSetLimits(PetscDrawSP, PetscReal, PetscReal, PetscReal, PetscReal);
    311: PETSC_EXTERN PetscErrorCode PetscDrawLGSPDraw(PetscDrawLG, PetscDrawSP);
    312: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPointColorized(PetscDrawSP, PetscReal *, PetscReal *, PetscReal *);

    314: PETSC_EXTERN PetscClassId PETSC_DRAWHG_CLASSID;

    316: PETSC_EXTERN PetscErrorCode PetscDrawHGCreate(PetscDraw, int, PetscDrawHG *);
    317: PETSC_EXTERN PetscErrorCode PetscDrawHGDestroy(PetscDrawHG *);
    318: PETSC_EXTERN PetscErrorCode PetscDrawHGAddValue(PetscDrawHG, PetscReal);
    319: PETSC_EXTERN PetscErrorCode PetscDrawHGAddWeightedValue(PetscDrawHG, PetscReal, PetscReal);
    320: PETSC_EXTERN PetscErrorCode PetscDrawHGDraw(PetscDrawHG);
    321: PETSC_EXTERN PetscErrorCode PetscDrawHGSave(PetscDrawHG);
    322: PETSC_EXTERN PetscErrorCode PetscDrawHGView(PetscDrawHG, PetscViewer);
    323: PETSC_EXTERN PetscErrorCode PetscDrawHGReset(PetscDrawHG);
    324: PETSC_EXTERN PetscErrorCode PetscDrawHGGetAxis(PetscDrawHG, PetscDrawAxis *);
    325: PETSC_EXTERN PetscErrorCode PetscDrawHGGetDraw(PetscDrawHG, PetscDraw *);
    326: PETSC_EXTERN PetscErrorCode PetscDrawHGSetLimits(PetscDrawHG, PetscReal, PetscReal, int, int);
    327: PETSC_EXTERN PetscErrorCode PetscDrawHGSetNumberBins(PetscDrawHG, int);
    328: PETSC_EXTERN PetscErrorCode PetscDrawHGSetColor(PetscDrawHG, int);
    329: PETSC_EXTERN PetscErrorCode PetscDrawHGCalcStats(PetscDrawHG, PetscBool);
    330: PETSC_EXTERN PetscErrorCode PetscDrawHGIntegerBins(PetscDrawHG, PetscBool);

    332: PETSC_EXTERN PetscClassId PETSC_DRAWBAR_CLASSID;

    334: PETSC_EXTERN PetscErrorCode PetscDrawBarCreate(PetscDraw, PetscDrawBar *);
    335: PETSC_EXTERN PetscErrorCode PetscDrawBarSetData(PetscDrawBar, PetscInt, const PetscReal[], const char *const *);
    336: PETSC_EXTERN PetscErrorCode PetscDrawBarDestroy(PetscDrawBar *);
    337: PETSC_EXTERN PetscErrorCode PetscDrawBarDraw(PetscDrawBar);
    338: PETSC_EXTERN PetscErrorCode PetscDrawBarSave(PetscDrawBar);
    339: PETSC_EXTERN PetscErrorCode PetscDrawBarSetColor(PetscDrawBar, int);
    340: PETSC_EXTERN PetscErrorCode PetscDrawBarSetLimits(PetscDrawBar, PetscReal, PetscReal);
    341: PETSC_EXTERN PetscErrorCode PetscDrawBarSort(PetscDrawBar, PetscBool, PetscReal);
    342: PETSC_EXTERN PetscErrorCode PetscDrawBarSetFromOptions(PetscDrawBar);
    343: PETSC_EXTERN PetscErrorCode PetscDrawBarGetAxis(PetscDrawBar, PetscDrawAxis *);
    344: PETSC_EXTERN PetscErrorCode PetscDrawBarGetDraw(PetscDrawBar, PetscDraw *);

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

    349: /*
    350:     Handling of X11 I/O window resizing, window closing and errors in parallel
    351: */
    352: #if PetscDefined(HAVE_X) && PetscDefined(HAVE_SETJMP_H)
    353:   #include <setjmp.h>

    355: PETSC_EXTERN jmp_buf PetscXIOErrorHandlerJumpBuf;
    356: PETSC_EXTERN void    PetscXIOErrorHandlerJump(void *);
    357: /*S
    358:   PetscXIOErrorHandlerFn - Function type for the X11 I/O error handler installed by `PetscSetXIOErrorHandler()`, called when the X server connection is lost

    360:   Calling Sequence:
    361: . display - the X `Display *` whose connection has failed (passed as `void *` to avoid pulling in X headers)

    363:   Level: developer

    365:   Note:
    366:   By default PETSc installs a handler that gracefully aborts the program rather than letting Xlib call `exit()`.

    368: .seealso: `PetscDraw`, `PetscSetXIOErrorHandler()`
    369: S*/
    370: PETSC_EXTERN_TYPEDEF typedef void                    PetscXIOErrorHandlerFn(void *display);
    371: PETSC_EXTERN_TYPEDEF typedef PetscXIOErrorHandlerFn *PetscXIOErrorHandler;
    372: PETSC_EXTERN PetscXIOErrorHandlerFn                 *PetscSetXIOErrorHandler(PetscXIOErrorHandlerFn *);

    374:   /*MC
    375:    PetscDrawCollectiveBegin - Begins a set of draw operations

    377:    Collective

    379:    Synopsis:
    380: #include <petscdraw.h>
    381:     PetscErrorCode PetscDrawCollectiveBegin(PetscDraw draw)

    383:    Collective

    385:    Input Parameter:
    386: .   draw - the draw object

    388:    Level: advanced

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

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

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

    398:    Developer Note:
    399:    This only applies to X windows and so should have a more specific name such as `PetscDrawXCollectiveBegin()`

    401: .seealso: `PetscDraw`, `PetscDrawCollectiveEnd()`
    402: M*/
    403:   #define PetscDrawCollectiveBegin(draw) \
    404:     do { \
    405:       jmp_buf _Petsc_jmpbuf; \
    406:       PetscXIOErrorHandlerFn *volatile _Petsc_xioerrhdl = PETSC_NULLPTR; \
    407:       PetscBool _Petsc_isdrawx, _Petsc_xioerr = PETSC_FALSE; \
    408:       PetscCall(PetscObjectTypeCompare((PetscObject)(draw), PETSC_DRAW_X, &_Petsc_isdrawx)); \
    409:       if (_Petsc_isdrawx) { \
    410:         PetscCall(PetscMemcpy(&_Petsc_jmpbuf, &PetscXIOErrorHandlerJumpBuf, sizeof(_Petsc_jmpbuf))); \
    411:         _Petsc_xioerrhdl = PetscSetXIOErrorHandler(PetscXIOErrorHandlerJump); \
    412:         if (setjmp(PetscXIOErrorHandlerJumpBuf)) { \
    413:           _Petsc_xioerr = PETSC_TRUE; \
    414:           do { \
    415:             PetscDrawCollectiveEnd(draw); \
    416:           } \
    417:         } \
    418:         do { \
    419:       } while (0)

    421:   /*MC
    422:    PetscDrawCollectiveEnd - Ends a set of draw operations begun with `PetscDrawCollectiveBegin()`

    424:    Collective

    426:    Synopsis:
    427: #include <petscdraw.h>
    428:     PetscErrorCode PetscDrawCollectiveEnd(PetscDraw draw)

    430:    Collective

    432:    Input Parameter:
    433: .   draw - the draw object

    435:    Level: advanced

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

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

    443:    Developer Note:
    444:    This only applies to X windows and so should have a more specific name such as `PetscDrawXCollectiveEnd()`

    446: .seealso: `PetscDraw`, `PetscDrawCollectiveBegin()`
    447: M*/
    448:   #define PetscDrawCollectiveEnd(draw) \
    449:     if (_Petsc_isdrawx) { \
    450:       (void)PetscSetXIOErrorHandler(_Petsc_xioerrhdl); \
    451:       PetscCall(PetscMemcpy(&PetscXIOErrorHandlerJumpBuf, &_Petsc_jmpbuf, sizeof(PetscXIOErrorHandlerJumpBuf))); \
    452:       PetscCallMPI(MPIU_Allreduce(MPI_IN_PLACE, &_Petsc_xioerr, 1, MPI_C_BOOL, MPI_LOR, PetscObjectComm((PetscObject)(draw)))); \
    453:       if (_Petsc_xioerr) { \
    454:         PetscCall(PetscDrawSetType((draw), PETSC_DRAW_NULL)); \
    455:         PetscFunctionReturn(PETSC_SUCCESS); \
    456:       } \
    457:     } \
    458:     } \
    459:     while (0)

    461: #else
    462:   #define PetscDrawCollectiveBegin(draw)
    463:   #define PetscDrawCollectiveEnd(draw)
    464: #endif /* PetscDefined(HAVE_X) && PetscDefined(HAVE_SETJMP_H) */

    466: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawType(PetscViewer, PetscDrawType *);
    467: PETSC_EXTERN PetscErrorCode PetscViewerDrawSetTitle(PetscViewer, const char[]);
    468: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetTitle(PetscViewer, const char *[]);
    469: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDraw(PetscViewer, PetscInt, PetscDraw *);
    470: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseAdd(PetscViewer, PetscInt);
    471: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseSet(PetscViewer, PetscInt);
    472: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawLG(PetscViewer, PetscInt, PetscDrawLG *);
    473: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawAxis(PetscViewer, PetscInt, PetscDrawAxis *);