Permalink
Browse files

Make Lua use active layer

  • Loading branch information...
feragon committed Jul 15, 2016
1 parent bb8205b commit bc6369efc0e932b8a500f82bc79787e9450c3a64
@@ -61,7 +61,7 @@ end
function ArcOperations:getArc(center, radius, beginAngle, endAngle)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local a = Arc(center, radius, beginAngle, endAngle, false, layer)
a:setId(self.arc_id)
@@ -58,7 +58,7 @@ function CircleOperations:getCircle(center, radius)
end
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local c = Circle(center, radius, layer)
c:setId(self.circle_id)
@@ -34,7 +34,7 @@ end
function DimAlignedOperations:getDimAligned(startPoint, endPoint, middleOfText, text)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local dim = DimAligned.dimAuto(startPoint, endPoint, middleOfText, text, layer, MetaInfo())
dim:setId(self.dimAligned_id)
@@ -34,7 +34,7 @@ end
function DimAngularOperations:getDimAngular(certerPoint, firstPoint, secondPoint, text)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local dim = DimAngular.dimAuto(certerPoint, firstPoint, secondPoint, text, layer, MetaInfo())
dim:setId(self.dimAngular_id)
@@ -32,7 +32,7 @@ end
function DimDiametricOperations:getDimDiametric(defPoint1, defPoint2, text)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local dim = DimDiametric(defPoint1, 5, 1, 1, text, defPoint2, 1, layer, MetaInfo())
dim:setId(self.dimDiametric_id)
@@ -34,7 +34,7 @@ end
function DimLinearOperations:getDimLinear(startPoint, endPoint, middleOfText, text)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local dim = DimLinear.dimAuto(startPoint, endPoint, middleOfText, text, layer, MetaInfo())
dim:setId(self.dimLinear_id)
@@ -33,7 +33,7 @@ end
function DimRadialOperations:getDimRadial(defPoint1, defPoint2, middleOfText, text)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local dim = DimRadial(defPoint1, middleOfText, 5, 0, 1, 1, text, defPoint2, 1, layer, MetaInfo())
dim:setId(self.dimRadial_id)
@@ -72,7 +72,7 @@ end
function EllipseOperations:getEllipse(center, majorPoint, minorRadius, startAngle, endAngle)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local e = Ellipse(center, majorPoint, minorRadius, startAngle, endAngle, false, layer)
e:setId(self.ellipse_id)
@@ -71,7 +71,7 @@ end
function LineOperations:createLine(p1, p2)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local l
if(self.length == nil) then
l = Line(p1, p2, layer)
@@ -60,7 +60,7 @@ end
function LWPolylineOperations:getLWPolyline(vertexes)
if(#vertexes > 1) then
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local lwp = LWPolyline(vertexes, 1, 1, 1, false, Coord(0,0), layer, MetaInfo())
lwp:setId(self.lwPolyline_id)
@@ -43,7 +43,7 @@ end
function SplineOperations:getSpline(points)
local d = active_widget():document()
local layer = d:layerByName("0")
local layer = active_layer()
local s = Spline(points, {}, {}, 1, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, layer, MetaInfo())
s:setId(self.spline_id)
@@ -1,4 +1,3 @@
layer = Layer("Fractal", Color(255,255,255,255))
function drawTree( ce, x1, y1, angle, depth)
if depth == 0 then return end;
@@ -17,6 +16,7 @@ local group = tab:addGroup("Fractal")
local fractalButton = create_button("Fractal tree")
tab:addButton(group, fractalButton, 0, 0, 1, 1)
luaInterface:luaConnect(fractalButton, "pressed()", function()
layer = active_layer()
local b=Builder(active_widget():document())
drawTree(b, 0, 0, 90, 14);
b:execute()
@@ -1,5 +1,3 @@
local layer = Layer("Gear", Color(255,255,255,255))
local Gear = {}
Gear.__index = Gear
@@ -136,6 +134,7 @@ local group = tab:addGroup("Gear")
local gearButton = create_button("Gear")
tab:addButton(group, gearButton, 0, 0, 1, 1)
luaInterface:luaConnect(gearButton, "pressed()", function()
layer = active_layer()
local gear=Gear()
b=Builder(active_widget():document())
@@ -31,6 +31,10 @@ function open_file()
end
end
function active_layer()
return layers:activeLayer()
end
local function open_lua_script()
local luaScript = lc.LuaScript(mdiArea, cliCommand)
luaScript:show()
@@ -74,6 +78,9 @@ function create_main_window()
add_commandline()
layers = lc.Layers(mdiArea)
mainWindow:addDockWidget(2, layers)
if(hideUI ~= true) then
add_toolbar()

0 comments on commit bc6369e

Please sign in to comment.