1 /*
2 Provides the calling sequences for all the basic PetscDraw routines.
3 */
4 #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/
5 const char *const PetscDrawMarkerTypes[] = {"CROSS", "POINT", "PLUS", "CIRCLE", "PetscDrawMarkerType", "PETSC_DRAW_MARKER_", NULL};
6
7 /*@
8 PetscDrawMarker - draws a marker onto a drawable.
9
10 Not Collective
11
12 Input Parameters:
13 + draw - the drawing context
14 . xl - horizontal coordinate of the marker
15 . yl - vertical coordinate of the marker
16 - cl - the color of the marker
17
18 Level: beginner
19
20 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawString()`, `PetscDrawSetMarkerType()`, `PetscDrawGetMarkerType()`
21 @*/
PetscDrawMarker(PetscDraw draw,PetscReal xl,PetscReal yl,int cl)22 PetscErrorCode PetscDrawMarker(PetscDraw draw, PetscReal xl, PetscReal yl, int cl)
23 {
24 PetscFunctionBegin;
25 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
26 if (draw->markertype == PETSC_DRAW_MARKER_CROSS) {
27 if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
28 int i, j, k;
29 PetscUseTypeMethod(draw, coordinatetopixel, xl, yl, &i, &j);
30 for (k = -2; k <= 2; k++) {
31 PetscUseTypeMethod(draw, pointpixel, i + k, j + k, cl);
32 PetscUseTypeMethod(draw, pointpixel, i + k, j - k, cl);
33 }
34 } else PetscUseTypeMethod(draw, string, xl, yl, cl, "x");
35 } else if (draw->markertype == PETSC_DRAW_MARKER_PLUS) {
36 if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
37 int i, j, k;
38 PetscUseTypeMethod(draw, coordinatetopixel, xl, yl, &i, &j);
39 for (k = -2; k <= 2; k++) {
40 PetscUseTypeMethod(draw, pointpixel, i, j + k, cl);
41 PetscUseTypeMethod(draw, pointpixel, i + k, j, cl);
42 }
43 } else PetscUseTypeMethod(draw, string, xl, yl, cl, "+");
44 } else if (draw->markertype == PETSC_DRAW_MARKER_CIRCLE) {
45 if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
46 int i, j, k;
47 PetscUseTypeMethod(draw, coordinatetopixel, xl, yl, &i, &j);
48 for (k = -1; k <= 1; k++) {
49 PetscUseTypeMethod(draw, pointpixel, i + 2, j + k, cl);
50 PetscUseTypeMethod(draw, pointpixel, i - 2, j + k, cl);
51 PetscUseTypeMethod(draw, pointpixel, i + k, j + 2, cl);
52 PetscUseTypeMethod(draw, pointpixel, i + k, j - 2, cl);
53 }
54 } else PetscUseTypeMethod(draw, string, xl, yl, cl, "+");
55 } else PetscUseTypeMethod(draw, point, xl, yl, cl);
56 PetscFunctionReturn(PETSC_SUCCESS);
57 }
58
59 /*@
60 PetscDrawSetMarkerType - sets the type of marker to display with `PetscDrawMarker()`
61
62 Not Collective
63
64 Input Parameters:
65 + draw - the drawing context
66 - mtype - either `PETSC_DRAW_MARKER_CROSS` (default) or `PETSC_DRAW_MARKER_POINT`
67
68 Options Database Key:
69 . -draw_marker_type - x or point
70
71 Level: beginner
72
73 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawMarker()`, `PetscDrawGetMarkerType()`, `PetscDrawMarkerType`
74 @*/
PetscDrawSetMarkerType(PetscDraw draw,PetscDrawMarkerType mtype)75 PetscErrorCode PetscDrawSetMarkerType(PetscDraw draw, PetscDrawMarkerType mtype)
76 {
77 PetscFunctionBegin;
78 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
79 draw->markertype = mtype;
80 PetscFunctionReturn(PETSC_SUCCESS);
81 }
82
83 /*@
84 PetscDrawGetMarkerType - gets the type of marker to display with `PetscDrawMarker()`
85
86 Not Collective
87
88 Input Parameters:
89 + draw - the drawing context
90 - mtype - either `PETSC_DRAW_MARKER_CROSS` (default) or `PETSC_DRAW_MARKER_POINT`
91
92 Level: beginner
93
94 .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawMarker()`, `PetscDrawSetMarkerType()`, `PetscDrawMarkerType`
95 @*/
PetscDrawGetMarkerType(PetscDraw draw,PetscDrawMarkerType * mtype)96 PetscErrorCode PetscDrawGetMarkerType(PetscDraw draw, PetscDrawMarkerType *mtype)
97 {
98 PetscFunctionBegin;
99 PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
100 *mtype = draw->markertype;
101 PetscFunctionReturn(PETSC_SUCCESS);
102 }
103