Permalink
Browse files

Scale and remove

  • Loading branch information...
feragon committed Jun 28, 2016
1 parent ab2e308 commit 0c8013ee8307279d278d46474a9ed4456cb66555
View
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="256"
height="256"
viewBox="0 0 72.248892 72.248892"
id="svg4295"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="delete_b.svg"
inkscape:export-filename="D:\LC_Recources\icons\delete.png"
inkscape:export-xdpi="8.4375"
inkscape:export-ydpi="8.4375">
<metadata
id="metadata4325">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs4323">
<linearGradient
id="linearGradient4316"
osb:paint="solid">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4318" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4316"
id="linearGradient4320"
x1="33.020002"
y1="59.831115"
x2="63.217782"
y2="59.831115"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4316"
id="linearGradient4322"
x1="11.28889"
y1="24.271113"
x2="13.546668"
y2="24.271113"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4316"
id="linearGradient4324"
x1="9.0311117"
y1="12.417779"
x2="63.217782"
y2="12.417779"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4316"
id="linearGradient4326"
x1="58.702226"
y1="36.124447"
x2="60.960004"
y2="36.124447"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1176"
id="namedview4321"
showgrid="true"
units="px"
inkscape:snap-grids="true"
inkscape:zoom="3.7226562"
inkscape:cx="110.57019"
inkscape:cy="128"
inkscape:window-x="-4"
inkscape:window-y="-4"
inkscape:window-maximized="1"
inkscape:current-layer="svg4295"
inkscape:object-nodes="true"
inkscape:snap-object-midpoints="false">
<inkscape:grid
type="xygrid"
id="grid4867" />
</sodipodi:namedview>
<g
id="g4345">
<g
id="g4328">
<path
style="fill:url(#linearGradient4320);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.25777793;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:4.51555586,2.25777793;stroke-dashoffset:5.87022262;stroke-opacity:1"
d="m 33.020002,59.831115 30.19778,0"
id="path5586"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:url(#linearGradient4322);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.25777793;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:4.51555586,2.25777793;stroke-dashoffset:5.64444482;stroke-opacity:1"
d="m 12.417779,39.511114 0,-30.4800023"
id="path5588"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:url(#linearGradient4326);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.25777793;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:4.51555586,2.25777793;stroke-dashoffset:2.25777793;stroke-opacity:1"
d="m 59.831115,63.217782 0,-54.1866703"
id="path5590"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:url(#linearGradient4324);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.25777793;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:4.51555586,2.25777793;stroke-dashoffset:2.25777793;stroke-opacity:1"
d="m 9.0311117,12.417779 54.1866703,0"
id="path5592"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.25777793;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 9.0311117,36.124447 36.124447,63.217782"
id="path5594"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.25777793;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 12.417779,63.217782 0,-23.706668"
id="path4873"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path4875"
d="m 9.031112,59.831116 23.706667,0"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.25777793;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<path
inkscape:connector-curvature="0"
id="path4341"
d="M 49.557655,45.042099 27.206794,22.691238"
style="fill:#00ff7f;fill-rule:evenodd;stroke:#00ff7f;stroke-width:4.51555586;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:#00ff7f;fill-rule:evenodd;stroke:#00ff7f;stroke-width:4.51555586;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 27.206794,45.042099 49.557655,22.691238"
id="path4343"
inkscape:connector-curvature="0" />
</g>
</svg>
View
Binary file not shown.
View
@@ -18,5 +18,7 @@
<file alias="modify.svg">icons/modify.svg</file>
<file alias="modifyrotate.png">icons/modifyrotate.png</file>
<file alias="move_copy.svg">icons/move_copy.svg</file>
<file alias="scale.png">icons/scale.png</file>
<file alias="delete.svg">icons/delete.svg</file>
</qresource>
</RCC>
@@ -14,6 +14,8 @@ require 'actions.lwpolylineoperations'
require 'actions.moveoperation'
require 'actions.rotateoperation'
require 'actions.copyoperation'
require 'actions.scaleoperation'
require 'actions.removeoperation'
Operations = {}
Operations.__index = Operations
@@ -0,0 +1,42 @@
RemoveOperation = {}
RemoveOperation.__index = RemoveOperation
setmetatable(RemoveOperation, {
__index = Operations,
__call = function (o, ...)
local self = setmetatable({}, o)
self:_init(...)
return self
end,
})
function RemoveOperation:_init(id)
Operations._init(self, id)
self.selection = active_widget():selection()
self:remove()
end
function RemoveOperation:remove()
local b = Builder(active_widget():document())
for k, entity in pairs(self.selection) do
b:append(entity)
end
b:push()
b:remove()
b:execute()
message(tostring(#self.selection) .. " items removed")
self:close()
end
function RemoveOperation:close()
if(not self.finished) then
self.finished = true
event.trigger('operationFinished')
end
end
@@ -0,0 +1,85 @@
ScaleOperation = {}
ScaleOperation.__index = ScaleOperation
setmetatable(ScaleOperation, {
__index = Operations,
__call = function (o, ...)
local self = setmetatable({}, o)
self:_init(...)
return self
end,
})
function ScaleOperation:_init(id)
Operations._init(self, id)
self.selection = active_widget():selection()
message(tostring(#self.selection) .. " items selected")
if(#self.selection > 0) then
self.origin = nil
self.factor = nil
self.tempEntities = {}
event.register('point', self)
event.register('number', self)
message("Give origin point")
else
self.finished = true
event.trigger('operationFinished')
end
end
function ScaleOperation:onEvent(eventName, ...)
if(Operations.forMe(self) == false) then
return
end
if(eventName == "point" or eventName == "number") then
self:newData(...)
end
end
function ScaleOperation:newData(data)
if(self.origin == nil) then
self.origin = Operations:getCoordinate(data)
message("Enter scale factor or entity end")
elseif(type(data) == "number") then
self.factor = Coordinate(data, data, data)
self:scale()
end
end
function ScaleOperation:scale()
local b = Builder(active_widget():document())
for k, entity in pairs(self.selection) do
b:append(entity)
end
b:push()
b:scale(self.origin, self.factor)
b:execute()
self:close()
end
function ScaleOperation:close()
if(not self.finished) then
self.finished = true
for k, entity in pairs(self.tempEntities) do
active_widget():tempEntities():removeEntity(entity)
end
event.delete('point', self)
event.delete('number', self)
event.trigger('operationFinished')
end
end
@@ -67,6 +67,8 @@ function add_commandline()
add_command("MOVE", move_selected_entities)
add_command("ROTATE", rotate_selected_entities)
add_command("COPY", copy_selected_entities)
add_command("SCALE", scale_selected_entities)
add_command("REMOVE", remove_selected_entities)
event.register("point", setLastPoint)
end
View
@@ -123,4 +123,14 @@ end
function copy_selected_entities()
new_operation()
op[active_widget().id] = CopyOperation(active_widget().id)
end
function scale_selected_entities()
new_operation()
op[active_widget().id] = ScaleOperation(active_widget().id)
end
function remove_selected_entities()
new_operation()
op[active_widget().id] = RemoveOperation(active_widget().id)
end
View
@@ -108,4 +108,12 @@ function add_toolbar()
local copyButton = create_button("", ":/icons/move_copy.svg")
quickAccess:addButton(modifyGroup, copyButton, 0, 1, 1, 1)
luaInterface:luaConnect(copyButton, "pressed()", copy_selected_entities)
local scaleButton = create_button("", ":/icons/scale.png")
quickAccess:addButton(modifyGroup, scaleButton, 1, 1, 1, 1)
luaInterface:luaConnect(scaleButton, "pressed()", scale_selected_entities)
local removeButton = create_button("", ":/icons/delete.svg")
quickAccess:addButton(modifyGroup, removeButton, 2, 0, 1, 1)
luaInterface:luaConnect(removeButton, "pressed()", remove_selected_entities)
end

0 comments on commit 0c8013e

Please sign in to comment.