Actual source code: dmarker.c
petsc-3.12.5 2020-03-29
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_",0};
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
21: .seealso: PetscDrawPoint(), PetscDrawString(), PetscDrawSetMarkerType(), PetscDrawGetMarkerType()
23: @*/
24: PetscErrorCode PetscDrawMarker(PetscDraw draw,PetscReal xl,PetscReal yl,int cl)
25: {
30: if (draw->markertype == PETSC_DRAW_MARKER_CROSS){
31: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
32: int i,j,k;
33: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
34: for (k=-2; k<=2; k++) {
35: (*draw->ops->pointpixel)(draw,i+k,j+k,cl);
36: (*draw->ops->pointpixel)(draw,i+k,j-k,cl);
37: }
38: } else if (draw->ops->string) {
39: (*draw->ops->string)(draw,xl,yl,cl,"x");
40: } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type CROSS");
41: } else if (draw->markertype == PETSC_DRAW_MARKER_PLUS){
42: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
43: int i,j,k;
44: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
45: for (k=-2; k<=2; k++) {
46: (*draw->ops->pointpixel)(draw,i,j+k,cl);
47: (*draw->ops->pointpixel)(draw,i+k,j,cl);
48: }
49: } else if (draw->ops->string) {
50: (*draw->ops->string)(draw,xl,yl,cl,"+");
51: } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type PLUS");
52: } else if (draw->markertype == PETSC_DRAW_MARKER_CIRCLE){
53: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
54: int i,j,k;
55: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
56: for (k=-1; k<=1; k++) {
57: (*draw->ops->pointpixel)(draw,i+2,j+k,cl);
58: (*draw->ops->pointpixel)(draw,i-2,j+k,cl);
59: (*draw->ops->pointpixel)(draw,i+k,j+2,cl);
60: (*draw->ops->pointpixel)(draw,i+k,j-2,cl);
61: }
62: } else if (draw->ops->string) {
63: (*draw->ops->string)(draw,xl,yl,cl,"+");
64: } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type CIRCLE");
65: } else {
66: (*draw->ops->point)(draw,xl,yl,cl);
67: }
68: return(0);
69: }
71: /*@
72: PetscDrawSetMarkerType - sets the type of marker to display with PetscDrawMarker()
74: Not collective
76: Input Parameters:
77: + draw - the drawing context
78: - mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT
80: Options Database:
81: . -draw_marker_type - x or point
83: Level: beginner
86: .seealso: PetscDrawPoint(), PetscDrawMarker(), PetscDrawGetMarkerType()
88: @*/
89: PetscErrorCode PetscDrawSetMarkerType(PetscDraw draw,PetscDrawMarkerType mtype)
90: {
93: draw->markertype = mtype;
94: return(0);
95: }
97: /*@
98: PetscDrawGetMarkerType - gets the type of marker to display with PetscDrawMarker()
100: Not collective
102: Input Parameters:
103: + draw - the drawing context
104: - mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT
106: Level: beginner
109: .seealso: PetscDrawPoint(), PetscDrawMarker(), PetscDrawSetMarkerType()
111: @*/
112: PetscErrorCode PetscDrawGetMarkerType(PetscDraw draw,PetscDrawMarkerType *mtype)
113: {
116: *mtype = draw->markertype;
117: return(0);
118: }