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