- 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:
@@ -1339,7 +1339,7 @@ class ResizeEditorExc(FCShapeTool):
|
||||
dia_on_row = self.draw_app.ui.tools_table_exc.item(row, 1).text()
|
||||
self.selected_dia_set.add(float(dia_on_row))
|
||||
|
||||
# since we add a new tool, we update also the intial state of the tool_table through it's dictionary
|
||||
# since we add a new tool, we update also the intial state of the plugin_table through it's dictionary
|
||||
# we add a new entry in the tool2tooldia dict
|
||||
self.draw_app.tool2tooldia[len(self.draw_app.olddia_newdia)] = new_dia
|
||||
|
||||
@@ -1414,9 +1414,9 @@ class ResizeEditorExc(FCShapeTool):
|
||||
# remove the geometry with the old size
|
||||
self.current_storage.remove(select_shape)
|
||||
|
||||
# a hack to make the tool_table display less drills per diameter when shape(drill) is deleted
|
||||
# a hack to make the plugin_table display less drills per diameter when shape(drill) is deleted
|
||||
# self.points_edit it's only useful first time when we load the data into the storage
|
||||
# but is still used as reference when building tool_table in self.build_ui()
|
||||
# but is still used as reference when building plugin_table in self.build_ui()
|
||||
# the number of drills displayed in column 2 is just a len(self.points_edit) therefore
|
||||
# deleting self.points_edit elements (doesn't matter who but just the number)
|
||||
# solved the display issue.
|
||||
@@ -1439,10 +1439,10 @@ class ResizeEditorExc(FCShapeTool):
|
||||
|
||||
sel_shapes_to_be_deleted.append(select_shape)
|
||||
|
||||
# a hack to make the tool_table display more drills/slots per diameter when shape(drill/slot)
|
||||
# a hack to make the plugin_table display more drills/slots per diameter when shape(drill/slot)
|
||||
# is added.
|
||||
# self.points_edit it's only useful first time when we load the data into the storage
|
||||
# but is still used as reference when building tool_table in self.build_ui()
|
||||
# but is still used as reference when building plugin_table in self.build_ui()
|
||||
# the number of drills displayed in column 2 is just a len(self.points_edit) therefore
|
||||
# deleting self.points_edit elements (doesn't matter who but just the number)
|
||||
# solved the display issue.
|
||||
@@ -1766,7 +1766,7 @@ class AppExcEditor(QtCore.QObject):
|
||||
# here store the tools dict for the new excellon object
|
||||
self.new_tools = {}
|
||||
|
||||
# dictionary to store the tool_row and diameters in Tool_table
|
||||
# dictionary to store the tool_row and diameters in plugin_table
|
||||
# it will be updated everytime self.build_ui() is called
|
||||
self.olddia_newdia = {}
|
||||
|
||||
@@ -1956,7 +1956,7 @@ class AppExcEditor(QtCore.QObject):
|
||||
self.olddia_newdia.clear()
|
||||
self.tool2tooldia.clear()
|
||||
|
||||
# update the olddia_newdia dict to make sure we have an updated state of the tool_table
|
||||
# update the olddia_newdia dict to make sure we have an updated state of the plugin_table
|
||||
for key in self.points_edit:
|
||||
self.olddia_newdia[key] = key
|
||||
|
||||
@@ -2296,7 +2296,7 @@ class AppExcEditor(QtCore.QObject):
|
||||
"Save and reedit Excellon if you need to add this tool. "))
|
||||
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 tool2tooldia dict
|
||||
self.tool2tooldia[len(self.olddia_newdia)] = tool_dia
|
||||
|
||||
@@ -2414,7 +2414,7 @@ class AppExcEditor(QtCore.QObject):
|
||||
# tool diameter is already in use so we move the drills from the prior tool to the new tool
|
||||
destination_storage = self.storage_dict[new_dia]
|
||||
|
||||
# since we add a new tool, we update also the intial state of the tool_table through it's dictionary
|
||||
# since we add a new tool, we update also the intial state of the plugin_table through it's dictionary
|
||||
# we add a new entry in the tool2tooldia dict
|
||||
self.tool2tooldia[len(self.olddia_newdia)] = new_dia
|
||||
|
||||
@@ -3780,9 +3780,9 @@ class AppExcEditor(QtCore.QObject):
|
||||
if del_shape in self.storage_dict[storage].get_objects():
|
||||
if isinstance(del_shape.geo, MultiLineString):
|
||||
self.storage_dict[storage].remove(del_shape)
|
||||
# a hack to make the tool_table display less drills per diameter
|
||||
# a hack to make the plugin_table display less drills per diameter
|
||||
# self.points_edit it's only useful first time when we load the data into the storage
|
||||
# but is still used as referecen when building tool_table in self.build_ui()
|
||||
# but is still used as referecen when building plugin_table in self.build_ui()
|
||||
# the number of drills displayed in column 2 is just a len(self.points_edit) therefore
|
||||
# deleting self.points_edit elements (doesn't matter who but just the number)
|
||||
# solved the display issue.
|
||||
@@ -3806,15 +3806,15 @@ class AppExcEditor(QtCore.QObject):
|
||||
self.delete_selected()
|
||||
self.replot()
|
||||
|
||||
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_exc[toolname]["button"].setChecked(True)
|
||||
self.on_tool_select(toolname)
|
||||
self.tools_exc[pluginName]["button"].setChecked(True)
|
||||
self.on_tool_select(pluginName)
|
||||
|
||||
def set_selected(self, sel_shape):
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class BufferSelectionTool(AppTool):
|
||||
Simple input for buffer distance.
|
||||
"""
|
||||
|
||||
toolName = _("Buffer Selection")
|
||||
pluginName = _("Buffer Selection")
|
||||
|
||||
def __init__(self, app, draw_app):
|
||||
AppTool.__init__(self, app)
|
||||
@@ -63,7 +63,7 @@ class BufferSelectionTool(AppTool):
|
||||
self.decimals = app.decimals
|
||||
|
||||
# Title
|
||||
title_label = FCLabel("%s" % ('Editor ' + self.toolName))
|
||||
title_label = FCLabel("%s" % ('Editor ' + self.pluginName))
|
||||
title_label.setStyleSheet("""
|
||||
QLabel
|
||||
{
|
||||
@@ -144,14 +144,14 @@ class BufferSelectionTool(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
|
||||
|
||||
@@ -222,7 +222,7 @@ class TextInputTool(AppTool):
|
||||
Simple input for buffer distance.
|
||||
"""
|
||||
|
||||
toolName = _("Text Input Tool")
|
||||
pluginName = _("Text Input Tool")
|
||||
|
||||
def __init__(self, app, draw_app):
|
||||
AppTool.__init__(self, app)
|
||||
@@ -244,7 +244,7 @@ class TextInputTool(AppTool):
|
||||
self.text_tool_frame.setLayout(self.text_tools_box)
|
||||
|
||||
# Title
|
||||
title_label = FCLabel("%s" % self.toolName)
|
||||
title_label = FCLabel("%s" % self.pluginName)
|
||||
title_label.setStyleSheet("""
|
||||
QLabel
|
||||
{
|
||||
@@ -384,14 +384,14 @@ class TextInputTool(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
|
||||
|
||||
@@ -463,7 +463,7 @@ class PaintOptionsTool(AppTool):
|
||||
Inputs to specify how to paint the selected polygons.
|
||||
"""
|
||||
|
||||
toolName = _("Paint Tool")
|
||||
pluginName = _("Paint Tool")
|
||||
|
||||
def __init__(self, app, fcdraw):
|
||||
AppTool.__init__(self, app)
|
||||
@@ -473,7 +473,7 @@ class PaintOptionsTool(AppTool):
|
||||
self.decimals = self.app.decimals
|
||||
|
||||
# Title
|
||||
title_label = FCLabel("%s" % self.toolName)
|
||||
title_label = FCLabel("%s" % self.pluginName)
|
||||
title_label.setStyleSheet("""
|
||||
QLabel
|
||||
{
|
||||
@@ -600,14 +600,14 @@ class PaintOptionsTool(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
|
||||
|
||||
@@ -675,7 +675,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")
|
||||
@@ -691,7 +691,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
|
||||
{
|
||||
@@ -1095,23 +1095,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
|
||||
|
||||
@@ -5164,15 +5164,15 @@ class AppGeoEditor(QtCore.QObject):
|
||||
|
||||
return storage
|
||||
|
||||
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[toolname]["button"].setChecked(True)
|
||||
self.on_tool_select(toolname)
|
||||
self.tools[pluginName]["button"].setChecked(True)
|
||||
self.on_tool_select(pluginName)
|
||||
|
||||
def set_selected(self, shape):
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user