xref: /petsc/src/sys/classes/draw/interface/dpoint.c (revision c4762a1b19cd2af06abeed90e8f9d34fb975dd94)
1 
2 /*
3        Provides the calling sequences for all the basic PetscDraw routines.
4 */
5 #include <petsc/private/drawimpl.h>  /*I "petscdraw.h" I*/
6 
7 /*@
8    PetscDrawPoint - PetscDraws a point onto a drawable.
9 
10    Not collective
11 
12    Input Parameters:
13 +  draw - the drawing context
14 .  xl,yl - the coordinates of the point
15 -  cl - the color of the point
16 
17    Level: beginner
18 
19 
20 .seealso: PetscDrawPointPixel(), PetscDrawPointSetSize(), PetscDrawLine(), PetscDrawRectangle(), PetscDrawTriangle(), PetscDrawEllipse(),
21           PetscDrawMarker(), PetscDrawString(), PetscDrawArrow()
22 
23 @*/
24 PetscErrorCode  PetscDrawPoint(PetscDraw draw,PetscReal xl,PetscReal yl,int cl)
25 {
26   PetscErrorCode ierr;
27 
28   PetscFunctionBegin;
29   PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1);
30   if (!draw->ops->point) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"This draw type %s does not support drawing points",((PetscObject)draw)->type_name);
31   ierr = (*draw->ops->point)(draw,xl,yl,cl);CHKERRQ(ierr);
32   PetscFunctionReturn(0);
33 }
34 
35 /*@
36    PetscDrawPointPixel - PetscDraws a point onto a drawable, in pixel coordinates
37 
38    Not collective
39 
40    Input Parameters:
41 +  draw - the drawing context
42 .  x,y - the pixel coordinates of the point
43 -  c - the color of the point
44 
45    Level: beginner
46 
47 
48 .seealso: PetscDrawPoint(), PetscDrawPointSetSize()
49 
50 @*/
51 PetscErrorCode  PetscDrawPointPixel(PetscDraw draw,int x,int y,int c)
52 {
53   PetscErrorCode ierr;
54 
55   PetscFunctionBegin;
56   PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1);
57   if (!draw->ops->pointpixel) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"This draw type %s does not support drawing point pixels",((PetscObject)draw)->type_name);
58   ierr = (*draw->ops->pointpixel)(draw,x,y,c);CHKERRQ(ierr);
59   PetscFunctionReturn(0);
60 }
61 
62 /*@
63    PetscDrawPointSetSize - Sets the point size for future draws.  The size is
64    relative to the user coordinates of the window; 0.0 denotes the natural
65    width, 1.0 denotes the entire viewport.
66 
67    Not collective
68 
69    Input Parameters:
70 +  draw - the drawing context
71 -  width - the width in user coordinates
72 
73    Level: advanced
74 
75    Note:
76    Even a size of zero insures that a single pixel is colored.
77 
78 .seealso: PetscDrawPoint(), PetscDrawMarker()
79 @*/
80 PetscErrorCode  PetscDrawPointSetSize(PetscDraw draw,PetscReal width)
81 {
82   PetscErrorCode ierr;
83 
84   PetscFunctionBegin;
85   PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1);
86   if (width < 0.0 || width > 1.0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Bad size %g, should be between 0 and 1",(double)width);
87   if (draw->ops->pointsetsize) {
88     ierr = (*draw->ops->pointsetsize)(draw,width);CHKERRQ(ierr);
89   }
90   PetscFunctionReturn(0);
91 }
92