Hello.
I have just tried plotting with iuplua_plot and have stumbled upon a
problem:
- After switching off plot.SHOWCROSSHAIR the last set of cross-hair lines
remains visible.
AI generated description:
*Title:* IupPlot: stale crosshair lines remain after setting SHOWCROSSHAIR
to NONE on GTK
*Environment*
-
IUP: 3.32 (VersionNumber() = 332000)
-
Driver: GTK
-
Language binding: Lua (iuplua, iuplua_plot)
-
OS: Linux
*Description*
When the SHOWCROSSHAIR attribute is changed from "HORIZONTAL" to "NONE",
the crosshair lines remain visible on the plot. The lines disappear only
after the mouse is moved.
*Steps to reproduce*
1.
Create an IupPlot and display it.
2.
Enable the crosshair by setting plot.SHOWCROSSHAIR = "HORIZONTAL".
3.
Move the mouse over the plot so that the crosshair is drawn.
4.
Set plot.SHOWCROSSHAIR = "NONE" without moving the mouse.
*Expected behavior*
The crosshair lines should disappear immediately when SHOWCROSSHAIR is set
to "NONE".
*Actual behavior*
The crosshair lines remain visible until the mouse is moved. Calling
iup.Update(plot), iup.Refresh(plot), setting plot.REDRAW = "YES", and
calling iup.Redraw(plot, 1) did not resolve the issue.
The behavior appears to be related to mouse-movement handling: moving the
pointer outside the plot and then moving it again after showing the plot
clears the stale lines.
Could this be a GTK-specific issue with crosshair redraw or cleanup in
IupPlot?
Code:
#!/usr/bin/lua5.4
-- hello_iup_plot.lua
--[[
title: hello_iup_plot.lua
author: khaz
created on: Thu Oct 22 17:14:18 2026
--]]
require("iuplua")
require("iuplua_plot")
require("iupluaim")
local pos = arg[0]:match(".*()/") or 0
FTITLE = string.sub(arg[0], pos + 1, -5)
local loc = {"params", loc=FTITLE}
local dump = require("seq").dump
local printd = require("softdev.debug").printd
printd(("iup.Version(): %s"):format(iup.Version()), loc)
printd(("iup.VersionNumber(): %s"):format(iup.VersionNumber()), loc)
print("iup.GetGlobal('DRIVER') =", iup.GetGlobal("DRIVER"))
local plot = iup.plot{
TITLE = "sine and cosine",
AXS_XLABEL = "t",
AXS_YLABEL = "y",
GRID = "YES",
MARGINLEFT = "50",
MARGINBOTTOM = "40",
-- ciemny motyw
BGCOLOR = "0 0 0", -- tło całego widżetu (poza wykresem)
PLOT_BGCOLOR = "0 0 0", -- tło pola wykresu (w niektórych wersjach:
AXS_BGCOLOR)
FGCOLOR = "255 255 255", -- kolor tekstu i ramki
AXS_XCOLOR = "200 200 200", -- osie
AXS_YCOLOR = "200 200 200",
GRIDCOLOR = "60 60 60", -- siatka, ciemnoszara
TITLECOLOR = "255 255 255",
AXS_XLABELCOLOR = "255 255 255", -- opisy osi
AXS_YLABELCOLOR = "255 255 255",
AXS_XMIN = "0",
AXS_XMAX = 2*math.pi,
AXS_YMIN = "-1.1",
AXS_YMAX = "1.1",
-- wyłącz automatyczne skalowanie, inaczej zakres może zostać nadpisany
AXS_XAUTOMIN = "NO",
AXS_XAUTOMAX = "NO",
AXS_YAUTOMIN = "NO",
AXS_YAUTOMAX = "NO",
}
printd("plot.ANTIALIAS = ", plot.ANTIALIAS, loc)
plot.ANTIALIAS = "Yes"
printd("plot.ANTIALIAS = ", plot.ANTIALIAS, loc)
-- SHOWCROSSHAIR: shows the crosshair cursor. Can be: NONE, HORIZONTAL,
VERTICAL.
printd("plot.SHOWCROSSHAIR = ", plot.SHOWCROSSHAIR, loc)
-- !DEV -- TODO:
-- local function toggle_crosshair(crosshair)
-- local loc = {"params", loc=FTITLE .. "::toggle_crosshair"}
-- local result = "NONE"
-- if crosshair then result = "HORIZONTAL" end
-- printd(("result = %s"):format(result), loc)
-- return result
-- end
-- plot.SHOWCROSSHAIR = toggle_crosshair(crosshair)
-- plot.SHOWCROSSHAIR = "HORIZONTAL"
-- plot.SHOWCROSSHAIR = "HORIZONTAL"
plot.SHOWCROSSHAIR = "NONE"
printd("plot.TIPFORMAT = ", plot.TIPFORMAT, loc)
-- seria 1: sinus
plot:Begin(0)
for i = 0, 200 do
local x = i / 10
plot:Add(x, math.sin(x))
end
plot:End()
plot.LEGEND = "YES"
plot.DS_NAME = "sin(t)"
plot.DS_COLOR = "0 255 0" -- kolor serii (po End; dla serii 0)
plot.DS_LINEWIDTH = "2"
-- seria 1: cosinus
plot:Begin(0)
for i = 0, 200 do
local x = i / 10
plot:Add(x, math.cos(x))
end
plot:End()
plot.LEGEND = "YES"
plot.DS_NAME = "cos(t)"
plot.DS_COLOR = "255 128 0"
plot.DS_LINEWIDTH = "3"
local dlg = iup.dialog{
plot,
title = "IUP plot",
size = "500x300",
}
-- attemps for formatting the legend:
plot.LEGEND = "YES"
plot.LEGENDPOS = "TOPRIGHT" -- TOPLEFT, BOTTOMRIGHT, BOTTOMLEFT, XY
plot.LEGENDFONTSIZE = "16" -- rozmiar tylko dla legendy
plot.FONT = "Hermit, 12"
plot.TITLEFONTSIZE = "32"
-- loading icon:
local icon = iup.LoadImage("res/moon_48.png") -- zwraca obiekt obrazka,
nil przy błędzie
if icon then
dlg.icon = icon -- lub dlg.icon = icon.handle / nazwa, zob.
niżej
end
local maximized = false
local function nudge_cursor()
local pos = iup.GetGlobal("CURSORPOS")
local x, y = pos:match("^(%-?%d+)x(%-?%d+)$")
if not x then
print("Nie udało się odczytać CURSORPOS:", pos)
return
end
x, y = tonumber(x), tonumber(y)
iup.SetGlobal("CURSORPOS", ("%dx%d"):format(x + 1, y))
iup.SetGlobal("CURSORPOS", ("%dx%d"):format(x, y))
end
-- local function clear_crosshair() -- I've tried some options
-- if cursor then
-- plot.SHOWCROSSHAIR = "NONE"
-- plot.REDRAW = "YES"
-- else
-- return
-- end
-- return iup.DEFAULT
-- end
-- iup.SetIdle(clear_crosshair)
local full = false
function dlg:k_any(c)
local loc = {"params", loc=FTITLE .. "::dlg:k_any"}
if c == iup.K_cW then return iup.CLOSE end
if c == iup.K_f or c == iup.K_F then
full = not full
self.fullscreen = full and "YES" or "NO"
end
if c == iup.K_c or c == iup.K_C then
crosshair = not crosshair
plot.SHOWCROSSHAIR = crosshair and "HORIZONTAL" or "NONE"
iup.REDRAW = "YES"
plot.REDRAW = "YES"
nudge_cursor()
-- iup.Update(plot) -- I've tried some options
-- iup.Refresh(plot)
-- plot:show()
-- dlg:show()
iup.Redraw(plot, 1)
end
return iup.IGNORE
end
dlg:show()
if iup.MainLoopLevel() == 0 then
iup.MainLoop()
end
I will most certainly appreciate advice.
Best regards,
Khaz.
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users