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