Added intersection tool to Drawing Tool.
This commit is contained in:
parent
e353413cd3
commit
23b20ba716
|
@ -1579,7 +1579,7 @@ class App(QtCore.QObject):
|
|||
app_obj.progress.emit(0)
|
||||
self.log.error(str(e))
|
||||
raise
|
||||
return
|
||||
#return
|
||||
|
||||
# Further parsing
|
||||
self.progress.emit(70) # TODO: Note the mixture of self and app_obj used here
|
||||
|
|
|
@ -546,6 +546,7 @@ class FlatCAMDraw(QtCore.QObject):
|
|||
self.add_polygon_btn = self.drawing_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
|
||||
self.add_path_btn = self.drawing_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
|
||||
self.union_btn = self.drawing_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
|
||||
self.intersection_btn = self.drawing_toolbar.addAction(QtGui.QIcon('share/intersection32.png'), 'Polygon Intersection')
|
||||
self.subtract_btn = self.drawing_toolbar.addAction(QtGui.QIcon('share/subtract32.png'), 'Polygon Subtraction')
|
||||
self.cutpath_btn = self.drawing_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
|
||||
self.move_btn = self.drawing_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
|
||||
|
@ -581,6 +582,7 @@ class FlatCAMDraw(QtCore.QObject):
|
|||
self.canvas.mpl_connect('key_release_event', self.on_canvas_key_release)
|
||||
|
||||
self.union_btn.triggered.connect(self.union)
|
||||
self.intersection_btn.triggered.connect(self.intersection)
|
||||
self.subtract_btn.triggered.connect(self.subtract)
|
||||
self.cutpath_btn.triggered.connect(self.cutpath)
|
||||
self.delete_btn.triggered.connect(self.on_delete_btn)
|
||||
|
@ -1185,6 +1187,32 @@ class FlatCAMDraw(QtCore.QObject):
|
|||
|
||||
self.replot()
|
||||
|
||||
def intersection(self):
|
||||
"""
|
||||
Makes intersectino of selected polygons. Original polygons are deleted.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
|
||||
shapes = self.get_selected()
|
||||
|
||||
results = shapes[0].geo
|
||||
|
||||
for shape in shapes[1:]:
|
||||
results = results.intersection(shape.geo)
|
||||
|
||||
# Delete originals.
|
||||
for_deletion = [s for s in self.get_selected()]
|
||||
for shape in for_deletion:
|
||||
self.delete_shape(shape)
|
||||
|
||||
# Selected geometry is now gone!
|
||||
self.selected = []
|
||||
|
||||
self.add_shape(DrawToolShape(results))
|
||||
|
||||
self.replot()
|
||||
|
||||
def subtract(self):
|
||||
selected = self.get_selected()
|
||||
tools = selected[1:]
|
||||
|
|
|
@ -12,10 +12,13 @@ class FCProcess(object):
|
|||
self.descr = descr
|
||||
|
||||
def __del__(self):
|
||||
# print "#######################"
|
||||
# print "# FCProcess.__del__() #"
|
||||
# print "#######################"
|
||||
self.done()
|
||||
|
||||
def done(self):
|
||||
print "FCProcess.done()"
|
||||
# print "FCProcess.done()"
|
||||
for fcn in self.callbacks["done"]:
|
||||
fcn(self)
|
||||
|
||||
|
@ -108,7 +111,7 @@ class FCVisibleProcessContainer(QtCore.QObject, FCProcessContainer):
|
|||
self.something_changed.emit()
|
||||
|
||||
def update_view(self):
|
||||
print "FCVisibleProcessContainer.update_view()"
|
||||
# print "FCVisibleProcessContainer.update_view()"
|
||||
if len(self.procs) == 0:
|
||||
self.view.set_idle()
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 487 B |
Binary file not shown.
After Width: | Height: | Size: 569 B |
Binary file not shown.
After Width: | Height: | Size: 659 B |
|
@ -0,0 +1,34 @@
|
|||
from time import sleep
|
||||
from PyQt4 import QtCore
|
||||
from FlatCAMWorker import Worker
|
||||
|
||||
class MyObj():
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __del__(self):
|
||||
print "##### Distroyed ######"
|
||||
|
||||
|
||||
def parse():
|
||||
o = MyObj()
|
||||
raise Exception("Intentional Exception")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
qo = QtCore.QObject
|
||||
worker = Worker(qo)
|
||||
thr1 = QtCore.QThread()
|
||||
worker.moveToThread(thr1)
|
||||
qo.connect(thr1, QtCore.SIGNAL("started()"), worker.run)
|
||||
thr1.start()
|
||||
|
||||
while True:
|
||||
try:
|
||||
parse()
|
||||
print "Parse returned."
|
||||
except Exception:
|
||||
pass
|
||||
sleep(5)
|
||||
print "Competed successfully."
|
|
@ -0,0 +1,6 @@
|
|||
import cProfile
|
||||
import pstats
|
||||
from camlib import *
|
||||
|
||||
g = Geometry()
|
||||
|
Loading…
Reference in New Issue