Actual source code: dmarker.c

petsc-3.7.5 2017-01-01
Report Typos and Errors
  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: {

 34:   if (draw->markertype == PETSC_DRAW_MARKER_CROSS){
 35:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
 36:       int i,j,k;
 37:       (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
 38:       for (k=-2; k<=2; k++) {
 39:         (*draw->ops->pointpixel)(draw,i+k,j+k,cl);
 40:         (*draw->ops->pointpixel)(draw,i+k,j-k,cl);
 41:       }
 42:     } else if (draw->ops->string) {
 43:        (*draw->ops->string)(draw,xl,yl,cl,"x");
 44:     } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type CROSS");
 45:   } else if (draw->markertype == PETSC_DRAW_MARKER_PLUS){
 46:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
 47:       int i,j,k;
 48:       (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
 49:       for (k=-2; k<=2; k++) {
 50:         (*draw->ops->pointpixel)(draw,i,j+k,cl);
 51:         (*draw->ops->pointpixel)(draw,i+k,j,cl);
 52:       }
 53:     } else if (draw->ops->string) {
 54:        (*draw->ops->string)(draw,xl,yl,cl,"+");
 55:     } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type PLUS");
 56:   } else if (draw->markertype == PETSC_DRAW_MARKER_CIRCLE){
 57:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
 58:       int i,j,k;
 59:       (*draw->ops->coordinatetopixel)(draw,xl,yl,&i,&j);
 60:       for (k=-1; k<=1; k++) {
 61:         (*draw->ops->pointpixel)(draw,i+2,j+k,cl);
 62:         (*draw->ops->pointpixel)(draw,i-2,j+k,cl);
 63:         (*draw->ops->pointpixel)(draw,i+k,j+2,cl);
 64:         (*draw->ops->pointpixel)(draw,i+k,j-2,cl);
 65:       }
 66:     } else if (draw->ops->string) {
 67:        (*draw->ops->string)(draw,xl,yl,cl,"+");
 68:     } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"No support for drawing marker type CIRCLE");
 69:   } else {
 70:     (*draw->ops->point)(draw,xl,yl,cl);
 71:   }
 72:   return(0);
 73: }

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

 80:    Not collective

 82:    Input Parameters:
 83: +  draw - the drawing context
 84: -  mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT

 86:    Options Database:
 87: .  -draw_marker_type - x or point

 89:    Level: beginner

 91:    Concepts: marker^drawing
 92:    Concepts: drawing^marker

 94: .seealso: PetscDrawPoint(), PetscDrawMarker()

 96: @*/
 97: PetscErrorCode  PetscDrawSetMarkerType(PetscDraw draw,PetscDrawMarkerType mtype)
 98: {
101:   draw->markertype = mtype;
102:   return(0);
103: }

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

110:    Not collective

112:    Input Parameters:
113: +  draw - the drawing context
114: -  mtype - either PETSC_DRAW_MARKER_CROSS (default) or PETSC_DRAW_MARKER_POINT

116:    Level: beginner

118:    Concepts: marker^drawing
119:    Concepts: drawing^marker

121: .seealso: PetscDrawPoint(), PetscDrawMarker()

123: @*/
124: PetscErrorCode  PetscDrawGetMarkerType(PetscDraw draw,PetscDrawMarkerType *mtype)
125: {
128:   *mtype = draw->markertype;
129:   return(0);
130: }