Actual source code: drawnull.c

petsc-3.11.4 2019-09-28
Report Typos and Errors
  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: }


111: static struct _PetscDrawOps DvOps = { NULL,/* PetscDrawSetDoubleBuffer_Null */
112:                                       NULL,/* PetscDrawFlush_Null */
113:                                       PetscDrawLine_Null,
114:                                       NULL,/* PetscDrawLineSetWidth_Null */
115:                                       PetscDrawLineGetWidth_Null,
116:                                       PetscDrawPoint_Null,
117:                                       NULL,/* PetscDrawPointSetSize_Null */
118:                                       PetscDrawString_Null,
119:                                       PetscDrawStringVertical_Null,
120:                                       NULL,/* PetscDrawStringSetSize_Null */
121:                                       PetscDrawStringGetSize_Null,
122:                                       NULL,/* PetscDrawSetViewport_Null */
123:                                       NULL,/* PetscDrawClear_Null */
124:                                       PetscDrawRectangle_Null,
125:                                       PetscDrawTriangle_Null,
126:                                       PetscDrawEllipse_Null,
127:                                       NULL,/* PetscDrawGetMouseButton_Null */
128:                                       NULL,/* PetscDrawPause_Null */
129:                                       NULL,/* PetscDrawBeginPage_Null */
130:                                       NULL,/* PetscDrawEndPage_Null */
131:                                       NULL,/* PetscDrawGetPopup_Null */
132:                                       NULL,/* PetscDrawSetTitle_Null */
133:                                       NULL,/* PetscDrawCheckResizedWindow_Null */
134:                                       NULL,/* PetscDrawResizeWindow_Null */
135:                                       NULL,/* PetscDrawDestroy_Null */
136:                                       NULL,/* PetscDrawView_Null */
137:                                       PetscDrawGetSingleton_Null,
138:                                       PetscDrawRestoreSingleton_Null,
139:                                       NULL,/* PetscDrawSave_Null */
140:                                       NULL,/* PetscDrawGetImage_Null */
141:                                       NULL,/* PetscDrawSetCoordinates_Null */
142:                                       PetscDrawArrow_Null,
143:                                       PetscDrawCoordinateToPixel_Null,
144:                                       PetscDrawPixelToCoordinate_Null,
145:                                       PetscDrawPointPixel_Null,
146:                                       PetscDrawStringBoxed_Null};


149: /*MC
150:      PETSC_DRAW_NULL - PETSc graphics device that ignores all draw commands

152:    Level: beginner

154: .seealso:  PetscDrawOpenNull(), PetscDrawIsNull()
155: M*/
156: PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw);

158: PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw draw)
159: {
162:   draw->pause   = 0;
163:   draw->coor_xl = 0; draw->coor_xr = 1;
164:   draw->coor_yl = 0; draw->coor_yr = 1;
165:   draw->port_xl = 0; draw->port_xr = 1;
166:   draw->port_yl = 0; draw->port_yr = 1;
167:   PetscDrawDestroy(&draw->popup);

169:   PetscMemcpy(draw->ops,&DvOps,sizeof(DvOps));
170:   draw->data = NULL;
171:   return(0);
172: }

174: /*@
175:    PetscDrawOpenNull - Opens a null drawing context. All draw commands to
176:    it are ignored.

178:    Output Parameter:
179: .  draw - the drawing context

181:    Level: advanced
182: @*/
183: PetscErrorCode  PetscDrawOpenNull(MPI_Comm comm,PetscDraw *win)
184: {

188:   PetscDrawCreate(comm,NULL,NULL,0,0,1,1,win);
189:   PetscDrawSetType(*win,PETSC_DRAW_NULL);
190:   return(0);
191: }

193: /*@
194:    PetscDrawIsNull - Returns PETSC_TRUE if draw is a null draw object.

196:    Not collective

198:    Input Parameter:
199: .  draw - the draw context

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

204:    Level: advanced
205: @*/
206: PetscErrorCode  PetscDrawIsNull(PetscDraw draw,PetscBool *yes)
207: {

213:   PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,yes);
214:   return(0);
215: }