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: 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: 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: 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: 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: PetscDrawPushCurrentPoint(), PetscDrawSetCurrentPoint(), PetscDrawGetCurrentPoint()
115: @*/
116: PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw draw)
117: {
120: return 0;
121: }
123: /*@
124: PetscDrawLine - PetscDraws 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: PetscDrawArrow(), PetscDrawLineSetWidth(), PetscDrawLineGetWidth(), PetscDrawRectangle(), PetscDrawTriangle(), PetscDrawEllipse(),
136: PetscDrawMarker(), PetscDrawPoint()
138: @*/
139: PetscErrorCode PetscDrawLine(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
140: {
143: (*draw->ops->line)(draw,xl,yl,xr,yr,cl);
144: return 0;
145: }
147: /*@
148: PetscDrawArrow - PetscDraws a line with arrow head at end if the line is long enough
150: Not collective
152: Input Parameters:
153: + draw - the drawing context
154: . xl,yl,xr,yr - the coordinates of the line endpoints
155: - cl - the colors of the endpoints
157: Level: beginner
159: .seealso: PetscDrawLine(), PetscDrawLineSetWidth(), PetscDrawLineGetWidth(), PetscDrawRectangle(), PetscDrawTriangle(), PetscDrawEllipse(),
160: PetscDrawMarker(), PetscDrawPoint()
162: @*/
163: PetscErrorCode PetscDrawArrow(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
164: {
167: (*draw->ops->arrow)(draw,xl,yl,xr,yr,cl);
168: return 0;
169: }
171: /*@
172: PetscDrawLineSetWidth - Sets the line width for future draws. The width is
173: relative to the user coordinates of the window; 0.0 denotes the natural
174: width; 1.0 denotes the entire viewport.
176: Not collective
178: Input Parameters:
179: + draw - the drawing context
180: - width - the width in user coordinates
182: Level: advanced
184: .seealso: PetscDrawLineGetWidth(), PetscDrawLine(), PetscDrawArrow()
185: @*/
186: PetscErrorCode PetscDrawLineSetWidth(PetscDraw draw,PetscReal width)
187: {
189: if (draw->ops->linesetwidth) {
190: (*draw->ops->linesetwidth)(draw,width);
191: }
192: return 0;
193: }
195: /*@
196: PetscDrawLineGetWidth - Gets the line width for future draws. The width is
197: relative to the user coordinates of the window; 0.0 denotes the natural
198: width; 1.0 denotes the interior viewport.
200: Not collective
202: Input Parameter:
203: . draw - the drawing context
205: Output Parameter:
206: . width - the width in user coordinates
208: Level: advanced
210: Notes:
211: Not currently implemented.
213: .seealso: PetscDrawLineSetWidth(), PetscDrawLine(), PetscDrawArrow()
214: @*/
215: PetscErrorCode PetscDrawLineGetWidth(PetscDraw draw,PetscReal *width)
216: {
220: (*draw->ops->linegetwidth)(draw,width);
221: return 0;
222: }