Actual source code: dmouse.c
1: /*$Id: dmouse.c,v 1.36 2001/08/10 03:28:19 bsmith Exp $*/
2: /*
3: Provides the calling sequences for all the basic PetscDraw routines.
4: */
5: #include src/sys/src/draw/drawimpl.h
7: /*@
8: PetscDrawGetMouseButton - Returns location of mouse and which button was
9: pressed. Waits for button to be pressed.
11: Not collective (Use PetscDrawSynchronizedGetMouseButton() for collective)
13: Input Parameter:
14: . draw - the window to be used
16: Output Parameters:
17: + button - one of BUTTON_LEFT, BUTTON_CENTER, BUTTON_RIGHT
18: . x_user, y_user - user coordinates of location (user may pass in 0).
19: - x_phys, y_phys - window coordinates (user may pass in 0).
21: Level: intermediate
23: Notes:
24: Only processor 0 of the communicator used to create the PetscDraw may call this routine.
26: .seealso: PetscDrawSynchronizedGetMouseButton()
27: @*/
28: int PetscDrawGetMouseButton(PetscDraw draw,PetscDrawButton *button,PetscReal* x_user,PetscReal *y_user,PetscReal *x_phys,PetscReal *y_phys)
29: {
30: int ierr;
31: PetscTruth isnull;
35: *button = BUTTON_NONE;
36: PetscTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,&isnull);
37: if (isnull) return(0);
38: if (!draw->ops->getmousebutton) return(0);
39: (*draw->ops->getmousebutton)(draw,button,x_user,y_user,x_phys,y_phys);
40: return(0);
41: }
43: /*@
44: PetscDrawSynchronizedGetMouseButton - Returns location of mouse and which button was
45: pressed. Waits for button to be pressed.
47: Collective over PetscDraw
49: Input Parameter:
50: . draw - the window to be used
52: Output Parameters:
53: + button - one of BUTTON_LEFT, BUTTON_CENTER, BUTTON_RIGHT
54: . x_user, y_user - user coordinates of location (user may pass in 0).
55: - x_phys, y_phys - window coordinates (user may pass in 0).
57: Level: intermediate
59: .seealso: PetscDrawGetMouseButton()
60: @*/
61: int PetscDrawSynchronizedGetMouseButton(PetscDraw draw,PetscDrawButton *button,PetscReal* x_user,PetscReal *y_user,PetscReal *x_phys,PetscReal *y_phys)
62: {
63: PetscReal bcast[4];
64: int ierr,rank;
68: MPI_Comm_rank(draw->comm,&rank);
69: if (!rank) {
70: PetscDrawGetMouseButton(draw,button,x_user,y_user,x_phys,y_phys);
71: }
72: if (button) {
73: MPI_Bcast(button,1,MPI_INT,0,draw->comm);
74: }
75: if (x_user) bcast[0] = *x_user;
76: if (y_user) bcast[1] = *y_user;
77: if (x_phys) bcast[2] = *x_phys;
78: if (y_phys) bcast[3] = *y_phys;
79: MPI_Bcast(bcast,4,MPIU_REAL,0,draw->comm);
80: if (x_user) *x_user = bcast[0];
81: if (y_user) *y_user = bcast[1];
82: if (x_phys) *x_phys = bcast[2];
83: if (y_phys) *y_phys = bcast[3];
84: return(0);
85: }