xref: /petsc/src/sys/classes/draw/tests/ex4.c (revision 0e03b746557e2551025fde0294144c0532d12f68)
1 
2 static char help[] = "Demonstrates use of PetscDrawZoom()\n";
3 
4 #if defined(PETSC_APPLE_FRAMEWORK)
5 
6 #include <PETSc/petscsys.h>
7 #include <PETSc/petscdraw.h>
8 #else
9 #include <petscsys.h>
10 #include <petscdraw.h>
11 #endif
12 
13 PetscErrorCode zoomfunction(PetscDraw draw,void *dummy)
14 {
15   int            i;
16   MPI_Comm       comm = PetscObjectComm((PetscObject)draw);
17   PetscMPIInt    size,rank;
18   PetscErrorCode ierr;
19 
20   ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr);
21   ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr);
22   for (i=rank; i<256; i+=size) {
23     PetscReal y = ((PetscReal)i)/(256-1);
24     ierr = PetscDrawLine(draw,0.0,y,1.0,y,i);CHKERRQ(ierr);
25   }
26   return 0;
27 }
28 
29 int main(int argc,char **argv)
30 {
31   int            x = 0,y = 0,width = 256,height = 256;
32   PetscDraw      draw;
33   PetscErrorCode ierr;
34 
35   ierr = PetscInitialize(&argc,&argv,NULL,help);if (ierr) return ierr;
36   ierr = PetscDrawCreate(PETSC_COMM_WORLD,NULL,"Title",x,y,width,height,&draw);CHKERRQ(ierr);
37   ierr = PetscDrawSetFromOptions(draw);CHKERRQ(ierr);
38   ierr = PetscDrawZoom(draw,zoomfunction,NULL);CHKERRQ(ierr);
39   ierr = PetscDrawDestroy(&draw);CHKERRQ(ierr);
40   ierr = PetscFinalize();
41   return ierr;
42 }
43 
44 
45 
46 
47 /*TEST
48 
49    build:
50      requires: x
51 
52    test:
53      output_file: output/ex1_1.out
54 
55    test:
56      suffix: db
57      args: -draw_double_buffer 0
58      output_file: output/ex1_1.out
59 
60    test:
61      suffix: df
62      args: -draw_fast
63      output_file: output/ex1_1.out
64 
65    test:
66      suffix: dv
67      args: -draw_virtual
68      output_file: output/ex1_1.out
69 
70 TEST*/
71