Actual source code: drawnull.c
1: #include <petsc/private/drawimpl.h>
3: static PetscErrorCode PetscDrawCoordinateToPixel_Null(PetscDraw draw,PetscReal x,PetscReal y,int *i,int *j)
4: {
6: *i = *j = 0;
7: return(0);
8: }
10: static PetscErrorCode PetscDrawPixelToCoordinate_Null(PetscDraw draw,int i,int j,PetscReal *x,PetscReal *y)
11: {
13: *x = *y = 0;
14: return(0);
15: }
17: static PetscErrorCode PetscDrawPoint_Null(PetscDraw draw,PetscReal x,PetscReal y,int c)
18: {
20: return(0);
21: }
23: static PetscErrorCode PetscDrawPointPixel_Null(PetscDraw draw,int x,int y,int c)
24: {
26: return(0);
27: }
29: static PetscErrorCode PetscDrawLineGetWidth_Null(PetscDraw draw,PetscReal *width)
30: {
32: if (width) *width = 0.01;
33: return(0);
34: }
36: static PetscErrorCode PetscDrawLine_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
37: {
39: return(0);
40: }
42: static PetscErrorCode PetscDrawArrow_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
43: {
45: return(0);
46: }
48: static PetscErrorCode PetscDrawRectangle_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int c1,int c2,int c3,int c4)
49: {
51: return(0);
52: }
54: static PetscErrorCode PetscDrawEllipse_Null(PetscDraw Win,PetscReal x,PetscReal y,PetscReal a,PetscReal b,int c)
55: {
57: return(0);
58: }
60: static PetscErrorCode PetscDrawTriangle_Null(PetscDraw draw,PetscReal X1,PetscReal Y_1,PetscReal X2,PetscReal Y2,PetscReal X3,PetscReal Y3,int c1,int c2,int c3)
61: {
63: return(0);
64: }
66: static PetscErrorCode PetscDrawStringGetSize_Null(PetscDraw draw,PetscReal *x,PetscReal *y)
67: {
69: if (x) *x = 0.01;
70: if (y) *y = 0.01;
71: return(0);
72: }
74: static PetscErrorCode PetscDrawString_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[])
75: {
77: return(0);
78: }
80: static PetscErrorCode PetscDrawStringVertical_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[])
81: {
83: return(0);
84: }
86: static PetscErrorCode PetscDrawStringBoxed_Null(PetscDraw draw,PetscReal sxl,PetscReal syl,int sc,int bc,const char text[],PetscReal *w,PetscReal *h)
87: {
89: if (w) *w = 0.01;
90: if (h) *h = 0.01;
91: return(0);
92: }
94: static PetscErrorCode PetscDrawGetSingleton_Null(PetscDraw draw,PetscDraw *sdraw)
95: {
98: PetscDrawOpenNull(PETSC_COMM_SELF,sdraw);
99: return(0);
100: }
102: static PetscErrorCode PetscDrawRestoreSingleton_Null(PetscDraw draw,PetscDraw *sdraw)
103: {
106: PetscDrawDestroy(sdraw);
107: return(0);
108: }
110: static struct _PetscDrawOps DvOps = { NULL,/* PetscDrawSetDoubleBuffer_Null */
111: NULL,/* PetscDrawFlush_Null */
112: PetscDrawLine_Null,
113: NULL,/* PetscDrawLineSetWidth_Null */
114: PetscDrawLineGetWidth_Null,
115: PetscDrawPoint_Null,
116: NULL,/* PetscDrawPointSetSize_Null */
117: PetscDrawString_Null,
118: PetscDrawStringVertical_Null,
119: NULL,/* PetscDrawStringSetSize_Null */
120: PetscDrawStringGetSize_Null,
121: NULL,/* PetscDrawSetViewport_Null */
122: NULL,/* PetscDrawClear_Null */
123: PetscDrawRectangle_Null,
124: PetscDrawTriangle_Null,
125: PetscDrawEllipse_Null,
126: NULL,/* PetscDrawGetMouseButton_Null */
127: NULL,/* PetscDrawPause_Null */
128: NULL,/* PetscDrawBeginPage_Null */
129: NULL,/* PetscDrawEndPage_Null */
130: NULL,/* PetscDrawGetPopup_Null */
131: NULL,/* PetscDrawSetTitle_Null */
132: NULL,/* PetscDrawCheckResizedWindow_Null */
133: NULL,/* PetscDrawResizeWindow_Null */
134: NULL,/* PetscDrawDestroy_Null */
135: NULL,/* PetscDrawView_Null */
136: PetscDrawGetSingleton_Null,
137: PetscDrawRestoreSingleton_Null,
138: NULL,/* PetscDrawSave_Null */
139: NULL,/* PetscDrawGetImage_Null */
140: NULL,/* PetscDrawSetCoordinates_Null */
141: PetscDrawArrow_Null,
142: PetscDrawCoordinateToPixel_Null,
143: PetscDrawPixelToCoordinate_Null,
144: PetscDrawPointPixel_Null,
145: PetscDrawStringBoxed_Null};
147: /*MC
148: PETSC_DRAW_NULL - PETSc graphics device that ignores all draw commands
150: Level: beginner
152: .seealso: PetscDrawOpenNull(), PetscDrawIsNull()
153: M*/
154: PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw);
156: PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw draw)
157: {
160: draw->pause = 0;
161: draw->coor_xl = 0; draw->coor_xr = 1;
162: draw->coor_yl = 0; draw->coor_yr = 1;
163: draw->port_xl = 0; draw->port_xr = 1;
164: draw->port_yl = 0; draw->port_yr = 1;
165: PetscDrawDestroy(&draw->popup);
167: PetscMemcpy(draw->ops,&DvOps,sizeof(DvOps));
168: draw->data = NULL;
169: return(0);
170: }
172: /*@
173: PetscDrawOpenNull - Opens a null drawing context. All draw commands to
174: it are ignored.
176: Input Parameter:
177: . comm - MPI communicator
179: Output Parameter:
180: . draw - the drawing context
182: Level: advanced
183: @*/
184: PetscErrorCode PetscDrawOpenNull(MPI_Comm comm,PetscDraw *win)
185: {
189: PetscDrawCreate(comm,NULL,NULL,0,0,1,1,win);
190: PetscDrawSetType(*win,PETSC_DRAW_NULL);
191: return(0);
192: }
194: /*@
195: PetscDrawIsNull - Returns PETSC_TRUE if draw is a null draw object.
197: Not collective
199: Input Parameter:
200: . draw - the draw context
202: Output Parameter:
203: . yes - PETSC_TRUE if it is a null draw object; otherwise PETSC_FALSE
205: Level: advanced
206: @*/
207: PetscErrorCode PetscDrawIsNull(PetscDraw draw,PetscBool *yes)
208: {
214: PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,yes);
215: return(0);
216: }