* IUP scroll bars v and h

Writing and using plugins for Version 5 and above.
Post Reply
User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

IUP scroll bars v and h

Post by Ron Melby » 16 Feb 2020 14:58

Code: Select all

 require 'iuplua' 
  require 'iupluacontrols'
  require 'iuplua_pplot'  

  plot = iup.pplot{TITLE = 'Cem Dta',
    MARGINTOP='25',
    MARGINLEFT='25',
    MARGINRIGHT='25',
    MARGINBOTTOM='25',
    AXS_XLABEL='lati',
    AXS_YLABEL='long'
  }

  iup.PPlotBegin(plot, 0)
  for _, v in pairs(CEMRCD) do
    iup.PPlotAdd(plot, tonumber(v.GLATI), tonumber(v.GLONG))
 end
  iup.PPlotEnd(plot)

  plot.DS_MODE = 'MARK'
  plot.DS_MARKSTYLE = 'CIRCLE'
--  plot.DS_MARKSIZE  = 4

  dlg = iup.dialog{plot; title='Cem Plot',size='FULLxFULL'}
  dlg:show()
  iup.MainLoop()
this is my simple graph plot of cemetery latitude and longitude. There is data that is off the page. I can get to it by boxing an area and clicking on it. I would like to be able to have a horizontal and vertical scrollbox(???) around it, or some other thing, that will allow me to scroll into each quadrant. I am unsure how to accomplish that, I have looked, but this is all very uncertain to me at the moment. I think that I stick it inside a scrollbox somehow, the plot, but dont know how that works and do the plot.ds* stay where they are. it must be that -- lol well I dont know what it must be. cant find an example.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 18165
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: IUP scroll bars v and h

Post by tatewise » 16 Feb 2020 17:50

This produces scrollbars for me:

Code: Select all

  box = iup.vbox{ iup.hbox{ plot; size = "900x900"; }; size = "900x900"; }

  sb = iup.scrollbox{ box; size="600x300"; }

  dlg = iup.dialog{ sb; title='Cem Plot'; }
  dlg:show()
  iup.MainLoop()
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: IUP scroll bars v and h

Post by Ron Melby » 16 Feb 2020 18:14

a plot
in an hbox
in a vbox
in a dialog


I would have never come to that. not ever.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 18165
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: IUP scroll bars v and h

Post by tatewise » 16 Feb 2020 18:36

It took me a while to work it out.
But when I used just plot on its own the grid automatically fitted the window so scrollbars not needed.
Maybe you have a much larger data set?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: IUP scroll bars v and h

Post by Ron Melby » 16 Feb 2020 18:41

yes, 635 cemetery addresses, overwhelmingly in quadrant IV, and it clips off at the bottom of the screen.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 18165
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: IUP scroll bars v and h

Post by tatewise » 16 Feb 2020 20:02

BTW: You only need the hbox if you need a Horizontal Scrollbar
and you only need the vbox if you need a Vertical Scrollbar.

The following script worked well for me without needing any scrollbars.
The MARGIN* settings had to be '50' and AXS_X/YCROSSORIGIN="NO" to get axis & label displayed.
With AXS_X/YAUTOMIN/MAX="NO" and AXS_X/YMIN/MAX values set, the plots are well within the grid.
The window can be enlarged and the grid automatically expands.

Code: Select all

  require 'iuplua' 
  require 'iupluacontrols'
  require 'iuplua_pplot'  

  plot = iup.pplot{
    TITLE = 'Cem Data',
    MARGINTOP='50',
    MARGINLEFT='50',
    MARGINRIGHT='50',
    MARGINBOTTOM='50',
    AXS_XCROSSORIGIN="NO",
    AXS_YCROSSORIGIN="NO",
    AXS_XLABEL="Latitude",
    AXS_YLABEL="Longitude",
    AXS_XAUTOMIN="NO",
    AXS_XAUTOMAX="NO",
    AXS_YAUTOMIN="NO",
    AXS_YAUTOMAX="NO",
  }

  iup.PPlotBegin(plot, 0)
  local xmin =  99
  local xmax = -99
  local ymin =  99
  local ymax = -99
  for _, v in pairs(CEMRCD) do
    local xval = tonumber(v.GLATI)
    local yval = tonumber(v.GLONG)
    iup.PPlotAdd( plot, xval, yval )
    xmin = math.min(xmin,xval)
    xmax = math.max(xmax,xval)
    ymin = math.min(ymin,yval)
    ymax = math.max(ymax,yval)
  end
  iup.PPlotEnd(plot)

  plot.AXS_XMIN = xmin-1 
  plot.AXS_XMAX = xmax+1 
  plot.AXS_YMIN = ymin-1
  plot.AXS_YMAX = ymax+1

  plot.DS_MODE = 'MARK'
  plot.DS_MARKSTYLE = 'CIRCLE'

  dlg = iup.dialog{ plot; title='Cem Plot'; size="HALFxHALF"; }
  dlg:show()
  iup.MainLoop()
Did you you can hold down left mouse button and draw a rectangle around any data points to zoom into them?
That can be repeated in the zoomed display. Just left-click to zoom back out.

CemPlotData.png
CemPlotData.png (9.32 KiB) Viewed 1204 times
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: IUP scroll bars v and h

Post by Ron Melby » 19 Feb 2020 23:47

https://webserver2.tecgraf.puc-rio.br/i ... _plot.html

I find the documentation opaque. I am trying to find some way to extend both major marks 5, 10, 15, 20, and so on , into a crosshatch pattern, like graph paper. Am I missing it or?
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 18165
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: IUP scroll bars v and h

Post by tatewise » 20 Feb 2020 10:03

You must have overlooked Grid Configuration section for GRID, GRIDCOLOR, GRIDLINESTYLE, etc...
e.g.
GRID='YES',
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: IUP scroll bars v and h

Post by Ron Melby » 20 Feb 2020 19:35

placement was the issue. not sure where things go, sometimes it seems random.

I am trying to find a way to use TIP or some other thing to label the address, so when I click on the dot, or hover it, it shows LOC, but not having luck at all.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 18165
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: IUP scroll bars v and h

Post by tatewise » 20 Feb 2020 21:00

I suggest you look at CLICKSAMPLE_CB and use the sample_index to lookup LOC from your original data, and display that in a popup box.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: IUP scroll bars v and h

Post by Ron Melby » 21 Feb 2020 13:05

function matDSP()

Code: Select all

  require 'iuplua' 
  require 'iupluacontrols'
  require 'iuplua_pplot'  
  
function CLICKSAMPLE_CB(ih, ds_index, sample_index, x, y,  button)

if x then
  debug = debug
  end

--[[
ih: identifier of the element that activated the event.
ds_index: index of the dataset
sample_index: index of the sample in the dataset
x: X coordinate value of the sample
y: Y coordinate value of the sample
button: identifies the activated mouse button:
IUP_BUTTON1 - left mouse button (button 1)
IUP_BUTTON2 - middle mouse button (button 2)
IUP_BUTTON3 - right mouse button (button 3)
]]
end
 
 plot = iup.pplot
  {
    TITLE = 'Cem Dta',
    MARGINTOP='15',
    MARGINLEFT='15',
    MARGINRIGHT='15',
    MARGINBOTTOM='15',
    AXS_XLABEL='lati',
    AXS_YLABEL='long',
    GRID = 'YES'
  }

  iup.PPlotBegin(plot, 0)
  for _, v in pairs(CEMRCD) do
    iup.PPlotAdd(plot, tonumber(v.GLATI), tonumber(v.GLONG))
  --  TIP = v.LOC, v.GLONG, v.GLATI  
 end
  iup.PPlotEnd(plot)
  plot.DS_MODE = 'MARK'
  plot.DS_MARKSTYLE = 'CIRCLE'

  sflctl = iup.vbox{iup.hbox{plot; size = '1536'; NORMALIZESIZE = 'BOTH';}; size = '1536'; NORMALIZESIZE = 'BOTH';}
  sfl = iup.scrollbox{sflctl; size = '640x320'; }

  dlg = iup.dialog{sfl; title = 'Cem Plot'} 
  dlg:show()
  iup.MainLoop()
my understanding of a callback in any language I have ever programmed in is that the external program thru whatever mechanism it uses, calls back a function of a certain name on some event.
so, I believe that function name to be CLICKSAMPLE_CB. I am on a toshiba laptop, with the typical on keyboard touchpad, left and right button. I can hammer them to my hearts content, and nothing occurs.

ih:clicksample_cb(ds_index, sample_index, x, y, button: number) -> (ret: number) [in Lua] << this, of course is NOT LUA. and contains absolutely no information whatsoever, it is unintelligible garbage, and does not assist in coding the callback.
I have searched the net for an example, and none are found....
but my understanding of how IUP does anything is obviously wrong.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 18165
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: IUP scroll bars v and h

Post by tatewise » 21 Feb 2020 15:55

Firstly, you are mixing up the documentation for the two plot libraries:
https://webserver2.tecgraf.puc-rio.br/i ... _plot.html is iup.plot built into iup.
http://underpop.online.fr/i/iup/en/ctrl/iup_pplot.html is iup.pplot that you are using.

Second, as it says in Selection and Editing, you must enable the DS_EDIT attribute.

Thirdly, the callback is SELECT_CB for iup.pplot (CLICKSAMPLE_CB is only for iup.plot).

So this code works if you hold down Ctrl key while clicking a data point:

Code: Select all

  plot.DS_EDIT = "YES"

  function plot:select_cb(index, sample_index, x, y, select)
    local Loc = CEMRCD[sample_index+1].LOC
    print("Select",sample_index,Loc,select)
    return iup.IGNORE
  end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: IUP scroll bars v and h

Post by Ron Melby » 21 Feb 2020 19:56

I could not get fh to find IupPlot.

ok, so thats part of my problem then.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 18165
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: IUP scroll bars v and h

Post by tatewise » 21 Feb 2020 21:26

As I said in another thread, see Knowledge Base > IUP GUI Builder References where it states that FH V6 uses IUP 3.11.2 whereas IupPlot (since 3.12) is only in a later version.

So you have to use IupPPlot which has different callbacks.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: IUP scroll bars v and h

Post by Ron Melby » 22 Feb 2020 00:40

I invesigated CLICKSAMPLE_CB on your recommendation, mike. Nothing errored, it just didnt work.

so now I will do the other way, see if I can get that to go.
FH V.6.2.7 Win 10 64 bit

User avatar
tatewise
Megastar
Posts: 18165
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: IUP scroll bars v and h

Post by tatewise » 22 Feb 2020 10:45

I was misled by your cross-reference to the wrong documentation and assumed that was the version you were using.

I have made a small change to the callback function so the data point details update the plot TITLE.

Code: Select all

  plot.DS_EDIT = "YES"

  function plot:select_cb( index, sample_index, x, y, select )
    local Loc = CEMRCD[sample_index+1].LOC
    plot.TITLE = "Cem Data: "..Loc.." at Lat: "..x.." Long: "..y
    return iup.IGNORE
  end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Megastar
Posts: 567
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: IUP scroll bars v and h

Post by Ron Melby » 22 Feb 2020 15:33

I would use IupPlot, if it was available. but it is not.
FH V.6.2.7 Win 10 64 bit

Post Reply