Actual source code: petscdraw.h

petsc-3.4.5 2014-06-29
  1: /*
  2:   Interface to the PETSc graphics (currently only support for X-windows
  3: */
  6: #include <petscsys.h>
  7: #include <petscdrawtypes.h>

  9: PETSC_EXTERN PetscClassId PETSC_DRAW_CLASSID;

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

 14:    Level: beginner

 16: .seealso: PetscDrawSetType(), PetscDraw, PetscViewer, PetscDrawCreate()
 17: J*/
 18: typedef const char* PetscDrawType;
 19: #define PETSC_DRAW_X          "x"
 20: #define PETSC_DRAW_GLUT       "glut"
 21: #define PETSC_DRAW_OPENGLES   "opengles"
 22: #define PETSC_DRAW_NULL       "null"
 23: #define PETSC_DRAW_WIN32      "win32"
 24: #define PETSC_DRAW_TIKZ       "tikz"

 26: PETSC_EXTERN PetscFunctionList PetscDrawList;
 27: PETSC_EXTERN PetscErrorCode PetscDrawRegisterAll(void);
 28: PETSC_EXTERN PetscErrorCode PetscDrawInitializePackage(void);
 29: PETSC_EXTERN PetscErrorCode PetscDrawRegister(const char[],PetscErrorCode(*)(PetscDraw));

 31: PETSC_EXTERN PetscErrorCode PetscDrawGetType(PetscDraw,PetscDrawType*);
 32: PETSC_EXTERN PetscErrorCode PetscDrawSetType(PetscDraw,PetscDrawType);
 33: PETSC_EXTERN PetscErrorCode PetscDrawCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
 34: PETSC_EXTERN PetscErrorCode PetscDrawSetFromOptions(PetscDraw);
 35: PETSC_EXTERN PetscErrorCode PetscDrawSetSave(PetscDraw,const char*,PetscBool);

 37: /*
 38:    Number of basic colors in the draw routines, the others are used
 39:    for a uniform colormap.
 40: */
 41: #define PETSC_DRAW_BASIC_COLORS 33

 43: #define PETSC_DRAW_ROTATE          -1         /* will rotate through the colors, start with 2 */
 44: #define PETSC_DRAW_WHITE            0
 45: #define PETSC_DRAW_BLACK            1
 46: #define PETSC_DRAW_RED              2
 47: #define PETSC_DRAW_GREEN            3
 48: #define PETSC_DRAW_CYAN             4
 49: #define PETSC_DRAW_BLUE             5
 50: #define PETSC_DRAW_MAGENTA          6
 51: #define PETSC_DRAW_AQUAMARINE       7
 52: #define PETSC_DRAW_FORESTGREEN      8
 53: #define PETSC_DRAW_ORANGE           9
 54: #define PETSC_DRAW_VIOLET          10
 55: #define PETSC_DRAW_BROWN           11
 56: #define PETSC_DRAW_PINK            12
 57: #define PETSC_DRAW_CORAL           13
 58: #define PETSC_DRAW_GRAY            14
 59: #define PETSC_DRAW_YELLOW          15

 61: #define PETSC_DRAW_GOLD            16
 62: #define PETSC_DRAW_LIGHTPINK       17
 63: #define PETSC_DRAW_MEDIUMTURQUOISE 18
 64: #define PETSC_DRAW_KHAKI           19
 65: #define PETSC_DRAW_DIMGRAY         20
 66: #define PETSC_DRAW_YELLOWGREEN     21
 67: #define PETSC_DRAW_SKYBLUE         22
 68: #define PETSC_DRAW_DARKGREEN       23
 69: #define PETSC_DRAW_NAVYBLUE        24
 70: #define PETSC_DRAW_SANDYBROWN      25
 71: #define PETSC_DRAW_CADETBLUE       26
 72: #define PETSC_DRAW_POWDERBLUE      27
 73: #define PETSC_DRAW_DEEPPINK        28
 74: #define PETSC_DRAW_THISTLE         29
 75: #define PETSC_DRAW_LIMEGREEN       30
 76: #define PETSC_DRAW_LAVENDERBLUSH   31
 77: #define PETSC_DRAW_PLUM            32

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

 82: #define PETSC_DRAW_FULL_SIZE    -3
 83: #define PETSC_DRAW_HALF_SIZE    -4
 84: #define PETSC_DRAW_THIRD_SIZE   -5
 85: #define PETSC_DRAW_QUARTER_SIZE -6

 87: PETSC_EXTERN PetscErrorCode PetscDrawOpenNull(MPI_Comm,PetscDraw *);
 88: PETSC_EXTERN PetscErrorCode PetscDrawDestroy(PetscDraw*);
 89: PETSC_EXTERN PetscErrorCode PetscDrawIsNull(PetscDraw,PetscBool *);

 91: PETSC_EXTERN PetscErrorCode PetscDrawGetPopup(PetscDraw,PetscDraw*);
 92: PETSC_EXTERN PetscErrorCode PetscDrawCheckResizedWindow(PetscDraw);
 93: PETSC_EXTERN PetscErrorCode PetscDrawResizeWindow(PetscDraw,int,int);

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

 97: PETSC_EXTERN PetscErrorCode PetscDrawPixelToCoordinate(PetscDraw,PetscInt,PetscInt,PetscReal*,PetscReal*);
 98: PETSC_EXTERN PetscErrorCode PetscDrawCoordinateToPixel(PetscDraw,PetscReal,PetscReal,PetscInt*,PetscInt*);

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

102: PETSC_EXTERN PetscErrorCode PetscDrawLine(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
103: PETSC_EXTERN PetscErrorCode PetscDrawArrow(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
104: PETSC_EXTERN PetscErrorCode PetscDrawLineSetWidth(PetscDraw,PetscReal);
105: PETSC_EXTERN PetscErrorCode PetscDrawLineGetWidth(PetscDraw,PetscReal*);

107: PETSC_EXTERN PetscErrorCode PetscDrawPoint(PetscDraw,PetscReal,PetscReal,int);
108: PETSC_EXTERN PetscErrorCode PetscDrawPointPixel(PetscDraw,PetscInt,PetscInt,int);
109: PETSC_EXTERN PetscErrorCode PetscDrawPointSetSize(PetscDraw,PetscReal);

111: PETSC_EXTERN PetscErrorCode PetscDrawRectangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int,int);
112: PETSC_EXTERN PetscErrorCode PetscDrawTriangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int);
113: PETSC_EXTERN PetscErrorCode PetscDrawEllipse(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
114: PETSC_EXTERN PetscErrorCode PetscDrawTensorContourPatch(PetscDraw,int,int,PetscReal*,PetscReal*,PetscReal,PetscReal,PetscReal*);
115: PETSC_EXTERN PetscErrorCode PetscDrawTensorContour(PetscDraw,int,int,const PetscReal[],const PetscReal[],PetscReal *);

117: PETSC_EXTERN PetscErrorCode PetscDrawString(PetscDraw,PetscReal,PetscReal,int,const char[]);
118: PETSC_EXTERN PetscErrorCode PetscDrawBoxedString(PetscDraw,PetscReal,PetscReal,int,int,const char[],PetscReal*,PetscReal*);
119: PETSC_EXTERN PetscErrorCode PetscDrawBoxedStringSize(PetscDraw,const char[],PetscReal*,PetscReal*);
120: PETSC_EXTERN PetscErrorCode PetscDrawStringVertical(PetscDraw,PetscReal,PetscReal,int,const char[]);
121: PETSC_EXTERN PetscErrorCode PetscDrawStringSetSize(PetscDraw,PetscReal,PetscReal);
122: PETSC_EXTERN PetscErrorCode PetscDrawStringGetSize(PetscDraw,PetscReal*,PetscReal*);

124: PETSC_EXTERN PetscErrorCode PetscDrawSetViewPort(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
125: PETSC_EXTERN PetscErrorCode PetscDrawGetViewPort(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
126: PETSC_EXTERN PetscErrorCode PetscDrawSplitViewPort(PetscDraw);

128: PETSC_EXTERN PetscErrorCode PetscDrawSetCoordinates(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
129: PETSC_EXTERN PetscErrorCode PetscDrawGetCoordinates(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);

131: PETSC_EXTERN PetscErrorCode PetscDrawSetTitle(PetscDraw,const char[]);
132: PETSC_EXTERN PetscErrorCode PetscDrawAppendTitle(PetscDraw,const char[]);
133: PETSC_EXTERN PetscErrorCode PetscDrawGetTitle(PetscDraw,char **);

135: PETSC_EXTERN PetscErrorCode PetscDrawSetPause(PetscDraw,PetscReal);
136: PETSC_EXTERN PetscErrorCode PetscDrawGetPause(PetscDraw,PetscReal*);
137: PETSC_EXTERN PetscErrorCode PetscDrawPause(PetscDraw);
138: PETSC_EXTERN PetscErrorCode PetscDrawSetDoubleBuffer(PetscDraw);
139: PETSC_EXTERN PetscErrorCode PetscDrawFlush(PetscDraw);
140: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedFlush(PetscDraw);
141: PETSC_EXTERN PetscErrorCode PetscDrawClear(PetscDraw);
142: PETSC_EXTERN PetscErrorCode PetscDrawSave(PetscDraw);
143: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedClear(PetscDraw);
144: PETSC_EXTERN PetscErrorCode PetscDrawBOP(PetscDraw);
145: PETSC_EXTERN PetscErrorCode PetscDrawEOP(PetscDraw);

147: PETSC_EXTERN PetscErrorCode PetscDrawSetDisplay(PetscDraw,const char[]);
148: PETSC_EXTERN PetscErrorCode PetscDrawGetSingleton(PetscDraw,PetscDraw*);
149: PETSC_EXTERN PetscErrorCode PetscDrawRestoreSingleton(PetscDraw,PetscDraw*);

151: PETSC_EXTERN PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw,PetscReal*,PetscReal*);
152: PETSC_EXTERN PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw,PetscReal,PetscReal);
153: PETSC_EXTERN PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw,PetscReal,PetscReal);
154: PETSC_EXTERN PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw);
155: PETSC_EXTERN PetscErrorCode PetscDrawGetBoundingBox(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);

157: /*E
158:     PetscDrawButton - Used to determine which button was pressed

160:    Level: intermediate

162: .seealso: PetscDrawGetMouseButton(), PetscDrawSynchronizedGetMouseButton()
163: E*/
164: 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;

166: PETSC_EXTERN PetscErrorCode PetscDrawGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);
167: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);

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

171: /*S
172:      PetscDrawViewPorts - Subwindows in a PetscDraw object

174:    Level: intermediate

176:   Concepts: graphics

178: .seealso:  PetscDrawViewPortsCreate(), PetscDrawViewPortsSet()
179: S*/
180: typedef struct {
181:   PetscInt  nports;
182:   PetscReal *xl;
183:   PetscReal *xr;
184:   PetscReal *yl;
185:   PetscReal *yr;
186:   PetscDraw draw;
187:   PetscReal port_xl,port_yl,port_xr,port_yr;   /* original port of parent PetscDraw */

189: } PetscDrawViewPorts;
190: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreate(PetscDraw,PetscInt,PetscDrawViewPorts**);
191: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreateRect(PetscDraw,PetscInt,PetscInt,PetscDrawViewPorts**);
192: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsDestroy(PetscDrawViewPorts*);
193: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsSet(PetscDrawViewPorts*,PetscInt);

195: PETSC_EXTERN PetscClassId PETSC_DRAWAXIS_CLASSID;

197: PETSC_EXTERN PetscErrorCode PetscDrawAxisCreate(PetscDraw,PetscDrawAxis *);
198: PETSC_EXTERN PetscErrorCode PetscDrawAxisDestroy(PetscDrawAxis*);
199: PETSC_EXTERN PetscErrorCode PetscDrawAxisDraw(PetscDrawAxis);
200: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLimits(PetscDrawAxis,PetscReal,PetscReal,PetscReal,PetscReal);
201: PETSC_EXTERN PetscErrorCode PetscDrawAxisGetLimits(PetscDrawAxis,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
202: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetHoldLimits(PetscDrawAxis,PetscBool );
203: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetColors(PetscDrawAxis,int,int,int);
204: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLabels(PetscDrawAxis,const char[],const char[],const char[]);

206: PETSC_EXTERN PetscClassId PETSC_DRAWLG_CLASSID;

208: PETSC_EXTERN PetscErrorCode PetscDrawLGCreate(PetscDraw,PetscInt,PetscDrawLG *);
209: PETSC_EXTERN PetscErrorCode PetscDrawLGDestroy(PetscDrawLG*);
210: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoint(PetscDrawLG,const PetscReal*,const PetscReal*);
211: PETSC_EXTERN PetscErrorCode PetscDrawLGAddCommonPoint(PetscDrawLG,const PetscReal,const PetscReal*);
212: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoints(PetscDrawLG,PetscInt,PetscReal**,PetscReal**);
213: PETSC_EXTERN PetscErrorCode PetscDrawLGDraw(PetscDrawLG);
214: PETSC_EXTERN PetscErrorCode PetscDrawLGView(PetscDrawLG,PetscViewer);
215: PETSC_EXTERN PetscErrorCode PetscDrawLGReset(PetscDrawLG);
216: PETSC_EXTERN PetscErrorCode PetscDrawLGSetDimension(PetscDrawLG,PetscInt);
217: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDimension(PetscDrawLG,PetscInt*);
218: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLegend(PetscDrawLG,const char *const*);
219: PETSC_EXTERN PetscErrorCode PetscDrawLGGetAxis(PetscDrawLG,PetscDrawAxis *);
220: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDraw(PetscDrawLG,PetscDraw *);
221: PETSC_EXTERN PetscErrorCode PetscDrawLGIndicateDataPoints(PetscDrawLG);
222: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLimits(PetscDrawLG,PetscReal,PetscReal,PetscReal,PetscReal);
223: PETSC_EXTERN PetscErrorCode PetscDrawLGSetColors(PetscDrawLG,const int*);

225: PETSC_EXTERN PetscClassId PETSC_DRAWSP_CLASSID;

227: PETSC_EXTERN PetscErrorCode PetscDrawSPCreate(PetscDraw,int,PetscDrawSP *);
228: PETSC_EXTERN PetscErrorCode PetscDrawSPDestroy(PetscDrawSP*);
229: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoint(PetscDrawSP,PetscReal*,PetscReal*);
230: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoints(PetscDrawSP,int,PetscReal**,PetscReal**);
231: PETSC_EXTERN PetscErrorCode PetscDrawSPDraw(PetscDrawSP,PetscBool);
232: PETSC_EXTERN PetscErrorCode PetscDrawSPReset(PetscDrawSP);
233: PETSC_EXTERN PetscErrorCode PetscDrawSPSetDimension(PetscDrawSP,int);
234: PETSC_EXTERN PetscErrorCode PetscDrawSPGetAxis(PetscDrawSP,PetscDrawAxis *);
235: PETSC_EXTERN PetscErrorCode PetscDrawSPGetDraw(PetscDrawSP,PetscDraw *);
236: PETSC_EXTERN PetscErrorCode PetscDrawSPSetLimits(PetscDrawSP,PetscReal,PetscReal,PetscReal,PetscReal);
237: PETSC_EXTERN PetscErrorCode PetscDrawLGSPDraw(PetscDrawLG,PetscDrawSP);

239: PETSC_EXTERN PetscClassId PETSC_DRAWHG_CLASSID;

241: PETSC_EXTERN PetscErrorCode PetscDrawHGCreate(PetscDraw,int,PetscDrawHG *);
242: PETSC_EXTERN PetscErrorCode PetscDrawHGDestroy(PetscDrawHG*);
243: PETSC_EXTERN PetscErrorCode PetscDrawHGAddValue(PetscDrawHG,PetscReal);
244: PETSC_EXTERN PetscErrorCode PetscDrawHGDraw(PetscDrawHG);
245: PETSC_EXTERN PetscErrorCode PetscDrawHGView(PetscDrawHG,PetscViewer);
246: PETSC_EXTERN PetscErrorCode PetscDrawHGReset(PetscDrawHG);
247: PETSC_EXTERN PetscErrorCode PetscDrawHGGetAxis(PetscDrawHG,PetscDrawAxis *);
248: PETSC_EXTERN PetscErrorCode PetscDrawHGGetDraw(PetscDrawHG,PetscDraw *);
249: PETSC_EXTERN PetscErrorCode PetscDrawHGSetLimits(PetscDrawHG,PetscReal,PetscReal,int,int);
250: PETSC_EXTERN PetscErrorCode PetscDrawHGSetNumberBins(PetscDrawHG,int);
251: PETSC_EXTERN PetscErrorCode PetscDrawHGSetColor(PetscDrawHG,int);
252: PETSC_EXTERN PetscErrorCode PetscDrawHGCalcStats(PetscDrawHG, PetscBool );
253: PETSC_EXTERN PetscErrorCode PetscDrawHGIntegerBins(PetscDrawHG, PetscBool );

255: /*
256:     PetscViewer routines that allow you to access underlying PetscDraw objects
257: */
258: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDraw(PetscViewer,PetscInt,PetscDraw*);
259: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseAdd(PetscViewer,PetscInt);
260: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseSet(PetscViewer,PetscInt);
261: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawLG(PetscViewer,PetscInt,PetscDrawLG*);
262: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawAxis(PetscViewer,PetscInt,PetscDrawAxis*);

264: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetCmapHue(unsigned char *,unsigned char *,unsigned char *,int);
265: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetGamma(PetscReal);

267: #endif