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 - horizontal coordinate of lower left corner of bounding box
 17: .   yl - vertical coordinate of lower left corner of bounding box
 18: .   xr - horizontal coordinate of upper right corner of bounding box
 19: -   yr - vertical coordinate of upper right corner of bounding box

 21:    Level: intermediate

 23: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawSetCurrentPoint()`
 24: @*/
 25: PetscErrorCode PetscDrawGetBoundingBox(PetscDraw draw, PetscReal *xl, PetscReal *yl, PetscReal *xr, PetscReal *yr)
 26: {
 27:   PetscFunctionBegin;
 33:   if (xl) *xl = draw->boundbox_xl;
 34:   if (yl) *yl = draw->boundbox_yl;
 35:   if (xr) *xr = draw->boundbox_xr;
 36:   if (yr) *yr = draw->boundbox_yr;
 37:   PetscFunctionReturn(PETSC_SUCCESS);
 38: }

 40: /*@
 41:    PetscDrawGetCurrentPoint - Gets the current draw point, some codes use this point to determine where to draw next

 43:    Not Collective

 45:    Input Parameter:
 46: .  draw - the drawing context

 48:    Output Parameters:
 49: +   x - horizontal coordinate of the current point
 50: -   y - vertical coordinate of the current point

 52:    Level: intermediate

 54: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawSetCurrentPoint()`
 55: @*/
 56: PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw draw, PetscReal *x, PetscReal *y)
 57: {
 58:   PetscFunctionBegin;
 62:   *x = draw->currentpoint_x[draw->currentpoint];
 63:   *y = draw->currentpoint_y[draw->currentpoint];
 64:   PetscFunctionReturn(PETSC_SUCCESS);
 65: }

 67: /*@
 68:    PetscDrawSetCurrentPoint - Sets the current draw point, some codes use this point to determine where to draw next

 70:    Not Collective

 72:    Input Parameters:
 73: +  draw - the drawing context
 74: .   x - horizontal coordinate of the current point
 75: -   y - vertical coordinate of the current point

 77:    Level: intermediate

 79: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawGetCurrentPoint()`
 80: @*/
 81: PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw draw, PetscReal x, PetscReal y)
 82: {
 83:   PetscFunctionBegin;
 85:   draw->currentpoint_x[draw->currentpoint] = x;
 86:   draw->currentpoint_y[draw->currentpoint] = y;
 87:   PetscFunctionReturn(PETSC_SUCCESS);
 88: }

 90: /*@
 91:    PetscDrawPushCurrentPoint - Pushes a new current draw point, retaining the old one, some codes use this point to determine where to draw next

 93:    Not Collective

 95:    Input Parameters:
 96: +  draw - the drawing context
 97: .   x - horizontal coordinate of the current point
 98: -   y - vertical coordinate of the current point

100:    Level: intermediate

102: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawGetCurrentPoint()`
103: @*/
104: PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw draw, PetscReal x, PetscReal y)
105: {
106:   PetscFunctionBegin;
108:   PetscCheck(draw->currentpoint <= 19, PETSC_COMM_SELF, PETSC_ERR_SUP, "You have pushed too many current points");
109:   draw->currentpoint_x[++draw->currentpoint] = x;
110:   draw->currentpoint_y[draw->currentpoint]   = y;
111:   PetscFunctionReturn(PETSC_SUCCESS);
112: }

114: /*@
115:    PetscDrawPopCurrentPoint - Pops a current draw point (discarding it)

117:    Not Collective

119:    Input Parameter:
120: .  draw - the drawing context

122:    Level: intermediate

124: .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawSetCurrentPoint()`, `PetscDrawGetCurrentPoint()`
125: @*/
126: PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw draw)
127: {
128:   PetscFunctionBegin;
130:   PetscCheck(draw->currentpoint-- > 0, PETSC_COMM_SELF, PETSC_ERR_SUP, "You have popped too many current points");
131:   PetscFunctionReturn(PETSC_SUCCESS);
132: }

134: /*@
135:    PetscDrawLine - draws a line onto a drawable.

137:    Not Collective

139:    Input Parameters:
140: +  draw - the drawing context
141: .  xl - horizontal coordinate of first end point
142: .  yl - vertical coordinate of first end point
143: .  xr - horizontal coordinate of second end point
144: .  yr - vertical coordinate of second end point
145: -  cl - the colors of the endpoints

147:    Level: beginner

149: .seealso: `PetscDraw`, `PetscDrawArrow()`, `PetscDrawLineSetWidth()`, `PetscDrawLineGetWidth()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`,
150:           `PetscDrawMarker()`, `PetscDrawPoint()`
151: @*/
152: PetscErrorCode PetscDrawLine(PetscDraw draw, PetscReal xl, PetscReal yl, PetscReal xr, PetscReal yr, int cl)
153: {
154:   PetscFunctionBegin;
156:   PetscUseTypeMethod(draw, line, xl, yl, xr, yr, cl);
157:   PetscFunctionReturn(PETSC_SUCCESS);
158: }

160: /*@
161:    PetscDrawArrow - draws a line with arrow head at end if the line is long enough

163:    Not Collective

165:    Input Parameters:
166: +  draw - the drawing context
167: .  xl - horizontal coordinate of first end point
168: .  yl - vertical coordinate of first end point
169: .  xr - horizontal coordinate of second end point
170: .  yr - vertical coordinate of second end point
171: -  cl - the colors of the endpoints

173:    Level: beginner

175: .seealso: `PetscDraw`, `PetscDrawLine()`, `PetscDrawLineSetWidth()`, `PetscDrawLineGetWidth()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`,
176:           `PetscDrawMarker()`, `PetscDrawPoint()`
177: @*/
178: PetscErrorCode PetscDrawArrow(PetscDraw draw, PetscReal xl, PetscReal yl, PetscReal xr, PetscReal yr, int cl)
179: {
180:   PetscFunctionBegin;
182:   PetscUseTypeMethod(draw, arrow, xl, yl, xr, yr, cl);
183:   PetscFunctionReturn(PETSC_SUCCESS);
184: }

186: /*@
187:    PetscDrawLineSetWidth - Sets the line width for future draws.  The width is
188:    relative to the user coordinates of the window; 0.0 denotes the natural
189:    width; 1.0 denotes the entire viewport.

191:    Not Collective

193:    Input Parameters:
194: +  draw - the drawing context
195: -  width - the width in user coordinates

197:    Level: advanced

199: .seealso: `PetscDraw`, `PetscDrawLineGetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()`
200: @*/
201: PetscErrorCode PetscDrawLineSetWidth(PetscDraw draw, PetscReal width)
202: {
203:   PetscFunctionBegin;
205:   PetscTryTypeMethod(draw, linesetwidth, width);
206:   PetscFunctionReturn(PETSC_SUCCESS);
207: }

209: /*@
210:    PetscDrawLineGetWidth - Gets the line width for future draws.  The width is
211:    relative to the user coordinates of the window; 0.0 denotes the natural
212:    width; 1.0 denotes the interior viewport.

214:    Not Collective

216:    Input Parameter:
217: .  draw - the drawing context

219:    Output Parameter:
220: .  width - the width in user coordinates

222:    Level: advanced

224:    Note:
225:    Not currently implemented.

227: .seealso: `PetscDraw`, `PetscDrawLineSetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()`
228: @*/
229: PetscErrorCode PetscDrawLineGetWidth(PetscDraw draw, PetscReal *width)
230: {
231:   PetscFunctionBegin;
234:   PetscUseTypeMethod(draw, linegetwidth, width);
235:   PetscFunctionReturn(PETSC_SUCCESS);
236: }