Actual source code: dmarker.c
petsc-3.6.1 2015-08-06
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_",0};
10: /*@
11: PetscDrawMarker - PetscDraws a marker onto a drawable.
13: Not collective
15: Input Parameters:
16: + draw - the drawing context
17: . xl,yl - the coordinates of the marker
18: - cl - the color of the marker
20: Level: beginner
22: Concepts: marker^drawing
23: Concepts: drawing^marker
25: .seealso: PetscDrawPoint(), PetscDrawString(), PetscDrawSetMarkerType()
27: @*/
28: PetscErrorCode PetscDrawMarker(PetscDraw draw,PetscReal xl,PetscReal yl,int cl)
29: {
31: PetscBool isnull;
35: PetscDrawIsNull(draw,&isnull);
36: if (isnull) return(0);
37: if (draw->markertype == PETSC_DRAW_MARKER_CROSS){
38: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
39: PetscInt i,j,k;
40: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
41: for (k=-2; k<=2; k++) {
42: (*draw->ops->pointpixel)(draw,i+k,j+k,cl);
43: (*draw->ops->pointpixel)(draw,i+k,j-k,cl);
44: }
45: } else if (draw->ops->string) {
46: (*draw->ops->string)(draw,xl,yl,cl,"x");
47: } else SETERRQ(PetscObjectComm((PetscObject)draw),PETSC_ERR_SUP,"No support for drawing marker type CROSS");
48: } else if (draw->markertype == PETSC_DRAW_MARKER_PLUS){
49: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
50: PetscInt i,j,k;
51: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
52: for (k=-2; k<=2; k++) {
53: (*draw->ops->pointpixel)(draw,i,j+k,cl);
54: (*draw->ops->pointpixel)(draw,i+k,j,cl);
55: }
56: } else if (draw->ops->string) {
57: (*draw->ops->string)(draw,xl,yl,cl,"+");
58: } else SETERRQ(PetscObjectComm((PetscObject)draw),PETSC_ERR_SUP,"No support for drawing marker type PLUS");
59: } else if (draw->markertype == PETSC_DRAW_MARKER_CIRCLE){
60: if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
61: PetscInt i,j,k;
62: (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
63: for (k=-1; k<=1; k++) {
64: (*draw->ops->pointpixel)(draw,i+2,j+k,cl);
65: (*draw->ops->pointpixel)(draw,i-2,j+k,cl);
66: (*draw->ops->pointpixel)(draw,i+k,j+2,cl);
67: (*draw->ops->pointpixel)(draw,i+k,j-2,cl);
68: }
69: } else if (draw->ops->string) {
70: (*draw->ops->string)(draw,xl,yl,cl,"+");
71: } else SETERRQ(PetscObjectComm((PetscObject)draw),PETSC_ERR_SUP,"No support for drawing marker type CIRCLE");
72: } else {
73: (*draw->ops->point)(draw,xl,yl,cl);
74: }
75: return(0);
76: }
80: /*@
81: PetscDrawSetMarkerType - sets the type of marker to display with PetscDrawMarker()
83: Not collective
85: Input Parameters:
86: + draw - the drawing context
87: - mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT
89: Options Database:
90: . -draw_marker_type - x or point
92: Level: beginner
94: Concepts: marker^drawing
95: Concepts: drawing^marker
97: .seealso: PetscDrawPoint(), PetscDrawMarker()
99: @*/
100: PetscErrorCode PetscDrawSetMarkerType(PetscDraw draw,PetscDrawMarkerType mtype)
101: {
104: draw->markertype = mtype;
105: return(0);
106: }
110: /*@
111: PetscDrawGetMarkerType - gets the type of marker to display with PetscDrawMarker()
113: Not collective
115: Input Parameters:
116: + draw - the drawing context
117: - mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT
119: Level: beginner
121: Concepts: marker^drawing
122: Concepts: drawing^marker
124: .seealso: PetscDrawPoint(), PetscDrawMarker()
126: @*/
127: PetscErrorCode PetscDrawGetMarkerType(PetscDraw draw,PetscDrawMarkerType *mtype)
128: {
131: *mtype = draw->markertype;
132: return(0);
133: }