Permalink
Browse files

Remove entity if creation is not done

  • Loading branch information...
feragon committed Jun 21, 2016
1 parent dd459d6 commit 3028a5ced096ae966493f43e112d28df750419d3
@@ -96,6 +96,7 @@ function ArcOperations:createTempArc(point)
end
function ArcOperations:createArc()
self.finished = true
active_widget():tempEntities():removeEntity(self.arc)
local b = Builder(active_widget():document())
@@ -106,4 +107,15 @@ function ArcOperations:createArc()
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
end
function ArcOperations:close()
if(not self.finished) then
active_widget():tempEntities():removeEntity(self.arc)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
end
end
@@ -74,6 +74,7 @@ function CircleOperations:createTempCircle(point)
end
function CircleOperations:createCircle(point)
self.finished = true
active_widget():tempEntities():removeEntity(self.circle)
local b = Builder(active_widget():document())
@@ -84,4 +85,15 @@ function CircleOperations:createCircle(point)
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
end
function CircleOperations:close()
if(not self.finished) then
active_widget():tempEntities():removeEntity(self.circle)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
end
end
@@ -112,6 +112,7 @@ function DimAlignedOperations:createTempDimAligned(point)
end
function DimAlignedOperations:createDimAligned()
self.finished = true
active_widget():tempEntities():removeEntity(self.dimAligned)
local b = Builder(active_widget():document())
@@ -123,4 +124,21 @@ function DimAlignedOperations:createDimAligned()
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
function DimAlignedOperations:close()
if(not self.finished) then
if(self.startPoint ~= nil and self.endPoint ~= nil and self.middleOfText ~= nil) then
self.text = "<>"
self:createDimAligned()
else
active_widget():tempEntities():removeEntity(self.dimAligned)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
end
end
@@ -107,6 +107,7 @@ function DimAngularOperations:createTempDimAngular(point)
end
function DimAngularOperations:createDimAngular()
self.finished = true
active_widget():tempEntities():removeEntity(self.dimAngular)
local b = Builder(active_widget():document())
@@ -118,4 +119,21 @@ function DimAngularOperations:createDimAngular()
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
function DimAngularOperations:close()
if(not self.finished) then
if(self.centerPoint ~= nil and self.firstPoint ~= nil and self.secondPoint ~= nil) then
self.text = "<>"
self:createDimAngular()
else
active_widget():tempEntities():removeEntity(self.dimAngular)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
end
end
@@ -101,6 +101,7 @@ function DimDiametricOperations:createTempDimDiametric(point)
end
function DimDiametricOperations:createDimDiametric()
self.finished = true
active_widget():tempEntities():removeEntity(self.dimDiametric)
local b = Builder(active_widget():document())
@@ -112,4 +113,21 @@ function DimDiametricOperations:createDimDiametric()
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
function DimDiametricOperations:close()
if(not self.finished) then
if(self.definitionPoint ~= nil and self.definitionPoint2 ~= nil) then
self.text = "<>"
self:createDimDiametric()
else
active_widget():tempEntities():removeEntity(self.dimDiametric)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
end
end
@@ -107,6 +107,7 @@ function DimLinearOperations:createTempDimLinear(point)
end
function DimLinearOperations:createDimLinear()
self.finished = true
active_widget():tempEntities():removeEntity(self.dimLinear)
local b = Builder(active_widget():document())
@@ -118,4 +119,21 @@ function DimLinearOperations:createDimLinear()
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
function DimLinearOperations:close()
if(not self.finished) then
if(self.startPoint ~= nil and self.endPoint ~= nil and self.middleOfText ~= nil) then
self.text = "<>"
self:createDimLinear()
else
active_widget():tempEntities():removeEntity(self.dimLinear)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
end
end
@@ -110,6 +110,7 @@ function DimRadialOperations:createTempDimRadial(point)
end
function DimRadialOperations:createDimRadial()
self.finished = true
active_widget():tempEntities():removeEntity(self.dimRadial)
local b = Builder(active_widget():document())
@@ -121,4 +122,21 @@ function DimRadialOperations:createDimRadial()
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
function DimRadialOperations:close()
if(not self.finished) then
if(self.definitionPoint ~= nil and self.definitionPoint2 ~= nil and self.middleOfText ~= nil) then
self.text = "<>"
self:createDimRadial()
else
active_widget():tempEntities():removeEntity(self.dimRadial)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
event.delete('text', self)
end
end
end
@@ -112,6 +112,7 @@ function EllipseOperations:createTempEllipse(point)
end
function EllipseOperations:createEllipse()
self.finished = true
active_widget():tempEntities():removeEntity(self.ellipse)
if(not self.isArc) then
@@ -127,4 +128,15 @@ function EllipseOperations:createEllipse()
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
end
function EllipseOperations:close()
if(not self.finished) then
active_widget():tempEntities():removeEntity(self.ellipse)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
end
end
@@ -39,6 +39,7 @@ end
function LineOperations:newPoint(point)
if(self.lastPoint ~= nil) then
self.finished = true
active_widget():tempEntities():removeEntity(self.lastLine)
local b = Builder(active_widget():document())
@@ -82,4 +83,15 @@ function LineOperations:createLine(p1, p2)
l:setId(self.line_id)
return l
end
function LineOperations:close()
if(not self.finished) then
active_widget():tempEntities():removeEntity(self.lastLine)
self.finished = true
event.delete('mouseMove', self)
event.delete('number', self)
event.delete('point', self)
end
end
@@ -22,6 +22,7 @@ setmetatable(Operations, {
function Operations:_init(id)
self.id = id
self.finished = false
end
function Operations:forMe()
@@ -50,4 +51,7 @@ function Operations:getCoordinate(coordinate)
end
return nil
end
function Operations:close()
end
View
@@ -1,38 +1,56 @@
local function finish_operation()
message(tostring(active_widget().id))
if(op[active_widget().id] ~= nil) then
op[active_widget().id]:close()
end
end
function create_line()
finish_operation()
op[active_widget().id] = LineOperations(active_widget().id)
end
function create_circle()
finish_operation()
op[active_widget().id] = CircleOperations(active_widget().id)
end
function create_arc()
finish_operation()
op[active_widget().id] = ArcOperations(active_widget().id)
end
function create_ellipse()
finish_operation()
op[active_widget().id] = EllipseOperations(active_widget().id, false)
end
function create_arc_ellipse()
finish_operation()
op[active_widget().id] = EllipseOperations(active_widget().id, true)
end
function create_dim_aligned()
finish_operation()
op[active_widget().id] = DimAlignedOperations(active_widget().id)
end
function create_dim_angular()
finish_operation()
op[active_widget().id] = DimAngularOperations(active_widget().id)
end
function create_dim_diametric()
finish_operation()
op[active_widget().id] = DimDiametricOperations(active_widget().id)
end
function create_dim_linear()
finish_operation()
op[active_widget().id] = DimLinearOperations(active_widget().id)
end
function create_dim_radial()
finish_operation()
op[active_widget().id] = DimRadialOperations(active_widget().id)
end

0 comments on commit 3028a5c

Please sign in to comment.