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 PetscErrorCode ierr; 97 PetscFunctionBegin; 98 ierr = PetscDrawOpenNull(PETSC_COMM_SELF,sdraw);CHKERRQ(ierr); 99 PetscFunctionReturn(0); 100 } 101 102 static PetscErrorCode PetscDrawRestoreSingleton_Null(PetscDraw draw,PetscDraw *sdraw) 103 { 104 PetscErrorCode ierr; 105 PetscFunctionBegin; 106 ierr = PetscDrawDestroy(sdraw);CHKERRQ(ierr); 107 PetscFunctionReturn(0); 108 } 109 110 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}; 147 148 149 /*MC 150 PETSC_DRAW_NULL - PETSc graphics device that ignores all draw commands 151 152 Level: beginner 153 154 .seealso: PetscDrawOpenNull(), PetscDrawIsNull() 155 M*/ 156 PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw); 157 158 PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw draw) 159 { 160 PetscErrorCode ierr; 161 PetscFunctionBegin; 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 ierr = PetscDrawDestroy(&draw->popup);CHKERRQ(ierr); 168 169 ierr = PetscMemcpy(draw->ops,&DvOps,sizeof(DvOps));CHKERRQ(ierr); 170 draw->data = NULL; 171 PetscFunctionReturn(0); 172 } 173 174 /*@ 175 PetscDrawOpenNull - Opens a null drawing context. All draw commands to 176 it are ignored. 177 178 Output Parameter: 179 . draw - the drawing context 180 181 Level: advanced 182 @*/ 183 PetscErrorCode PetscDrawOpenNull(MPI_Comm comm,PetscDraw *win) 184 { 185 PetscErrorCode ierr; 186 187 PetscFunctionBegin; 188 ierr = PetscDrawCreate(comm,NULL,NULL,0,0,1,1,win);CHKERRQ(ierr); 189 ierr = PetscDrawSetType(*win,PETSC_DRAW_NULL);CHKERRQ(ierr); 190 PetscFunctionReturn(0); 191 } 192 193 /*@ 194 PetscDrawIsNull - Returns PETSC_TRUE if draw is a null draw object. 195 196 Not collective 197 198 Input Parameter: 199 . draw - the draw context 200 201 Output Parameter: 202 . yes - PETSC_TRUE if it is a null draw object; otherwise PETSC_FALSE 203 204 Level: advanced 205 @*/ 206 PetscErrorCode PetscDrawIsNull(PetscDraw draw,PetscBool *yes) 207 { 208 PetscErrorCode ierr; 209 210 PetscFunctionBegin; 211 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 212 PetscValidIntPointer(yes,2); 213 ierr = PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,yes);CHKERRQ(ierr); 214 PetscFunctionReturn(0); 215 } 216