Date: 2025-03-29T05:58:42+00:00

Actual source code: dmarker.c

      1: /*
      2:        Provides the calling sequences for all the basic PetscDraw routines.
      3: */
      4: #include <petsc/private/drawimpl.h>
      5: const char *const PetscDrawMarkerTypes[] = {"CROSS", "POINT", "PLUS", "CIRCLE", "PetscDrawMarkerType", "PETSC_DRAW_MARKER_", NULL};

      7: /*@
      8:   PetscDrawMarker - draws a marker onto a drawable.

     10:   Not Collective

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

     18:   Level: beginner

     20: .seealso: `PetscDraw`, `PetscDrawPoint()`, `PetscDrawString()`, `PetscDrawSetMarkerType()`, `PetscDrawGetMarkerType()`
     21: @*/
     22: PetscErrorCode PetscDrawMarker(PetscDraw draw, PetscReal xl, PetscReal yl, int cl)
     23: {
     24:   PetscFunctionBegin;
     26:   if (draw->markertype == PETSC_DRAW_MARKER_CROSS) {
     27:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
     28:       int i, j, k;
     29:       PetscUseTypeMethod(draw, coordinatetopixel, xl, yl, &i, &j);
     30:       for (k = -2; k <= 2; k++) {
     31:         PetscUseTypeMethod(draw, pointpixel, i + k, j + k, cl);
     32:         PetscUseTypeMethod(draw, pointpixel, i + k, j - k, cl);
     33:       }
     34:     } else PetscUseTypeMethod(draw, string, xl, yl, cl, "x");
     35:   } else if (draw->markertype == PETSC_DRAW_MARKER_PLUS) {
     36:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
     37:       int i, j, k;
     38:       PetscUseTypeMethod(draw, coordinatetopixel, xl, yl, &i, &j);
     39:       for (k = -2; k <= 2; k++) {
     40:         PetscUseTypeMethod(draw, pointpixel, i, j + k, cl);
     41:         PetscUseTypeMethod(draw, pointpixel, i + k, j, cl);
     42:       }
     43:     } else PetscUseTypeMethod(draw, string, xl, yl, cl, "+");
     44:   } else if (draw->markertype == PETSC_DRAW_MARKER_CIRCLE) {
     45:     if (draw->ops->coordinatetopixel && draw->ops->pointpixel) {
     46:       int i, j, k;
     47:       PetscUseTypeMethod(draw, coordinatetopixel, xl, yl, &i, &j);
     48:       for (k = -1; k <= 1; k++) {
     49:         PetscUseTypeMethod(draw, pointpixel, i + 2, j + k, cl);
     50:         PetscUseTypeMethod(draw, pointpixel, i - 2, j + k, cl);
     51:         PetscUseTypeMethod(draw, pointpixel, i + k, j + 2, cl);
     52:         PetscUseTypeMethod(draw, pointpixel, i + k, j - 2, cl);
     53:       }
     54:     } else PetscUseTypeMethod(draw, string, xl, yl, cl, "+");
     55:   } else PetscUseTypeMethod(draw, point, xl, yl, cl);
     56:   PetscFunctionReturn(PETSC_SUCCESS);
     57: }

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

     62:   Not Collective

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

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

     71:   Level: beginner

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

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

     86:   Not Collective

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

     92:   Level: beginner

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