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 /*@ 8 PetscDrawGetBoundingBox - Gets the bounding box of all PetscDrawStringBoxed() commands 9 10 Not collective 11 12 Input Parameter: 13 . draw - the drawing context 14 15 Output Parameters: 16 . xl,yl,xr,yr - coordinates of lower left and upper right corners of bounding box 17 18 Level: intermediate 19 20 .seealso: `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawSetCurrentPoint()` 21 @*/ 22 PetscErrorCode PetscDrawGetBoundingBox(PetscDraw draw, PetscReal *xl, PetscReal *yl, PetscReal *xr, PetscReal *yr) { 23 PetscFunctionBegin; 24 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 25 if (xl) PetscValidRealPointer(xl, 2); 26 if (yl) PetscValidRealPointer(yl, 3); 27 if (xr) PetscValidRealPointer(xr, 4); 28 if (yr) PetscValidRealPointer(yr, 5); 29 if (xl) *xl = draw->boundbox_xl; 30 if (yl) *yl = draw->boundbox_yl; 31 if (xr) *xr = draw->boundbox_xr; 32 if (yr) *yr = draw->boundbox_yr; 33 PetscFunctionReturn(0); 34 } 35 36 /*@ 37 PetscDrawGetCurrentPoint - Gets the current draw point, some codes use this point to determine where to draw next 38 39 Not collective 40 41 Input Parameter: 42 . draw - the drawing context 43 44 Output Parameters: 45 . x,y - the current point 46 47 Level: intermediate 48 49 .seealso: `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawSetCurrentPoint()` 50 @*/ 51 PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw draw, PetscReal *x, PetscReal *y) { 52 PetscFunctionBegin; 53 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 54 PetscValidRealPointer(x, 2); 55 PetscValidRealPointer(y, 3); 56 *x = draw->currentpoint_x[draw->currentpoint]; 57 *y = draw->currentpoint_y[draw->currentpoint]; 58 PetscFunctionReturn(0); 59 } 60 61 /*@ 62 PetscDrawSetCurrentPoint - Sets the current draw point, some codes use this point to determine where to draw next 63 64 Not collective 65 66 Input Parameters: 67 + draw - the drawing context 68 - x,y - the location of the current point 69 70 Level: intermediate 71 72 .seealso: `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawGetCurrentPoint()` 73 @*/ 74 PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw draw, PetscReal x, PetscReal y) { 75 PetscFunctionBegin; 76 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 77 draw->currentpoint_x[draw->currentpoint] = x; 78 draw->currentpoint_y[draw->currentpoint] = y; 79 PetscFunctionReturn(0); 80 } 81 82 /*@ 83 PetscDrawPushCurrentPoint - Pushes a new current draw point, retaining the old one, some codes use this point to determine where to draw next 84 85 Not collective 86 87 Input Parameters: 88 + draw - the drawing context 89 - x,y - the location of the current point 90 91 Level: intermediate 92 93 .seealso: `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawGetCurrentPoint()` 94 @*/ 95 PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw draw, PetscReal x, PetscReal y) { 96 PetscFunctionBegin; 97 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 98 PetscCheck(draw->currentpoint <= 19, PETSC_COMM_SELF, PETSC_ERR_SUP, "You have pushed too many current points"); 99 draw->currentpoint_x[++draw->currentpoint] = x; 100 draw->currentpoint_y[draw->currentpoint] = y; 101 PetscFunctionReturn(0); 102 } 103 104 /*@ 105 PetscDrawPopCurrentPoint - Pops a current draw point (discarding it) 106 107 Not collective 108 109 Input Parameter: 110 . draw - the drawing context 111 112 Level: intermediate 113 114 .seealso: `PetscDrawPushCurrentPoint()`, `PetscDrawSetCurrentPoint()`, `PetscDrawGetCurrentPoint()` 115 @*/ 116 PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw draw) { 117 PetscFunctionBegin; 118 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 119 PetscCheck(draw->currentpoint-- > 0, PETSC_COMM_SELF, PETSC_ERR_SUP, "You have popped too many current points"); 120 PetscFunctionReturn(0); 121 } 122 123 /*@ 124 PetscDrawLine - PetscDraws a line onto a drawable. 125 126 Not collective 127 128 Input Parameters: 129 + draw - the drawing context 130 . xl,yl,xr,yr - the coordinates of the line endpoints 131 - cl - the colors of the endpoints 132 133 Level: beginner 134 135 .seealso: `PetscDrawArrow()`, `PetscDrawLineSetWidth()`, `PetscDrawLineGetWidth()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`, 136 `PetscDrawMarker()`, `PetscDrawPoint()` 137 138 @*/ 139 PetscErrorCode PetscDrawLine(PetscDraw draw, PetscReal xl, PetscReal yl, PetscReal xr, PetscReal yr, int cl) { 140 PetscFunctionBegin; 141 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 142 PetscUseTypeMethod(draw, line, xl, yl, xr, yr, cl); 143 PetscFunctionReturn(0); 144 } 145 146 /*@ 147 PetscDrawArrow - PetscDraws a line with arrow head at end if the line is long enough 148 149 Not collective 150 151 Input Parameters: 152 + draw - the drawing context 153 . xl,yl,xr,yr - the coordinates of the line endpoints 154 - cl - the colors of the endpoints 155 156 Level: beginner 157 158 .seealso: `PetscDrawLine()`, `PetscDrawLineSetWidth()`, `PetscDrawLineGetWidth()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`, 159 `PetscDrawMarker()`, `PetscDrawPoint()` 160 161 @*/ 162 PetscErrorCode PetscDrawArrow(PetscDraw draw, PetscReal xl, PetscReal yl, PetscReal xr, PetscReal yr, int cl) { 163 PetscFunctionBegin; 164 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 165 PetscUseTypeMethod(draw, arrow, xl, yl, xr, yr, cl); 166 PetscFunctionReturn(0); 167 } 168 169 /*@ 170 PetscDrawLineSetWidth - Sets the line width for future draws. The width is 171 relative to the user coordinates of the window; 0.0 denotes the natural 172 width; 1.0 denotes the entire viewport. 173 174 Not collective 175 176 Input Parameters: 177 + draw - the drawing context 178 - width - the width in user coordinates 179 180 Level: advanced 181 182 .seealso: `PetscDrawLineGetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()` 183 @*/ 184 PetscErrorCode PetscDrawLineSetWidth(PetscDraw draw, PetscReal width) { 185 PetscFunctionBegin; 186 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 187 PetscTryTypeMethod(draw, linesetwidth, width); 188 PetscFunctionReturn(0); 189 } 190 191 /*@ 192 PetscDrawLineGetWidth - Gets the line width for future draws. The width is 193 relative to the user coordinates of the window; 0.0 denotes the natural 194 width; 1.0 denotes the interior viewport. 195 196 Not collective 197 198 Input Parameter: 199 . draw - the drawing context 200 201 Output Parameter: 202 . width - the width in user coordinates 203 204 Level: advanced 205 206 Notes: 207 Not currently implemented. 208 209 .seealso: `PetscDrawLineSetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()` 210 @*/ 211 PetscErrorCode PetscDrawLineGetWidth(PetscDraw draw, PetscReal *width) { 212 PetscFunctionBegin; 213 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 214 PetscValidRealPointer(width, 2); 215 PetscUseTypeMethod(draw, linegetwidth, width); 216 PetscFunctionReturn(0); 217 } 218