Actual source code: petscdraw.h

petsc-3.5.4 2015-05-23
Report Typos and Errors
  1: /*
  2:   Interface to the PETSc graphics
  3: */
  6: #include <petscsys.h>
  7: #include <petscdrawtypes.h>

  9: PETSC_EXTERN PetscClassId PETSC_DRAW_CLASSID;

 11: PETSC_EXTERN PetscFunctionList PetscDrawList;
 12: PETSC_EXTERN PetscErrorCode PetscDrawRegisterAll(void);
 13: PETSC_EXTERN PetscErrorCode PetscDrawInitializePackage(void);
 14: PETSC_EXTERN PetscErrorCode PetscDrawRegister(const char[],PetscErrorCode(*)(PetscDraw));

 16: PETSC_EXTERN PetscErrorCode PetscDrawGetType(PetscDraw,PetscDrawType*);
 17: PETSC_EXTERN PetscErrorCode PetscDrawSetType(PetscDraw,PetscDrawType);
 18: PETSC_EXTERN PetscErrorCode PetscDrawCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDraw*);
 19: PETSC_EXTERN PetscErrorCode PetscDrawSetFromOptions(PetscDraw);
 20: PETSC_EXTERN PetscErrorCode PetscDrawSetSave(PetscDraw,const char*,PetscBool);
 21: PETSC_EXTERN PetscErrorCode PetscDrawSetSaveFinalImage(PetscDraw,const char*);
 22: PETSC_EXTERN PetscErrorCode PetscDrawView(PetscDraw,PetscViewer);
 23: PETSC_STATIC_INLINE PetscErrorCode PetscDrawViewFromOptions(PetscDraw A,const char prefix[],const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,prefix,name);}

 25: /*
 26:    Number of basic colors in the draw routines, the others are used
 27:    for a uniform colormap.
 28: */
 29: #define PETSC_DRAW_BASIC_COLORS 33

 31: #define PETSC_DRAW_ROTATE          -1         /* will rotate through the colors, start with 2 */
 32: #define PETSC_DRAW_WHITE            0
 33: #define PETSC_DRAW_BLACK            1
 34: #define PETSC_DRAW_RED              2
 35: #define PETSC_DRAW_GREEN            3
 36: #define PETSC_DRAW_CYAN             4
 37: #define PETSC_DRAW_BLUE             5
 38: #define PETSC_DRAW_MAGENTA          6
 39: #define PETSC_DRAW_AQUAMARINE       7
 40: #define PETSC_DRAW_FORESTGREEN      8
 41: #define PETSC_DRAW_ORANGE           9
 42: #define PETSC_DRAW_VIOLET          10
 43: #define PETSC_DRAW_BROWN           11
 44: #define PETSC_DRAW_PINK            12
 45: #define PETSC_DRAW_CORAL           13
 46: #define PETSC_DRAW_GRAY            14
 47: #define PETSC_DRAW_YELLOW          15

 49: #define PETSC_DRAW_GOLD            16
 50: #define PETSC_DRAW_LIGHTPINK       17
 51: #define PETSC_DRAW_MEDIUMTURQUOISE 18
 52: #define PETSC_DRAW_KHAKI           19
 53: #define PETSC_DRAW_DIMGRAY         20
 54: #define PETSC_DRAW_YELLOWGREEN     21
 55: #define PETSC_DRAW_SKYBLUE         22
 56: #define PETSC_DRAW_DARKGREEN       23
 57: #define PETSC_DRAW_NAVYBLUE        24
 58: #define PETSC_DRAW_SANDYBROWN      25
 59: #define PETSC_DRAW_CADETBLUE       26
 60: #define PETSC_DRAW_POWDERBLUE      27
 61: #define PETSC_DRAW_DEEPPINK        28
 62: #define PETSC_DRAW_THISTLE         29
 63: #define PETSC_DRAW_LIMEGREEN       30
 64: #define PETSC_DRAW_LAVENDERBLUSH   31
 65: #define PETSC_DRAW_PLUM            32

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

 70: #define PETSC_DRAW_FULL_SIZE    -3
 71: #define PETSC_DRAW_HALF_SIZE    -4
 72: #define PETSC_DRAW_THIRD_SIZE   -5
 73: #define PETSC_DRAW_QUARTER_SIZE -6

 75: PETSC_EXTERN PetscErrorCode PetscDrawOpenNull(MPI_Comm,PetscDraw *);
 76: PETSC_EXTERN PetscErrorCode PetscDrawDestroy(PetscDraw*);
 77: PETSC_EXTERN PetscErrorCode PetscDrawIsNull(PetscDraw,PetscBool *);

 79: PETSC_EXTERN PetscErrorCode PetscDrawGetPopup(PetscDraw,PetscDraw*);
 80: PETSC_EXTERN PetscErrorCode PetscDrawCheckResizedWindow(PetscDraw);
 81: PETSC_EXTERN PetscErrorCode PetscDrawResizeWindow(PetscDraw,int,int);

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

 85: PETSC_EXTERN PetscErrorCode PetscDrawPixelToCoordinate(PetscDraw,PetscInt,PetscInt,PetscReal*,PetscReal*);
 86: PETSC_EXTERN PetscErrorCode PetscDrawCoordinateToPixel(PetscDraw,PetscReal,PetscReal,PetscInt*,PetscInt*);

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

 90: PETSC_EXTERN PetscErrorCode PetscDrawLine(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
 91: PETSC_EXTERN PetscErrorCode PetscDrawArrow(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
 92: PETSC_EXTERN PetscErrorCode PetscDrawLineSetWidth(PetscDraw,PetscReal);
 93: PETSC_EXTERN PetscErrorCode PetscDrawLineGetWidth(PetscDraw,PetscReal*);

 95: PETSC_EXTERN PetscErrorCode PetscDrawPoint(PetscDraw,PetscReal,PetscReal,int);
 96: PETSC_EXTERN PetscErrorCode PetscDrawPointPixel(PetscDraw,PetscInt,PetscInt,int);
 97: PETSC_EXTERN PetscErrorCode PetscDrawPointSetSize(PetscDraw,PetscReal);

 99: PETSC_EXTERN PetscErrorCode PetscDrawRectangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int,int);
100: PETSC_EXTERN PetscErrorCode PetscDrawTriangle(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,int,int,int);
101: PETSC_EXTERN PetscErrorCode PetscDrawEllipse(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal,int);
102: PETSC_EXTERN PetscErrorCode PetscDrawTensorContourPatch(PetscDraw,int,int,PetscReal*,PetscReal*,PetscReal,PetscReal,PetscReal*);
103: PETSC_EXTERN PetscErrorCode PetscDrawTensorContour(PetscDraw,int,int,const PetscReal[],const PetscReal[],PetscReal *);

105: PETSC_EXTERN PetscErrorCode PetscDrawString(PetscDraw,PetscReal,PetscReal,int,const char[]);
106: PETSC_EXTERN PetscErrorCode PetscDrawBoxedString(PetscDraw,PetscReal,PetscReal,int,int,const char[],PetscReal*,PetscReal*);
107: PETSC_EXTERN PetscErrorCode PetscDrawBoxedStringSize(PetscDraw,const char[],PetscReal*,PetscReal*);
108: PETSC_EXTERN PetscErrorCode PetscDrawStringVertical(PetscDraw,PetscReal,PetscReal,int,const char[]);
109: PETSC_EXTERN PetscErrorCode PetscDrawStringSetSize(PetscDraw,PetscReal,PetscReal);
110: PETSC_EXTERN PetscErrorCode PetscDrawStringGetSize(PetscDraw,PetscReal*,PetscReal*);

112: PETSC_EXTERN PetscErrorCode PetscDrawSetViewPort(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
113: PETSC_EXTERN PetscErrorCode PetscDrawGetViewPort(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
114: PETSC_EXTERN PetscErrorCode PetscDrawSplitViewPort(PetscDraw);

116: PETSC_EXTERN PetscErrorCode PetscDrawSetCoordinates(PetscDraw,PetscReal,PetscReal,PetscReal,PetscReal);
117: PETSC_EXTERN PetscErrorCode PetscDrawGetCoordinates(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);

119: PETSC_EXTERN PetscErrorCode PetscDrawSetTitle(PetscDraw,const char[]);
120: PETSC_EXTERN PetscErrorCode PetscDrawAppendTitle(PetscDraw,const char[]);
121: PETSC_EXTERN PetscErrorCode PetscDrawGetTitle(PetscDraw,char **);

123: PETSC_EXTERN PetscErrorCode PetscDrawSetPause(PetscDraw,PetscReal);
124: PETSC_EXTERN PetscErrorCode PetscDrawGetPause(PetscDraw,PetscReal*);
125: PETSC_EXTERN PetscErrorCode PetscDrawPause(PetscDraw);
126: PETSC_EXTERN PetscErrorCode PetscDrawSetDoubleBuffer(PetscDraw);
127: PETSC_EXTERN PetscErrorCode PetscDrawFlush(PetscDraw);
128: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedFlush(PetscDraw);
129: PETSC_EXTERN PetscErrorCode PetscDrawClear(PetscDraw);
130: PETSC_EXTERN PetscErrorCode PetscDrawSave(PetscDraw);
131: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedClear(PetscDraw);
132: PETSC_EXTERN PetscErrorCode PetscDrawBOP(PetscDraw);
133: PETSC_EXTERN PetscErrorCode PetscDrawEOP(PetscDraw);

135: PETSC_EXTERN PetscErrorCode PetscDrawSetDisplay(PetscDraw,const char[]);
136: PETSC_EXTERN PetscErrorCode PetscDrawGetSingleton(PetscDraw,PetscDraw*);
137: PETSC_EXTERN PetscErrorCode PetscDrawRestoreSingleton(PetscDraw,PetscDraw*);

139: PETSC_EXTERN PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw,PetscReal*,PetscReal*);
140: PETSC_EXTERN PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw,PetscReal,PetscReal);
141: PETSC_EXTERN PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw,PetscReal,PetscReal);
142: PETSC_EXTERN PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw);
143: PETSC_EXTERN PetscErrorCode PetscDrawGetBoundingBox(PetscDraw,PetscReal*,PetscReal*,PetscReal*,PetscReal*);

145: /*E
146:     PetscDrawButton - Used to determine which button was pressed

148:    Level: intermediate

150: .seealso: PetscDrawGetMouseButton(), PetscDrawSynchronizedGetMouseButton()
151: E*/
152: 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;

154: PETSC_EXTERN PetscErrorCode PetscDrawGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);
155: PETSC_EXTERN PetscErrorCode PetscDrawSynchronizedGetMouseButton(PetscDraw,PetscDrawButton *,PetscReal*,PetscReal *,PetscReal *,PetscReal *);

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

159: /*S
160:      PetscDrawViewPorts - Subwindows in a PetscDraw object

162:    Level: intermediate

164:   Concepts: graphics

166: .seealso:  PetscDrawViewPortsCreate(), PetscDrawViewPortsSet()
167: S*/
168: typedef struct {
169:   PetscInt  nports;
170:   PetscReal *xl;
171:   PetscReal *xr;
172:   PetscReal *yl;
173:   PetscReal *yr;
174:   PetscDraw draw;
175:   PetscReal port_xl,port_yl,port_xr,port_yr;   /* original port of parent PetscDraw */

177: } PetscDrawViewPorts;
178: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreate(PetscDraw,PetscInt,PetscDrawViewPorts**);
179: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsCreateRect(PetscDraw,PetscInt,PetscInt,PetscDrawViewPorts**);
180: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsDestroy(PetscDrawViewPorts*);
181: PETSC_EXTERN PetscErrorCode PetscDrawViewPortsSet(PetscDrawViewPorts*,PetscInt);

183: PETSC_EXTERN PetscClassId PETSC_DRAWAXIS_CLASSID;

185: PETSC_EXTERN PetscErrorCode PetscDrawAxisCreate(PetscDraw,PetscDrawAxis *);
186: PETSC_EXTERN PetscErrorCode PetscDrawAxisDestroy(PetscDrawAxis*);
187: PETSC_EXTERN PetscErrorCode PetscDrawAxisDraw(PetscDrawAxis);
188: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLimits(PetscDrawAxis,PetscReal,PetscReal,PetscReal,PetscReal);
189: PETSC_EXTERN PetscErrorCode PetscDrawAxisGetLimits(PetscDrawAxis,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
190: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetHoldLimits(PetscDrawAxis,PetscBool );
191: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetColors(PetscDrawAxis,int,int,int);
192: PETSC_EXTERN PetscErrorCode PetscDrawAxisSetLabels(PetscDrawAxis,const char[],const char[],const char[]);

194: PETSC_EXTERN PetscClassId PETSC_DRAWLG_CLASSID;

196: PETSC_EXTERN PetscErrorCode PetscDrawLGCreate(PetscDraw,PetscInt,PetscDrawLG *);
197: PETSC_EXTERN PetscErrorCode PetscDrawLGDestroy(PetscDrawLG*);
198: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoint(PetscDrawLG,const PetscReal*,const PetscReal*);
199: PETSC_EXTERN PetscErrorCode PetscDrawLGAddCommonPoint(PetscDrawLG,const PetscReal,const PetscReal*);
200: PETSC_EXTERN PetscErrorCode PetscDrawLGAddPoints(PetscDrawLG,PetscInt,PetscReal**,PetscReal**);
201: PETSC_EXTERN PetscErrorCode PetscDrawLGDraw(PetscDrawLG);
202: PETSC_EXTERN PetscErrorCode PetscDrawLGView(PetscDrawLG,PetscViewer);
203: PETSC_EXTERN PetscErrorCode PetscDrawLGReset(PetscDrawLG);
204: PETSC_EXTERN PetscErrorCode PetscDrawLGSetDimension(PetscDrawLG,PetscInt);
205: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDimension(PetscDrawLG,PetscInt*);
206: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLegend(PetscDrawLG,const char *const*);
207: PETSC_EXTERN PetscErrorCode PetscDrawLGGetAxis(PetscDrawLG,PetscDrawAxis *);
208: PETSC_EXTERN PetscErrorCode PetscDrawLGGetDraw(PetscDrawLG,PetscDraw *);
209: PETSC_EXTERN PetscErrorCode PetscDrawLGIndicateDataPoints(PetscDrawLG,PetscBool);
210: PETSC_EXTERN PetscErrorCode PetscDrawLGSetLimits(PetscDrawLG,PetscReal,PetscReal,PetscReal,PetscReal);
211: PETSC_EXTERN PetscErrorCode PetscDrawLGSetColors(PetscDrawLG,const int*);
212: PETSC_EXTERN PetscErrorCode PetscDrawLGSetFromOptions(PetscDrawLG);

214: PETSC_EXTERN PetscClassId PETSC_DRAWSP_CLASSID;

216: PETSC_EXTERN PetscErrorCode PetscDrawSPCreate(PetscDraw,int,PetscDrawSP *);
217: PETSC_EXTERN PetscErrorCode PetscDrawSPDestroy(PetscDrawSP*);
218: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoint(PetscDrawSP,PetscReal*,PetscReal*);
219: PETSC_EXTERN PetscErrorCode PetscDrawSPAddPoints(PetscDrawSP,int,PetscReal**,PetscReal**);
220: PETSC_EXTERN PetscErrorCode PetscDrawSPDraw(PetscDrawSP,PetscBool);
221: PETSC_EXTERN PetscErrorCode PetscDrawSPReset(PetscDrawSP);
222: PETSC_EXTERN PetscErrorCode PetscDrawSPSetDimension(PetscDrawSP,int);
223: PETSC_EXTERN PetscErrorCode PetscDrawSPGetAxis(PetscDrawSP,PetscDrawAxis *);
224: PETSC_EXTERN PetscErrorCode PetscDrawSPGetDraw(PetscDrawSP,PetscDraw *);
225: PETSC_EXTERN PetscErrorCode PetscDrawSPSetLimits(PetscDrawSP,PetscReal,PetscReal,PetscReal,PetscReal);
226: PETSC_EXTERN PetscErrorCode PetscDrawLGSPDraw(PetscDrawLG,PetscDrawSP);

228: PETSC_EXTERN PetscClassId PETSC_DRAWHG_CLASSID;

230: PETSC_EXTERN PetscErrorCode PetscDrawHGCreate(PetscDraw,int,PetscDrawHG *);
231: PETSC_EXTERN PetscErrorCode PetscDrawHGDestroy(PetscDrawHG*);
232: PETSC_EXTERN PetscErrorCode PetscDrawHGAddValue(PetscDrawHG,PetscReal);
233: PETSC_EXTERN PetscErrorCode PetscDrawHGDraw(PetscDrawHG);
234: PETSC_EXTERN PetscErrorCode PetscDrawHGView(PetscDrawHG,PetscViewer);
235: PETSC_EXTERN PetscErrorCode PetscDrawHGReset(PetscDrawHG);
236: PETSC_EXTERN PetscErrorCode PetscDrawHGGetAxis(PetscDrawHG,PetscDrawAxis *);
237: PETSC_EXTERN PetscErrorCode PetscDrawHGGetDraw(PetscDrawHG,PetscDraw *);
238: PETSC_EXTERN PetscErrorCode PetscDrawHGSetLimits(PetscDrawHG,PetscReal,PetscReal,int,int);
239: PETSC_EXTERN PetscErrorCode PetscDrawHGSetNumberBins(PetscDrawHG,int);
240: PETSC_EXTERN PetscErrorCode PetscDrawHGSetColor(PetscDrawHG,int);
241: PETSC_EXTERN PetscErrorCode PetscDrawHGCalcStats(PetscDrawHG, PetscBool );
242: PETSC_EXTERN PetscErrorCode PetscDrawHGIntegerBins(PetscDrawHG, PetscBool );

244: /*
245:     PetscViewer routines that allow you to access underlying PetscDraw objects
246: */
247: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDraw(PetscViewer,PetscInt,PetscDraw*);
248: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseAdd(PetscViewer,PetscInt);
249: PETSC_EXTERN PetscErrorCode PetscViewerDrawBaseSet(PetscViewer,PetscInt);
250: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawLG(PetscViewer,PetscInt,PetscDrawLG*);
251: PETSC_EXTERN PetscErrorCode PetscViewerDrawGetDrawAxis(PetscViewer,PetscInt,PetscDrawAxis*);

253: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetCmapHue(unsigned char *,unsigned char *,unsigned char *,int);
254: PETSC_EXTERN PetscErrorCode PetscDrawUtilitySetGamma(PetscReal);

256: #endif