1af0996ceSBarry Smith #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/
25c6c1daeSBarry Smith
35c6c1daeSBarry Smith /*@
45c6c1daeSBarry Smith PetscDrawGetMouseButton - Returns location of mouse and which button was
55c6c1daeSBarry Smith pressed. Waits for button to be pressed.
65c6c1daeSBarry Smith
7c3339decSBarry Smith Collective
85c6c1daeSBarry Smith
95c6c1daeSBarry Smith Input Parameter:
105c6c1daeSBarry Smith . draw - the window to be used
115c6c1daeSBarry Smith
125c6c1daeSBarry Smith Output Parameters:
13811af0c4SBarry Smith + button - one of `PETSC_BUTTON_LEFT`, `PETSC_BUTTON_CENTER`, `PETSC_BUTTON_RIGHT`, `PETSC_BUTTON_WHEEL_UP`, `PETSC_BUTTON_WHEEL_DOWN`
146b867d5aSJose E. Roman . x_user - horizontal user coordinate of location (user may pass in NULL).
156b867d5aSJose E. Roman . y_user - vertical user coordinate of location (user may pass in NULL).
166b867d5aSJose E. Roman . x_phys - horizontal window coordinate (user may pass in NULL).
176b867d5aSJose E. Roman - y_phys - vertical window coordinate (user may pass in NULL).
185c6c1daeSBarry Smith
19811af0c4SBarry Smith Note:
2095452b02SPatrick Sanan Only processor 0 actually waits for the button to be pressed.
215c6c1daeSBarry Smith
2264f23424SLisandro Dalcin Level: intermediate
23811af0c4SBarry Smith
24811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawButton`
255c6c1daeSBarry Smith @*/
PetscDrawGetMouseButton(PetscDraw draw,PetscDrawButton * button,PetscReal * x_user,PetscReal * y_user,PetscReal * x_phys,PetscReal * y_phys)26d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawGetMouseButton(PetscDraw draw, PetscDrawButton *button, PetscReal *x_user, PetscReal *y_user, PetscReal *x_phys, PetscReal *y_phys)
27d71ae5a4SJacob Faibussowitsch {
2809440f25SLisandro Dalcin PetscReal bcast[4] = {0, 0, 0, 0};
295c6c1daeSBarry Smith
305c6c1daeSBarry Smith PetscFunctionBegin;
315c6c1daeSBarry Smith PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
32*4f572ea9SToby Isaac PetscAssertPointer(button, 2);
33e118a51fSLisandro Dalcin *button = PETSC_BUTTON_NONE;
343ba16761SJacob Faibussowitsch if (!draw->ops->getmousebutton) PetscFunctionReturn(PETSC_SUCCESS);
35e118a51fSLisandro Dalcin
36dbbe0bcdSBarry Smith PetscUseTypeMethod(draw, getmousebutton, button, x_user, y_user, x_phys, y_phys);
37e118a51fSLisandro Dalcin
389566063dSJacob Faibussowitsch PetscCallMPI(MPI_Bcast((PetscEnum *)button, 1, MPIU_ENUM, 0, PetscObjectComm((PetscObject)draw)));
395c6c1daeSBarry Smith if (x_user) bcast[0] = *x_user;
405c6c1daeSBarry Smith if (y_user) bcast[1] = *y_user;
415c6c1daeSBarry Smith if (x_phys) bcast[2] = *x_phys;
425c6c1daeSBarry Smith if (y_phys) bcast[3] = *y_phys;
439566063dSJacob Faibussowitsch PetscCallMPI(MPI_Bcast(bcast, 4, MPIU_REAL, 0, PetscObjectComm((PetscObject)draw)));
445c6c1daeSBarry Smith if (x_user) *x_user = bcast[0];
455c6c1daeSBarry Smith if (y_user) *y_user = bcast[1];
465c6c1daeSBarry Smith if (x_phys) *x_phys = bcast[2];
475c6c1daeSBarry Smith if (y_phys) *y_phys = bcast[3];
483ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
495c6c1daeSBarry Smith }
50