rdbox(3f) - [M_drawplus:locator] - reads two points and outline defined box and return points (LICENSE:MIT)
Synopsis
Description
Options
Example
Author
License
subroutine rdbox(returnx1,returny1,returnx2,returny2,ikey)
real,intent(out) :: returnx1, returny1 real,intent(out) :: returnx2, returny2 integer,intent(out) :: ikey
In workstation windows click, hold down mouse, release at opposite corner to define the opposite corners of a box. The box is drawn using current drawing attributes. The IKEY value indicates which mouse was pressed.
Note that on a device such as a Tektronix terminal (or emulator, such as xterm(1)) where you have to wait for a keypress to get the position of the crosshairs LOCATOR(3f) returns 0 automatically on every second call. So RDBOX(3f) waits for the locator to return zero so that we know the mouse button has been released.
As the mouse is moved a dot is drawn at each point, leaving a trail marking the mouse motion. Simple directions are written to stdout, and when a box is defined the coordinates of the corners are printed:
*rdbox* READY *rdbox* RELEASE MOUSE AT OTHER CORNER corners are 0.311320752 0.584905684 and 0.311320752 0.584905684 ; and key is 4
RETURNX1,RETURNY1 return coordinates of first corner of box RETURNX2,RETURNY2 return coordinates of opposite corner of box IKEY returns the identifier of the mouse that was pressed, using the LOCATOR(3f) function from the M_DRAW(3fm) module.
o A return value of 2 indicates the second mouse button has been pressed. o A return value of 1 indicates the first mouse button has been pressed.
Sample program:
program demo_rdbox use M_drawplus, only : rdbox use M_draw implicit none real :: x1, y1, x2, y2 integer :: key call vinit( ) call color(D_GREEN) do call rdbox(x1,y1,x2,y2,key) if(key.le.0)exit ! if the mouse is clicked twice without moving exit the loop if(x1.eq.x2 .and. y1.eq.y2)exit write(*,*)corners are ,x1,y1, and ,x2,y2,; and key is ,key call move2(x1,y1) call draw2(x2,y2) call move2(x1,y2) call draw2(x2,y1) enddo call vexit() end program demo_rdbox
John S. Urban
MIT License
Nemo Release 3.1 | rdbox (3) | February 23, 2025 |