Actual source code: dline.c

petsc-3.7.5 2017-01-01
Report Typos and Errors
  2: /*
  3:        Provides the calling sequences for all the basic PetscDraw routines.
  4: */
  5: #include <petsc/private/drawimpl.h>  /*I "petscdraw.h" I*/

  9: /*@
 10:    PetscDrawGetBoundingBox - Gets the bounding box of all PetscDrawStringBoxed() commands

 12:    Not collective

 14:    Input Parameter:
 15: .  draw - the drawing context

 17:    Output Parameters:
 18: .   xl,yl,xr,yr - coordinates of lower left and upper right corners of bounding box

 20:    Level: intermediate

 22: .seealso:  PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawSetCurrentPoint()
 23: @*/
 24: PetscErrorCode  PetscDrawGetBoundingBox(PetscDraw draw,PetscReal *xl,PetscReal *yl,PetscReal *xr,PetscReal *yr)
 25: {
 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:   return(0);
 37: }

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

 44:    Not collective

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

 49:    Output Parameters:
 50: .   x,y - the current point

 52:    Level: intermediate

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

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

 72:    Not collective

 74:    Input Parameters:
 75: +  draw - the drawing context
 76: -  x,y - the location of the current point

 78:    Level: intermediate

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

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

 96:    Not collective

 98:    Input Parameters:
 99: +  draw - the drawing context
100: -  x,y - the location of the current point

102:    Level: intermediate

104: .seealso:  PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawGetCurrentPoint()
105: @*/
106: PetscErrorCode  PetscDrawPushCurrentPoint(PetscDraw draw,PetscReal x,PetscReal y)
107: {
110:   if (draw->currentpoint > 19) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"You have pushed too many current points");
111:   draw->currentpoint_x[++draw->currentpoint] = x;
112:   draw->currentpoint_y[draw->currentpoint]   = y;
113:   return(0);
114: }

118: /*@
119:    PetscDrawPopCurrentPoint - Pops a current draw point (discarding it)

121:    Not collective

123:    Input Parameter:
124: .  draw - the drawing context

126:    Level: intermediate

128: .seealso:  PetscDrawPushCurrentPoint(), PetscDrawSetCurrentPoint(), PetscDrawGetCurrentPoint()
129: @*/
130: PetscErrorCode  PetscDrawPopCurrentPoint(PetscDraw draw)
131: {
134:   if (draw->currentpoint-- == 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"You have popped too many current points");
135:   return(0);
136: }

140: /*@
141:    PetscDrawLine - PetscDraws a line onto a drawable.

143:    Not collective

145:    Input Parameters:
146: +  draw - the drawing context
147: .  xl,yl,xr,yr - the coordinates of the line endpoints
148: -  cl - the colors of the endpoints

150:    Level: beginner

152:    Concepts: line^drawing
153:    Concepts: drawing^line

155: @*/
156: PetscErrorCode  PetscDrawLine(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
157: {

162:   if (!draw->ops->line) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"This draw type %s does not support drawing lines",((PetscObject)draw)->type_name);
163:   (*draw->ops->line)(draw,xl,yl,xr,yr,cl);
164:   return(0);
165: }

169: /*@
170:    PetscDrawArrow - PetscDraws a line with arrow head at end if the line is long enough

172:    Not collective

174:    Input Parameters:
175: +  draw - the drawing context
176: .  xl,yl,xr,yr - the coordinates of the line endpoints
177: -  cl - the colors of the endpoints

179:    Level: beginner

181:    Concepts: line^drawing
182:    Concepts: drawing^line

184: @*/
185: PetscErrorCode  PetscDrawArrow(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
186: {

191:   if (!draw->ops->arrow) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"This draw type %s does not support drawing arrows",((PetscObject)draw)->type_name);
192:   (*draw->ops->arrow)(draw,xl,yl,xr,yr,cl);
193:   return(0);
194: }

198: /*@
199:    PetscDrawLineSetWidth - Sets the line width for future draws.  The width is
200:    relative to the user coordinates of the window; 0.0 denotes the natural
201:    width; 1.0 denotes the entire viewport.

203:    Not collective

205:    Input Parameters:
206: +  draw - the drawing context
207: -  width - the width in user coordinates

209:    Level: advanced

211:    Concepts: line^width

213: .seealso:  PetscDrawLineGetWidth()
214: @*/
215: PetscErrorCode  PetscDrawLineSetWidth(PetscDraw draw,PetscReal width)
216: {

221:   if (draw->ops->linesetwidth) {
222:     (*draw->ops->linesetwidth)(draw,width);
223:   }
224:   return(0);
225: }

229: /*@
230:    PetscDrawLineGetWidth - Gets the line width for future draws.  The width is
231:    relative to the user coordinates of the window; 0.0 denotes the natural
232:    width; 1.0 denotes the interior viewport.

234:    Not collective

236:    Input Parameter:
237: .  draw - the drawing context

239:    Output Parameter:
240: .  width - the width in user coordinates

242:    Level: advanced

244:    Notes:
245:    Not currently implemented.

247:    Concepts: line^width

249: .seealso:  PetscDrawLineSetWidth()
250: @*/
251: PetscErrorCode  PetscDrawLineGetWidth(PetscDraw draw,PetscReal *width)
252: {

258:   if (!draw->ops->linegetwidth) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"This draw type %s does not support getting line width",((PetscObject)draw)->type_name);
259:   (*draw->ops->linegetwidth)(draw,width);
260:   return(0);
261: }