xref: /petsc/src/sys/classes/draw/tests/ex4.c (revision a69119a591a03a9d906b29c0a4e9802e4d7c9795)
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   int         i;
15   MPI_Comm    comm = PetscObjectComm((PetscObject)draw);
16   PetscMPIInt size, rank;
17 
18   PetscCallMPI(MPI_Comm_size(comm, &size));
19   PetscCallMPI(MPI_Comm_rank(comm, &rank));
20   for (i = rank; i < 256; i += size) {
21     PetscReal y = ((PetscReal)i) / (256 - 1);
22     PetscCall(PetscDrawLine(draw, 0.0, y, 1.0, y, i));
23   }
24   return 0;
25 }
26 
27 int main(int argc, char **argv) {
28   int       x = 0, y = 0, width = 256, height = 256;
29   PetscDraw draw;
30 
31   PetscFunctionBeginUser;
32   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
33   PetscCall(PetscDrawCreate(PETSC_COMM_WORLD, NULL, "Title", x, y, width, height, &draw));
34   PetscCall(PetscDrawSetFromOptions(draw));
35   PetscCall(PetscDrawZoom(draw, zoomfunction, NULL));
36   PetscCall(PetscDrawDestroy(&draw));
37   PetscCall(PetscFinalize());
38   return 0;
39 }
40 
41 /*TEST
42 
43    build:
44      requires: x
45 
46    test:
47      output_file: output/ex1_1.out
48 
49    test:
50      suffix: db
51      args: -draw_double_buffer 0
52      output_file: output/ex1_1.out
53 
54    test:
55      suffix: df
56      args: -draw_fast
57      output_file: output/ex1_1.out
58 
59    test:
60      suffix: dv
61      args: -draw_virtual
62      output_file: output/ex1_1.out
63 
64 TEST*/
65