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 PETSC_DLLEXPORT PetscDrawRegisterAll(const char *);
     37: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawRegisterDestroy(void);

     39: EXTERN PetscErrorCode PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscDrawGetType(PetscDraw,PetscDrawType*);
     86: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSetType(PetscDraw,const PetscDrawType);
     87: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
     88: EXTERN PetscErrorCode PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscDrawOpenX(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
    133: EXTERN PetscErrorCode PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscDrawOpenNull(MPI_Comm,PetscDraw *);
    140: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawDestroy(PetscDraw);
    141: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawIsNull(PetscDraw,PetscTruth*);

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

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

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

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

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

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

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

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

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

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

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

    191: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawGetSingleton(PetscDraw,PetscDraw*);
    192: EXTERN PetscErrorCode PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscDrawGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);
    204: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSynchronizedGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);

    206: EXTERN PetscErrorCode PETSC_DLLEXPORT 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:   PetscInt  nports;
    219:   PetscReal *xl,*xr,*yl,*yr;
    220:   PetscDraw draw;
    221: } PetscDrawViewPorts;
    222: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawViewPortsCreate(PetscDraw,int,PetscDrawViewPorts**);
    223: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawViewPortsDestroy(PetscDrawViewPorts*);
    224: EXTERN PetscErrorCode PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscDrawAxisCreate(PetscDraw,PetscDrawAxis *);
    240: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawAxisDestroy(PetscDrawAxis);
    241: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawAxisDraw(PetscDrawAxis);
    242: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawAxisSetLimits(PetscDrawAxis,PetscReal,PetscReal,PetscReal,PetscReal);
    243: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawAxisSetHoldLimits(PetscDrawAxis,PetscTruth);
    244: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawAxisSetColors(PetscDrawAxis,int,int,int);
    245: EXTERN PetscErrorCode PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscDrawLGCreate(PetscDraw,int,PetscDrawLG *);
    261: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGDestroy(PetscDrawLG);
    262: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGAddPoint(PetscDrawLG,PetscReal*,PetscReal*);
    263: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGAddPoints(PetscDrawLG,int,PetscReal**,PetscReal**);
    264: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGDraw(PetscDrawLG);
    265: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGPrint(PetscDrawLG);
    266: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGReset(PetscDrawLG);
    267: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGSetDimension(PetscDrawLG,int);
    268: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGGetAxis(PetscDrawLG,PetscDrawAxis *);
    269: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGGetDraw(PetscDrawLG,PetscDraw *);
    270: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawLGIndicateDataPoints(PetscDrawLG);
    271: EXTERN PetscErrorCode PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscDrawSPCreate(PetscDraw,int,PetscDrawSP *);
    287: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPDestroy(PetscDrawSP);
    288: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPAddPoint(PetscDrawSP,PetscReal*,PetscReal*);
    289: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPAddPoints(PetscDrawSP,int,PetscReal**,PetscReal**);
    290: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPDraw(PetscDrawSP);
    291: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPReset(PetscDrawSP);
    292: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPSetDimension(PetscDrawSP,int);
    293: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPGetAxis(PetscDrawSP,PetscDrawAxis *);
    294: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPGetDraw(PetscDrawSP,PetscDraw *);
    295: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawSPSetLimits(PetscDrawSP,PetscReal,PetscReal,PetscReal,PetscReal);
    296: EXTERN PetscErrorCode PETSC_DLLEXPORT 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 PETSC_DLLEXPORT PetscDrawHGCreate(PetscDraw,int,PetscDrawHG *);
    312: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGDestroy(PetscDrawHG);
    313: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGAddValue(PetscDrawHG,PetscReal);
    314: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGDraw(PetscDrawHG);
    315: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGPrint(PetscDrawHG);
    316: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGReset(PetscDrawHG);
    317: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGGetAxis(PetscDrawHG,PetscDrawAxis *);
    318: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGGetDraw(PetscDrawHG,PetscDraw *);
    319: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGSetLimits(PetscDrawHG,PetscReal,PetscReal,int,int);
    320: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGSetNumberBins(PetscDrawHG,int);
    321: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGSetColor(PetscDrawHG,int);
    322: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGCalcStats(PetscDrawHG, PetscTruth);
    323: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscDrawHGIntegerBins(PetscDrawHG, PetscTruth);

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

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

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

    343: #endif