Actual source code: ex4.c
1: static char help[] = "Demonstrates use of PetscDrawZoom()\n";
3: #if defined(PETSC_APPLE_FRAMEWORK)
4: #include <PETSc/petscsys.h>
5: #include <PETSc/petscdraw.h>
6: #else
7: #include <petscsys.h>
8: #include <petscdraw.h>
9: #endif
11: PetscErrorCode zoomfunction(PetscDraw draw, void *dummy)
12: {
13: MPI_Comm comm;
14: PetscMPIInt size, rank;
16: PetscFunctionBeginUser;
17: PetscCall(PetscObjectGetComm((PetscObject)draw, &comm));
18: PetscCallMPI(MPI_Comm_size(comm, &size));
19: PetscCallMPI(MPI_Comm_rank(comm, &rank));
20: for (int 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: PetscFunctionReturn(PETSC_SUCCESS);
25: }
27: int main(int argc, char **argv)
28: {
29: int x = 0, y = 0, width = 256, height = 256;
30: PetscDraw draw;
32: PetscFunctionBeginUser;
33: PetscCall(PetscInitialize(&argc, &argv, NULL, help));
34: PetscCall(PetscDrawCreate(PETSC_COMM_WORLD, NULL, "Title", x, y, width, height, &draw));
35: PetscCall(PetscDrawSetFromOptions(draw));
36: PetscCall(PetscDrawZoom(draw, zoomfunction, NULL));
37: PetscCall(PetscDrawDestroy(&draw));
38: PetscCall(PetscFinalize());
39: return 0;
40: }
42: /*TEST
44: build:
45: requires: x
47: test:
48: output_file: output/empty.out
50: test:
51: suffix: db
52: args: -draw_double_buffer 0
53: output_file: output/empty.out
55: test:
56: suffix: df
57: args: -draw_fast
58: output_file: output/empty.out
60: test:
61: suffix: dv
62: args: -draw_virtual
63: output_file: output/empty.out
65: TEST*/