Actual source code: dmouse.c

petsc-3.7.0 2016-04-25
Report Typos and Errors
  2: /*
  3:        Provides the calling sequences for all the basic PetscDraw routines.
  4: */
  5: #include <petsc/private/drawimpl.h>  /*I "petscdraw.h" I*/

  9: /*@
 10:     PetscDrawGetMouseButton - Returns location of mouse and which button was
 11:     pressed. Waits for button to be pressed.

 13:     Collective over PetscDraw

 15:     Input Parameter:
 16: .   draw - the window to be used

 18:     Output Parameters:
 19: +   button - one of PETSC_BUTTON_LEFT, PETSC_BUTTON_CENTER, PETSC_BUTTON_RIGHT, PETSC_BUTTON_WHEEL_UP, PETSC_BUTTON_WHEEL_DOWN
 20: .   x_user, y_user - user coordinates of location (user may pass in NULL).
 21: -   x_phys, y_phys - window coordinates (user may pass in NULL).

 23:     Notes: Only processor 0 actually waits for the button to be pressed.

 25:     Level: intermediate
 26: @*/
 27: PetscErrorCode  PetscDrawGetMouseButton(PetscDraw draw,PetscDrawButton *button,PetscReal *x_user,PetscReal *y_user,PetscReal *x_phys,PetscReal *y_phys)
 28: {
 29:   PetscReal      bcast[4] = {0,0,0,0};

 35:   *button = PETSC_BUTTON_NONE;
 36:   if (!draw->ops->getmousebutton) return(0);

 38:   (*draw->ops->getmousebutton)(draw,button,x_user,y_user,x_phys,y_phys);

 40:   MPI_Bcast((PetscEnum*)button,1,MPIU_ENUM,0,PetscObjectComm((PetscObject)draw));
 41:   if (x_user) bcast[0] = *x_user;
 42:   if (y_user) bcast[1] = *y_user;
 43:   if (x_phys) bcast[2] = *x_phys;
 44:   if (y_phys) bcast[3] = *y_phys;
 45:   MPI_Bcast(bcast,4,MPIU_REAL,0,PetscObjectComm((PetscObject)draw));
 46:   if (x_user) *x_user = bcast[0];
 47:   if (y_user) *y_user = bcast[1];
 48:   if (x_phys) *x_phys = bcast[2];
 49:   if (y_phys) *y_phys = bcast[3];
 50:   return(0);
 51: }