xref: /petsc/src/sys/classes/draw/interface/dpoint.c (revision 4d67ab215a024a3127c6e55d96511f31e108de68)
1 
2 #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/
3 
4 /*@
5    PetscDrawPoint - draws a point onto a drawable.
6 
7    Not Collective
8 
9    Input Parameters:
10 +  draw - the drawing context
11 .  xl,yl - the coordinates of the point
12 -  cl - the color of the point
13 
14    Level: beginner
15 
16 .seealso: `PetscDraw`, `PetscDrawPointPixel()`, `PetscDrawPointSetSize()`, `PetscDrawLine()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`,
17           `PetscDrawMarker()`, `PetscDrawString()`, `PetscDrawArrow()`
18 @*/
19 PetscErrorCode PetscDrawPoint(PetscDraw draw, PetscReal xl, PetscReal yl, int cl)
20 {
21   PetscFunctionBegin;
22   PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
23   PetscUseTypeMethod(draw, point, xl, yl, cl);
24   PetscFunctionReturn(PETSC_SUCCESS);
25 }
26 
27 /*@
28    PetscDrawPointPixel - draws a point onto a drawable, in pixel coordinates
29 
30    Not Collective
31 
32    Input Parameters:
33 +  draw - the drawing context
34 .  x,y - the pixel coordinates of the point
35 -  c - the color of the point
36 
37    Level: beginner
38 
39 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawPointSetSize()`
40 @*/
41 PetscErrorCode PetscDrawPointPixel(PetscDraw draw, int x, int y, int c)
42 {
43   PetscFunctionBegin;
44   PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
45   PetscUseTypeMethod(draw, pointpixel, x, y, c);
46   PetscFunctionReturn(PETSC_SUCCESS);
47 }
48 
49 /*@
50    PetscDrawPointSetSize - Sets the point size for future draws.  The size is
51    relative to the user coordinates of the window; 0.0 denotes the natural
52    width, 1.0 denotes the entire viewport.
53 
54    Not Collective
55 
56    Input Parameters:
57 +  draw - the drawing context
58 -  width - the width in user coordinates
59 
60    Level: advanced
61 
62    Note:
63    Even a size of zero insures that a single pixel is colored.
64 
65 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawMarker()`
66 @*/
67 PetscErrorCode PetscDrawPointSetSize(PetscDraw draw, PetscReal width)
68 {
69   PetscFunctionBegin;
70   PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
71   PetscCheck(width >= 0.0 && width <= 1.0, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Bad size %g, should be between 0 and 1", (double)width);
72   PetscTryTypeMethod(draw, pointsetsize, width);
73   PetscFunctionReturn(PETSC_SUCCESS);
74 }
75