1 #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/ 2 3 #undef __FUNCT__ 4 #define __FUNCT__ "PetscDrawCoordinateToPixel_Null" 5 static PetscErrorCode PetscDrawCoordinateToPixel_Null(PetscDraw draw,PetscReal x,PetscReal y,int *i,int *j) 6 { 7 PetscFunctionBegin; 8 *i = *j = 0; 9 PetscFunctionReturn(0); 10 } 11 12 #undef __FUNCT__ 13 #define __FUNCT__ "PetscDrawPixelToCoordinate_Null" 14 static PetscErrorCode PetscDrawPixelToCoordinate_Null(PetscDraw draw,int i,int j,PetscReal *x,PetscReal *y) 15 { 16 PetscFunctionBegin; 17 *x = *y = 0; 18 PetscFunctionReturn(0); 19 } 20 21 #undef __FUNCT__ 22 #define __FUNCT__ "PetscDrawPoint_Null" 23 static PetscErrorCode PetscDrawPoint_Null(PetscDraw draw,PetscReal x,PetscReal y,int c) 24 { 25 PetscFunctionBegin; 26 PetscFunctionReturn(0); 27 } 28 29 #undef __FUNCT__ 30 #define __FUNCT__ "PetscDrawPointPixel_Null" 31 static PetscErrorCode PetscDrawPointPixel_Null(PetscDraw draw,int x,int y,int c) 32 { 33 PetscFunctionBegin; 34 PetscFunctionReturn(0); 35 } 36 37 #undef __FUNCT__ 38 #define __FUNCT__ "PetscDrawLineGetWidth_Null" 39 static PetscErrorCode PetscDrawLineGetWidth_Null(PetscDraw draw,PetscReal *width) 40 { 41 PetscFunctionBegin; 42 if (width) *width = 0.01; 43 PetscFunctionReturn(0); 44 } 45 46 #undef __FUNCT__ 47 #define __FUNCT__ "PetscDrawLine_Null" 48 static PetscErrorCode PetscDrawLine_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl) 49 { 50 PetscFunctionBegin; 51 PetscFunctionReturn(0); 52 } 53 54 #undef __FUNCT__ 55 #define __FUNCT__ "PetscDrawArrow_Null" 56 static PetscErrorCode PetscDrawArrow_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl) 57 { 58 PetscFunctionBegin; 59 PetscFunctionReturn(0); 60 } 61 62 #undef __FUNCT__ 63 #define __FUNCT__ "PetscDrawRectangle_Null" 64 static PetscErrorCode PetscDrawRectangle_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int c1,int c2,int c3,int c4) 65 { 66 PetscFunctionBegin; 67 PetscFunctionReturn(0); 68 } 69 70 #undef __FUNCT__ 71 #define __FUNCT__ "PetscDrawEllipse_Null" 72 static PetscErrorCode PetscDrawEllipse_Null(PetscDraw Win,PetscReal x,PetscReal y,PetscReal a,PetscReal b,int c) 73 { 74 PetscFunctionBegin; 75 PetscFunctionReturn(0); 76 } 77 78 #undef __FUNCT__ 79 #define __FUNCT__ "PetscDrawTriangle_Null" 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 { 82 PetscFunctionBegin; 83 PetscFunctionReturn(0); 84 } 85 86 #undef __FUNCT__ 87 #define __FUNCT__ "PetscDrawStringGetSize_Null" 88 static PetscErrorCode PetscDrawStringGetSize_Null(PetscDraw draw,PetscReal *x,PetscReal *y) 89 { 90 PetscFunctionBegin; 91 if (x) *x = 0.01; 92 if (y) *y = 0.01; 93 PetscFunctionReturn(0); 94 } 95 96 #undef __FUNCT__ 97 #define __FUNCT__ "PetscDrawString_Null" 98 static PetscErrorCode PetscDrawString_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[]) 99 { 100 PetscFunctionBegin; 101 PetscFunctionReturn(0); 102 } 103 104 #undef __FUNCT__ 105 #define __FUNCT__ "PetscDrawStringVertical_Null" 106 static PetscErrorCode PetscDrawStringVertical_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[]) 107 { 108 PetscFunctionBegin; 109 PetscFunctionReturn(0); 110 } 111 112 #undef __FUNCT__ 113 #define __FUNCT__ "PetscDrawStringBoxed_Null" 114 static PetscErrorCode PetscDrawStringBoxed_Null(PetscDraw draw,PetscReal sxl,PetscReal syl,int sc,int bc,const char text[],PetscReal *w,PetscReal *h) 115 { 116 PetscFunctionBegin; 117 if (w) *w = 0.01; 118 if (h) *h = 0.01; 119 PetscFunctionReturn(0); 120 } 121 122 #undef __FUNCT__ 123 #define __FUNCT__ "PetscDrawGetSingleton_Null" 124 static PetscErrorCode PetscDrawGetSingleton_Null(PetscDraw draw,PetscDraw *sdraw) 125 { 126 PetscErrorCode ierr; 127 PetscFunctionBegin; 128 ierr = PetscDrawOpenNull(PETSC_COMM_SELF,sdraw);CHKERRQ(ierr); 129 PetscFunctionReturn(0); 130 } 131 132 #undef __FUNCT__ 133 #define __FUNCT__ "PetscDrawRestoreSingleton_Null" 134 static PetscErrorCode PetscDrawRestoreSingleton_Null(PetscDraw draw,PetscDraw *sdraw) 135 { 136 PetscErrorCode ierr; 137 PetscFunctionBegin; 138 ierr = PetscDrawDestroy(sdraw);CHKERRQ(ierr); 139 PetscFunctionReturn(0); 140 } 141 142 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}; 179 180 181 /*MC 182 PETSC_DRAW_NULL - PETSc graphics device that ignores all draw commands 183 184 Level: beginner 185 186 .seealso: PetscDrawOpenNull(), PetscDrawIsNull() 187 M*/ 188 PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw); 189 190 #undef __FUNCT__ 191 #define __FUNCT__ "PetscDrawCreate_Null" 192 PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw draw) 193 { 194 PetscErrorCode ierr; 195 PetscFunctionBegin; 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 ierr = PetscDrawDestroy(&draw->popup);CHKERRQ(ierr); 202 203 ierr = PetscMemcpy(draw->ops,&DvOps,sizeof(DvOps));CHKERRQ(ierr); 204 draw->data = NULL; 205 PetscFunctionReturn(0); 206 } 207 208 #undef __FUNCT__ 209 #define __FUNCT__ "PetscDrawOpenNull" 210 /*@ 211 PetscDrawOpenNull - Opens a null drawing context. All draw commands to 212 it are ignored. 213 214 Output Parameter: 215 . draw - the drawing context 216 217 Level: advanced 218 @*/ 219 PetscErrorCode PetscDrawOpenNull(MPI_Comm comm,PetscDraw *win) 220 { 221 PetscErrorCode ierr; 222 223 PetscFunctionBegin; 224 ierr = PetscDrawCreate(comm,NULL,NULL,0,0,1,1,win);CHKERRQ(ierr); 225 ierr = PetscDrawSetType(*win,PETSC_DRAW_NULL);CHKERRQ(ierr); 226 PetscFunctionReturn(0); 227 } 228 229 #undef __FUNCT__ 230 #define __FUNCT__ "PetscDrawIsNull" 231 /*@ 232 PetscDrawIsNull - Returns PETSC_TRUE if draw is a null draw object. 233 234 Not collective 235 236 Input Parameter: 237 . draw - the draw context 238 239 Output Parameter: 240 . yes - PETSC_TRUE if it is a null draw object; otherwise PETSC_FALSE 241 242 Level: advanced 243 @*/ 244 PetscErrorCode PetscDrawIsNull(PetscDraw draw,PetscBool *yes) 245 { 246 PetscErrorCode ierr; 247 248 PetscFunctionBegin; 249 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 250 PetscValidIntPointer(yes,2); 251 ierr = PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,yes);CHKERRQ(ierr); 252 PetscFunctionReturn(0); 253 } 254