1 #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/ 2 3 static PetscErrorCode PetscDrawCoordinateToPixel_Null(PetscDraw draw,PetscReal x,PetscReal y,int *i,int *j) 4 { 5 PetscFunctionBegin; 6 *i = *j = 0; 7 PetscFunctionReturn(0); 8 } 9 10 static PetscErrorCode PetscDrawPixelToCoordinate_Null(PetscDraw draw,int i,int j,PetscReal *x,PetscReal *y) 11 { 12 PetscFunctionBegin; 13 *x = *y = 0; 14 PetscFunctionReturn(0); 15 } 16 17 static PetscErrorCode PetscDrawPoint_Null(PetscDraw draw,PetscReal x,PetscReal y,int c) 18 { 19 PetscFunctionBegin; 20 PetscFunctionReturn(0); 21 } 22 23 static PetscErrorCode PetscDrawPointPixel_Null(PetscDraw draw,int x,int y,int c) 24 { 25 PetscFunctionBegin; 26 PetscFunctionReturn(0); 27 } 28 29 static PetscErrorCode PetscDrawLineGetWidth_Null(PetscDraw draw,PetscReal *width) 30 { 31 PetscFunctionBegin; 32 if (width) *width = 0.01; 33 PetscFunctionReturn(0); 34 } 35 36 static PetscErrorCode PetscDrawLine_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl) 37 { 38 PetscFunctionBegin; 39 PetscFunctionReturn(0); 40 } 41 42 static PetscErrorCode PetscDrawArrow_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl) 43 { 44 PetscFunctionBegin; 45 PetscFunctionReturn(0); 46 } 47 48 static PetscErrorCode PetscDrawRectangle_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int c1,int c2,int c3,int c4) 49 { 50 PetscFunctionBegin; 51 PetscFunctionReturn(0); 52 } 53 54 static PetscErrorCode PetscDrawEllipse_Null(PetscDraw Win,PetscReal x,PetscReal y,PetscReal a,PetscReal b,int c) 55 { 56 PetscFunctionBegin; 57 PetscFunctionReturn(0); 58 } 59 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 { 62 PetscFunctionBegin; 63 PetscFunctionReturn(0); 64 } 65 66 static PetscErrorCode PetscDrawStringGetSize_Null(PetscDraw draw,PetscReal *x,PetscReal *y) 67 { 68 PetscFunctionBegin; 69 if (x) *x = 0.01; 70 if (y) *y = 0.01; 71 PetscFunctionReturn(0); 72 } 73 74 static PetscErrorCode PetscDrawString_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[]) 75 { 76 PetscFunctionBegin; 77 PetscFunctionReturn(0); 78 } 79 80 static PetscErrorCode PetscDrawStringVertical_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[]) 81 { 82 PetscFunctionBegin; 83 PetscFunctionReturn(0); 84 } 85 86 static PetscErrorCode PetscDrawStringBoxed_Null(PetscDraw draw,PetscReal sxl,PetscReal syl,int sc,int bc,const char text[],PetscReal *w,PetscReal *h) 87 { 88 PetscFunctionBegin; 89 if (w) *w = 0.01; 90 if (h) *h = 0.01; 91 PetscFunctionReturn(0); 92 } 93 94 static PetscErrorCode PetscDrawGetSingleton_Null(PetscDraw draw,PetscDraw *sdraw) 95 { 96 PetscFunctionBegin; 97 PetscCall(PetscDrawOpenNull(PETSC_COMM_SELF,sdraw)); 98 PetscFunctionReturn(0); 99 } 100 101 static PetscErrorCode PetscDrawRestoreSingleton_Null(PetscDraw draw,PetscDraw *sdraw) 102 { 103 PetscFunctionBegin; 104 PetscCall(PetscDrawDestroy(sdraw)); 105 PetscFunctionReturn(0); 106 } 107 108 static struct _PetscDrawOps DvOps = { NULL,/* PetscDrawSetDoubleBuffer_Null */ 109 NULL,/* PetscDrawFlush_Null */ 110 PetscDrawLine_Null, 111 NULL,/* PetscDrawLineSetWidth_Null */ 112 PetscDrawLineGetWidth_Null, 113 PetscDrawPoint_Null, 114 NULL,/* PetscDrawPointSetSize_Null */ 115 PetscDrawString_Null, 116 PetscDrawStringVertical_Null, 117 NULL,/* PetscDrawStringSetSize_Null */ 118 PetscDrawStringGetSize_Null, 119 NULL,/* PetscDrawSetViewport_Null */ 120 NULL,/* PetscDrawClear_Null */ 121 PetscDrawRectangle_Null, 122 PetscDrawTriangle_Null, 123 PetscDrawEllipse_Null, 124 NULL,/* PetscDrawGetMouseButton_Null */ 125 NULL,/* PetscDrawPause_Null */ 126 NULL,/* PetscDrawBeginPage_Null */ 127 NULL,/* PetscDrawEndPage_Null */ 128 NULL,/* PetscDrawGetPopup_Null */ 129 NULL,/* PetscDrawSetTitle_Null */ 130 NULL,/* PetscDrawCheckResizedWindow_Null */ 131 NULL,/* PetscDrawResizeWindow_Null */ 132 NULL,/* PetscDrawDestroy_Null */ 133 NULL,/* PetscDrawView_Null */ 134 PetscDrawGetSingleton_Null, 135 PetscDrawRestoreSingleton_Null, 136 NULL,/* PetscDrawSave_Null */ 137 NULL,/* PetscDrawGetImage_Null */ 138 NULL,/* PetscDrawSetCoordinates_Null */ 139 PetscDrawArrow_Null, 140 PetscDrawCoordinateToPixel_Null, 141 PetscDrawPixelToCoordinate_Null, 142 PetscDrawPointPixel_Null, 143 PetscDrawStringBoxed_Null}; 144 145 /*MC 146 PETSC_DRAW_NULL - PETSc graphics device that ignores all draw commands 147 148 Level: beginner 149 150 .seealso: PetscDrawOpenNull(), PetscDrawIsNull() 151 M*/ 152 PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw); 153 154 PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw draw) 155 { 156 PetscFunctionBegin; 157 draw->pause = 0; 158 draw->coor_xl = 0; draw->coor_xr = 1; 159 draw->coor_yl = 0; draw->coor_yr = 1; 160 draw->port_xl = 0; draw->port_xr = 1; 161 draw->port_yl = 0; draw->port_yr = 1; 162 PetscCall(PetscDrawDestroy(&draw->popup)); 163 164 PetscCall(PetscMemcpy(draw->ops,&DvOps,sizeof(DvOps))); 165 draw->data = NULL; 166 PetscFunctionReturn(0); 167 } 168 169 /*@ 170 PetscDrawOpenNull - Opens a null drawing context. All draw commands to 171 it are ignored. 172 173 Input Parameter: 174 . comm - MPI communicator 175 176 Output Parameter: 177 . draw - the drawing context 178 179 Level: advanced 180 @*/ 181 PetscErrorCode PetscDrawOpenNull(MPI_Comm comm,PetscDraw *win) 182 { 183 PetscFunctionBegin; 184 PetscCall(PetscDrawCreate(comm,NULL,NULL,0,0,1,1,win)); 185 PetscCall(PetscDrawSetType(*win,PETSC_DRAW_NULL)); 186 PetscFunctionReturn(0); 187 } 188 189 /*@ 190 PetscDrawIsNull - Returns PETSC_TRUE if draw is a null draw object. 191 192 Not collective 193 194 Input Parameter: 195 . draw - the draw context 196 197 Output Parameter: 198 . yes - PETSC_TRUE if it is a null draw object; otherwise PETSC_FALSE 199 200 Level: advanced 201 @*/ 202 PetscErrorCode PetscDrawIsNull(PetscDraw draw,PetscBool *yes) 203 { 204 PetscFunctionBegin; 205 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 206 PetscValidBoolPointer(yes,2); 207 PetscCall(PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,yes)); 208 PetscFunctionReturn(0); 209 } 210