One to be aware of if using multiple %pl regions and get_plot_data@.
In the example below there are two %pl regions, both with full mouse input.
Data in each plot is different and the plots have different sizes.
Moving the mouse across any of the regions and keeping an eye on the output window, it is apparent that the call back function correctly returns the pixel coordinates for each graph, however get_plot_data@ always returns the data corresponding to the last drawn plot.
Ken
module data_mod
implicit none
integer, parameter :: dp = kind(1.d0)
integer, parameter :: npts = 100
real(kind=dp) :: time(1:npts) = 0.d0, decay(1:npts) = 0.d0, rocof(1:npts) = 0.d0, time2(1:npts) = 0.d0
contains
integer function create_data()
real(kind=dp) :: t = 0.d0, dt = 0.10d0
integer i
do i = 1, npts
time(i) = t ; decay(i) = 50.d0*(exp(-t/4.d0) ) ; t = t + dt
if (i .gt. 1) then
rocof(i) = ( decay(i) - decay(i-1) ) / dt
end if
end do
time2 = 2.d0*time
create_data = 1
end function create_data
integer function plot()
include<windows.ins>
integer i
i= winio@('%bg[blue]&')
i=winio@('%`bg[white]&')
call winop@('%pl[native]')
call winop@('%pl[title='Frequency (Hz)']')
call winop@('%pl[width=2]')
call winop@('%pl[gridlines,x_array,frame,etched]')
call winop@('%pl[link=lines, symbol=0, colour=blue, pen_style=0]')
call winop@('%pl[x_axis= 'Time (s)', y-axis=@]')
call winop@('%pl[full_mouse_input]')
i = winio@('%^pl&',600,250,npts,time,decay,plot1_cb)
i=winio@('%ff%2nl%`bg[white]&')
call winop@('%pl[native]')
call winop@('%pl[title='Rate of change of frequency (Hz/s)']')
call winop@('%pl[width=2]')
call winop@('%pl[gridlines,x_array,frame,etched]')
call winop@('%pl[link=lines, symbol=0, colour=blue, pen_style=0]')
call winop@('%pl[x_axis= 'Time (s)', y-axis=@]')
call winop@('%pl[full_mouse_input]')
i = winio@('%^pl&',300,125,npts,time2,rocof,plot2_cb)
i = winio@(' ')
plot = 1
end function plot
integer function plot1_cb()
include<windows.ins>
CHARACTER(80) reason
integer i, ix, iy
real(kind=dp) x, y
reason = clearwin_string@('CALLBACK_REASON')
if (reason .eq. 'MOUSE_MOVE') then
ix = clearwin_info@('GRAPHICS_MOUSE_X')
iy = clearwin_info@('GRAPHICS_MOUSE_Y')
i = get_plot_data@(ix,iy,x,y)
write(6,*) ix, iy, x, y
end if
plot1_cb = 1
end function plot1_cb
integer function plot2_cb()
include<windows.ins>
CHARACTER(80) reason
integer i, ix, iy
real(kind=dp) x, y
reason = clearwin_string@('CALLBACK_REASON')
if (reason .eq. 'MOUSE_MOVE') then
ix = clearwin_info@('GRAPHICS_MOUSE_X')
iy = clearwin_info@('GRAPHICS_MOUSE_Y')
i = get_plot_data@(ix,iy,x,y)
write(6,*) ix, iy, x, y
end if
plot2_cb = 1
end function plot2_cb
end module data_mod
program main
use data_mod
implicit none
integer i
i = create_data()
i = plot()
end program main