- fixed issue with geometry name not being updated immediately after change while doing geocutout TclCommand

- some changes to enable/disable project context menu entry handlers
This commit is contained in:
Marius Stanciu
2019-06-02 14:04:14 +03:00
parent dca57edf24
commit c409df0a8e
5 changed files with 43 additions and 72 deletions

View File

@@ -1404,8 +1404,8 @@ class App(QtCore.QObject):
self.ui.menuhelp_videohelp.triggered.connect(lambda: webbrowser.open(self.video_url)) self.ui.menuhelp_videohelp.triggered.connect(lambda: webbrowser.open(self.video_url))
self.ui.menuhelp_shortcut_list.triggered.connect(self.on_shortcut_list) self.ui.menuhelp_shortcut_list.triggered.connect(self.on_shortcut_list)
self.ui.menuprojectenable.triggered.connect(lambda: self.enable_plots(self.collection.get_selected())) self.ui.menuprojectenable.triggered.connect(self.on_enable_sel_plots)
self.ui.menuprojectdisable.triggered.connect(lambda: self.disable_plots(self.collection.get_selected())) self.ui.menuprojectdisable.triggered.connect(self.on_disable_sel_plots)
self.ui.menuprojectgeneratecnc.triggered.connect(lambda: self.generate_cnc_job(self.collection.get_selected())) self.ui.menuprojectgeneratecnc.triggered.connect(lambda: self.generate_cnc_job(self.collection.get_selected()))
self.ui.menuprojectviewsource.triggered.connect(self.on_view_source) self.ui.menuprojectviewsource.triggered.connect(self.on_view_source)
@@ -5159,7 +5159,6 @@ class App(QtCore.QObject):
:return: None :return: None
""" """
# self.plotcanvas.auto_adjust_axes()
self.plotcanvas.vispy_canvas.update() # TODO: Need update canvas? self.plotcanvas.vispy_canvas.update() # TODO: Need update canvas?
self.on_zoom_fit(None) self.on_zoom_fit(None)
self.collection.update_view() self.collection.update_view()
@@ -8278,85 +8277,52 @@ The normal flow when working in FlatCAM is the following:</span></p>
self.enable_plots(self.collection.get_list()) self.enable_plots(self.collection.get_list())
self.inform.emit(_("[success] All plots enabled.")) self.inform.emit(_("[success] All plots enabled."))
# TODO: FIX THIS def on_enable_sel_plots(self):
''' object_list = self.collection.get_selected()
By default this is not threaded self.enable_plots(objects=object_list)
If threaded the app give warnings like this: self.inform.emit(_("[success] Selected plots enabled..."))
QObject::connect: Cannot queue arguments of type 'QVector<int>' def on_disable_sel_plots(self):
(Make sure 'QVector<int>' is registered using qRegisterMetaType(). # self.inform.emit(_("Disabling plots ..."))
''' object_list = self.collection.get_selected()
def enable_plots(self, objects, threaded=True): self.disable_plots(objects=object_list)
if threaded is True: self.inform.emit(_("[success] Selected plots disabled..."))
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) def enable_plots(self, objects):
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
# self.progress.emit(0)
self.plots_updated.emit()
# self.collection.update_view()
# 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 disable_plots(self, objects, threaded=True):
# TODO: This method is very similar to replot_all. Try to merge.
""" """
Disables plots Disables plots
:param objects: list :param objects: list of Objects to be enabled
Objects to be disabled
:return: :return:
""" """
if threaded is True: log.debug("Enabling plots ...")
# 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: def worker_task(app_obj):
obj.options['plot'] = False # app_obj.inform.emit(_("Enabling plots ..."))
# percentage += delta for obj in objects:
# self.progress.emit(int(percentage*100)) obj.options['plot'] = True
self.plots_updated.emit()
# self.progress.emit(0) # Send to worker
self.plots_updated.emit() self.worker_task.emit({'fcn': worker_task, 'params': [self]})
# self.collection.update_view()
# Send to worker def disable_plots(self, objects):
self.worker_task.emit({'fcn': worker_task, 'params': [self]}) """
else: Disables plots
:param objects: list of Objects to be disabled
:return:
"""
log.debug("Disabling plots ...")
def worker_task(app_obj):
self.inform.emit(_("Disabling plots ..."))
for obj in objects: for obj in objects:
obj.options['plot'] = False obj.options['plot'] = False
self.plots_updated.emit() self.plots_updated.emit()
# self.collection.update_view()
# Send to worker
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
def clear_plots(self): def clear_plots(self):

View File

@@ -137,7 +137,6 @@ class FlatCAMObj(QtCore.QObject):
if key == 'plot': if key == 'plot':
self.visible = self.options['plot'] self.visible = self.options['plot']
# self.emit(QtCore.SIGNAL("optionChanged"), key)
self.optionChanged.emit(key) self.optionChanged.emit(key)
def set_ui(self, ui): def set_ui(self, ui):

View File

@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
================================================= =================================================
2.06.2019
- fixed issue with geometry name not being updated immediately after change while doing geocutout TclCommand
- some changes to enable/disable project context menu entry handlers
1.06.2019 1.06.2019
- fixed text annotation for CNC job so there are no overlapping numbers when 2 lines meet on the same point - fixed text annotation for CNC job so there are no overlapping numbers when 2 lines meet on the same point

View File

@@ -120,7 +120,7 @@ class TclCommandCutout(TclCommand):
geo_obj.solid_geometry = cascaded_union([LineString(segment) for segment in cuts]) geo_obj.solid_geometry = cascaded_union([LineString(segment) for segment in cuts])
try: try:
obj.app.new_object("geometry", name + "_cutout", geo_init_me) self.app.new_object("geometry", name + "_cutout", geo_init_me)
self.app.inform.emit("[success] Rectangular-form Cutout operation finished.") self.app.inform.emit("[success] Rectangular-form Cutout operation finished.")
except Exception as e: except Exception as e:
return "Operation failed: %s" % str(e) return "Operation failed: %s" % str(e)

View File

@@ -221,6 +221,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
cutout_obj.plot() cutout_obj.plot()
self.app.inform.emit("[success] Any-form Cutout operation finished.") self.app.inform.emit("[success] Any-form Cutout operation finished.")
self.app.plots_updated.emit()
elif isinstance(cutout_obj, FlatCAMGerber): elif isinstance(cutout_obj, FlatCAMGerber):
def geo_init(geo_obj, app_obj): def geo_init(geo_obj, app_obj):
@@ -267,7 +268,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
ymin - gapsize, ymin - gapsize,
px + gapsize, px + gapsize,
ymax + gapsize) ymax + gapsize)
geo_obj.solid_geometry = geo geo_obj.solid_geometry = deepcopy(geo)
outname = cutout_obj.options["name"] + "_cutout" outname = cutout_obj.options["name"] + "_cutout"
self.app.new_object('geometry', outname, geo_init) self.app.new_object('geometry', outname, geo_init)