Actual source code: drawnull.c

      1: #include <petsc/private/drawimpl.h>

      3: static PetscErrorCode PetscDrawCoordinateToPixel_Null(PetscDraw draw,PetscReal x,PetscReal y,int *i,int *j)
      4: {
      5:   *i = *j = 0;
      6:   return 0;
      7: }

      9: static PetscErrorCode PetscDrawPixelToCoordinate_Null(PetscDraw draw,int i,int j,PetscReal *x,PetscReal *y)
     10: {
     11:   *x = *y = 0;
     12:   return 0;
     13: }

     15: static PetscErrorCode PetscDrawPoint_Null(PetscDraw draw,PetscReal x,PetscReal y,int c)
     16: {
     17:   return 0;
     18: }

     20: static PetscErrorCode PetscDrawPointPixel_Null(PetscDraw draw,int x,int y,int c)
     21: {
     22:   return 0;
     23: }

     25: static PetscErrorCode PetscDrawLineGetWidth_Null(PetscDraw draw,PetscReal *width)
     26: {
     27:   if (width) *width = 0.01;
     28:   return 0;
     29: }

     31: static PetscErrorCode PetscDrawLine_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
     32: {
     33:   return 0;
     34: }

     36: static PetscErrorCode PetscDrawArrow_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)
     37: {
     38:   return 0;
     39: }

     41: static PetscErrorCode PetscDrawRectangle_Null(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int c1,int c2,int c3,int c4)
     42: {
     43:   return 0;
     44: }

     46: static PetscErrorCode PetscDrawEllipse_Null(PetscDraw Win,PetscReal x,PetscReal y,PetscReal a,PetscReal b,int c)
     47: {
     48:   return 0;
     49: }

     51: static PetscErrorCode PetscDrawTriangle_Null(PetscDraw draw,PetscReal X1,PetscReal Y_1,PetscReal X2,PetscReal Y2,PetscReal X3,PetscReal Y3,int c1,int c2,int c3)
     52: {
     53:   return 0;
     54: }

     56: static PetscErrorCode PetscDrawStringGetSize_Null(PetscDraw draw,PetscReal *x,PetscReal  *y)
     57: {
     58:   if (x) *x = 0.01;
     59:   if (y) *y = 0.01;
     60:   return 0;
     61: }

     63: static PetscErrorCode PetscDrawString_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[])
     64: {
     65:   return 0;
     66: }

     68: static PetscErrorCode PetscDrawStringVertical_Null(PetscDraw draw,PetscReal x,PetscReal y,int c,const char chrs[])
     69: {
     70:   return 0;
     71: }

     73: static PetscErrorCode PetscDrawStringBoxed_Null(PetscDraw draw,PetscReal sxl,PetscReal syl,int sc,int bc,const char text[],PetscReal *w,PetscReal *h)
     74: {
     75:   if (w) *w = 0.01;
     76:   if (h) *h = 0.01;
     77:   return 0;
     78: }

     80: static PetscErrorCode PetscDrawGetSingleton_Null(PetscDraw draw,PetscDraw *sdraw)
     81: {
     82:   PetscDrawOpenNull(PETSC_COMM_SELF,sdraw);
     83:   return 0;
     84: }

     86: static PetscErrorCode PetscDrawRestoreSingleton_Null(PetscDraw draw,PetscDraw *sdraw)
     87: {
     88:   PetscDrawDestroy(sdraw);
     89:   return 0;
     90: }

     92: static struct _PetscDrawOps DvOps = { NULL,/* PetscDrawSetDoubleBuffer_Null */
     93:                                       NULL,/* PetscDrawFlush_Null */
     94:                                       PetscDrawLine_Null,
     95:                                       NULL,/* PetscDrawLineSetWidth_Null */
     96:                                       PetscDrawLineGetWidth_Null,
     97:                                       PetscDrawPoint_Null,
     98:                                       NULL,/* PetscDrawPointSetSize_Null */
     99:                                       PetscDrawString_Null,
    100:                                       PetscDrawStringVertical_Null,
    101:                                       NULL,/* PetscDrawStringSetSize_Null */
    102:                                       PetscDrawStringGetSize_Null,
    103:                                       NULL,/* PetscDrawSetViewport_Null */
    104:                                       NULL,/* PetscDrawClear_Null */
    105:                                       PetscDrawRectangle_Null,
    106:                                       PetscDrawTriangle_Null,
    107:                                       PetscDrawEllipse_Null,
    108:                                       NULL,/* PetscDrawGetMouseButton_Null */
    109:                                       NULL,/* PetscDrawPause_Null */
    110:                                       NULL,/* PetscDrawBeginPage_Null */
    111:                                       NULL,/* PetscDrawEndPage_Null */
    112:                                       NULL,/* PetscDrawGetPopup_Null */
    113:                                       NULL,/* PetscDrawSetTitle_Null */
    114:                                       NULL,/* PetscDrawCheckResizedWindow_Null */
    115:                                       NULL,/* PetscDrawResizeWindow_Null */
    116:                                       NULL,/* PetscDrawDestroy_Null */
    117:                                       NULL,/* PetscDrawView_Null */
    118:                                       PetscDrawGetSingleton_Null,
    119:                                       PetscDrawRestoreSingleton_Null,
    120:                                       NULL,/* PetscDrawSave_Null */
    121:                                       NULL,/* PetscDrawGetImage_Null */
    122:                                       NULL,/* PetscDrawSetCoordinates_Null */
    123:                                       PetscDrawArrow_Null,
    124:                                       PetscDrawCoordinateToPixel_Null,
    125:                                       PetscDrawPixelToCoordinate_Null,
    126:                                       PetscDrawPointPixel_Null,
    127:                                       PetscDrawStringBoxed_Null};

    129: /*MC
    130:      PETSC_DRAW_NULL - PETSc graphics device that ignores all draw commands

    132:    Level: beginner

    134: .seealso:  PetscDrawOpenNull(), PetscDrawIsNull()
    135: M*/
    136: PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw);

    138: PETSC_EXTERN PetscErrorCode PetscDrawCreate_Null(PetscDraw draw)
    139: {
    140:   draw->pause   = 0;
    141:   draw->coor_xl = 0; draw->coor_xr = 1;
    142:   draw->coor_yl = 0; draw->coor_yr = 1;
    143:   draw->port_xl = 0; draw->port_xr = 1;
    144:   draw->port_yl = 0; draw->port_yr = 1;
    145:   PetscDrawDestroy(&draw->popup);

    147:   PetscMemcpy(draw->ops,&DvOps,sizeof(DvOps));
    148:   draw->data = NULL;
    149:   return 0;
    150: }

    152: /*@
    153:    PetscDrawOpenNull - Opens a null drawing context. All draw commands to
    154:    it are ignored.

    156:    Input Parameter:
    157: .  comm - MPI communicator

    159:    Output Parameter:
    160: .  draw - the drawing context

    162:    Level: advanced
    163: @*/
    164: PetscErrorCode  PetscDrawOpenNull(MPI_Comm comm,PetscDraw *win)
    165: {
    166:   PetscDrawCreate(comm,NULL,NULL,0,0,1,1,win);
    167:   PetscDrawSetType(*win,PETSC_DRAW_NULL);
    168:   return 0;
    169: }

    171: /*@
    172:    PetscDrawIsNull - Returns PETSC_TRUE if draw is a null draw object.

    174:    Not collective

    176:    Input Parameter:
    177: .  draw - the draw context

    179:    Output Parameter:
    180: .  yes - PETSC_TRUE if it is a null draw object; otherwise PETSC_FALSE

    182:    Level: advanced
    183: @*/
    184: PetscErrorCode  PetscDrawIsNull(PetscDraw draw,PetscBool *yes)
    185: {
    188:   PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,yes);
    189:   return 0;
    190: }