Actual source code: ex1.c
petsc-3.13.6 2020-09-29
2: static char help[] = "Demonstrates opening and drawing in a window\n";
4: #include <petscsys.h>
5: #include <petscdraw.h>
7: int main(int argc,char **argv)
8: {
9: PetscDraw draw;
11: int x = 0,y = 0,width = 300,height = 300;
13: PetscInitialize(&argc,&argv,NULL,help);if (ierr) return ierr;
15: PetscDrawCreate(PETSC_COMM_WORLD,0,"Title",x,y,width,height,&draw);
16: PetscDrawSetPause(draw,2.0);
17: PetscDrawSetFromOptions(draw);
18: PetscDrawSetViewPort(draw,.25,.25,.75,.75);
20: PetscDrawLine(draw,0.0,0.0,1.0,1.0,PETSC_DRAW_BLACK);
21: PetscDrawString(draw,.2,.2,PETSC_DRAW_RED,"Some Text");
22: PetscDrawString(draw,.5,.5,PETSC_DRAW_GREEN,"Some Text");
23: PetscDrawString(draw,.2,.8,PETSC_DRAW_BLUE,"Some Text");
24: PetscDrawFlush(draw);
25: PetscDrawPause(draw);
26: PetscDrawSave(draw);
28: PetscDrawClear(draw);
29: /*PetscDrawStringSetSize(draw,.5,.5);*/
30: PetscDrawString(draw,.2,.2,PETSC_DRAW_RED,"Some Text");
31: PetscDrawString(draw,.5,.5,PETSC_DRAW_GREEN,"Some Text");
32: PetscDrawString(draw,.2,.8,PETSC_DRAW_BLUE,"Some Text");
33: PetscDrawFlush(draw);
34: PetscDrawPause(draw);
35: PetscDrawSave(draw);
37: PetscDrawResizeWindow(draw,600,600);
38: PetscDrawGetWindowSize(draw,&width,&height);
39: PetscDrawSetViewPort(draw,0,0,1,1);
40: PetscDrawClear(draw);
41: /*PetscDrawLine(draw,0.0,0.0,1.0,1.0,PETSC_DRAW_RED);*/
42: /*PetscDrawLine(draw,0.0,1.0,1.0,0.0,PETSC_DRAW_BLUE);*/
43: PetscDrawString(draw,.2,.2,PETSC_DRAW_RED,"Some Text\n Some Other Text");
44: PetscDrawString(draw,.5,.5,PETSC_DRAW_RED,"ABCygj\n()[]F$");
45: PetscDrawString(draw,0,0,PETSC_DRAW_RED,"Horizontal Text (ABCygj)");
46: PetscDrawStringVertical(draw,0,1,PETSC_DRAW_RED,"Vertical Text");
47: PetscDrawFlush(draw);
48: PetscDrawPause(draw);
49: PetscDrawSave(draw);
51: PetscDrawDestroy(&draw);
52: PetscFinalize();
53: return ierr;
54: }
58: /*TEST
60: build:
61: requires: x
63: test:
64: output_file: output/ex1_1.out
66: TEST*/