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 - PetscDraws 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: PetscDrawPoint(), PetscDrawString(), PetscDrawSetMarkerType(), PetscDrawGetMarkerType()
22: @*/
23: PetscErrorCode PetscDrawMarker(PetscDraw draw,PetscReal xl,PetscReal yl,int cl)
24: {
29: if (draw->markertype == PETSC_DRAW_MARKER_CROSS) {
30: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
31: int i,j,k;
32: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
33: for (k=-2; k<=2; k++) {
34: (*draw->ops->pointpixel)(draw,i+k,j+k,cl);
35: (*draw->ops->pointpixel)(draw,i+k,j-k,cl);
36: }
37: } else if (draw->ops->string) {
38: (*draw->ops->string)(draw,xl,yl,cl,"x");
39: } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type CROSS");
40: } else if (draw->markertype == PETSC_DRAW_MARKER_PLUS) {
41: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
42: int i,j,k;
43: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
44: for (k=-2; k<=2; k++) {
45: (*draw->ops->pointpixel)(draw,i,j+k,cl);
46: (*draw->ops->pointpixel)(draw,i+k,j,cl);
47: }
48: } else if (draw->ops->string) {
49: (*draw->ops->string)(draw,xl,yl,cl,"+");
50: } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type PLUS");
51: } else if (draw->markertype == PETSC_DRAW_MARKER_CIRCLE) {
52: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
53: int i,j,k;
54: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
55: for (k=-1; k<=1; k++) {
56: (*draw->ops->pointpixel)(draw,i+2,j+k,cl);
57: (*draw->ops->pointpixel)(draw,i-2,j+k,cl);
58: (*draw->ops->pointpixel)(draw,i+k,j+2,cl);
59: (*draw->ops->pointpixel)(draw,i+k,j-2,cl);
60: }
61: } else if (draw->ops->string) {
62: (*draw->ops->string)(draw,xl,yl,cl,"+");
63: } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type CIRCLE");
64: } else {
65: (*draw->ops->point)(draw,xl,yl,cl);
66: }
67: return(0);
68: }
70: /*@
71: PetscDrawSetMarkerType - sets the type of marker to display with PetscDrawMarker()
73: Not collective
75: Input Parameters:
76: + draw - the drawing context
77: - mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT
79: Options Database:
80: . -draw_marker_type - x or point
82: Level: beginner
84: .seealso: PetscDrawPoint(), PetscDrawMarker(), PetscDrawGetMarkerType()
86: @*/
87: PetscErrorCode PetscDrawSetMarkerType(PetscDraw draw,PetscDrawMarkerType mtype)
88: {
91: draw->markertype = mtype;
92: return(0);
93: }
95: /*@
96: PetscDrawGetMarkerType - gets the type of marker to display with PetscDrawMarker()
98: Not collective
100: Input Parameters:
101: + draw - the drawing context
102: - mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT
104: Level: beginner
106: .seealso: PetscDrawPoint(), PetscDrawMarker(), PetscDrawSetMarkerType()
108: @*/
109: PetscErrorCode PetscDrawGetMarkerType(PetscDraw draw,PetscDrawMarkerType *mtype)
110: {
113: *mtype = draw->markertype;
114: return(0);
115: }