Actual source code: petscdraw.h

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

  8: PETSC_EXTERN PetscClassId PETSC_DRAW_CLASSID;

 10: /*J
 11:     PetscDrawType - String with the name of a PetscDraw 

 13:    Level: beginner

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

 25:    Level: beginner

 27:   Concepts: graphics

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

 33: PETSC_EXTERN PetscFList PetscDrawList;
 34: PETSC_EXTERN PetscErrorCode PetscDrawRegisterAll(const char[]);
 35: PETSC_EXTERN PetscErrorCode PetscDrawInitializePackage(const char[]);
 36: PETSC_EXTERN PetscErrorCode PetscDrawRegisterDestroy(void);

 38: PETSC_EXTERN PetscErrorCode PetscDrawRegister(const char*,const char*,const char*,PetscErrorCode(*)(PetscDraw));

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

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

 46:    Not Collective

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

 54:    Level: developer

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

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

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

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

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

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

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

 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: PETSC_EXTERN PetscErrorCode PetscDrawOpenX(MPI_Comm,const char[],const char[],int,int,int,int,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: PETSC_EXTERN PetscErrorCode PetscDrawOpenNull(MPI_Comm,PetscDraw *);
140: PETSC_EXTERN PetscErrorCode PetscDrawDestroy(PetscDraw*);
141: PETSC_EXTERN PetscErrorCode PetscDrawIsNull(PetscDraw,PetscBool *);

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

147: PETSC_EXTERN PetscErrorCode PetscDrawScalePopup(PetscDraw,PetscReal,PetscReal);

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

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

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

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

168: PETSC_EXTERN PetscErrorCode PetscDrawSetViewPort(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,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 PetscDrawFlush(PetscDraw);
183: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedFlush(PetscDraw);
184: PETSC_EXTERN PetscErrorCode PetscDrawClear(PetscDraw);
185: PETSC_EXTERN PetscErrorCode PetscDrawSave(PetscDraw);
186: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedClear(PetscDraw);
187: PETSC_EXTERN PetscErrorCode PetscDrawBOP(PetscDraw);
188: PETSC_EXTERN PetscErrorCode PetscDrawEOP(PetscDraw);

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

193: PETSC_EXTERN PetscErrorCode PetscDrawGetSingleton(PetscDraw,PetscDraw*);
194: PETSC_EXTERN PetscErrorCode PetscDrawRestoreSingleton(PetscDraw,PetscDraw*);

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

199:    Level: intermediate

201: .seealso: PetscDrawGetMouseButton(), PetscDrawSynchronizedGetMouseButton()
202: E*/
203: typedef enum {PETSC_BUTTON_NONE,PETSC_BUTTON_LEFT,PETSC_BUTTON_CENTER,PETSC_BUTTON_RIGHT,PETSC_BUTTON_LEFT_SHIFT,PETSC_BUTTON_CENTER_SHIFT,PETSC_BUTTON_RIGHT_SHIFT} PetscDrawButton;

205: PETSC_EXTERN PetscErrorCode PetscDrawGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);
206: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);

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

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

213:    Level: intermediate

215:   Concepts: graphics

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

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

235:    Level: advanced

237:   Concepts: graphics, axis

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

243: PETSC_EXTERN PetscClassId PETSC_DRAWAXIS_CLASSID;

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

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

256:    Level: advanced

258:   Concepts: graphics, axis

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

264: PETSC_EXTERN PetscClassId PETSC_DRAWLG_CLASSID;

266: PETSC_EXTERN PetscErrorCode PetscDrawLGCreate(PetscDraw,int,PetscDrawLG *);
267: PETSC_EXTERN PetscErrorCode PetscDrawLGDestroy(PetscDrawLG*);
268: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoint(PetscDrawLG,PetscReal*,PetscReal*);
269: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoints(PetscDrawLG,int,PetscReal**,PetscReal**);
270: PETSC_EXTERN PetscErrorCode PetscDrawLGDraw(PetscDrawLG);
271: PETSC_EXTERN PetscErrorCode PetscDrawLGPrint(PetscDrawLG);
272: PETSC_EXTERN PetscErrorCode PetscDrawLGReset(PetscDrawLG);
273: PETSC_EXTERN PetscErrorCode PetscDrawLGSetDimension(PetscDrawLG,PetscInt);
274: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLegend(PetscDrawLG,const char *const*);
275: PETSC_EXTERN PetscErrorCode PetscDrawLGGetAxis(PetscDrawLG,PetscDrawAxis *);
276: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDraw(PetscDrawLG,PetscDraw *);
277: PETSC_EXTERN PetscErrorCode PetscDrawLGIndicateDataPoints(PetscDrawLG);
278: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLimits(PetscDrawLG,PetscReal,PetscReal,PetscReal,PetscReal);
279: PETSC_EXTERN PetscErrorCode PetscDrawLGSetColors(PetscDrawLG,const int*);

281: /*S
282:      PetscDrawSP - Manages drawing scatter plots

284:    Level: advanced

286:   Concepts: graphics, scatter plots

288: .seealso:  PetscDrawSPCreate()
289: S*/
290: typedef struct _p_PetscDrawSP*   PetscDrawSP;

292: PETSC_EXTERN PetscClassId PETSC_DRAWSP_CLASSID;

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

306: /*S
307:      PetscDrawHG - Manages drawing histograms

309:    Level: advanced

311:   Concepts: graphics, histograms

313: .seealso:  PetscDrawHGCreate()
314: S*/
315: typedef struct _p_PetscDrawHG*   PetscDrawHG;

317: PETSC_EXTERN PetscClassId PETSC_DRAWHG_CLASSID;

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

333: /*
334:     PetscViewer routines that allow you to access underlying PetscDraw objects
335: */
336: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDraw(PetscViewer,PetscInt,PetscDraw*);
337: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseAdd(PetscViewer,PetscInt);
338: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseSet(PetscViewer,PetscInt);
339: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawLG(PetscViewer,PetscInt,PetscDrawLG*);
340: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawAxis(PetscViewer,PetscInt,PetscDrawAxis*);

342: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetCmapHue(unsigned char *,unsigned char *,unsigned char *,int);
343: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetGamma(PetscReal);

345: #endif