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 - draws a marker onto a drawable.

 11:    Not Collective

 13:    Input Parameters:
 14: +  draw - the drawing context
 15: .  xl - horizontal coordinate of the marker
 16: .  yl - vertical coordinate of the marker
 17: -  cl - the color of the marker

 19:    Level: beginner

 21: .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawString()`, `PetscDrawSetMarkerType()`, `PetscDrawGetMarkerType()`
 22: @*/
 23: PetscErrorCode PetscDrawMarker(PetscDraw draw, PetscReal xl, PetscReal yl, int cl)
 24: {
 25:   PetscFunctionBegin;
 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(PETSC_SUCCESS);
 58: }

 60: /*@
 61:    PetscDrawSetMarkerType - sets the type of marker to display with `PetscDrawMarker()`

 63:    Not Collective

 65:    Input Parameters:
 66: +  draw - the drawing context
 67: -  mtype - either `PETSC_DRAW_MARKER_CROSS` (default) or `PETSC_DRAW_MARKER_POINT`

 69:    Options Database Key:
 70: .  -draw_marker_type - x or point

 72:    Level: beginner

 74: .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawMarker()`, `PetscDrawGetMarkerType()`, `PetscDrawMarkerType`
 75: @*/
 76: PetscErrorCode PetscDrawSetMarkerType(PetscDraw draw, PetscDrawMarkerType mtype)
 77: {
 78:   PetscFunctionBegin;
 80:   draw->markertype = mtype;
 81:   PetscFunctionReturn(PETSC_SUCCESS);
 82: }

 84: /*@
 85:    PetscDrawGetMarkerType - gets the type of marker to display with `PetscDrawMarker()`

 87:    Not Collective

 89:    Input Parameters:
 90: +  draw - the drawing context
 91: -  mtype - either `PETSC_DRAW_MARKER_CROSS` (default) or `PETSC_DRAW_MARKER_POINT`

 93:    Level: beginner

 95: .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawMarker()`, `PetscDrawSetMarkerType()`, `PetscDrawMarkerType`
 96: @*/
 97: PetscErrorCode PetscDrawGetMarkerType(PetscDraw draw, PetscDrawMarkerType *mtype)
 98: {
 99:   PetscFunctionBegin;
101:   *mtype = draw->markertype;
102:   PetscFunctionReturn(PETSC_SUCCESS);
103: }