- 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
This commit is contained in:
@@ -4979,6 +4979,7 @@ class App(QtCore.QObject):
|
|||||||
# self.plotcanvas.auto_adjust_axes()
|
# 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()
|
||||||
|
|
||||||
# TODO: Rework toolbar 'clear', 'replot' functions
|
# TODO: Rework toolbar 'clear', 'replot' functions
|
||||||
def on_toolbar_replot(self):
|
def on_toolbar_replot(self):
|
||||||
@@ -7936,23 +7937,23 @@ The normal flow when working in FlatCAM is the following:</span></p>
|
|||||||
QObject::connect: Cannot queue arguments of type 'QVector<int>'
|
QObject::connect: Cannot queue arguments of type 'QVector<int>'
|
||||||
(Make sure 'QVector<int>' is registered using qRegisterMetaType().
|
(Make sure 'QVector<int>' is registered using qRegisterMetaType().
|
||||||
'''
|
'''
|
||||||
def enable_plots(self, objects, threaded=False):
|
def enable_plots(self, objects, threaded=True):
|
||||||
if threaded is True:
|
if threaded is True:
|
||||||
def worker_task(app_obj):
|
def worker_task(app_obj):
|
||||||
percentage = 0.1
|
# percentage = 0.1
|
||||||
try:
|
# try:
|
||||||
delta = 0.9 / len(objects)
|
# delta = 0.9 / len(objects)
|
||||||
except ZeroDivisionError:
|
# except ZeroDivisionError:
|
||||||
self.progress.emit(0)
|
# self.progress.emit(0)
|
||||||
return
|
# return
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
obj.options['plot'] = True
|
obj.options['plot'] = True
|
||||||
percentage += delta
|
# percentage += delta
|
||||||
self.progress.emit(int(percentage*100))
|
# self.progress.emit(int(percentage*100))
|
||||||
|
|
||||||
self.progress.emit(0)
|
# self.progress.emit(0)
|
||||||
self.plots_updated.emit()
|
self.plots_updated.emit()
|
||||||
self.collection.update_view()
|
# self.collection.update_view()
|
||||||
|
|
||||||
# Send to worker
|
# Send to worker
|
||||||
# self.worker.add_task(worker_task, [self])
|
# self.worker.add_task(worker_task, [self])
|
||||||
@@ -7960,9 +7961,9 @@ The normal flow when working in FlatCAM is the following:</span></p>
|
|||||||
else:
|
else:
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
obj.options['plot'] = True
|
obj.options['plot'] = True
|
||||||
self.progress.emit(0)
|
# self.progress.emit(0)
|
||||||
self.plots_updated.emit()
|
self.plots_updated.emit()
|
||||||
self.collection.update_view()
|
# self.collection.update_view()
|
||||||
|
|
||||||
# TODO: FIX THIS
|
# TODO: FIX THIS
|
||||||
'''
|
'''
|
||||||
@@ -7972,7 +7973,7 @@ The normal flow when working in FlatCAM is the following:</span></p>
|
|||||||
QObject::connect: Cannot queue arguments of type 'QVector<int>'
|
QObject::connect: Cannot queue arguments of type 'QVector<int>'
|
||||||
(Make sure 'QVector<int>' is registered using qRegisterMetaType().
|
(Make sure 'QVector<int>' 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.
|
# TODO: This method is very similar to replot_all. Try to merge.
|
||||||
"""
|
"""
|
||||||
Disables plots
|
Disables plots
|
||||||
@@ -7982,23 +7983,23 @@ The normal flow when working in FlatCAM is the following:</span></p>
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if threaded is True:
|
if threaded is True:
|
||||||
self.progress.emit(10)
|
# self.progress.emit(10)
|
||||||
def worker_task(app_obj):
|
def worker_task(app_obj):
|
||||||
percentage = 0.1
|
# percentage = 0.1
|
||||||
try:
|
# try:
|
||||||
delta = 0.9 / len(objects)
|
# delta = 0.9 / len(objects)
|
||||||
except ZeroDivisionError:
|
# except ZeroDivisionError:
|
||||||
self.progress.emit(0)
|
# self.progress.emit(0)
|
||||||
return
|
# return
|
||||||
|
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
obj.options['plot'] = False
|
obj.options['plot'] = False
|
||||||
percentage += delta
|
# percentage += delta
|
||||||
self.progress.emit(int(percentage*100))
|
# self.progress.emit(int(percentage*100))
|
||||||
|
|
||||||
self.progress.emit(0)
|
# self.progress.emit(0)
|
||||||
self.plots_updated.emit()
|
self.plots_updated.emit()
|
||||||
self.collection.update_view()
|
# self.collection.update_view()
|
||||||
|
|
||||||
# Send to worker
|
# Send to worker
|
||||||
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
|
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
|
||||||
@@ -8006,7 +8007,7 @@ The normal flow when working in FlatCAM is the following:</span></p>
|
|||||||
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()
|
# self.collection.update_view()
|
||||||
|
|
||||||
def clear_plots(self):
|
def clear_plots(self):
|
||||||
|
|
||||||
|
|||||||
@@ -256,13 +256,6 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
|||||||
# self.view.setAcceptDrops(True)
|
# self.view.setAcceptDrops(True)
|
||||||
# self.view.setDropIndicatorShown(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 = QtGui.QFont()
|
||||||
font.setPixelSize(12)
|
font.setPixelSize(12)
|
||||||
font.setFamily("Seagoe UI")
|
font.setFamily("Seagoe UI")
|
||||||
@@ -385,9 +378,10 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
|||||||
return index.internalPointer().data(index.column())
|
return index.internalPointer().data(index.column())
|
||||||
|
|
||||||
if role == Qt.ForegroundRole:
|
if role == Qt.ForegroundRole:
|
||||||
|
color = QColor(self.app.defaults['global_proj_item_color'])
|
||||||
obj = index.internalPointer().obj
|
obj = index.internalPointer().obj
|
||||||
if 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:
|
else:
|
||||||
return index.internalPointer().data(index.column())
|
return index.internalPointer().data(index.column())
|
||||||
|
|
||||||
@@ -690,6 +684,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
|||||||
:param name: Name of the FlatCAM Object
|
:param name: Name of the FlatCAM Object
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
log.debug("ObjectCollection.set_inactive()")
|
||||||
|
|
||||||
obj = self.get_by_name(name)
|
obj = self.get_by_name(name)
|
||||||
item = obj.item
|
item = obj.item
|
||||||
group = self.group_items[obj.kind]
|
group = self.group_items[obj.kind]
|
||||||
@@ -769,4 +765,4 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
|||||||
return obj_list
|
return obj_list
|
||||||
|
|
||||||
def update_view(self):
|
def update_view(self):
|
||||||
self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex())
|
self.dataChanged.emit(QtCore.QModelIndex(), QtCore.QModelIndex(), [QtCore.Qt.EditRole])
|
||||||
|
|||||||
@@ -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
|
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.
|
- 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user