Actual source code: dline.c
2: /*
3: Provides the calling sequences for all the basic PetscDraw routines.
4: */
5: #include <petsc/private/drawimpl.h>
7: /*@
8: PetscDrawGetBoundingBox - Gets the bounding box of all `PetscDrawStringBoxed()` commands
10: Not collective
12: Input Parameter:
13: . draw - the drawing context
15: Output Parameters:
16: . xl,yl,xr,yr - coordinates of lower left and upper right corners of bounding box
18: Level: intermediate
20: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawSetCurrentPoint()`
21: @*/
22: PetscErrorCode PetscDrawGetBoundingBox(PetscDraw draw, PetscReal *xl, PetscReal *yl, PetscReal *xr, PetscReal *yr)
23: {
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: return 0;
34: }
36: /*@
37: PetscDrawGetCurrentPoint - Gets the current draw point, some codes use this point to determine where to draw next
39: Not collective
41: Input Parameter:
42: . draw - the drawing context
44: Output Parameters:
45: . x,y - the current point
47: Level: intermediate
49: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawSetCurrentPoint()`
50: @*/
51: PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw draw, PetscReal *x, PetscReal *y)
52: {
56: *x = draw->currentpoint_x[draw->currentpoint];
57: *y = draw->currentpoint_y[draw->currentpoint];
58: return 0;
59: }
61: /*@
62: PetscDrawSetCurrentPoint - Sets the current draw point, some codes use this point to determine where to draw next
64: Not collective
66: Input Parameters:
67: + draw - the drawing context
68: - x,y - the location of the current point
70: Level: intermediate
72: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawGetCurrentPoint()`
73: @*/
74: PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw draw, PetscReal x, PetscReal y)
75: {
77: draw->currentpoint_x[draw->currentpoint] = x;
78: draw->currentpoint_y[draw->currentpoint] = y;
79: return 0;
80: }
82: /*@
83: PetscDrawPushCurrentPoint - Pushes a new current draw point, retaining the old one, some codes use this point to determine where to draw next
85: Not collective
87: Input Parameters:
88: + draw - the drawing context
89: - x,y - the location of the current point
91: Level: intermediate
93: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawGetCurrentPoint()`
94: @*/
95: PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw draw, PetscReal x, PetscReal y)
96: {
99: draw->currentpoint_x[++draw->currentpoint] = x;
100: draw->currentpoint_y[draw->currentpoint] = y;
101: return 0;
102: }
104: /*@
105: PetscDrawPopCurrentPoint - Pops a current draw point (discarding it)
107: Not collective
109: Input Parameter:
110: . draw - the drawing context
112: Level: intermediate
114: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawSetCurrentPoint()`, `PetscDrawGetCurrentPoint()`
115: @*/
116: PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw draw)
117: {
120: return 0;
121: }
123: /*@
124: PetscDrawLine - draws a line onto a drawable.
126: Not collective
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
133: Level: beginner
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: {
141: PetscUseTypeMethod(draw, line, xl, yl, xr, yr, cl);
142: return 0;
143: }
145: /*@
146: PetscDrawArrow - draws a line with arrow head at end if the line is long enough
148: Not collective
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
155: Level: beginner
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: {
163: PetscUseTypeMethod(draw, arrow, xl, yl, xr, yr, cl);
164: return 0;
165: }
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.
172: Not collective
174: Input Parameters:
175: + draw - the drawing context
176: - width - the width in user coordinates
178: Level: advanced
180: .seealso: `PetscDraw`, `PetscDrawLineGetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()`
181: @*/
182: PetscErrorCode PetscDrawLineSetWidth(PetscDraw draw, PetscReal width)
183: {
185: PetscTryTypeMethod(draw, linesetwidth, width);
186: return 0;
187: }
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.
194: Not collective
196: Input Parameter:
197: . draw - the drawing context
199: Output Parameter:
200: . width - the width in user coordinates
202: Level: advanced
204: Note:
205: Not currently implemented.
207: .seealso: `PetscDraw`, `PetscDrawLineSetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()`
208: @*/
209: PetscErrorCode PetscDrawLineGetWidth(PetscDraw draw, PetscReal *width)
210: {
213: PetscUseTypeMethod(draw, linegetwidth, width);
214: return 0;
215: }