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: {
 26:   if (draw->markertype == PETSC_DRAW_MARKER_CROSS) {
 27:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
 28:       int i,j,k;
 29:       (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
 30:       for (k=-2; k<=2; k++) {
 31:         (*draw->ops->pointpixel)(draw,i+k,j+k,cl);
 32:         (*draw->ops->pointpixel)(draw,i+k,j-k,cl);
 33:       }
 34:     } else if (draw->ops->string) {
 35:        (*draw->ops->string)(draw,xl,yl,cl,"x");
 36:     } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type CROSS");
 37:   } else if (draw->markertype == PETSC_DRAW_MARKER_PLUS) {
 38:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
 39:       int 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,j+k,cl);
 43:         (*draw->ops->pointpixel)(draw,i+k,j,cl);
 44:       }
 45:     } else if (draw->ops->string) {
 46:        (*draw->ops->string)(draw,xl,yl,cl,"+");
 47:     } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type PLUS");
 48:   } else if (draw->markertype == PETSC_DRAW_MARKER_CIRCLE) {
 49:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
 50:       int i,j,k;
 51:       (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
 52:       for (k=-1; k<=1; k++) {
 53:         (*draw->ops->pointpixel)(draw,i+2,j+k,cl);
 54:         (*draw->ops->pointpixel)(draw,i-2,j+k,cl);
 55:         (*draw->ops->pointpixel)(draw,i+k,j+2,cl);
 56:         (*draw->ops->pointpixel)(draw,i+k,j-2,cl);
 57:       }
 58:     } else if (draw->ops->string) {
 59:        (*draw->ops->string)(draw,xl,yl,cl,"+");
 60:     } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type CIRCLE");
 61:   } else {
 62:     (*draw->ops->point)(draw,xl,yl,cl);
 63:   }
 64:   return 0;
 65: }

 67: /*@
 68:    PetscDrawSetMarkerType - sets the type of marker to display with PetscDrawMarker()

 70:    Not collective

 72:    Input Parameters:
 73: +  draw - the drawing context
 74: -  mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT

 76:    Options Database:
 77: .  -draw_marker_type - x or point

 79:    Level: beginner

 81: .seealso: PetscDrawPoint(), PetscDrawMarker(), PetscDrawGetMarkerType()

 83: @*/
 84: PetscErrorCode  PetscDrawSetMarkerType(PetscDraw draw,PetscDrawMarkerType mtype)
 85: {
 87:   draw->markertype = mtype;
 88:   return 0;
 89: }

 91: /*@
 92:    PetscDrawGetMarkerType - gets the type of marker to display with PetscDrawMarker()

 94:    Not collective

 96:    Input Parameters:
 97: +  draw - the drawing context
 98: -  mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT

100:    Level: beginner

102: .seealso: PetscDrawPoint(), PetscDrawMarker(), PetscDrawSetMarkerType()

104: @*/
105: PetscErrorCode  PetscDrawGetMarkerType(PetscDraw draw,PetscDrawMarkerType *mtype)
106: {
108:   *mtype = draw->markertype;
109:   return 0;
110: }