xref: /petsc/src/sys/classes/draw/interface/dpoint.c (revision 66af8762ec03dbef0e079729eb2a1734a35ed7ff)
1 #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/
2 
3 /*@
4   PetscDrawPoint - draws a point onto a drawable.
5 
6   Not Collective
7 
8   Input Parameters:
9 + draw - the drawing context
10 . xl   - horizatonal coordinate of the point
11 . yl   - vertical coordinate 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    - horizontal pixel coordinates of the point
35 . y    - vertical pixel coordinates of the point
36 - c    - the color of the point
37 
38   Level: beginner
39 
40 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawPointSetSize()`
41 @*/
42 PetscErrorCode PetscDrawPointPixel(PetscDraw draw, int x, int y, int c)
43 {
44   PetscFunctionBegin;
45   PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
46   PetscUseTypeMethod(draw, pointpixel, x, y, c);
47   PetscFunctionReturn(PETSC_SUCCESS);
48 }
49 
50 /*@
51   PetscDrawPointSetSize - Sets the point size for future draws.  The size is
52   relative to the user coordinates of the window; 0.0 denotes the natural
53   width, 1.0 denotes the entire viewport.
54 
55   Not Collective
56 
57   Input Parameters:
58 + draw  - the drawing context
59 - width - the width in user coordinates
60 
61   Level: advanced
62 
63   Note:
64   Even a size of zero insures that a single pixel is colored.
65 
66 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawMarker()`
67 @*/
68 PetscErrorCode PetscDrawPointSetSize(PetscDraw draw, PetscReal width)
69 {
70   PetscFunctionBegin;
71   PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
72   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);
73   PetscTryTypeMethod(draw, pointsetsize, width);
74   PetscFunctionReturn(PETSC_SUCCESS);
75 }
76