xref: /petsc/src/sys/classes/draw/interface/dpoint.c (revision 29912973eddc2d63379123316d6141c93d64bbc2)
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 - horizatonal coordinate of the point
12 .  yl - vertical coordinate of the point
13 -  cl - the color of the point
14 
15    Level: beginner
16 
17 .seealso: `PetscDraw`, `PetscDrawPointPixel()`, `PetscDrawPointSetSize()`, `PetscDrawLine()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`,
18           `PetscDrawMarker()`, `PetscDrawString()`, `PetscDrawArrow()`
19 @*/
20 PetscErrorCode PetscDrawPoint(PetscDraw draw, PetscReal xl, PetscReal yl, int cl)
21 {
22   PetscFunctionBegin;
23   PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
24   PetscUseTypeMethod(draw, point, xl, yl, cl);
25   PetscFunctionReturn(PETSC_SUCCESS);
26 }
27 
28 /*@
29    PetscDrawPointPixel - draws a point onto a drawable, in pixel coordinates
30 
31    Not Collective
32 
33    Input Parameters:
34 +  draw - the drawing context
35 .  x - horizontal pixel coordinates of the point
36 .  y - vertical pixel coordinates of the point
37 -  c - the color of the point
38 
39    Level: beginner
40 
41 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawPointSetSize()`
42 @*/
43 PetscErrorCode PetscDrawPointPixel(PetscDraw draw, int x, int y, int c)
44 {
45   PetscFunctionBegin;
46   PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
47   PetscUseTypeMethod(draw, pointpixel, x, y, c);
48   PetscFunctionReturn(PETSC_SUCCESS);
49 }
50 
51 /*@
52    PetscDrawPointSetSize - Sets the point size for future draws.  The size is
53    relative to the user coordinates of the window; 0.0 denotes the natural
54    width, 1.0 denotes the entire viewport.
55 
56    Not Collective
57 
58    Input Parameters:
59 +  draw - the drawing context
60 -  width - the width in user coordinates
61 
62    Level: advanced
63 
64    Note:
65    Even a size of zero insures that a single pixel is colored.
66 
67 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawMarker()`
68 @*/
69 PetscErrorCode PetscDrawPointSetSize(PetscDraw draw, PetscReal width)
70 {
71   PetscFunctionBegin;
72   PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
73   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);
74   PetscTryTypeMethod(draw, pointsetsize, width);
75   PetscFunctionReturn(PETSC_SUCCESS);
76 }
77