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 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 PetscDrawRegisterDestroy(void);

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

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

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

     47:    Not Collective

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

     55:    Level: developer

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

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

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

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

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

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

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

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

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

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

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

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

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

    147: EXTERN PetscErrorCode PetscDrawScalePopup(PetscDraw,PetscReal min,PetscReal max);

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

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

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

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

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

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

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

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

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

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

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

    197:    Level: intermediate

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

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

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

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

    211:    Level: intermediate

    213:   Concepts: graphics

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

    226: /*S
    227:      PetscDrawAxis - Manages X-Y axis

    229:    Level: advanced

    231:   Concepts: graphics, axis

    233: .seealso:  PetscDrawAxisCreate(), PetscDrawAxisSetLimits(), PetscDrawAxisSetColors(), PetscDrawAxisSetLabels()
    234: S*/
    235: typedef struct _p_DrawAxis* PetscDrawAxis;

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

    247: /*S
    248:      PetscDrawLG - Manages drawing x-y plots

    250:    Level: advanced

    252:   Concepts: graphics, axis

    254: .seealso:  PetscDrawAxisCreate(), PetscDrawLGCreate(), PetscDrawLGAddPoint()
    255: S*/
    256: typedef struct _p_DrawLG*   PetscDrawLG;

    260: EXTERN PetscErrorCode PetscDrawLGCreate(PetscDraw,int,PetscDrawLG *);
    261: EXTERN PetscErrorCode PetscDrawLGDestroy(PetscDrawLG);
    262: EXTERN PetscErrorCode PetscDrawLGAddPoint(PetscDrawLG,PetscReal*,PetscReal*);
    263: EXTERN PetscErrorCode PetscDrawLGAddPoints(PetscDrawLG,int,PetscReal**,PetscReal**);
    264: EXTERN PetscErrorCode PetscDrawLGDraw(PetscDrawLG);
    265: EXTERN PetscErrorCode PetscDrawLGPrint(PetscDrawLG);
    266: EXTERN PetscErrorCode PetscDrawLGReset(PetscDrawLG);
    267: EXTERN PetscErrorCode PetscDrawLGSetDimension(PetscDrawLG,int);
    268: EXTERN PetscErrorCode PetscDrawLGGetAxis(PetscDrawLG,PetscDrawAxis *);
    269: EXTERN PetscErrorCode PetscDrawLGGetDraw(PetscDrawLG,PetscDraw *);
    270: EXTERN PetscErrorCode PetscDrawLGIndicateDataPoints(PetscDrawLG);
    271: EXTERN PetscErrorCode PetscDrawLGSetLimits(PetscDrawLG,PetscReal,PetscReal,PetscReal,PetscReal);

    273: /*S
    274:      PetscDrawSP - Manages drawing scatter plots

    276:    Level: advanced

    278:   Concepts: graphics, scatter plots

    280: .seealso:  PetscDrawSPCreate()
    281: S*/
    282: typedef struct _p_DrawSP*   PetscDrawSP;

    286: EXTERN PetscErrorCode PetscDrawSPCreate(PetscDraw,int,PetscDrawSP *);
    287: EXTERN PetscErrorCode PetscDrawSPDestroy(PetscDrawSP);
    288: EXTERN PetscErrorCode PetscDrawSPAddPoint(PetscDrawSP,PetscReal*,PetscReal*);
    289: EXTERN PetscErrorCode PetscDrawSPAddPoints(PetscDrawSP,int,PetscReal**,PetscReal**);
    290: EXTERN PetscErrorCode PetscDrawSPDraw(PetscDrawSP);
    291: EXTERN PetscErrorCode PetscDrawSPReset(PetscDrawSP);
    292: EXTERN PetscErrorCode PetscDrawSPSetDimension(PetscDrawSP,int);
    293: EXTERN PetscErrorCode PetscDrawSPGetAxis(PetscDrawSP,PetscDrawAxis *);
    294: EXTERN PetscErrorCode PetscDrawSPGetDraw(PetscDrawSP,PetscDraw *);
    295: EXTERN PetscErrorCode PetscDrawSPSetLimits(PetscDrawSP,PetscReal,PetscReal,PetscReal,PetscReal);
    296: EXTERN PetscErrorCode PetscDrawLGSPDraw(PetscDrawLG,PetscDrawSP);

    298: /*S
    299:      PetscDrawHG - Manages drawing histograms

    301:    Level: advanced

    303:   Concepts: graphics, histograms

    305: .seealso:  PetscDrawHGCreate()
    306: S*/
    307: typedef struct _p_DrawHG*   PetscDrawHG;

    311: EXTERN PetscErrorCode PetscDrawHGCreate(PetscDraw,int,PetscDrawHG *);
    312: EXTERN PetscErrorCode PetscDrawHGDestroy(PetscDrawHG);
    313: EXTERN PetscErrorCode PetscDrawHGAddValue(PetscDrawHG,PetscReal);
    314: EXTERN PetscErrorCode PetscDrawHGDraw(PetscDrawHG);
    315: EXTERN PetscErrorCode PetscDrawHGPrint(PetscDrawHG);
    316: EXTERN PetscErrorCode PetscDrawHGReset(PetscDrawHG);
    317: EXTERN PetscErrorCode PetscDrawHGGetAxis(PetscDrawHG,PetscDrawAxis *);
    318: EXTERN PetscErrorCode PetscDrawHGGetDraw(PetscDrawHG,PetscDraw *);
    319: EXTERN PetscErrorCode PetscDrawHGSetLimits(PetscDrawHG,PetscReal,PetscReal,int,int);
    320: EXTERN PetscErrorCode PetscDrawHGSetNumberBins(PetscDrawHG,int);
    321: EXTERN PetscErrorCode PetscDrawHGSetColor(PetscDrawHG,int);
    322: EXTERN PetscErrorCode PetscDrawHGCalcStats(PetscDrawHG, PetscTruth);
    323: EXTERN PetscErrorCode PetscDrawHGIntegerBins(PetscDrawHG, PetscTruth);

    325: /*
    326:     PetscViewer routines that allow you to access underlying PetscDraw objects
    327: */
    328: EXTERN PetscErrorCode PetscViewerDrawGetDraw(PetscViewer,int,PetscDraw*);
    329: EXTERN PetscErrorCode PetscViewerDrawGetDrawLG(PetscViewer,int,PetscDrawLG*);
    330: EXTERN PetscErrorCode PetscViewerDrawGetDrawAxis(PetscViewer,int,PetscDrawAxis*);

    332: EXTERN PetscErrorCode PetscDrawUtilitySetCmapHue(unsigned char *,unsigned char *,unsigned char *,int);
    333: EXTERN PetscErrorCode PetscDrawUtilitySetGamma(PetscReal);

    335: /* Mesh management routines */
    336: typedef struct _p_DrawMesh* PetscDrawMesh;
    337: PetscErrorCode PetscDrawMeshCreate(PetscDrawMesh *,PetscReal *,PetscReal *,PetscReal *,
    338:                         int,int,int,int,int,int,int,int,int,int,int,int,int,PetscReal *,int);
    339: PetscErrorCode PetscDrawMeshCreateSimple(PetscDrawMesh *,PetscReal *,PetscReal *,PetscReal *,int,int,int,int,PetscReal *,int);
    340: PetscErrorCode PetscDrawMeshDestroy(PetscDrawMesh *);

    343: #endif