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: `PetscDraw`, `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: `PetscDraw`, `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: `PetscDraw`, `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: `PetscDraw`, `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: `PetscDraw`, `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 - draws 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: `PetscDraw`, `PetscDrawArrow()`, `PetscDrawLineSetWidth()`, `PetscDrawLineGetWidth()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`, 136 `PetscDrawMarker()`, `PetscDrawPoint()` 137 @*/ 138 PetscErrorCode PetscDrawLine(PetscDraw draw, PetscReal xl, PetscReal yl, PetscReal xr, PetscReal yr, int cl) { 139 PetscFunctionBegin; 140 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 141 PetscUseTypeMethod(draw, line, xl, yl, xr, yr, cl); 142 PetscFunctionReturn(0); 143 } 144 145 /*@ 146 PetscDrawArrow - draws a line with arrow head at end if the line is long enough 147 148 Not collective 149 150 Input Parameters: 151 + draw - the drawing context 152 . xl,yl,xr,yr - the coordinates of the line endpoints 153 - cl - the colors of the endpoints 154 155 Level: beginner 156 157 .seealso: `PetscDraw`, `PetscDrawLine()`, `PetscDrawLineSetWidth()`, `PetscDrawLineGetWidth()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`, 158 `PetscDrawMarker()`, `PetscDrawPoint()` 159 @*/ 160 PetscErrorCode PetscDrawArrow(PetscDraw draw, PetscReal xl, PetscReal yl, PetscReal xr, PetscReal yr, int cl) { 161 PetscFunctionBegin; 162 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 163 PetscUseTypeMethod(draw, arrow, xl, yl, xr, yr, cl); 164 PetscFunctionReturn(0); 165 } 166 167 /*@ 168 PetscDrawLineSetWidth - Sets the line width for future draws. The width is 169 relative to the user coordinates of the window; 0.0 denotes the natural 170 width; 1.0 denotes the entire viewport. 171 172 Not collective 173 174 Input Parameters: 175 + draw - the drawing context 176 - width - the width in user coordinates 177 178 Level: advanced 179 180 .seealso: `PetscDraw`, `PetscDrawLineGetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()` 181 @*/ 182 PetscErrorCode PetscDrawLineSetWidth(PetscDraw draw, PetscReal width) { 183 PetscFunctionBegin; 184 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 185 PetscTryTypeMethod(draw, linesetwidth, width); 186 PetscFunctionReturn(0); 187 } 188 189 /*@ 190 PetscDrawLineGetWidth - Gets the line width for future draws. The width is 191 relative to the user coordinates of the window; 0.0 denotes the natural 192 width; 1.0 denotes the interior viewport. 193 194 Not collective 195 196 Input Parameter: 197 . draw - the drawing context 198 199 Output Parameter: 200 . width - the width in user coordinates 201 202 Level: advanced 203 204 Note: 205 Not currently implemented. 206 207 .seealso: `PetscDraw`, `PetscDrawLineSetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()` 208 @*/ 209 PetscErrorCode PetscDrawLineGetWidth(PetscDraw draw, PetscReal *width) { 210 PetscFunctionBegin; 211 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1); 212 PetscValidRealPointer(width, 2); 213 PetscUseTypeMethod(draw, linegetwidth, width); 214 PetscFunctionReturn(0); 215 } 216