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