Actual source code: drawnull.c

petsc-3.7.5 2017-01-01
Report Typos and Errors
  1: #include <petsc/private/drawimpl.h>                        /*I  "petscdraw.h" I*/

  5: static PetscErrorCode PetscDrawCoordinateToPixel_Null(PetscDraw draw,PetscReal x,PetscReal y,int *i,int *j)
  6: {
  8:   *i = *j = 0;
  9:   return(0);
 10: }

 14: static PetscErrorCode PetscDrawPixelToCoordinate_Null(PetscDraw draw,int i,int j,PetscReal *x,PetscReal *y)
 15: {
 17:   *x = *y = 0;
 18:   return(0);
 19: }

 23: static PetscErrorCode PetscDrawPoint_Null(PetscDraw draw,PetscReal x,PetscReal y,int c)
 24: {
 26:   return(0);
 27: }

 31: static PetscErrorCode PetscDrawPointPixel_Null(PetscDraw draw,int x,int y,int c)
 32: {
 34:   return(0);
 35: }

 39: static PetscErrorCode PetscDrawLineGetWidth_Null(PetscDraw draw,PetscReal *width)
 40: {
 42:   if (width) *width = 0.01;
 43:   return(0);
 44: }

 48: static PetscErrorCode PetscDrawLine_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
 49: {
 51:   return(0);
 52: }

 56: static PetscErrorCode PetscDrawArrow_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
 57: {
 59:   return(0);
 60: }

 64: static PetscErrorCode PetscDrawRectangle_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int c1,int c2,int c3,int c4)
 65: {
 67:   return(0);
 68: }

 72: static PetscErrorCode PetscDrawEllipse_Null(PetscDraw Win,PetscReal x,PetscReal y,PetscReal a,PetscReal b,int c)
 73: {
 75:   return(0);
 76: }

 80: 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)
 81: {
 83:   return(0);
 84: }

 88: static PetscErrorCode PetscDrawStringGetSize_Null(PetscDraw draw,PetscReal *x,PetscReal  *y)
 89: {
 91:   if (x) *x = 0.01;
 92:   if (y) *y = 0.01;
 93:   return(0);
 94: }

 98: static PetscErrorCode PetscDrawString_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[])
 99: {
101:   return(0);
102: }

106: static PetscErrorCode PetscDrawStringVertical_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[])
107: {
109:   return(0);
110: }

114: static PetscErrorCode PetscDrawStringBoxed_Null(PetscDraw draw,PetscReal sxl,PetscReal syl,int sc,int bc,const char text[],PetscReal *w,PetscReal *h)
115: {
117:   if (w) *w = 0.01;
118:   if (h) *h = 0.01;
119:   return(0);
120: }

124: static PetscErrorCode PetscDrawGetSingleton_Null(PetscDraw draw,PetscDraw *sdraw)
125: {
128:   PetscDrawOpenNull(PETSC_COMM_SELF,sdraw);
129:   return(0);
130: }

134: static PetscErrorCode PetscDrawRestoreSingleton_Null(PetscDraw draw,PetscDraw *sdraw)
135: {
138:   PetscDrawDestroy(sdraw);
139:   return(0);
140: }


143: static struct _PetscDrawOps DvOps = { NULL,/* PetscDrawSetDoubleBuffer_Null */
144:                                       NULL,/* PetscDrawFlush_Null */
145:                                       PetscDrawLine_Null,
146:                                       NULL,/* PetscDrawLineSetWidth_Null */
147:                                       PetscDrawLineGetWidth_Null,
148:                                       PetscDrawPoint_Null,
149:                                       NULL,/* PetscDrawPointSetSize_Null */
150:                                       PetscDrawString_Null,
151:                                       PetscDrawStringVertical_Null,
152:                                       NULL,/* PetscDrawStringSetSize_Null */
153:                                       PetscDrawStringGetSize_Null,
154:                                       NULL,/* PetscDrawSetViewport_Null */
155:                                       NULL,/* PetscDrawClear_Null */
156:                                       PetscDrawRectangle_Null,
157:                                       PetscDrawTriangle_Null,
158:                                       PetscDrawEllipse_Null,
159:                                       NULL,/* PetscDrawGetMouseButton_Null */
160:                                       NULL,/* PetscDrawPause_Null */
161:                                       NULL,/* PetscDrawBeginPage_Null */
162:                                       NULL,/* PetscDrawEndPage_Null */
163:                                       NULL,/* PetscDrawGetPopup_Null */
164:                                       NULL,/* PetscDrawSetTitle_Null */
165:                                       NULL,/* PetscDrawCheckResizedWindow_Null */
166:                                       NULL,/* PetscDrawResizeWindow_Null */
167:                                       NULL,/* PetscDrawDestroy_Null */
168:                                       NULL,/* PetscDrawView_Null */
169:                                       PetscDrawGetSingleton_Null,
170:                                       PetscDrawRestoreSingleton_Null,
171:                                       NULL,/* PetscDrawSave_Null */
172:                                       NULL,/* PetscDrawGetImage_Null */
173:                                       NULL,/* PetscDrawSetCoordinates_Null */
174:                                       PetscDrawArrow_Null,
175:                                       PetscDrawCoordinateToPixel_Null,
176:                                       PetscDrawPixelToCoordinate_Null,
177:                                       PetscDrawPointPixel_Null,
178:                                       PetscDrawStringBoxed_Null};


181: /*MC
182:      PETSC_DRAW_NULL - PETSc graphics device that ignores all draw commands

184:    Level: beginner

186: .seealso:  PetscDrawOpenNull(), PetscDrawIsNull()
187: M*/
188: PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw);

192: PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw draw)
193: {
196:   draw->pause   = 0;
197:   draw->coor_xl = 0; draw->coor_xr = 1;
198:   draw->coor_yl = 0; draw->coor_yr = 1;
199:   draw->port_xl = 0; draw->port_xr = 1;
200:   draw->port_yl = 0; draw->port_yr = 1;
201:   PetscDrawDestroy(&draw->popup);

203:   PetscMemcpy(draw->ops,&DvOps,sizeof(DvOps));
204:   draw->data = NULL;
205:   return(0);
206: }

210: /*@
211:    PetscDrawOpenNull - Opens a null drawing context. All draw commands to
212:    it are ignored.

214:    Output Parameter:
215: .  draw - the drawing context

217:    Level: advanced
218: @*/
219: PetscErrorCode  PetscDrawOpenNull(MPI_Comm comm,PetscDraw *win)
220: {

224:   PetscDrawCreate(comm,NULL,NULL,0,0,1,1,win);
225:   PetscDrawSetType(*win,PETSC_DRAW_NULL);
226:   return(0);
227: }

231: /*@
232:    PetscDrawIsNull - Returns PETSC_TRUE if draw is a null draw object.

234:    Not collective

236:    Input Parameter:
237: .  draw - the draw context

239:    Output Parameter:
240: .  yes - PETSC_TRUE if it is a null draw object; otherwise PETSC_FALSE

242:    Level: advanced
243: @*/
244: PetscErrorCode  PetscDrawIsNull(PetscDraw draw,PetscBool *yes)
245: {

251:   PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,yes);
252:   return(0);
253: }