Actual source code: ex10.c


  2: static char help[] = "Tests repeatedly setting a window type.\n";

  4: #include <petscsys.h>
  5: #include <petscdraw.h>

  7: int main(int argc, char **argv)
  8: {
  9:   PetscDraw draw;
 10:   int       x = 0, y = 0, width = 300, height = 300;

 12:   PetscFunctionBeginUser;
 13:   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
 14:   PetscCall(PetscDrawCreate(PETSC_COMM_WORLD, 0, "Title", x, y, width, height, &draw));
 15: #if defined(PETSC_HAVE_X)
 16:   PetscCall(PetscDrawSetType(draw, "x"));
 17:   PetscCall(PetscDrawSetType(draw, "null"));
 18:   PetscCall(PetscDrawSetType(draw, "x"));
 19: #else
 20:   PetscCall(PetscDrawSetType(draw, "null"));
 21: #endif
 22:   PetscCall(PetscDrawSetFromOptions(draw));
 23:   PetscCall(PetscDrawSetViewPort(draw, .25, .25, .75, .75));
 24:   PetscCall(PetscDrawClear(draw));
 25:   PetscCall(PetscDrawLine(draw, 0.0, 0.0, 1.0, 1.0, PETSC_DRAW_BLACK));
 26:   PetscCall(PetscDrawString(draw, .2, .2, PETSC_DRAW_RED, "Some Text"));
 27:   PetscCall(PetscDrawStringSetSize(draw, .5, .5));
 28:   PetscCall(PetscDrawString(draw, .2, .2, PETSC_DRAW_BLUE, "Some Text"));
 29:   PetscCall(PetscDrawFlush(draw));
 30:   PetscCall(PetscSleep(2));
 31:   PetscCall(PetscDrawResizeWindow(draw, 600, 600));
 32:   PetscCall(PetscDrawClear(draw));
 33:   PetscCall(PetscSleep(2));
 34:   PetscCall(PetscDrawLine(draw, 0.0, 1.0, 1.0, 0.0, PETSC_DRAW_BLUE));
 35:   PetscCall(PetscDrawFlush(draw));
 36:   PetscCall(PetscSleep(2));
 37:   PetscCall(PetscDrawDestroy(&draw));
 38:   PetscCall(PetscFinalize());
 39:   return 0;
 40: }

 42: /*TEST

 44:    build:
 45:      requires: x

 47:    test:
 48:      output_file: output/ex1_1.out

 50: TEST*/