1 2 /* 3 Provides the calling sequences for all the basic PetscDraw routines. 4 */ 5 #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/ 6 7 #undef __FUNCT__ 8 #define __FUNCT__ "PetscDrawGetBoundingBox" 9 /*@ 10 PetscDrawGetBoundingBox - Gets the bounding box of all PetscDrawStringBoxed() commands 11 12 Not collective 13 14 Input Parameter: 15 . draw - the drawing context 16 17 Output Parameters: 18 . xl,yl,xr,yr - coordinates of lower left and upper right corners of bounding box 19 20 Level: intermediate 21 22 .seealso: PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawSetCurrentPoint() 23 @*/ 24 PetscErrorCode PetscDrawGetBoundingBox(PetscDraw draw,PetscReal *xl,PetscReal *yl,PetscReal *xr,PetscReal *yr) 25 { 26 PetscFunctionBegin; 27 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 28 if (xl) PetscValidRealPointer(xl,2); 29 if (yl) PetscValidRealPointer(yl,3); 30 if (xr) PetscValidRealPointer(xr,4); 31 if (yr) PetscValidRealPointer(yr,5); 32 if (xl) *xl = draw->boundbox_xl; 33 if (yl) *yl = draw->boundbox_yl; 34 if (xr) *xr = draw->boundbox_xr; 35 if (yr) *yr = draw->boundbox_yr; 36 PetscFunctionReturn(0); 37 } 38 39 #undef __FUNCT__ 40 #define __FUNCT__ "PetscDrawGetCurrentPoint" 41 /*@ 42 PetscDrawGetCurrentPoint - Gets the current draw point, some codes use this point to determine where to draw next 43 44 Not collective 45 46 Input Parameter: 47 . draw - the drawing context 48 49 Output Parameters: 50 . x,y - the current point 51 52 Level: intermediate 53 54 .seealso: PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawSetCurrentPoint() 55 @*/ 56 PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw draw,PetscReal *x,PetscReal *y) 57 { 58 PetscFunctionBegin; 59 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 60 PetscValidRealPointer(x,2); 61 PetscValidRealPointer(y,3); 62 *x = draw->currentpoint_x[draw->currentpoint]; 63 *y = draw->currentpoint_y[draw->currentpoint]; 64 PetscFunctionReturn(0); 65 } 66 67 #undef __FUNCT__ 68 #define __FUNCT__ "PetscDrawSetCurrentPoint" 69 /*@ 70 PetscDrawSetCurrentPoint - Sets the current draw point, some codes use this point to determine where to draw next 71 72 Not collective 73 74 Input Parameters: 75 + draw - the drawing context 76 - x,y - the location of the current point 77 78 Level: intermediate 79 80 .seealso: PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawGetCurrentPoint() 81 @*/ 82 PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw draw,PetscReal x,PetscReal y) 83 { 84 PetscFunctionBegin; 85 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 86 draw->currentpoint_x[draw->currentpoint] = x; 87 draw->currentpoint_y[draw->currentpoint] = y; 88 PetscFunctionReturn(0); 89 } 90 91 #undef __FUNCT__ 92 #define __FUNCT__ "PetscDrawPushCurrentPoint" 93 /*@ 94 PetscDrawPushCurrentPoint - Pushes a new current draw point, retaining the old one, some codes use this point to determine where to draw next 95 96 Not collective 97 98 Input Parameters: 99 + draw - the drawing context 100 - x,y - the location of the current point 101 102 Level: intermediate 103 104 .seealso: PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawGetCurrentPoint() 105 @*/ 106 PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw draw,PetscReal x,PetscReal y) 107 { 108 PetscFunctionBegin; 109 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 110 if (draw->currentpoint > 19) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"You have pushed too many current points"); 111 draw->currentpoint_x[++draw->currentpoint] = x; 112 draw->currentpoint_y[draw->currentpoint] = y; 113 PetscFunctionReturn(0); 114 } 115 116 #undef __FUNCT__ 117 #define __FUNCT__ "PetscDrawPopCurrentPoint" 118 /*@ 119 PetscDrawPopCurrentPoint - Pops a current draw point (discarding it) 120 121 Not collective 122 123 Input Parameter: 124 . draw - the drawing context 125 126 Level: intermediate 127 128 .seealso: PetscDrawPushCurrentPoint(), PetscDrawSetCurrentPoint(), PetscDrawGetCurrentPoint() 129 @*/ 130 PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw draw) 131 { 132 PetscFunctionBegin; 133 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 134 if (draw->currentpoint-- == 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"You have popped too many current points"); 135 PetscFunctionReturn(0); 136 } 137 138 #undef __FUNCT__ 139 #define __FUNCT__ "PetscDrawLine" 140 /*@ 141 PetscDrawLine - PetscDraws a line onto a drawable. 142 143 Not collective 144 145 Input Parameters: 146 + draw - the drawing context 147 . xl,yl,xr,yr - the coordinates of the line endpoints 148 - cl - the colors of the endpoints 149 150 Level: beginner 151 152 Concepts: line^drawing 153 Concepts: drawing^line 154 155 .seealso: PetscDrawArrow(), PetscDrawLineSetWidth(), PetscDrawLineGetWidth(), PetscDrawRectangle(), PetscDrawTriangle(), PetscDrawEllipse(), 156 PetscDrawMarker(), PetscDrawPoint() 157 158 @*/ 159 PetscErrorCode PetscDrawLine(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl) 160 { 161 PetscErrorCode ierr; 162 163 PetscFunctionBegin; 164 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 165 if (!draw->ops->line) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"This draw type %s does not support drawing lines",((PetscObject)draw)->type_name); 166 ierr = (*draw->ops->line)(draw,xl,yl,xr,yr,cl);CHKERRQ(ierr); 167 PetscFunctionReturn(0); 168 } 169 170 #undef __FUNCT__ 171 #define __FUNCT__ "PetscDrawArrow" 172 /*@ 173 PetscDrawArrow - PetscDraws a line with arrow head at end if the line is long enough 174 175 Not collective 176 177 Input Parameters: 178 + draw - the drawing context 179 . xl,yl,xr,yr - the coordinates of the line endpoints 180 - cl - the colors of the endpoints 181 182 Level: beginner 183 184 Concepts: line^drawing 185 Concepts: drawing^line 186 187 .seealso: PetscDrawLine(), PetscDrawLineSetWidth(), PetscDrawLineGetWidth(), PetscDrawRectangle(), PetscDrawTriangle(), PetscDrawEllipse(), 188 PetscDrawMarker(), PetscDrawPoint() 189 190 @*/ 191 PetscErrorCode PetscDrawArrow(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl) 192 { 193 PetscErrorCode ierr; 194 195 PetscFunctionBegin; 196 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 197 if (!draw->ops->arrow) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"This draw type %s does not support drawing arrows",((PetscObject)draw)->type_name); 198 ierr = (*draw->ops->arrow)(draw,xl,yl,xr,yr,cl);CHKERRQ(ierr); 199 PetscFunctionReturn(0); 200 } 201 202 #undef __FUNCT__ 203 #define __FUNCT__ "PetscDrawLineSetWidth" 204 /*@ 205 PetscDrawLineSetWidth - Sets the line width for future draws. The width is 206 relative to the user coordinates of the window; 0.0 denotes the natural 207 width; 1.0 denotes the entire viewport. 208 209 Not collective 210 211 Input Parameters: 212 + draw - the drawing context 213 - width - the width in user coordinates 214 215 Level: advanced 216 217 Concepts: line^width 218 219 .seealso: PetscDrawLineGetWidth(), PetscDrawLine(), PetscDrawArrow() 220 @*/ 221 PetscErrorCode PetscDrawLineSetWidth(PetscDraw draw,PetscReal width) 222 { 223 PetscErrorCode ierr; 224 225 PetscFunctionBegin; 226 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 227 if (draw->ops->linesetwidth) { 228 ierr = (*draw->ops->linesetwidth)(draw,width);CHKERRQ(ierr); 229 } 230 PetscFunctionReturn(0); 231 } 232 233 #undef __FUNCT__ 234 #define __FUNCT__ "PetscDrawLineGetWidth" 235 /*@ 236 PetscDrawLineGetWidth - Gets the line width for future draws. The width is 237 relative to the user coordinates of the window; 0.0 denotes the natural 238 width; 1.0 denotes the interior viewport. 239 240 Not collective 241 242 Input Parameter: 243 . draw - the drawing context 244 245 Output Parameter: 246 . width - the width in user coordinates 247 248 Level: advanced 249 250 Notes: 251 Not currently implemented. 252 253 Concepts: line^width 254 255 .seealso: PetscDrawLineSetWidth(), PetscDrawLine(), PetscDrawArrow() 256 @*/ 257 PetscErrorCode PetscDrawLineGetWidth(PetscDraw draw,PetscReal *width) 258 { 259 PetscErrorCode ierr; 260 261 PetscFunctionBegin; 262 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 263 PetscValidScalarPointer(width,2); 264 if (!draw->ops->linegetwidth) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"This draw type %s does not support getting line width",((PetscObject)draw)->type_name); 265 ierr = (*draw->ops->linegetwidth)(draw,width);CHKERRQ(ierr); 266 PetscFunctionReturn(0); 267 } 268 269