Update instead of setting options when reading project. Fixes #204.

This commit is contained in:
Juan Pablo Caram 2016-07-02 17:36:19 -04:00
parent 01c2feca98
commit b4017cfec2
1 changed files with 17 additions and 0 deletions

View File

@ -49,6 +49,23 @@ class FlatCAMObj(QtCore.QObject):
# self.ui.offset_button.clicked.connect(self.on_offset_button_click)
# self.ui.scale_button.clicked.connect(self.on_scale_button_click)
def from_dict(self, d):
"""
This supersedes ``from_dict`` in derived classes. Derived classes
must inherit from FlatCAMObj first, then from derivatives of Geometry.
``self.options`` is only updated, not overwritten. This ensures that
options set by the app do not vanish when reading the objects
from a project file.
"""
for attr in self.ser_attrs:
if attr == 'options':
self.options.update(d[attr])
else:
setattr(self, attr, d[attr])
def on_options_change(self, key):
self.emit(QtCore.SIGNAL("optionChanged"), key)