- fixed bug where for Geometry objects after a successful object rename done in the Object collection view (Project tab), deselect the object and reselect it and then in the Selected tab the name is not the new one but the old one

- for Geometry objects, adding a new tool to the Tools table after a successful rename will now store the new name in the tool data
This commit is contained in:
Marius Stanciu
2019-06-17 17:01:27 +03:00
parent 0244c76605
commit ffa92524f0
4 changed files with 37 additions and 28 deletions

View File

@@ -5249,6 +5249,7 @@ class App(QtCore.QObject):
if index.isValid(): if index.isValid():
if index.internalPointer().parent_item != self.collection.root_item: if index.internalPointer().parent_item != self.collection.root_item:
self.ui.notebook.setCurrentWidget(self.ui.selected_tab) self.ui.notebook.setCurrentWidget(self.ui.selected_tab)
self.collection.on_item_activated(index)
def grid_status(self): def grid_status(self):
if self.ui.grid_snap_btn.isChecked(): if self.ui.grid_snap_btn.isChecked():

View File

@@ -68,6 +68,9 @@ class FlatCAMObj(QtCore.QObject):
self.form_fields = {} self.form_fields = {}
# store here the default data for Geometry Data
self.default_data = {}
self.kind = None # Override with proper name self.kind = None # Override with proper name
# self.shapes = ShapeCollection(parent=self.app.plotcanvas.vispy_canvas.view.scene) # self.shapes = ShapeCollection(parent=self.app.plotcanvas.vispy_canvas.view.scene)
@@ -137,7 +140,7 @@ class FlatCAMObj(QtCore.QObject):
if key == 'plot': if key == 'plot':
self.visible = self.options['plot'] self.visible = self.options['plot']
# self.optionChanged.emit(key) self.optionChanged.emit(key)
def set_ui(self, ui): def set_ui(self, ui):
self.ui = ui self.ui = ui
@@ -199,6 +202,7 @@ class FlatCAMObj(QtCore.QObject):
log.debug("on_name_activate() --> Could not remove the old object name from auto-completer model list") log.debug("on_name_activate() --> Could not remove the old object name from auto-completer model list")
self.options["name"] = self.ui.name_entry.get_value() self.options["name"] = self.ui.name_entry.get_value()
self.default_data["name"] = self.ui.name_entry.get_value()
self.app.collection.update_view() self.app.collection.update_view()
self.app.inform.emit(_("[success] Name changed from {old} to {new}").format(old=old_name, new=new_name)) self.app.inform.emit(_("[success] Name changed from {old} to {new}").format(old=old_name, new=new_name))
@@ -1938,10 +1942,6 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
self.ui.tools_table.setColumnWidth(5, 17) self.ui.tools_table.setColumnWidth(5, 17)
# horizontal_header.setStretchLastSection(True) # horizontal_header.setStretchLastSection(True)
# horizontal_header.setColumnWidth(2, QtWidgets.QHeaderView.ResizeToContents) # horizontal_header.setColumnWidth(2, QtWidgets.QHeaderView.ResizeToContents)
# horizontal_header.setStretchLastSection(True) # horizontal_header.setStretchLastSection(True)
@@ -3002,9 +3002,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.old_pp_state = '' self.old_pp_state = ''
self.old_toolchangeg_state = '' self.old_toolchangeg_state = ''
# store here the default data for Geometry Data
self.default_data = {}
# Attributes to be included in serialization # Attributes to be included in serialization
# Always append to it because it carries contents # Always append to it because it carries contents
# from predecessors. # from predecessors.
@@ -3013,7 +3010,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
def build_ui(self): def build_ui(self):
self.ui_disconnect() self.ui_disconnect()
FlatCAMObj.build_ui(self) FlatCAMObj.build_ui(self)
offset = 0 offset = 0
@@ -3151,6 +3147,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.set_tool_offset_visibility(selected_row) self.set_tool_offset_visibility(selected_row)
self.ui_connect() self.ui_connect()
# HACK: for whatever reasons the name in Selected tab is reverted to the original one after a successful rename
# done in the collection view but only for Geometry objects. Perhaps some references remains. Should be fixed.
self.ui.name_entry.set_value(self.options['name'])
def set_ui(self, ui): def set_ui(self, ui):
FlatCAMObj.set_ui(self, ui) FlatCAMObj.set_ui(self, ui)
@@ -3225,7 +3225,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
for def_key in self.default_data: for def_key in self.default_data:
for opt_key, opt_val in self.options.items(): for opt_key, opt_val in self.options.items():
if def_key == opt_key: if def_key == opt_key:
self.default_data[def_key] = opt_val self.default_data[def_key] = deepcopy(opt_val)
self.tooluid += 1 self.tooluid += 1
if not self.tools: if not self.tools:
@@ -3325,10 +3325,11 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
return return
def on_offset_value_edited(self): def on_offset_value_edited(self):
''' """
This will save the offset_value into self.tools storage whenever the oofset value is edited This will save the offset_value into self.tools storage whenever the offset value is edited
:return: :return:
''' """
for current_row in self.ui.geo_tools_table.selectedItems(): for current_row in self.ui.geo_tools_table.selectedItems():
# sometime the header get selected and it has row number -1 # sometime the header get selected and it has row number -1
# we don't want to do anything with the header :) # we don't want to do anything with the header :)
@@ -3371,7 +3372,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
# works for Entry # works for Entry
try: try:
self.ui.grid3.itemAt(i).widget().editingFinished.connect(self.gui_form_to_storage) self.ui.grid3.itemAt(i).widget().editingFinished.connect(self.gui_form_to_storage)
except: except Exception as e3:
pass pass
for row in range(self.ui.geo_tools_table.rowCount()): for row in range(self.ui.geo_tools_table.rowCount()):
@@ -3409,56 +3410,56 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
isinstance(self.ui.grid3.itemAt(i).widget(), IntEntry) or \ isinstance(self.ui.grid3.itemAt(i).widget(), IntEntry) or \
isinstance(self.ui.grid3.itemAt(i).widget(), FCEntry): isinstance(self.ui.grid3.itemAt(i).widget(), FCEntry):
self.ui.grid3.itemAt(i).widget().editingFinished.disconnect() self.ui.grid3.itemAt(i).widget().editingFinished.disconnect()
except: except Exception as e:
pass pass
try: try:
for row in range(self.ui.geo_tools_table.rowCount()): for row in range(self.ui.geo_tools_table.rowCount()):
for col in [2, 3, 4]: for col in [2, 3, 4]:
self.ui.geo_tools_table.cellWidget(row, col).currentIndexChanged.disconnect() self.ui.geo_tools_table.cellWidget(row, col).currentIndexChanged.disconnect()
except: except Exception as e:
pass pass
# I use lambda's because the connected functions have parameters that could be used in certain scenarios # I use lambda's because the connected functions have parameters that could be used in certain scenarios
try: try:
self.ui.addtool_btn.clicked.disconnect() self.ui.addtool_btn.clicked.disconnect()
except: except Exception as e:
pass pass
try: try:
self.ui.copytool_btn.clicked.disconnect() self.ui.copytool_btn.clicked.disconnect()
except: except Exception as e:
pass pass
try: try:
self.ui.deltool_btn.clicked.disconnect() self.ui.deltool_btn.clicked.disconnect()
except: except Exception as e:
pass pass
try: try:
self.ui.geo_tools_table.currentItemChanged.disconnect() self.ui.geo_tools_table.currentItemChanged.disconnect()
except: except Exception as e:
pass pass
try: try:
self.ui.geo_tools_table.itemChanged.disconnect() self.ui.geo_tools_table.itemChanged.disconnect()
except: except Exception as e:
pass pass
try: try:
self.ui.tool_offset_entry.editingFinished.disconnect() self.ui.tool_offset_entry.editingFinished.disconnect()
except: except Exception as e:
pass pass
for row in range(self.ui.geo_tools_table.rowCount()): for row in range(self.ui.geo_tools_table.rowCount()):
try: try:
self.ui.geo_tools_table.cellWidget(row, 6).clicked.disconnect() self.ui.geo_tools_table.cellWidget(row, 6).clicked.disconnect()
except: except Exception as e:
pass pass
try: try:
self.ui.plot_cb.stateChanged.disconnect() self.ui.plot_cb.stateChanged.disconnect()
except: except Exception as e:
pass pass
def on_tool_add(self, dia=None): def on_tool_add(self, dia=None):
@@ -3545,6 +3546,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
} }
}) })
self.tools[self.tooluid]['data']['name'] = self.options['name']
self.ui.tool_offset_entry.hide() self.ui.tool_offset_entry.hide()
self.ui.tool_offset_lbl.hide() self.ui.tool_offset_lbl.hide()

View File

@@ -263,10 +263,9 @@ class ObjectCollection(QtCore.QAbstractItemModel):
# ## GUI Events # ## GUI Events
self.view.selectionModel().selectionChanged.connect(self.on_list_selection_change) self.view.selectionModel().selectionChanged.connect(self.on_list_selection_change)
self.view.activated.connect(self.on_item_activated) # self.view.activated.connect(self.on_item_activated)
# self.view.keyPressed.connect(self.on_key)
self.view.keyPressed.connect(self.app.ui.keyPressEvent) self.view.keyPressed.connect(self.app.ui.keyPressEvent)
self.view.clicked.connect(self.on_mouse_down) # self.view.clicked.connect(self.on_mouse_down)
self.view.customContextMenuRequested.connect(self.on_menu_request) self.view.customContextMenuRequested.connect(self.on_menu_request)
self.click_modifier = None self.click_modifier = None
@@ -398,8 +397,9 @@ class ObjectCollection(QtCore.QAbstractItemModel):
def setData(self, index, data, role=None): def setData(self, index, data, role=None):
if index.isValid(): if index.isValid():
obj = index.internalPointer().obj obj = index.internalPointer().obj
if obj: if obj:
old_name = obj.options['name'] old_name = deepcopy(obj.options['name'])
new_name = str(data) new_name = str(data)
if old_name != new_name and new_name != '': if old_name != new_name and new_name != '':
# rename the object # rename the object

View File

@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
================================================= =================================================
17.06.2019
- fixed bug where for Geometry objects after a successful object rename done in the Object collection view (Project tab), deselect the object and reselect it and then in the Selected tab the name is not the new one but the old one
- for Geometry objects, adding a new tool to the Tools table after a successful rename will now store the new name in the tool data
15.06.2019 15.06.2019
- fixed bug in Gerber parser that made the Gerber files generated by Altium Designer 18 not to be loaded - fixed bug in Gerber parser that made the Gerber files generated by Altium Designer 18 not to be loaded