From 8062af7feb1bef6dcec2ec00db94852a2e06a847 Mon Sep 17 00:00:00 2001
From: Marius Stanciu
Date: Wed, 1 May 2019 03:33:15 +0300
Subject: [PATCH] - the project items color is now controlled from Foreground
Role in ObjectCollection.data() - made again plot functions threaded but
moved the dataChanged signal (update_view() ) to the main thread by using an
already existing signal (plots_updated signal) to avoid the errors with
register QVector
---
FlatCAMApp.py | 53 +++++++++++++++++++++++----------------------
ObjectCollection.py | 14 +++++-------
README.md | 5 +++++
3 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/FlatCAMApp.py b/FlatCAMApp.py
index 3dd4646f..410212fe 100644
--- a/FlatCAMApp.py
+++ b/FlatCAMApp.py
@@ -4979,6 +4979,7 @@ class App(QtCore.QObject):
# self.plotcanvas.auto_adjust_axes()
self.plotcanvas.vispy_canvas.update() # TODO: Need update canvas?
self.on_zoom_fit(None)
+ self.collection.update_view()
# TODO: Rework toolbar 'clear', 'replot' functions
def on_toolbar_replot(self):
@@ -7936,23 +7937,23 @@ The normal flow when working in FlatCAM is the following:
QObject::connect: Cannot queue arguments of type 'QVector'
(Make sure 'QVector' is registered using qRegisterMetaType().
'''
- def enable_plots(self, objects, threaded=False):
+ def enable_plots(self, objects, threaded=True):
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
+ # 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))
+ # percentage += delta
+ # self.progress.emit(int(percentage*100))
- self.progress.emit(0)
+ # self.progress.emit(0)
self.plots_updated.emit()
- self.collection.update_view()
+ # self.collection.update_view()
# Send to worker
# self.worker.add_task(worker_task, [self])
@@ -7960,9 +7961,9 @@ The normal flow when working in FlatCAM is the following:
else:
for obj in objects:
obj.options['plot'] = True
- self.progress.emit(0)
+ # self.progress.emit(0)
self.plots_updated.emit()
- self.collection.update_view()
+ # self.collection.update_view()
# TODO: FIX THIS
'''
@@ -7972,7 +7973,7 @@ The normal flow when working in FlatCAM is the following:
QObject::connect: Cannot queue arguments of type 'QVector'
(Make sure 'QVector' is registered using qRegisterMetaType().
'''
- def disable_plots(self, objects, threaded=False):
+ def disable_plots(self, objects, threaded=True):
# TODO: This method is very similar to replot_all. Try to merge.
"""
Disables plots
@@ -7982,23 +7983,23 @@ The normal flow when working in FlatCAM is the following:
"""
if threaded is True:
- self.progress.emit(10)
+ # 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
+ # 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))
+ # percentage += delta
+ # self.progress.emit(int(percentage*100))
- self.progress.emit(0)
+ # self.progress.emit(0)
self.plots_updated.emit()
- self.collection.update_view()
+ # self.collection.update_view()
# Send to worker
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
@@ -8006,7 +8007,7 @@ The normal flow when working in FlatCAM is the following:
for obj in objects:
obj.options['plot'] = False
self.plots_updated.emit()
- self.collection.update_view()
+ # self.collection.update_view()
def clear_plots(self):
diff --git a/ObjectCollection.py b/ObjectCollection.py
index 2f2d5711..153f68fe 100644
--- a/ObjectCollection.py
+++ b/ObjectCollection.py
@@ -256,13 +256,6 @@ class ObjectCollection(QtCore.QAbstractItemModel):
# self.view.setAcceptDrops(True)
# self.view.setDropIndicatorShown(True)
- color = self.app.defaults['global_proj_item_color']
- # set StyleSheet
- stylesheet = "QTreeView::item {color: %s;}" % color
-
- self.view.setStyleSheet(stylesheet)
-
-
font = QtGui.QFont()
font.setPixelSize(12)
font.setFamily("Seagoe UI")
@@ -385,9 +378,10 @@ class ObjectCollection(QtCore.QAbstractItemModel):
return index.internalPointer().data(index.column())
if role == Qt.ForegroundRole:
+ color = QColor(self.app.defaults['global_proj_item_color'])
obj = index.internalPointer().obj
if obj:
- return QtGui.QBrush(QtCore.Qt.black) if obj.options["plot"] else QtGui.QBrush(QtCore.Qt.darkGray)
+ return QtGui.QBrush(color) if obj.options["plot"] else QtGui.QBrush(QtCore.Qt.lightGray)
else:
return index.internalPointer().data(index.column())
@@ -690,6 +684,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
:param name: Name of the FlatCAM Object
:return: None
"""
+ log.debug("ObjectCollection.set_inactive()")
+
obj = self.get_by_name(name)
item = obj.item
group = self.group_items[obj.kind]
@@ -769,4 +765,4 @@ class ObjectCollection(QtCore.QAbstractItemModel):
return obj_list
def update_view(self):
- self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex())
+ self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex(), [QtCore.Qt.EditRole])
diff --git a/README.md b/README.md
index 0504b0d6..3530c21a 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
=================================================
+01.05.2019
+
+- the project items color is now controlled from Foreground Role in ObjectCollection.data()
+- made again plot functions threaded but moved the dataChanged signal (update_view() ) to the main thread by using an already existing signal (plots_updated signal) to avoid the errors with register QVector
+
30.04.2019
- in ObjectCollection class, made sure that renaming an object in Project View does not result in an empty name. If new name is blank the rename is cancelled.