Date: 2021-03-03T22:25:35+00:00

Actual source code: dmouse.c
petsc-3.14.5 2021-03-03
Report Typos and Errors

      2: /*
      3:        Provides the calling sequences for all the basic PetscDraw routines.
      4: */
      5: #include <petsc/private/drawimpl.h>

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

     11:     Collective over PetscDraw

     13:     Input Parameter:
     14: .   draw - the window to be used

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

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

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

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

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

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