X-Git-Url: https://i11git.iti.kit.edu/anon-gitweb/?p=Misc%2Fipe.git;a=blobdiff_plain;f=ipelets%2Fgraph%2Fgraph.lua;h=7889367cec395c8f954feb6d6bfd73bb11d400ad;hp=a61d7ef9a8223adcb6fafc5e3470848f969d50dc;hb=2014e0a1401fd8f29dbb52791814e42ecc1df09f;hpb=605122b64f9dff9c6fba9b49e5285f38747d3c7b diff --git a/ipelets/graph/graph.lua b/ipelets/graph/graph.lua index a61d7ef..7889367 100644 --- a/ipelets/graph/graph.lua +++ b/ipelets/graph/graph.lua @@ -86,14 +86,21 @@ _G.EDITTOOL.graph_backup_key = _G.EDITTOOL.key -- overwriting function _G.EDITTOOL:key(code, modifiers, text) + -- The parameters of the key() function have changed in version + -- 7.1.7. Thus, we potentially have to remap the parameters. + if text == nil then + text = code + end self:graph_backup_key(code, modifiers, text) if deactivateGraphMode then return end -- react if and only if we are currently editing a mark and key ESC -- or SPACE is pressed - if text ~= "\027" and code ~= 0x20 then return end - if not editing then return end + -- if text ~= "\027" and code ~= 0x20 then return end + if text ~= "\027" and text ~= " " then return end + if not editing then return end + editing = false -- finding new and old position @@ -131,35 +138,39 @@ local sqEps = 1 function moveEndpoints(oldPos, newPos, p, model) -- print(model.vno) for i, obj, sel, layer in p:objects() do + -- do nothing if the object is invisible and invisible objects + -- should not be moved if not p:visible(model.vno, layer) and not moveInvisibleObjects then goto continue end - if obj:type() == "path" then - local shape = obj:shape() - for _, subPath in ipairs(shape) do - if (subPath["type"] == "curve") then - for _,seg in ipairs(subPath) do - if (seg["type"] == "segment") then - for j, point in ipairs(seg) do - -- print(j, point, oldPos) - if (obj:matrix() * point - oldPos):sqLen() < sqEps then - seg[j] = obj:matrix():inverse() * newPos - -- print("test", seg[j]) - end - end - elseif (seg["type"] == "spline") then - if (obj:matrix() * seg[1] - oldPos):sqLen() < sqEps then - seg[1] = obj:matrix():inverse() * newPos - end - if (obj:matrix() * seg[#seg] - oldPos):sqLen() < sqEps then - seg[#seg] = obj:matrix():inverse() * newPos - end + -- do nothing if it is not a path + if obj:type() ~= "path" then + goto continue + end + local shape = obj:shape() + for _, subPath in ipairs(shape) do + if (subPath["type"] == "curve") then + for _,seg in ipairs(subPath) do + if (seg["type"] == "segment") then + for j, point in ipairs(seg) do + -- print(j, point, oldPos) + if (obj:matrix() * point - oldPos):sqLen() < sqEps then + seg[j] = obj:matrix():inverse() * newPos + -- print("test", seg[j]) + end + end + elseif (seg["type"] == "spline") then + if (obj:matrix() * seg[1] - oldPos):sqLen() < sqEps then + seg[1] = obj:matrix():inverse() * newPos + end + if (obj:matrix() * seg[#seg] - oldPos):sqLen() < sqEps then + seg[#seg] = obj:matrix():inverse() * newPos end end end - obj:setShape(shape) end + obj:setShape(shape) end ::continue:: end