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