- fixed more issues (new) in NCC Tool

- added a new layout named 'minimal'
This commit is contained in:
Marius Stanciu 2020-04-19 22:22:19 +03:00 committed by Marius
parent 49fa926d50
commit 2dfcdc95e4
8 changed files with 283 additions and 254 deletions

View File

@ -1733,7 +1733,7 @@ class App(QtCore.QObject):
# ONLY AT FIRST STARTUP INIT THE GUI LAYOUT TO 'COMPACT'
initial_lay = 'compact'
self.on_layout(lay=initial_lay)
self.ui.general_defaults_form.general_gui_group.on_layout(lay=initial_lay)
# Set the combobox in Preferences to the current layout
idx = self.ui.general_defaults_form.general_gui_group.layout_combo.findText(initial_lay)
@ -2173,8 +2173,6 @@ class App(QtCore.QObject):
self.ui.general_defaults_form.general_app_set_group.workspace_cb.stateChanged.connect(self.on_workspace)
self.ui.general_defaults_form.general_gui_group.layout_combo.activated.connect(self.on_layout)
# #############################################################################
# ############################# GUI SETTINGS SIGNALS ##########################
# #############################################################################
@ -2905,6 +2903,13 @@ class App(QtCore.QObject):
"Please reboot the application to update."))
self.old_defaults_found = False
# ######################################### INIT FINISHED #######################################################
# #################################################################################################################
# #################################################################################################################
# #################################################################################################################
# #################################################################################################################
# #################################################################################################################
@staticmethod
def copy_and_overwrite(from_path, to_path):
"""
@ -5097,10 +5102,11 @@ class App(QtCore.QObject):
Save the toolbars visibility status to the preferences file (current_defaults.FlatConfig) to be
used at the next launch of the application.
:param silent: whether to display a message in status bar or not; boolean
:param data_path: the path where to save the preferences file (current_defaults.FlatConfig)
:param silent: Whether to display a message in status bar or not; boolean
:param data_path: The path where to save the preferences file (current_defaults.FlatConfig)
When the application is portable it should be a mobile location.
:return: None
:param first_time: Boolean. If True will execute some code when the app is run first time
:return: None
"""
self.report_usage("save_defaults")
@ -5133,6 +5139,30 @@ class App(QtCore.QObject):
defaults.update(self.defaults)
self.propagate_defaults(silent=True)
if first_time is False:
self.save_toolbar_view()
# Save update options
filename = data_path + "/current_defaults.FlatConfig"
try:
f = open(filename, "w")
json.dump(defaults, f, default=to_dict, indent=2, sort_keys=True)
f.close()
except Exception as e:
log.debug("App.save_defaults() --> %s" % str(e))
self.inform.emit('[ERROR_NOTCL] %s %s' % (_("Failed to write defaults to file."), str(filename)))
return
if not silent:
self.inform.emit('[success] %s' % _("Preferences saved."))
def save_toolbar_view(self):
"""
Will save the toolbar view state to the defaults
:return: None
"""
# Save the toolbar view
tb_status = 0
if self.ui.toolbarfile.isVisible():
@ -5162,22 +5192,7 @@ class App(QtCore.QObject):
if self.ui.toolbarshell.isVisible():
tb_status += 256
if first_time is False:
self.defaults["global_toolbar_view"] = tb_status
# Save update options
filename = data_path + "/current_defaults.FlatConfig"
try:
f = open(filename, "w")
json.dump(defaults, f, default=to_dict, indent=2, sort_keys=True)
f.close()
except Exception as e:
log.debug("App.save_defaults() --> %s" % str(e))
self.inform.emit('[ERROR_NOTCL] %s %s' % (_("Failed to write defaults to file."), str(filename)))
return
if not silent:
self.inform.emit('[success] %s' % _("Preferences saved."))
self.defaults["global_toolbar_view"] = tb_status
def save_factory_defaults(self, silent_message=False, data_path=None):
"""
@ -6899,147 +6914,6 @@ class App(QtCore.QObject):
self.ui.general_defaults_form.general_app_set_group.workspace_cb.stateChanged.connect(self.on_workspace)
self.on_workspace()
def on_layout(self, index=None, lay=None):
"""
Set the toolbars layout (location)
:param index:
:param lay: type of layout to be set on the toolbard
:return: None
"""
self.report_usage("on_layout()")
if lay:
current_layout = lay
else:
current_layout = self.ui.general_defaults_form.general_gui_group.layout_combo.get_value()
lay_settings = QSettings("Open Source", "FlatCAM")
lay_settings.setValue('layout', current_layout)
# This will write the setting to the platform specific storage.
del lay_settings
# first remove the toolbars:
try:
self.ui.removeToolBar(self.ui.toolbarfile)
self.ui.removeToolBar(self.ui.toolbargeo)
self.ui.removeToolBar(self.ui.toolbarview)
self.ui.removeToolBar(self.ui.toolbarshell)
self.ui.removeToolBar(self.ui.toolbartools)
self.ui.removeToolBar(self.ui.exc_edit_toolbar)
self.ui.removeToolBar(self.ui.geo_edit_toolbar)
self.ui.removeToolBar(self.ui.grb_edit_toolbar)
self.ui.removeToolBar(self.ui.snap_toolbar)
self.ui.removeToolBar(self.ui.toolbarshell)
except Exception:
pass
if current_layout == 'standard':
# ## TOOLBAR INSTALLATION # ##
self.ui.toolbarfile = QtWidgets.QToolBar('File Toolbar')
self.ui.toolbarfile.setObjectName('File_TB')
self.ui.addToolBar(self.ui.toolbarfile)
self.ui.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
self.ui.toolbargeo.setObjectName('Edit_TB')
self.ui.addToolBar(self.ui.toolbargeo)
self.ui.toolbarview = QtWidgets.QToolBar('View Toolbar')
self.ui.toolbarview.setObjectName('View_TB')
self.ui.addToolBar(self.ui.toolbarview)
self.ui.toolbarshell = QtWidgets.QToolBar('Shell Toolbar')
self.ui.toolbarshell.setObjectName('Shell_TB')
self.ui.addToolBar(self.ui.toolbarshell)
self.ui.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
self.ui.toolbartools.setObjectName('Tools_TB')
self.ui.addToolBar(self.ui.toolbartools)
self.ui.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
# self.ui.exc_edit_toolbar.setVisible(False)
self.ui.exc_edit_toolbar.setObjectName('ExcEditor_TB')
self.ui.addToolBar(self.ui.exc_edit_toolbar)
self.ui.addToolBarBreak()
self.ui.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
# self.ui.geo_edit_toolbar.setVisible(False)
self.ui.geo_edit_toolbar.setObjectName('GeoEditor_TB')
self.ui.addToolBar(self.ui.geo_edit_toolbar)
self.ui.grb_edit_toolbar = QtWidgets.QToolBar('Gerber Editor Toolbar')
# self.ui.grb_edit_toolbar.setVisible(False)
self.ui.grb_edit_toolbar.setObjectName('GrbEditor_TB')
self.ui.addToolBar(self.ui.grb_edit_toolbar)
self.ui.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
self.ui.snap_toolbar.setObjectName('Snap_TB')
# self.ui.snap_toolbar.setMaximumHeight(30)
self.ui.addToolBar(self.ui.snap_toolbar)
self.ui.corner_snap_btn.setVisible(False)
self.ui.snap_magnet.setVisible(False)
elif current_layout == 'compact':
# ## TOOLBAR INSTALLATION # ##
self.ui.toolbarfile = QtWidgets.QToolBar('File Toolbar')
self.ui.toolbarfile.setObjectName('File_TB')
self.ui.addToolBar(Qt.LeftToolBarArea, self.ui.toolbarfile)
self.ui.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
self.ui.toolbargeo.setObjectName('Edit_TB')
self.ui.addToolBar(Qt.LeftToolBarArea, self.ui.toolbargeo)
self.ui.toolbarshell = QtWidgets.QToolBar('Shell Toolbar')
self.ui.toolbarshell.setObjectName('Shell_TB')
self.ui.addToolBar(Qt.LeftToolBarArea, self.ui.toolbarshell)
self.ui.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
self.ui.toolbartools.setObjectName('Tools_TB')
self.ui.addToolBar(Qt.LeftToolBarArea, self.ui.toolbartools)
self.ui.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
# self.ui.geo_edit_toolbar.setVisible(False)
self.ui.geo_edit_toolbar.setObjectName('GeoEditor_TB')
self.ui.addToolBar(Qt.RightToolBarArea, self.ui.geo_edit_toolbar)
self.ui.toolbarview = QtWidgets.QToolBar('View Toolbar')
self.ui.toolbarview.setObjectName('View_TB')
self.ui.addToolBar(Qt.RightToolBarArea, self.ui.toolbarview)
self.ui.addToolBarBreak(area=Qt.RightToolBarArea)
self.ui.grb_edit_toolbar = QtWidgets.QToolBar('Gerber Editor Toolbar')
# self.ui.grb_edit_toolbar.setVisible(False)
self.ui.grb_edit_toolbar.setObjectName('GrbEditor_TB')
self.ui.addToolBar(Qt.RightToolBarArea, self.ui.grb_edit_toolbar)
self.ui.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
self.ui.exc_edit_toolbar.setObjectName('ExcEditor_TB')
self.ui.addToolBar(Qt.RightToolBarArea, self.ui.exc_edit_toolbar)
self.ui.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
self.ui.snap_toolbar.setObjectName('Snap_TB')
self.ui.snap_toolbar.setMaximumHeight(30)
self.ui.splitter_left.addWidget(self.ui.snap_toolbar)
self.ui.corner_snap_btn.setVisible(True)
self.ui.snap_magnet.setVisible(True)
# add all the actions to the toolbars
self.ui.populate_toolbars()
# reconnect all the signals to the toolbar actions
self.connect_toolbar_signals()
self.ui.grid_snap_btn.setChecked(True)
self.on_grid_snap_triggered(state=True)
self.ui.grid_gap_x_entry.setText(str(self.defaults["global_gridx"]))
self.ui.grid_gap_y_entry.setText(str(self.defaults["global_gridy"]))
self.ui.snap_max_dist_entry.setText(str(self.defaults["global_snap_max"]))
self.ui.grid_gap_link_cb.setChecked(True)
def on_cursor_type(self, val):
"""

View File

@ -13,6 +13,8 @@ CAD program, and create G-Code for Isolation routing.
- fixed a bug that did not allow to edit GUI elements of type FCDoubleSpinner if it contained the percent symbol
- some small optimizations in the GUI of Cutout Tool
- fixed more issues (new) in NCC Tool
- added a new layout named 'minimal'
15.04.2020

View File

@ -2884,7 +2884,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.app.ui.corner_snap_btn.setEnabled(False)
self.app.ui.snap_magnet.setVisible(False)
self.app.ui.corner_snap_btn.setVisible(False)
elif layout == 'compact':
else:
# self.app.ui.exc_edit_toolbar.setVisible(True)
self.app.ui.snap_max_dist_entry.setEnabled(False)

View File

@ -3612,7 +3612,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.app.ui.corner_snap_btn.setEnabled(False)
self.app.ui.snap_magnet.setVisible(False)
self.app.ui.corner_snap_btn.setVisible(False)
elif layout == 'compact':
else:
# self.app.ui.geo_edit_toolbar.setVisible(True)
self.app.ui.snap_max_dist_entry.setEnabled(False)

View File

@ -3626,7 +3626,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.app.ui.corner_snap_btn.setEnabled(False)
self.app.ui.snap_magnet.setVisible(False)
self.app.ui.corner_snap_btn.setVisible(False)
elif layout == 'compact':
else:
# self.app.ui.exc_edit_toolbar.setVisible(True)
self.app.ui.snap_max_dist_entry.setEnabled(False)

View File

@ -798,9 +798,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("layout"):
layout = settings.value('layout', type=str)
if layout == 'standard':
pass
elif layout == 'compact':
if layout == 'compact':
self.removeToolBar(self.snap_toolbar)
self.snap_toolbar.setMaximumHeight(30)
self.splitter_left.addWidget(self.snap_toolbar)
@ -2347,41 +2345,34 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
QtWidgets.qApp.installEventFilter(self)
# restore the Toolbar State from file
# ########################################################################
# ################## RESTORE THE TOOLBAR STATE from file #################
# ########################################################################
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("saved_gui_state"):
saved_gui_state = settings.value('saved_gui_state')
self.restoreState(saved_gui_state)
log.debug("FlatCAMGUI.__init__() --> UI state restored.")
log.debug("FlatCAMGUI.__init__() --> UI state restored from QSettings.")
if settings.contains("layout"):
layout = settings.value('layout', type=str)
if layout == 'standard':
# self.exc_edit_toolbar.setVisible(False)
self.exc_edit_toolbar.setDisabled(True)
# self.geo_edit_toolbar.setVisible(False)
self.geo_edit_toolbar.setDisabled(True)
# self.grb_edit_toolbar.setVisible(False)
self.grb_edit_toolbar.setDisabled(True)
self.exc_edit_toolbar.setDisabled(True)
self.geo_edit_toolbar.setDisabled(True)
self.grb_edit_toolbar.setDisabled(True)
if layout == 'standard':
self.corner_snap_btn.setVisible(False)
self.snap_magnet.setVisible(False)
elif layout == 'compact':
self.exc_edit_toolbar.setDisabled(True)
self.geo_edit_toolbar.setDisabled(True)
self.grb_edit_toolbar.setDisabled(True)
else:
self.snap_magnet.setVisible(True)
self.corner_snap_btn.setVisible(True)
self.snap_magnet.setDisabled(True)
self.corner_snap_btn.setDisabled(True)
log.debug("FlatCAMGUI.__init__() --> UI layout restored from QSettings.")
log.debug("FlatCAMGUI.__init__() --> UI layout restored from QSettings. Layout = %s" % str(layout))
else:
# self.exc_edit_toolbar.setVisible(False)
self.exc_edit_toolbar.setDisabled(True)
# self.geo_edit_toolbar.setVisible(False)
self.geo_edit_toolbar.setDisabled(True)
# self.grb_edit_toolbar.setVisible(False)
self.grb_edit_toolbar.setDisabled(True)
self.corner_snap_btn.setVisible(False)
@ -2483,11 +2474,14 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
def populate_toolbars(self):
"""
Will populate the App Toolbars with theie actions
Will populate the App Toolbars with their actions
:return: None
"""
# ########################################################################
# ## File Toolbar # ##
# ########################################################################
self.file_open_gerber_btn = self.toolbarfile.addAction(
QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
self.file_open_excellon_btn = self.toolbarfile.addAction(
@ -2498,7 +2492,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.file_save_btn = self.toolbarfile.addAction(
QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
# ########################################################################
# ## Edit Toolbar # ##
# ########################################################################
self.newgeo_btn = self.toolbargeo.addAction(
QtGui.QIcon(self.app.resource_location + '/new_file_geo32.png'), _("New Blank Geometry"))
self.newgrb_btn = self.toolbargeo.addAction(
@ -2556,7 +2552,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.run_script_btn = self.toolbarshell.addAction(
QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
# ########################################################################
# ## Tools Toolbar # ##
# ########################################################################
self.dblsided_btn = self.toolbartools.addAction(
QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
self.align_btn = self.toolbartools.addAction(
@ -2601,7 +2599,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.cal_btn = self.toolbartools.addAction(
QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
# ########################################################################
# ## Excellon Editor Toolbar # ##
# ########################################################################
self.select_drill_btn = self.exc_edit_toolbar.addAction(
QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
self.add_drill_btn = self.exc_edit_toolbar.addAction(
@ -2625,7 +2625,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.move_drill_btn = self.exc_edit_toolbar.addAction(
QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
# ########################################################################
# ## Geometry Editor Toolbar # ##
# ########################################################################
self.geo_select_btn = self.geo_edit_toolbar.addAction(
QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select 'Esc'"))
self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
@ -2675,7 +2677,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.geo_move_btn = self.geo_edit_toolbar.addAction(
QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects"))
# ########################################################################
# ## Gerber Editor Toolbar # ##
# ########################################################################
self.grb_select_btn = self.grb_edit_toolbar.addAction(
QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
@ -2715,10 +2719,12 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.aperture_move_btn = self.grb_edit_toolbar.addAction(
QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
# ########################################################################
# ## Snap Toolbar # ##
# ########################################################################
# Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
# self.addToolBar(self.snap_toolbar)
self.grid_snap_btn = self.snap_toolbar.addAction(
QtGui.QIcon(self.app.resource_location + '/grid32.png'), _('Snap to grid'))
self.grid_gap_x_entry = FCEntry2()
@ -2757,29 +2763,25 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("layout"):
layout = settings.value('layout', type=str)
if layout == 'standard':
self.exc_edit_toolbar.setVisible(True)
self.exc_edit_toolbar.setDisabled(True)
self.geo_edit_toolbar.setVisible(True)
self.geo_edit_toolbar.setDisabled(True)
self.grb_edit_toolbar.setVisible(True)
self.grb_edit_toolbar.setDisabled(True)
if layout == 'standard':
self.corner_snap_btn.setVisible(False)
self.snap_magnet.setVisible(False)
elif layout == 'compact':
self.exc_edit_toolbar.setVisible(True)
self.exc_edit_toolbar.setDisabled(True)
self.geo_edit_toolbar.setVisible(True)
self.geo_edit_toolbar.setDisabled(True)
self.grb_edit_toolbar.setVisible(True)
self.grb_edit_toolbar.setDisabled(True)
else:
self.corner_snap_btn.setVisible(True)
self.snap_magnet.setVisible(True)
self.corner_snap_btn.setDisabled(True)
self.snap_magnet.setDisabled(True)
# on 'minimal' layout only some toolbars are active
if layout != 'minimal':
self.exc_edit_toolbar.setVisible(True)
self.exc_edit_toolbar.setDisabled(True)
self.geo_edit_toolbar.setVisible(True)
self.geo_edit_toolbar.setDisabled(True)
self.grb_edit_toolbar.setVisible(True)
self.grb_edit_toolbar.setDisabled(True)
def keyPressEvent(self, event):
"""
Key event handler for the entire app.

View File

@ -396,6 +396,7 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
# don't translate the QCombo items as they are used in QSettings and identified by name
self.layout_combo.addItem("standard")
self.layout_combo.addItem("compact")
self.layout_combo.addItem("minimal")
grid0.addWidget(self.layout_label, 4, 0)
grid0.addWidget(self.layout_combo, 4, 1)
@ -732,6 +733,9 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
self.proj_color_dis_entry.editingFinished.connect(self.on_proj_color_dis_entry)
self.proj_color_dis_button.clicked.connect(self.on_proj_color_dis_button)
self.layout_combo.activated.connect(self.on_layout)
def on_theme_change(self):
val = self.theme_radio.get_value()
t_settings = QSettings("Open Source", "FlatCAM")
@ -947,6 +951,156 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
self.proj_color_dis_entry.set_value(new_val_sel)
self.app.defaults['global_proj_item_dis_color'] = new_val_sel
def on_layout(self, index=None, lay=None):
"""
Set the toolbars layout (location)
:param index:
:param lay: Type of layout to be set on the toolbard
:return: None
"""
self.app.report_usage("on_layout()")
if lay:
current_layout = lay
else:
current_layout = self.layout_combo.get_value()
lay_settings = QSettings("Open Source", "FlatCAM")
lay_settings.setValue('layout', current_layout)
# This will write the setting to the platform specific storage.
del lay_settings
# first remove the toolbars:
try:
self.app.ui.removeToolBar(self.app.ui.toolbarfile)
self.app.ui.removeToolBar(self.app.ui.toolbargeo)
self.app.ui.removeToolBar(self.app.ui.toolbarview)
self.app.ui.removeToolBar(self.app.ui.toolbarshell)
self.app.ui.removeToolBar(self.app.ui.toolbartools)
self.app.ui.removeToolBar(self.app.ui.exc_edit_toolbar)
self.app.ui.removeToolBar(self.app.ui.geo_edit_toolbar)
self.app.ui.removeToolBar(self.app.ui.grb_edit_toolbar)
self.app.ui.removeToolBar(self.app.ui.snap_toolbar)
self.app.ui.removeToolBar(self.app.ui.toolbarshell)
except Exception:
pass
if current_layout == 'compact':
# ## TOOLBAR INSTALLATION # ##
self.app.ui.toolbarfile = QtWidgets.QToolBar('File Toolbar')
self.app.ui.toolbarfile.setObjectName('File_TB')
self.app.ui.addToolBar(Qt.LeftToolBarArea, self.app.ui.toolbarfile)
self.app.ui.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
self.app.ui.toolbargeo.setObjectName('Edit_TB')
self.app.ui.addToolBar(Qt.LeftToolBarArea, self.app.ui.toolbargeo)
self.app.ui.toolbarshell = QtWidgets.QToolBar('Shell Toolbar')
self.app.ui.toolbarshell.setObjectName('Shell_TB')
self.app.ui.addToolBar(Qt.LeftToolBarArea, self.app.ui.toolbarshell)
self.app.ui.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
self.app.ui.toolbartools.setObjectName('Tools_TB')
self.app.ui.addToolBar(Qt.LeftToolBarArea, self.app.ui.toolbartools)
self.app.ui.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
# self.app.ui.geo_edit_toolbar.setVisible(False)
self.app.ui.geo_edit_toolbar.setObjectName('GeoEditor_TB')
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.geo_edit_toolbar)
self.app.ui.toolbarview = QtWidgets.QToolBar('View Toolbar')
self.app.ui.toolbarview.setObjectName('View_TB')
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.toolbarview)
self.app.ui.addToolBarBreak(area=Qt.RightToolBarArea)
self.app.ui.grb_edit_toolbar = QtWidgets.QToolBar('Gerber Editor Toolbar')
# self.app.ui.grb_edit_toolbar.setVisible(False)
self.app.ui.grb_edit_toolbar.setObjectName('GrbEditor_TB')
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.grb_edit_toolbar)
self.app.ui.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
self.app.ui.exc_edit_toolbar.setObjectName('ExcEditor_TB')
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.exc_edit_toolbar)
self.app.ui.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
self.app.ui.snap_toolbar.setObjectName('Snap_TB')
self.app.ui.snap_toolbar.setMaximumHeight(30)
self.app.ui.splitter_left.addWidget(self.app.ui.snap_toolbar)
self.app.ui.corner_snap_btn.setVisible(True)
self.app.ui.snap_magnet.setVisible(True)
else:
# ## TOOLBAR INSTALLATION # ##
self.app.ui.toolbarfile = QtWidgets.QToolBar('File Toolbar')
self.app.ui.toolbarfile.setObjectName('File_TB')
self.app.ui.addToolBar(self.app.ui.toolbarfile)
self.app.ui.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
self.app.ui.toolbargeo.setObjectName('Edit_TB')
self.app.ui.addToolBar(self.app.ui.toolbargeo)
self.app.ui.toolbarview = QtWidgets.QToolBar('View Toolbar')
self.app.ui.toolbarview.setObjectName('View_TB')
self.app.ui.addToolBar(self.app.ui.toolbarview)
self.app.ui.toolbarshell = QtWidgets.QToolBar('Shell Toolbar')
self.app.ui.toolbarshell.setObjectName('Shell_TB')
self.app.ui.addToolBar(self.app.ui.toolbarshell)
self.app.ui.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
self.app.ui.toolbartools.setObjectName('Tools_TB')
self.app.ui.addToolBar(self.app.ui.toolbartools)
self.app.ui.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
# self.app.ui.exc_edit_toolbar.setVisible(False)
self.app.ui.exc_edit_toolbar.setObjectName('ExcEditor_TB')
self.app.ui.addToolBar(self.app.ui.exc_edit_toolbar)
self.app.ui.addToolBarBreak()
self.app.ui.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
# self.app.ui.geo_edit_toolbar.setVisible(False)
self.app.ui.geo_edit_toolbar.setObjectName('GeoEditor_TB')
self.app.ui.addToolBar(self.app.ui.geo_edit_toolbar)
self.app.ui.grb_edit_toolbar = QtWidgets.QToolBar('Gerber Editor Toolbar')
# self.app.ui.grb_edit_toolbar.setVisible(False)
self.app.ui.grb_edit_toolbar.setObjectName('GrbEditor_TB')
self.app.ui.addToolBar(self.app.ui.grb_edit_toolbar)
self.app.ui.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
self.app.ui.snap_toolbar.setObjectName('Snap_TB')
# self.app.ui.snap_toolbar.setMaximumHeight(30)
self.app.ui.addToolBar(self.app.ui.snap_toolbar)
self.app.ui.corner_snap_btn.setVisible(False)
self.app.ui.snap_magnet.setVisible(False)
if current_layout == 'minimal':
self.app.ui.toolbarview.setVisible(False)
self.app.ui.toolbarshell.setVisible(False)
self.app.ui.snap_toolbar.setVisible(False)
self.app.ui.geo_edit_toolbar.setVisible(False)
self.app.ui.grb_edit_toolbar.setVisible(False)
self.app.ui.exc_edit_toolbar.setVisible(False)
self.app.ui.lock_toolbar(lock=True)
# add all the actions to the toolbars
self.app.ui.populate_toolbars()
# reconnect all the signals to the toolbar actions
self.app.connect_toolbar_signals()
self.app.ui.grid_snap_btn.setChecked(True)
self.app.on_grid_snap_triggered(state=True)
self.app.ui.grid_gap_x_entry.setText(str(self.app.defaults["global_gridx"]))
self.app.ui.grid_gap_y_entry.setText(str(self.app.defaults["global_gridy"]))
self.app.ui.snap_max_dist_entry.setText(str(self.app.defaults["global_snap_max"]))
self.app.ui.grid_gap_link_cb.setChecked(True)
class GeneralAPPSetGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):

View File

@ -875,12 +875,12 @@ class NonCopperClear(FlatCAMTool, Gerber):
# store all the data associated with the row parameter to the self.tools storage
tooldia_item = float(self.tools_table.item(row, 1).text())
type_item = self.tools_table.cellWidget(row, 2).currentText()
operation_type_item = self.ui.geo_tools_table.cellWidget(row, 4).currentText()
nccoffset_item = self.ncc_choice_offset_cb.get_value()
nccoffset_value_item = float(self.ncc_offset_spinner.get_value())
# tooldia_item = float(self.tools_table.item(row, 1).text())
# type_item = self.tools_table.cellWidget(row, 2).currentText()
# operation_type_item = self.tools_table.cellWidget(row, 4).currentText()
#
# nccoffset_item = self.ncc_choice_offset_cb.get_value()
# nccoffset_value_item = float(self.ncc_offset_spinner.get_value())
# this new dict will hold the actual useful data, another dict that is the value of key 'data'
# temp_tools = {}
@ -1202,11 +1202,6 @@ class NonCopperClear(FlatCAMTool, Gerber):
except AttributeError:
pass
try:
self.tools_table.cellWidget(row, 4).currentIndexChanged.connect(self.on_tooltable_cellwidget_change)
except AttributeError:
pass
self.tool_type_radio.activated_custom.connect(self.on_tool_type)
for opt in self.form_fields:
@ -1238,11 +1233,11 @@ class NonCopperClear(FlatCAMTool, Gerber):
pass
for row in range(self.tools_table.rowCount()):
for col in [2, 4]:
try:
self.ui.geo_tools_table.cellWidget(row, col).currentIndexChanged.disconnect()
except (TypeError, AttributeError):
pass
try:
self.tools_table.cellWidget(row, 2).currentIndexChanged.disconnect()
except (TypeError, AttributeError):
pass
for opt in self.form_fields:
current_widget = self.form_fields[opt]
@ -1669,7 +1664,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.on_mouse_move)
self.kp = self.app.plotcanvas.graph_event_connect('key_press', self.on_key_press)
elif self.select_method == 'box':
elif self.select_method == _("Reference Object"):
self.bound_obj_name = self.reference_combo.currentText()
# Get source object.
try:
@ -2221,6 +2216,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
run non-threaded for TclShell usage
:return:
"""
log.debug("Executing the handler ...")
if run_threaded:
proc = self.app.proc_container.new(_("Non-Copper clearing ..."))
else:
@ -2306,7 +2303,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
except TypeError:
tool = eval(self.app.defaults["tools_ncctools"])
if ncc_select == 'box':
if ncc_select == _("Reference Object"):
env_obj, box_obj_kind = self.envelope_object(ncc_obj=ncc_obj, box_obj=sel_obj, ncc_select=ncc_select)
else:
env_obj, box_obj_kind = self.envelope_object(ncc_obj=ncc_obj, ncc_select=ncc_select)
@ -2330,19 +2327,19 @@ class NonCopperClear(FlatCAMTool, Gerber):
)
app_obj.proc_container.update_view_text(' %d%%' % 0)
tooluid = 0
tool_uid = 0
for k, v in self.ncc_tools.items():
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals, tool)):
tooluid = int(k)
tool_uid = int(k)
break
ncc_overlap = float(self.ncc_tools[tooluid]["data"]["tools_nccoverlap"]) / 100.0
ncc_margin = float(self.ncc_tools[tooluid]["data"]["tools_nccmargin"])
ncc_method = self.ncc_tools[tooluid]["data"]["tools_nccmethod"]
ncc_connect = self.ncc_tools[tooluid]["data"]["tools_nccconnect"]
ncc_contour = self.ncc_tools[tooluid]["data"]["tools_ncccontour"]
has_offset = self.ncc_tools[tooluid]["data"]["tools_ncc_offset_choice"]
ncc_offset = float(self.ncc_tools[tooluid]["data"]["tools_ncc_offset_value"])
ncc_overlap = float(self.ncc_tools[tool_uid]["data"]["tools_nccoverlap"]) / 100.0
ncc_margin = float(self.ncc_tools[tool_uid]["data"]["tools_nccmargin"])
ncc_method = self.ncc_tools[tool_uid]["data"]["tools_nccmethod"]
ncc_connect = self.ncc_tools[tool_uid]["data"]["tools_nccconnect"]
ncc_contour = self.ncc_tools[tool_uid]["data"]["tools_ncccontour"]
has_offset = self.ncc_tools[tool_uid]["data"]["tools_ncc_offset_choice"]
ncc_offset = float(self.ncc_tools[tool_uid]["data"]["tools_ncc_offset_value"])
cleared_geo[:] = []
@ -2513,8 +2510,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
# test if at least one tool has solid_geometry. If no tool has solid_geometry we raise an Exception
has_solid_geo = 0
for tooluid in geo_obj.tools:
if geo_obj.tools[tooluid]['solid_geometry']:
for tid in geo_obj.tools:
if geo_obj.tools[tid]['solid_geometry']:
has_solid_geo += 1
if has_solid_geo == 0:
app_obj.inform.emit('[ERROR] %s' %
@ -2537,13 +2534,13 @@ class NonCopperClear(FlatCAMTool, Gerber):
# create the solid_geometry
geo_obj.solid_geometry = []
for tooluid in geo_obj.tools:
if geo_obj.tools[tooluid]['solid_geometry']:
for tool_id in geo_obj.tools:
if geo_obj.tools[tool_id]['solid_geometry']:
try:
for geo in geo_obj.tools[tooluid]['solid_geometry']:
for geo in geo_obj.tools[tool_id]['solid_geometry']:
geo_obj.solid_geometry.append(geo)
except TypeError:
geo_obj.solid_geometry.append(geo_obj.tools[tooluid]['solid_geometry'])
geo_obj.solid_geometry.append(geo_obj.tools[tool_id]['solid_geometry'])
else:
# I will use this variable for this purpose although it was meant for something else
# signal that we have no geo in the object therefore don't create it
@ -2586,7 +2583,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
# repurposed flag for final object, geo_obj. True if it has any solid_geometry, False if not.
app_obj.poly_not_cleared = True
if ncc_select == 'box':
if ncc_select == _("Reference Object"):
env_obj, box_obj_kind = self.envelope_object(ncc_obj=ncc_obj, box_obj=sel_obj, ncc_select=ncc_select)
else:
env_obj, box_obj_kind = self.envelope_object(ncc_obj=ncc_obj, ncc_select=ncc_select)
@ -2615,19 +2612,19 @@ class NonCopperClear(FlatCAMTool, Gerber):
tool = sorted_tools.pop(0)
tooluid = 0
tool_uid = 0
for k, v in self.ncc_tools.items():
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals, tool)):
tooluid = int(k)
tool_uid = int(k)
break
ncc_overlap = float(self.ncc_tools[tooluid]["data"]["tools_nccoverlap"]) / 100.0
ncc_margin = float(self.ncc_tools[tooluid]["data"]["tools_nccmargin"])
ncc_method = self.ncc_tools[tooluid]["data"]["tools_nccmethod"]
ncc_connect = self.ncc_tools[tooluid]["data"]["tools_nccconnect"]
ncc_contour = self.ncc_tools[tooluid]["data"]["tools_ncccontour"]
has_offset = self.ncc_tools[tooluid]["data"]["tools_ncc_offset_choice"]
ncc_offset = float(self.ncc_tools[tooluid]["data"]["tools_ncc_offset_value"])
ncc_overlap = float(self.ncc_tools[tool_uid]["data"]["tools_nccoverlap"]) / 100.0
ncc_margin = float(self.ncc_tools[tool_uid]["data"]["tools_nccmargin"])
ncc_method = self.ncc_tools[tool_uid]["data"]["tools_nccmethod"]
ncc_connect = self.ncc_tools[tool_uid]["data"]["tools_nccconnect"]
ncc_contour = self.ncc_tools[tool_uid]["data"]["tools_ncccontour"]
has_offset = self.ncc_tools[tool_uid]["data"]["tools_ncc_offset_choice"]
ncc_offset = float(self.ncc_tools[tool_uid]["data"]["tools_ncc_offset_value"])
tool_used = tool - 1e-12
cleared_geo[:] = []
@ -2784,7 +2781,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
poly = p.buffer(buffer_value)
cleared_by_last_tool.append(poly)
# find the tooluid associated with the current tool_dia so we know
# find the tool uid associated with the current tool_dia so we know
# where to add the tool solid_geometry
for k, v in tools_storage.items():
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals,
@ -2822,13 +2819,13 @@ class NonCopperClear(FlatCAMTool, Gerber):
# create the solid_geometry
geo_obj.solid_geometry = []
for tooluid in geo_obj.tools:
if geo_obj.tools[tooluid]['solid_geometry']:
for tool_uid in geo_obj.tools:
if geo_obj.tools[tool_uid]['solid_geometry']:
try:
for geo in geo_obj.tools[tooluid]['solid_geometry']:
for geo in geo_obj.tools[tool_uid]['solid_geometry']:
geo_obj.solid_geometry.append(geo)
except TypeError:
geo_obj.solid_geometry.append(geo_obj.tools[tooluid]['solid_geometry'])
geo_obj.solid_geometry.append(geo_obj.tools[tool_uid]['solid_geometry'])
else:
# I will use this variable for this purpose although it was meant for something else
# signal that we have no geo in the object therefore don't create it
@ -3012,13 +3009,13 @@ class NonCopperClear(FlatCAMTool, Gerber):
bounding_box = cascaded_union(geo_buff_list)
elif ncc_select == 'box':
elif ncc_select == _("Reference Object"):
geo_n = ncc_sel_obj.solid_geometry
if ncc_sel_obj.kind == 'geometry':
try:
__ = iter(geo_n)
except Exception as e:
log.debug("NonCopperClear.clear_copper() 'box' --> %s" % str(e))
log.debug("NonCopperClear.clear_copper() 'Reference Object' --> %s" % str(e))
geo_n = [geo_n]
geo_buff_list = []