- fixed the Copy Object function when the object is Gerber

- added the Copy entry to the Project context menu
- made the functions behind Disable and Enable project context menu entries, non-threaded to fix a possible issue
This commit is contained in:
Marius Stanciu 2019-01-24 12:31:42 +02:00 committed by Marius
parent 780b5c8bf2
commit 8f787fc61a
4 changed files with 73 additions and 32 deletions

View File

@ -956,6 +956,7 @@ class App(QtCore.QObject):
self.ui.menuprojectenable.triggered.connect(lambda: self.enable_plots(self.collection.get_selected()))
self.ui.menuprojectdisable.triggered.connect(lambda: self.disable_plots(self.collection.get_selected()))
self.ui.menuprojectgeneratecnc.triggered.connect(lambda: self.generate_cnc_job(self.collection.get_selected()))
self.ui.menuprojectcopy.triggered.connect(self.on_copy_object)
self.ui.menuprojectdelete.triggered.connect(self.on_delete)
# Toolbar
@ -3090,8 +3091,11 @@ class App(QtCore.QObject):
def initialize(obj_init, app):
obj_init.solid_geometry = obj.solid_geometry
if obj.tools:
obj_init.tools = obj.tools
try:
if obj.tools:
obj_init.tools = obj.tools
except Exception as e:
log.debug("on_copy_object() --> %s" % str(e))
def initialize_excellon(obj_init, app):
obj_init.tools = obj.tools
@ -3118,8 +3122,11 @@ class App(QtCore.QObject):
def initialize_geometry(obj_init, app):
obj_init.solid_geometry = obj.solid_geometry
if obj.tools:
obj_init.tools = obj.tools
try:
if obj.tools:
obj_init.tools = obj.tools
except Exception as e:
log.debug("on_copy_object2() --> %s" % str(e))
def initialize_gerber(obj_init, app):
obj_init.solid_geometry = obj.solid_geometry
@ -5899,28 +5906,51 @@ class App(QtCore.QObject):
"info"
)
def enable_plots(self, objects):
def worker_task(app_obj):
percentage = 0.1
try:
delta = 0.9 / len(objects)
except ZeroDivisionError:
# TODO: FIX THIS
'''
By default this is not threaded
If threaded the app give warnings like this:
QObject::connect: Cannot queue arguments of type 'QVector<int>'
(Make sure 'QVector<int>' is registered using qRegisterMetaType().
'''
def enable_plots(self, objects, threaded=False):
if threaded is True:
def worker_task(app_obj):
percentage = 0.1
try:
delta = 0.9 / len(objects)
except ZeroDivisionError:
self.progress.emit(0)
return
for obj in objects:
obj.options['plot'] = True
percentage += delta
self.progress.emit(int(percentage*100))
self.progress.emit(0)
return
self.plots_updated.emit()
self.collection.update_view()
# Send to worker
# self.worker.add_task(worker_task, [self])
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
else:
for obj in objects:
obj.options['plot'] = True
percentage += delta
self.progress.emit(int(percentage*100))
self.progress.emit(0)
self.plots_updated.emit()
self.collection.update_view()
# Send to worker
# self.worker.add_task(worker_task, [self])
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
# TODO: FIX THIS
'''
By default this is not threaded
If threaded the app give warnings like this:
def disable_plots(self, objects):
QObject::connect: Cannot queue arguments of type 'QVector<int>'
(Make sure 'QVector<int>' is registered using qRegisterMetaType().
'''
def disable_plots(self, objects, threaded=False):
# TODO: This method is very similar to replot_all. Try to merge.
"""
Disables plots
@ -5928,28 +5958,34 @@ class App(QtCore.QObject):
Objects to be disabled
:return:
"""
self.progress.emit(10)
def worker_task(app_obj):
percentage = 0.1
try:
delta = 0.9 / len(objects)
except ZeroDivisionError:
if threaded is True:
self.progress.emit(10)
def worker_task(app_obj):
percentage = 0.1
try:
delta = 0.9 / len(objects)
except ZeroDivisionError:
self.progress.emit(0)
return
for obj in objects:
obj.options['plot'] = False
percentage += delta
self.progress.emit(int(percentage*100))
self.progress.emit(0)
return
self.plots_updated.emit()
self.collection.update_view()
# Send to worker
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
else:
for obj in objects:
obj.options['plot'] = False
percentage += delta
self.progress.emit(int(percentage*100))
self.progress.emit(0)
self.plots_updated.emit()
self.collection.update_view()
# Send to worker
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
def clear_plots(self):
objects = self.collection.get_list()

View File

@ -323,6 +323,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menuproject.addSeparator()
self.menuprojectgeneratecnc = self.menuproject.addAction('Generate CNC')
self.menuproject.addSeparator()
self.menuprojectcopy = self.menuproject.addAction('Copy')
self.menuprojectdelete = self.menuproject.addAction('Delete')
###############

View File

@ -388,6 +388,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
sel = len(self.view.selectedIndexes()) > 0
self.app.ui.menuprojectenable.setEnabled(sel)
self.app.ui.menuprojectdisable.setEnabled(sel)
self.app.ui.menuprojectcopy.setEnabled(sel)
self.app.ui.menuprojectdelete.setEnabled(sel)
if sel:

View File

@ -12,6 +12,9 @@ CAD program, and create G-Code for Isolation routing.
24.01.2019
- trying to fix painting single when the actual painted object it's a MultiPolygon
- fixed the Copy Object function when the object is Gerber
- added the Copy entry to the Project context menu
- made the functions behind Disable and Enable project context menu entries, non-threaded to fix a possible issue
23.01.2019