- some refactoring

- working on Milling Tool and Drilling Tool: made sure that the plugin UI is initialized only when the plugin (Tool) is run in order to avoid errors like (wrapped C++ objects was deleted)
This commit is contained in:
Marius Stanciu
2021-01-29 02:08:34 +02:00
committed by Marius
parent 6c3a99d876
commit 04649622eb
54 changed files with 581 additions and 561 deletions

View File

@@ -3270,7 +3270,7 @@ class AppGerberEditor(QtCore.QObject):
# store here the plot promises, if empty the delayed plot will be activated
self.grb_plot_promises = []
# dictionary to store the tool_row and aperture codes in Tool_table
# dictionary to store the tool_row and aperture codes in plugin_table
# it will be updated everytime self.build_ui() is called
self.oldapcode_newapcode = {}
@@ -3505,7 +3505,7 @@ class AppGerberEditor(QtCore.QObject):
self.oldapcode_newapcode.clear()
self.tid2apcode.clear()
# update the oldapcode_newapcode dict to make sure we have an updated state of the tool_table
# update the oldapcode_newapcode dict to make sure we have an updated state of the plugin_table
for key in self.storage_dict:
self.oldapcode_newapcode[key] = key
@@ -3793,7 +3793,7 @@ class AppGerberEditor(QtCore.QObject):
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Aperture already in the aperture table."))
return
# since we add a new tool, we update also the initial state of the tool_table through it's dictionary
# since we add a new tool, we update also the initial state of the plugin_table through it's dictionary
# we add a new entry in the tid2apcode dict
self.tid2apcode[len(self.oldapcode_newapcode)] = int(ap_code)
@@ -5684,15 +5684,15 @@ class AppGerberEditor(QtCore.QObject):
self.delete_selected()
self.plot_all()
def select_tool(self, toolname):
def select_tool(self, pluginName):
"""
Selects a drawing tool. Impacts the object and appGUI.
:param toolname: Name of the tool.
:param pluginName: Name of the tool.
:return: None
"""
self.tools_gerber[toolname]["button"].setChecked(True)
self.on_tool_select(toolname)
self.tools_gerber[pluginName]["button"].setChecked(True)
self.on_tool_select(pluginName)
def set_selected(self, geo_el):
@@ -6652,7 +6652,7 @@ class TransformEditorTool(AppTool):
Inputs to specify how to paint the selected polygons.
"""
toolName = _("Transform Tool")
pluginName = _("Transform Tool")
rotateName = _("Rotate")
skewName = _("Skew/Shear")
scaleName = _("Scale")
@@ -6668,7 +6668,7 @@ class TransformEditorTool(AppTool):
self.decimals = self.app.decimals
# ## Title
title_label = FCLabel("%s" % self.toolName)
title_label = FCLabel("%s" % self.pluginName)
title_label.setStyleSheet("""
QLabel
{
@@ -7072,23 +7072,23 @@ class TransformEditorTool(AppTool):
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "tool_tab":
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Plugin"))
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
self.app.ui.notebook.callback_on_close = self.on_tab_close
if toggle:
try:
if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
if self.app.ui.plugin_scroll_area.widget().objectName() == self.pluginName:
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
else:
self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
except AttributeError:
pass