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 19 PetscCallMPI(MPI_Comm_size(comm,&size)); 20 PetscCallMPI(MPI_Comm_rank(comm,&rank)); 21 for (i=rank; i<256; i+=size) { 22 PetscReal y = ((PetscReal)i)/(256-1); 23 PetscCall(PetscDrawLine(draw,0.0,y,1.0,y,i)); 24 } 25 return 0; 26 } 27 28 int main(int argc,char **argv) 29 { 30 int x = 0,y = 0,width = 256,height = 256; 31 PetscDraw draw; 32 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 } 41 42 /*TEST 43 44 build: 45 requires: x 46 47 test: 48 output_file: output/ex1_1.out 49 50 test: 51 suffix: db 52 args: -draw_double_buffer 0 53 output_file: output/ex1_1.out 54 55 test: 56 suffix: df 57 args: -draw_fast 58 output_file: output/ex1_1.out 59 60 test: 61 suffix: dv 62 args: -draw_virtual 63 output_file: output/ex1_1.out 64 65 TEST*/ 66