Actual source code: petscdraw.h

      1: /*
      2:   Interface to the PETSc graphics (currently only support for X-windows
      3: */
     6:  #include petsc.h

     11: /*E
     12:     PetscDrawType - String with the name of a PetscDraw

     14:    Level: beginner

     16: .seealso: PetscDrawSetType(), PetscDraw, PetscViewer
     17: E*/
     18: #define PetscDrawType const char*
     19: #define PETSC_DRAW_X     "x"
     20: #define PETSC_DRAW_NULL  "null"
     21: #define PETSC_DRAW_PS    "ps"
     22: #define PETSC_DRAW_WIN32 "win32"
     23:
     24: /*S
     25:      PetscDraw - Abstract PETSc object for graphics

     27:    Level: beginner

     29:   Concepts: graphics

     31: .seealso:  PetscDrawCreate(), PetscDrawSetType(), PetscDrawType
     32: S*/
     33: typedef struct _p_PetscDraw* PetscDraw;

     36: EXTERN PetscErrorCode  PetscDrawRegisterAll(const char[]);
     37: EXTERN PetscErrorCode  PetscDrawInitializePackage(const char[]);
     38: EXTERN PetscErrorCode  PetscDrawRegisterDestroy(void);

     40: EXTERN PetscErrorCode  PetscDrawRegister(const char*,const char*,const char*,PetscErrorCode(*)(PetscDraw));

     42: /*MC
     43:    PetscDrawRegisterDynamic - Adds a method to the Krylov subspace solver package.

     45:    Synopsis:
     46:    PetscErrorCode PetscDrawRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(PetscDraw))

     48:    Not Collective

     50:    Input Parameters:
     51: +  name_solver - name of a new user-defined solver
     52: .  path - path (either absolute or relative) the library containing this solver
     53: .  name_create - name of routine to create method context
     54: -  routine_create - routine to create method context

     56:    Level: developer

     58:    Notes:
     59:    PetscDrawRegisterDynamic() may be called multiple times to add several user-defined solvers.

     61:    If dynamic libraries are used, then the fourth input argument (routine_create)
     62:    is ignored.

     64:    Sample usage:
     65: .vb
     66:    PetscDrawRegisterDynamic("my_draw_type",/home/username/my_lib/lib/libO/solaris/mylib.a,
     67:                "MyDrawCreate",MyDrawCreate);
     68: .ve

     70:    Then, your solver can be chosen with the procedural interface via
     71: $     PetscDrawSetType(ksp,"my_draw_type")
     72:    or at runtime via the option
     73: $     -draw_type my_draw_type

     75:    Concepts: graphics^registering new draw classes
     76:    Concepts: PetscDraw^registering new draw classes

     78: .seealso: PetscDrawRegisterAll(), PetscDrawRegisterDestroy()
     79: M*/
     80: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
     81: #define PetscDrawRegisterDynamic(a,b,c,d) PetscDrawRegister(a,b,c,0)
     82: #else
     83: #define PetscDrawRegisterDynamic(a,b,c,d) PetscDrawRegister(a,b,c,d)
     84: #endif

     86: EXTERN PetscErrorCode  PetscDrawGetType(PetscDraw,PetscDrawType*);
     87: EXTERN PetscErrorCode  PetscDrawSetType(PetscDraw,PetscDrawType);
     88: EXTERN PetscErrorCode  PetscDrawCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
     89: EXTERN PetscErrorCode  PetscDrawSetFromOptions(PetscDraw);

     91: /*
     92:    Number of basic colors in the draw routines, the others are used
     93:    for a uniform colormap.
     94: */
     95: #define PETSC_DRAW_BASIC_COLORS 33

     97: #define PETSC_DRAW_ROTATE          -1         /* will rotate through the colors, start with 2 */
     98: #define PETSC_DRAW_WHITE            0
     99: #define PETSC_DRAW_BLACK            1
    100: #define PETSC_DRAW_RED              2
    101: #define PETSC_DRAW_GREEN            3
    102: #define PETSC_DRAW_CYAN             4
    103: #define PETSC_DRAW_BLUE             5
    104: #define PETSC_DRAW_MAGENTA          6
    105: #define PETSC_DRAW_AQUAMARINE       7
    106: #define PETSC_DRAW_FORESTGREEN      8
    107: #define PETSC_DRAW_ORANGE           9
    108: #define PETSC_DRAW_VIOLET          10
    109: #define PETSC_DRAW_BROWN           11
    110: #define PETSC_DRAW_PINK            12
    111: #define PETSC_DRAW_CORAL           13
    112: #define PETSC_DRAW_GRAY            14
    113: #define PETSC_DRAW_YELLOW          15

    115: #define PETSC_DRAW_GOLD            16
    116: #define PETSC_DRAW_LIGHTPINK       17
    117: #define PETSC_DRAW_MEDIUMTURQUOISE 18
    118: #define PETSC_DRAW_KHAKI           19
    119: #define PETSC_DRAW_DIMGRAY         20
    120: #define PETSC_DRAW_YELLOWGREEN     21
    121: #define PETSC_DRAW_SKYBLUE         22
    122: #define PETSC_DRAW_DARKGREEN       23
    123: #define PETSC_DRAW_NAVYBLUE        24
    124: #define PETSC_DRAW_SANDYBROWN      25
    125: #define PETSC_DRAW_CADETBLUE       26
    126: #define PETSC_DRAW_POWDERBLUE      27
    127: #define PETSC_DRAW_DEEPPINK        28
    128: #define PETSC_DRAW_THISTLE         29
    129: #define PETSC_DRAW_LIMEGREEN       30
    130: #define PETSC_DRAW_LAVENDERBLUSH   31
    131: #define PETSC_DRAW_PLUM            32

    133: EXTERN PetscErrorCode  PetscDrawOpenX(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
    134: EXTERN PetscErrorCode  PetscDrawOpenPS(MPI_Comm,char *,PetscDraw *);
    135: #define PETSC_DRAW_FULL_SIZE    -3
    136: #define PETSC_DRAW_HALF_SIZE    -4
    137: #define PETSC_DRAW_THIRD_SIZE   -5
    138: #define PETSC_DRAW_QUARTER_SIZE -6

    140: EXTERN PetscErrorCode  PetscDrawOpenNull(MPI_Comm,PetscDraw *);
    141: EXTERN PetscErrorCode  PetscDrawDestroy(PetscDraw);
    142: EXTERN PetscErrorCode  PetscDrawIsNull(PetscDraw,PetscTruth*);

    144: EXTERN PetscErrorCode  PetscDrawGetPopup(PetscDraw,PetscDraw*);
    145: EXTERN PetscErrorCode  PetscDrawCheckResizedWindow(PetscDraw);
    146: EXTERN PetscErrorCode  PetscDrawResizeWindow(PetscDraw,int,int);

    148: EXTERN PetscErrorCode  PetscDrawScalePopup(PetscDraw,PetscReal,PetscReal);

    150: EXTERN PetscErrorCode  PetscDrawLine(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
    151: EXTERN PetscErrorCode  PetscDrawLineSetWidth(PetscDraw,PetscReal);
    152: EXTERN PetscErrorCode  PetscDrawLineGetWidth(PetscDraw,PetscReal*);

    154: EXTERN PetscErrorCode  PetscDrawPoint(PetscDraw,PetscReal,PetscReal,int);
    155: EXTERN PetscErrorCode  PetscDrawPointSetSize(PetscDraw,PetscReal);

    157: EXTERN PetscErrorCode  PetscDrawRectangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int,int);
    158: EXTERN PetscErrorCode  PetscDrawTriangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int);
    159: EXTERN PetscErrorCode  PetscDrawEllipse(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
    160: EXTERN PetscErrorCode  PetscDrawTensorContourPatch(PetscDraw,int,int,PetscReal*,PetscReal*,PetscReal,PetscReal,PetscReal*);
    161: EXTERN PetscErrorCode  PetscDrawTensorContour(PetscDraw,int,int,const PetscReal[],const PetscReal[],PetscReal *);

    163: EXTERN PetscErrorCode  PetscDrawString(PetscDraw,PetscReal,PetscReal,int,const char[]);
    164: EXTERN PetscErrorCode  PetscDrawStringVertical(PetscDraw,PetscReal,PetscReal,int,const char[]);
    165: EXTERN PetscErrorCode  PetscDrawStringSetSize(PetscDraw,PetscReal,PetscReal);
    166: EXTERN PetscErrorCode  PetscDrawStringGetSize(PetscDraw,PetscReal*,PetscReal*);

    168: EXTERN PetscErrorCode  PetscDrawSetViewPort(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
    169: EXTERN PetscErrorCode  PetscDrawSplitViewPort(PetscDraw);

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

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

    178: EXTERN PetscErrorCode  PetscDrawSetPause(PetscDraw,int);
    179: EXTERN PetscErrorCode  PetscDrawGetPause(PetscDraw,int*);
    180: EXTERN PetscErrorCode  PetscDrawPause(PetscDraw);
    181: EXTERN PetscErrorCode  PetscDrawSetDoubleBuffer(PetscDraw);
    182: EXTERN PetscErrorCode  PetscDrawFlush(PetscDraw);
    183: EXTERN PetscErrorCode  PetscDrawSynchronizedFlush(PetscDraw);
    184: EXTERN PetscErrorCode  PetscDrawClear(PetscDraw);
    185: EXTERN PetscErrorCode  PetscDrawSynchronizedClear(PetscDraw);
    186: EXTERN PetscErrorCode  PetscDrawBOP(PetscDraw);
    187: EXTERN PetscErrorCode  PetscDrawEOP(PetscDraw);

    189: EXTERN PetscErrorCode  PetscDrawSetDisplay(PetscDraw,char*);
    190: #define PetscDrawSetFilename(a,b) PetscDrawSetDisplay(a,b)

    192: EXTERN PetscErrorCode  PetscDrawGetSingleton(PetscDraw,PetscDraw*);
    193: EXTERN PetscErrorCode  PetscDrawRestoreSingleton(PetscDraw,PetscDraw*);

    195: /*E
    196:     PetscDrawButton - Used to determine which button was pressed

    198:    Level: intermediate

    200: .seealso: PetscDrawGetMouseButton(), PetscDrawSynchronizedGetMouseButton()
    201: E*/
    202: typedef enum {BUTTON_NONE,BUTTON_LEFT,BUTTON_CENTER,BUTTON_RIGHT,BUTTON_LEFT_SHIFT,BUTTON_CENTER_SHIFT,BUTTON_RIGHT_SHIFT} PetscDrawButton;

    204: EXTERN PetscErrorCode  PetscDrawGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);
    205: EXTERN PetscErrorCode  PetscDrawSynchronizedGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);

    207: EXTERN PetscErrorCode  PetscDrawZoom(PetscDraw,PetscErrorCode (*)(PetscDraw,void *),void *);

    209: /*S
    210:      PetscDrawViewPorts - Subwindows in a PetscDraw object

    212:    Level: intermediate

    214:   Concepts: graphics

    216: .seealso:  PetscDrawViewPortsCreate(), PetscDrawViewPortsSet()
    217: S*/
    218: typedef struct {
    219:   PetscInt  nports;
    220:   PetscReal *xl;
    221:   PetscReal *xr;
    222:   PetscReal *yl;
    223:   PetscReal *yr;
    224:   PetscDraw draw;
    225: } PetscDrawViewPorts;
    226: EXTERN PetscErrorCode  PetscDrawViewPortsCreate(PetscDraw,PetscInt,PetscDrawViewPorts**);
    227: EXTERN PetscErrorCode  PetscDrawViewPortsCreateRect(PetscDraw,PetscInt,PetscInt,PetscDrawViewPorts**);
    228: EXTERN PetscErrorCode  PetscDrawViewPortsDestroy(PetscDrawViewPorts*);
    229: EXTERN PetscErrorCode  PetscDrawViewPortsSet(PetscDrawViewPorts*,int);

    231: /*S
    232:      PetscDrawAxis - Manages X-Y axis

    234:    Level: advanced

    236:   Concepts: graphics, axis

    238: .seealso:  PetscDrawAxisCreate(), PetscDrawAxisSetLimits(), PetscDrawAxisSetColors(), PetscDrawAxisSetLabels()
    239: S*/
    240: typedef struct _p_DrawAxis* PetscDrawAxis;

    244: EXTERN PetscErrorCode  PetscDrawAxisCreate(PetscDraw,PetscDrawAxis *);
    245: EXTERN PetscErrorCode  PetscDrawAxisDestroy(PetscDrawAxis);
    246: EXTERN PetscErrorCode  PetscDrawAxisDraw(PetscDrawAxis);
    247: EXTERN PetscErrorCode  PetscDrawAxisSetLimits(PetscDrawAxis,PetscReal,PetscReal,PetscReal,PetscReal);
    248: EXTERN PetscErrorCode  PetscDrawAxisSetHoldLimits(PetscDrawAxis,PetscTruth);
    249: EXTERN PetscErrorCode  PetscDrawAxisSetColors(PetscDrawAxis,int,int,int);
    250: EXTERN PetscErrorCode  PetscDrawAxisSetLabels(PetscDrawAxis,const char[],const char[],const char[]);

    252: /*S
    253:      PetscDrawLG - Manages drawing x-y plots

    255:    Level: advanced

    257:   Concepts: graphics, axis

    259: .seealso:  PetscDrawAxisCreate(), PetscDrawLGCreate(), PetscDrawLGAddPoint()
    260: S*/
    261: typedef struct _p_DrawLG*   PetscDrawLG;

    265: EXTERN PetscErrorCode  PetscDrawLGCreate(PetscDraw,int,PetscDrawLG *);
    266: EXTERN PetscErrorCode  PetscDrawLGDestroy(PetscDrawLG);
    267: EXTERN PetscErrorCode  PetscDrawLGAddPoint(PetscDrawLG,PetscReal*,PetscReal*);
    268: EXTERN PetscErrorCode  PetscDrawLGAddPoints(PetscDrawLG,int,PetscReal**,PetscReal**);
    269: EXTERN PetscErrorCode  PetscDrawLGDraw(PetscDrawLG);
    270: EXTERN PetscErrorCode  PetscDrawLGPrint(PetscDrawLG);
    271: EXTERN PetscErrorCode  PetscDrawLGReset(PetscDrawLG);
    272: EXTERN PetscErrorCode  PetscDrawLGSetDimension(PetscDrawLG,int);
    273: EXTERN PetscErrorCode  PetscDrawLGGetAxis(PetscDrawLG,PetscDrawAxis *);
    274: EXTERN PetscErrorCode  PetscDrawLGGetDraw(PetscDrawLG,PetscDraw *);
    275: EXTERN PetscErrorCode  PetscDrawLGIndicateDataPoints(PetscDrawLG);
    276: EXTERN PetscErrorCode  PetscDrawLGSetLimits(PetscDrawLG,PetscReal,PetscReal,PetscReal,PetscReal);

    278: /*S
    279:      PetscDrawSP - Manages drawing scatter plots

    281:    Level: advanced

    283:   Concepts: graphics, scatter plots

    285: .seealso:  PetscDrawSPCreate()
    286: S*/
    287: typedef struct _p_DrawSP*   PetscDrawSP;

    291: EXTERN PetscErrorCode  PetscDrawSPCreate(PetscDraw,int,PetscDrawSP *);
    292: EXTERN PetscErrorCode  PetscDrawSPDestroy(PetscDrawSP);
    293: EXTERN PetscErrorCode  PetscDrawSPAddPoint(PetscDrawSP,PetscReal*,PetscReal*);
    294: EXTERN PetscErrorCode  PetscDrawSPAddPoints(PetscDrawSP,int,PetscReal**,PetscReal**);
    295: EXTERN PetscErrorCode  PetscDrawSPDraw(PetscDrawSP);
    296: EXTERN PetscErrorCode  PetscDrawSPReset(PetscDrawSP);
    297: EXTERN PetscErrorCode  PetscDrawSPSetDimension(PetscDrawSP,int);
    298: EXTERN PetscErrorCode  PetscDrawSPGetAxis(PetscDrawSP,PetscDrawAxis *);
    299: EXTERN PetscErrorCode  PetscDrawSPGetDraw(PetscDrawSP,PetscDraw *);
    300: EXTERN PetscErrorCode  PetscDrawSPSetLimits(PetscDrawSP,PetscReal,PetscReal,PetscReal,PetscReal);
    301: EXTERN PetscErrorCode  PetscDrawLGSPDraw(PetscDrawLG,PetscDrawSP);

    303: /*S
    304:      PetscDrawHG - Manages drawing histograms

    306:    Level: advanced

    308:   Concepts: graphics, histograms

    310: .seealso:  PetscDrawHGCreate()
    311: S*/
    312: typedef struct _p_DrawHG*   PetscDrawHG;

    316: EXTERN PetscErrorCode  PetscDrawHGCreate(PetscDraw,int,PetscDrawHG *);
    317: EXTERN PetscErrorCode  PetscDrawHGDestroy(PetscDrawHG);
    318: EXTERN PetscErrorCode  PetscDrawHGAddValue(PetscDrawHG,PetscReal);
    319: EXTERN PetscErrorCode  PetscDrawHGDraw(PetscDrawHG);
    320: EXTERN PetscErrorCode  PetscDrawHGPrint(PetscDrawHG);
    321: EXTERN PetscErrorCode  PetscDrawHGReset(PetscDrawHG);
    322: EXTERN PetscErrorCode  PetscDrawHGGetAxis(PetscDrawHG,PetscDrawAxis *);
    323: EXTERN PetscErrorCode  PetscDrawHGGetDraw(PetscDrawHG,PetscDraw *);
    324: EXTERN PetscErrorCode  PetscDrawHGSetLimits(PetscDrawHG,PetscReal,PetscReal,int,int);
    325: EXTERN PetscErrorCode  PetscDrawHGSetNumberBins(PetscDrawHG,int);
    326: EXTERN PetscErrorCode  PetscDrawHGSetColor(PetscDrawHG,int);
    327: EXTERN PetscErrorCode  PetscDrawHGCalcStats(PetscDrawHG, PetscTruth);
    328: EXTERN PetscErrorCode  PetscDrawHGIntegerBins(PetscDrawHG, PetscTruth);

    330: /*
    331:     PetscViewer routines that allow you to access underlying PetscDraw objects
    332: */
    333: EXTERN PetscErrorCode  PetscViewerDrawGetDraw(PetscViewer,PetscInt,PetscDraw*);
    334: EXTERN PetscErrorCode  PetscViewerDrawBaseAdd(PetscViewer,PetscInt);
    335: EXTERN PetscErrorCode  PetscViewerDrawBaseSet(PetscViewer,PetscInt);
    336: EXTERN PetscErrorCode  PetscViewerDrawGetDrawLG(PetscViewer,PetscInt,PetscDrawLG*);
    337: EXTERN PetscErrorCode  PetscViewerDrawGetDrawAxis(PetscViewer,PetscInt,PetscDrawAxis*);

    339: EXTERN PetscErrorCode  PetscDrawUtilitySetCmapHue(unsigned char *,unsigned char *,unsigned char *,int);
    340: EXTERN PetscErrorCode  PetscDrawUtilitySetGamma(PetscReal);

    343: #endif