- small GUI changes in Optimal Tool and in Film Tool

- some PEP8 corrections
- some code annotations to make it easier to navigate in the FlatCAMGUI.py
- fixed exit FullScreen with Escape key
This commit is contained in:
Marius Stanciu 2019-10-04 15:24:38 +03:00
parent a90e7629dc
commit 6d2ed26e0e
6 changed files with 203 additions and 255 deletions

View File

@ -5169,7 +5169,6 @@ class App(QtCore.QObject):
obj_name_single = str(name) if name else "Combo_SingleGeo" obj_name_single = str(name) if name else "Combo_SingleGeo"
obj_name_multi = str(name) if name else "Combo_MultiGeo" obj_name_multi = str(name) if name else "Combo_MultiGeo"
tooldias = []
geo_type_list = set() geo_type_list = set()
objs = self.collection.get_selected() objs = self.collection.get_selected()
@ -5691,10 +5690,10 @@ class App(QtCore.QObject):
self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.connect( self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.connect(
lambda: self.on_toggle_units(no_pref=False)) lambda: self.on_toggle_units(no_pref=False))
def on_fullscreen(self): def on_fullscreen(self, disable=False):
self.report_usage("on_fullscreen()") self.report_usage("on_fullscreen()")
if self.toggle_fscreen is False: if self.toggle_fscreen is False and disable is False:
# self.ui.showFullScreen() # self.ui.showFullScreen()
self.ui.setWindowFlags(self.ui.windowFlags() | Qt.FramelessWindowHint) self.ui.setWindowFlags(self.ui.windowFlags() | Qt.FramelessWindowHint)
a = self.ui.geometry() a = self.ui.geometry()
@ -5723,7 +5722,7 @@ class App(QtCore.QObject):
tb.setVisible(False) tb.setVisible(False)
self.ui.splitter_left.setVisible(False) self.ui.splitter_left.setVisible(False)
self.toggle_fscreen = True self.toggle_fscreen = True
else: elif self.toggle_fscreen is True or disable is True:
self.ui.setWindowFlags(self.ui.windowFlags() & ~Qt.FramelessWindowHint) self.ui.setWindowFlags(self.ui.windowFlags() & ~Qt.FramelessWindowHint)
self.ui.setGeometry(self.x_pos, self.y_pos, self.width, self.height) self.ui.setGeometry(self.x_pos, self.y_pos, self.width, self.height)
self.ui.showNormal() self.ui.showNormal()
@ -9252,8 +9251,8 @@ class App(QtCore.QObject):
filenames = [name] filenames = [name]
else: else:
try: try:
filenames, _f = QtWidgets.QFileDialog.getOpenFileNames(caption=_("Open TCL script"), filenames, _f = QtWidgets.QFileDialog.getOpenFileNames(
directory=self.get_last_folder(), filter=_filter_) caption=_("Open TCL script"), directory=self.get_last_folder(), filter=_filter_)
except TypeError: except TypeError:
filenames, _f = QtWidgets.QFileDialog.getOpenFileNames(caption=_("Open TCL script"), filter=_filter_) filenames, _f = QtWidgets.QFileDialog.getOpenFileNames(caption=_("Open TCL script"), filter=_filter_)
@ -10119,6 +10118,7 @@ class App(QtCore.QObject):
it with shapes extracted from the SVG file. it with shapes extracted from the SVG file.
:param filename: Path to the SVG file. :param filename: Path to the SVG file.
:param geo_type: Type of FlatCAM object that will be created from SVG
:param outname: :param outname:
:return: :return:
""" """
@ -10162,6 +10162,7 @@ class App(QtCore.QObject):
it with shapes extracted from the DXF file. it with shapes extracted from the DXF file.
:param filename: Path to the DXF file. :param filename: Path to the DXF file.
:param geo_type: Type of FlatCAM object that will be created from DXF
:param outname: :param outname:
:type putname: str :type putname: str
:return: :return:
@ -10175,8 +10176,7 @@ class App(QtCore.QObject):
obj_type = geo_type obj_type = geo_type
else: else:
self.inform.emit('[ERROR_NOTCL] %s' % self.inform.emit('[ERROR_NOTCL] %s' %
_("Not supported type is picked as parameter. " _("Not supported type is picked as parameter. Only Geometry and Gerber are supported"))
"Only Geometry and Gerber are supported"))
return return
units = self.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() units = self.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
@ -10196,8 +10196,7 @@ class App(QtCore.QObject):
self.file_opened.emit("dxf", filename) self.file_opened.emit("dxf", filename)
# GUI feedback # GUI feedback
self.inform.emit('[success] %s: %s' % self.inform.emit('[success] %s: %s' % (_("Opened"), filename))
(_("Opened"), filename))
self.progress.emit(100) self.progress.emit(100)
def import_image(self, filename, o_type='gerber', dpi=96, mode='black', mask=[250, 250, 250, 250], outname=None): def import_image(self, filename, o_type='gerber', dpi=96, mode='black', mask=[250, 250, 250, 250], outname=None):
@ -11749,6 +11748,6 @@ class GracefulException(Exception):
super().__init__() super().__init__()
def __str__(self): def __str__(self):
return ('\n\n%s' % _("The user requested a graceful exit of the current task.")) return '\n\n%s' % _("The user requested a graceful exit of the current task.")
# end of file # end of file

View File

@ -1546,14 +1546,14 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
if aperture_to_plot_mark in self.apertures: if aperture_to_plot_mark in self.apertures:
for elem in self.apertures[aperture_to_plot_mark]['geometry']: for elem in self.apertures[aperture_to_plot_mark]['geometry']:
if 'solid' in elem: if 'solid' in elem:
geo = elem['solid'] geo = elem['solid']
if type(geo) == Polygon or type(geo) == LineString: if type(geo) == Polygon or type(geo) == LineString:
self.add_mark_shape(apid=aperture_to_plot_mark, shape=geo, color=color, self.add_mark_shape(apid=aperture_to_plot_mark, shape=geo, color=color,
face_color=color, visible=visibility)
else:
for el in geo:
self.add_mark_shape(apid=aperture_to_plot_mark, shape=el, color=color,
face_color=color, visible=visibility) face_color=color, visible=visibility)
else:
for el in geo:
self.add_mark_shape(apid=aperture_to_plot_mark, shape=el, color=color,
face_color=color, visible=visibility)
self.mark_shapes[aperture_to_plot_mark].redraw() self.mark_shapes[aperture_to_plot_mark].redraw()
@ -4323,7 +4323,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
tooldia = float(self.ui.geo_tools_table.item(row, 1).text()) tooldia = float(self.ui.geo_tools_table.item(row, 1).text())
new_cutz = (tooldia - vdia) / (2 * math.tan(math.radians(half_vangle))) new_cutz = (tooldia - vdia) / (2 * math.tan(math.radians(half_vangle)))
new_cutz = float('%.*f' % (self.decimals, -new_cutz)) # this value has to be negative new_cutz = float('%.*f' % (self.decimals, -new_cutz)) # this value has to be negative
self.ui.cutz_entry.set_value(new_cutz) self.ui.cutz_entry.set_value(new_cutz)
# store the new CutZ value into storage (self.tools) # store the new CutZ value into storage (self.tools)
@ -5337,8 +5337,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
except TypeError: except TypeError:
self.app.inform.emit('[ERROR_NOTCL] %s' % self.app.inform.emit('[ERROR_NOTCL] %s' %
_("An (x,y) pair of values are needed. " _("An (x,y) pair of values are needed. "
"Probable you entered only one value in the Offset field." "Probable you entered only one value in the Offset field.")
)) )
return return
self.geo_len = 0 self.geo_len = 0
@ -5421,8 +5421,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.app.inform.emit('[ERROR] %s' % self.app.inform.emit('[ERROR] %s' %
_("The Toolchange X,Y field in Edit -> Preferences " _("The Toolchange X,Y field in Edit -> Preferences "
"has to be in the format (x, y)\n" "has to be in the format (x, y)\n"
"but now there is only one value, not two." "but now there is only one value, not two.")
)) )
return 'fail' return 'fail'
coords_xy[0] *= factor coords_xy[0] *= factor
coords_xy[1] *= factor coords_xy[1] *= factor
@ -5519,7 +5519,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
# if self.app.is_legacy is False: # if self.app.is_legacy is False:
self.add_shape(shape=element, color=color, visible=visible, layer=0) self.add_shape(shape=element, color=color, visible=visible, layer=0)
def plot(self, visible=None, kind=None): def plot(self, visible=None, kind=None):
""" """
Plot the object. Plot the object.
@ -6242,8 +6241,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
m6_code = self.parse_custom_toolchange_code(self.ui.toolchange_text.get_value()) m6_code = self.parse_custom_toolchange_code(self.ui.toolchange_text.get_value())
if m6_code is None or m6_code == '': if m6_code is None or m6_code == '':
self.app.inform.emit('[ERROR_NOTCL] %s' % self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Cancelled. The Toolchange Custom code is enabled but it's empty." _("Cancelled. The Toolchange Custom code is enabled but it's empty.")
)) )
return 'fail' return 'fail'
g = g.replace('M6', m6_code) g = g.replace('M6', m6_code)
@ -6543,7 +6542,7 @@ class FlatCAMScript(FlatCAMObj):
self.script_editor_tab.buttonRun.show() self.script_editor_tab.buttonRun.show()
self.ui.autocomplete_cb.set_value(self.app.defaults['script_autocompleter']) self.ui.autocomplete_cb.set_value(self.app.defaults['script_autocompleter'])
self.on_autocomplete_changed(state= self.app.defaults['script_autocompleter']) self.on_autocomplete_changed(state=self.app.defaults['script_autocompleter'])
flt = "FlatCAM Scripts (*.FlatScript);;All Files (*.*)" flt = "FlatCAM Scripts (*.FlatScript);;All Files (*.*)"
self.script_editor_tab.buttonOpen.clicked.disconnect() self.script_editor_tab.buttonOpen.clicked.disconnect()

View File

@ -14,6 +14,11 @@ CAD program, and create G-Code for Isolation routing.
- updated the Film Tool and added the ability to generate Punched Positive films (holes in the pads) when a Gerber file is the film's source. The punch holes source can be either an Excellon file or the pads center - updated the Film Tool and added the ability to generate Punched Positive films (holes in the pads) when a Gerber file is the film's source. The punch holes source can be either an Excellon file or the pads center
- optimized Rules Check Tool so it runs faster when doing Copper 2 Copper rule - optimized Rules Check Tool so it runs faster when doing Copper 2 Copper rule
- small GUI changes in Optimal Tool and in Film Tool
- some PEP8 corrections
- some code annotations to make it easier to navigate in the FlatCAMGUI.py
- fixed exit FullScreen with Escape key
3.10.2019 3.10.2019

View File

@ -43,8 +43,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# ######### ## # ######### ##
self.menu = self.menuBar() self.menu = self.menuBar()
# ## File # ## # ########################################################################
self.menufile = self.menu.addMenu(_('&File')) # ########################## File # ######################################
# ########################################################################
self.menufile = self.menu.addMenu(_('File'))
self.menufile.setToolTipsVisible(True) self.menufile.setToolTipsVisible(True)
# New Project # New Project
@ -242,7 +244,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# exitAction.setStatusTip('Exit application') # exitAction.setStatusTip('Exit application')
self.menufile.addAction(self.menufile_exit) self.menufile.addAction(self.menufile_exit)
# ## Edit # ## # ########################################################################
# ########################## Edit # ######################################
# ########################################################################
self.menuedit = self.menu.addMenu(_('Edit')) self.menuedit = self.menu.addMenu(_('Edit'))
# Separator # Separator
self.menuedit.addSeparator() self.menuedit.addSeparator()
@ -359,7 +363,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# Separator # Separator
self.menuoptions.addSeparator() self.menuoptions.addSeparator()
# ## View # ## # ########################################################################
# ########################## View # ######################################
# ########################################################################
self.menuview = self.menu.addMenu(_('&View')) self.menuview = self.menu.addMenu(_('&View'))
self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), _('Enable all plots\tALT+1')) self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), _('Enable all plots\tALT+1'))
self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'), self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
@ -395,12 +401,21 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menuview_toggle_workspace = self.menuview.addAction(QtGui.QIcon('share/workspace24.png'), self.menuview_toggle_workspace = self.menuview.addAction(QtGui.QIcon('share/workspace24.png'),
_("Toggle Workspace\tSHIFT+W")) _("Toggle Workspace\tSHIFT+W"))
# ## Tool ### # ########################################################################
# ########################## Objects # ###################################
# ########################################################################
self.menufile = self.menu.addMenu(_('Objects'))
# ########################################################################
# ########################## Tool # ######################################
# ########################################################################
self.menutool = QtWidgets.QMenu(_('&Tool')) self.menutool = QtWidgets.QMenu(_('&Tool'))
self.menutoolaction = self.menu.addMenu(self.menutool) self.menutoolaction = self.menu.addMenu(self.menutool)
self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), _('&Command Line\tS')) self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), _('&Command Line\tS'))
# ## Help ### # ########################################################################
# ########################## Help # ######################################
# ########################################################################
self.menuhelp = self.menu.addMenu(_('&Help')) self.menuhelp = self.menu.addMenu(_('&Help'))
self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), _('Online Help\tF1')) self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), _('Online Help\tF1'))
self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), _('FlatCAM.org')) self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), _('FlatCAM.org'))
@ -420,7 +435,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
) )
self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/about32.png'), _('About FlatCAM')) self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/about32.png'), _('About FlatCAM'))
# ## FlatCAM Editor menu ### # ########################################################################
# ########################## GEOMETRY EDITOR # ###########################
# ########################################################################
self.geo_editor_menu = QtWidgets.QMenu(">Geo Editor<") self.geo_editor_menu = QtWidgets.QMenu(">Geo Editor<")
self.menu.addMenu(self.geo_editor_menu) self.menu.addMenu(self.geo_editor_menu)
@ -470,6 +487,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
QtGui.QIcon('share/corner32.png'), _("Toggle Corner Snap\tK") QtGui.QIcon('share/corner32.png'), _("Toggle Corner Snap\tK")
) )
# ########################################################################
# ########################## EXCELLON Editor # ###########################
# ########################################################################
self.exc_editor_menu = QtWidgets.QMenu(_(">Excellon Editor<")) self.exc_editor_menu = QtWidgets.QMenu(_(">Excellon Editor<"))
self.menu.addMenu(self.exc_editor_menu) self.menu.addMenu(self.exc_editor_menu)
@ -497,7 +517,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.exc_move_drill_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/move32.png'), self.exc_move_drill_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/move32.png'),
_('Move Drill(s)\tM')) _('Move Drill(s)\tM'))
# ## APPLICATION GERBER EDITOR MENU ### # ########################################################################
# ########################## GERBER Editor # #############################
# ########################################################################
self.grb_editor_menu = QtWidgets.QMenu(_(">Gerber Editor<")) self.grb_editor_menu = QtWidgets.QMenu(_(">Gerber Editor<"))
self.menu.addMenu(self.grb_editor_menu) self.menu.addMenu(self.grb_editor_menu)
@ -543,10 +565,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.exc_editor_menu.menuAction().setVisible(False) self.exc_editor_menu.menuAction().setVisible(False)
self.exc_editor_menu.setDisabled(True) self.exc_editor_menu.setDisabled(True)
# ################################ # ########################################################################
# ### Project Tab Context menu ### # ########################## Project Tab Context Menu # ##################
# ################################ # ########################################################################
self.menuproject = QtWidgets.QMenu() self.menuproject = QtWidgets.QMenu()
self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), _('Enable Plot')) self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), _('Enable Plot'))
self.menuprojectdisable = self.menuproject.addAction(QtGui.QIcon('share/clear_plot32.png'), _('Disable Plot')) self.menuprojectdisable = self.menuproject.addAction(QtGui.QIcon('share/clear_plot32.png'), _('Disable Plot'))
@ -562,9 +583,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), _('Properties')) self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), _('Properties'))
# ################ # ########################################################################
# ### Splitter ### # ####################### Central Widget -> Splitter # ##################
# ################ # ########################################################################
# IMPORTANT # # IMPORTANT #
# The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as # The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
@ -584,9 +605,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.splitter_left.addWidget(self.notebook) self.splitter_left.addWidget(self.notebook)
self.splitter_left.setHandleWidth(0) self.splitter_left.setHandleWidth(0)
# ############## # ########################################################################
# ## Toolbar ### # ########################## ToolBAR # ###################################
# ############## # ########################################################################
# ## TOOLBAR INSTALLATION ### # ## TOOLBAR INSTALLATION ###
self.toolbarfile = QtWidgets.QToolBar(_('File Toolbar')) self.toolbarfile = QtWidgets.QToolBar(_('File Toolbar'))
@ -637,7 +658,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.snap_toolbar.setMaximumHeight(30) self.snap_toolbar.setMaximumHeight(30)
self.splitter_left.addWidget(self.snap_toolbar) self.splitter_left.addWidget(self.snap_toolbar)
# ## File Toolbar ### # ########################################################################
# ########################## File Toolbar# ###############################
# ########################################################################
self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'), self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
_("Open Gerber")) _("Open Gerber"))
self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), _("Open Excellon")) self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), _("Open Excellon"))
@ -645,7 +668,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), _("Open project")) self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), _("Open project"))
self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), _("Save project")) self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), _("Save project"))
# ## Edit Toolbar ### # ########################################################################
# ########################## Edit Toolbar# ###############################
# ########################################################################
self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), _("New Blank Geometry")) self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), _("New Blank Geometry"))
self.newgrb_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32.png'), _("New Blank Gerber")) self.newgrb_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32.png'), _("New Blank Gerber"))
self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), _("New Blank Excellon")) self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), _("New Blank Excellon"))
@ -658,7 +683,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.toolbargeo.addSeparator() self.toolbargeo.addSeparator()
self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), _("&Delete")) self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), _("&Delete"))
# ## View Toolbar # ## # ########################################################################
# ########################## View Toolbar# ###############################
# ########################################################################
self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), _("&Replot")) self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), _("&Replot"))
self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), _("&Clear plot")) self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), _("&Clear plot"))
self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), _("Zoom In")) self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), _("Zoom In"))
@ -667,13 +694,17 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# self.toolbarview.setVisible(False) # self.toolbarview.setVisible(False)
# ## Shell Toolbar ## # ########################################################################
# ########################## Shell Toolbar# ##############################
# ########################################################################
self.shell_btn = self.toolbarshell.addAction(QtGui.QIcon('share/shell32.png'), _("&Command Line")) self.shell_btn = self.toolbarshell.addAction(QtGui.QIcon('share/shell32.png'), _("&Command Line"))
self.new_script_btn = self.toolbarshell.addAction(QtGui.QIcon('share/script_new24.png'), _('New Script ...')) self.new_script_btn = self.toolbarshell.addAction(QtGui.QIcon('share/script_new24.png'), _('New Script ...'))
self.open_script_btn = self.toolbarshell.addAction(QtGui.QIcon('share/open_script32.png'), _('Open Script ...')) self.open_script_btn = self.toolbarshell.addAction(QtGui.QIcon('share/open_script32.png'), _('Open Script ...'))
self.run_script_btn = self.toolbarshell.addAction(QtGui.QIcon('share/script16.png'), _('Run Script ...')) self.run_script_btn = self.toolbarshell.addAction(QtGui.QIcon('share/script16.png'), _('Run Script ...'))
# ## Tools Toolbar ## # ########################################################################
# ########################## Tools Toolbar# ##############################
# ########################################################################
self.dblsided_btn = self.toolbartools.addAction(QtGui.QIcon('share/doubleside32.png'), _("2Sided Tool")) self.dblsided_btn = self.toolbartools.addAction(QtGui.QIcon('share/doubleside32.png'), _("2Sided Tool"))
self.cutout_btn = self.toolbartools.addAction(QtGui.QIcon('share/cut16_bis.png'), _("&Cutout Tool")) self.cutout_btn = self.toolbartools.addAction(QtGui.QIcon('share/cut16_bis.png'), _("&Cutout Tool"))
self.ncc_btn = self.toolbartools.addAction(QtGui.QIcon('share/ncc16.png'), _("NCC Tool")) self.ncc_btn = self.toolbartools.addAction(QtGui.QIcon('share/ncc16.png'), _("NCC Tool"))
@ -692,7 +723,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'), _("Calculators Tool")) self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'), _("Calculators Tool"))
self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool")) self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool"))
# ## Drill Editor Toolbar ### # ########################################################################
# ########################## Excellon Editor Toolbar# ####################
# ########################################################################
self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select")) self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), _('Add Drill Hole')) self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), _('Add Drill Hole'))
self.add_drill_array_btn = self.exc_edit_toolbar.addAction( self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
@ -709,7 +742,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.exc_edit_toolbar.addSeparator() self.exc_edit_toolbar.addSeparator()
self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Drill")) self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Drill"))
# ## Geometry Editor Toolbar ### # ########################################################################
# ########################## Geometry Editor Toolbar# ####################
# ########################################################################
self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select")) self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), _('Add Circle')) self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), _('Add Circle'))
self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), _('Add Arc')) self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), _('Add Arc'))
@ -743,7 +778,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.geo_edit_toolbar.addSeparator() self.geo_edit_toolbar.addSeparator()
self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Objects ")) self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Objects "))
# ## Gerber Editor Toolbar # ## # ########################################################################
# ########################## Gerber Editor Toolbar# ######################
# ########################################################################
self.grb_select_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select")) self.grb_select_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/aperture32.png'), _("Add Pad")) self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/aperture32.png'), _("Add Pad"))
self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/padarray32.png'), _('Add Pad Array')) self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/padarray32.png'), _('Add Pad Array'))
@ -772,10 +809,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.grb_edit_toolbar.addSeparator() self.grb_edit_toolbar.addSeparator()
self.aperture_move_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move")) self.aperture_move_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
# # ## Snap Toolbar # ## # ########################################################################
# Snap GRID toolbar is always active to facilitate usage of measurements done on GRID # ########################## Snap Toolbar# ###############################
# self.addToolBar(self.snap_toolbar) # ########################################################################
# Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), _('Snap to grid')) self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), _('Snap to grid'))
self.grid_gap_x_entry = FCEntry2() self.grid_gap_x_entry = FCEntry2()
self.grid_gap_x_entry.setMaximumWidth(70) self.grid_gap_x_entry.setMaximumWidth(70)
@ -803,18 +841,13 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.snap_max_dist_entry.setToolTip(_("Max. magnet distance")) self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry) self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
# ############# ## # ########################################################################
# ## Notebook # ## # ########################## Notebook # ##################################
# ############# ## # ########################################################################
# ## Project # ##
# self.project_tab = QtWidgets.QWidget()
# self.project_tab.setObjectName("project_tab")
# # project_tab.setMinimumWidth(250) # Hack
# self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
# self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
# self.notebook.addTab(self.project_tab,_( "Project"))
# ########################################################################
# ########################## PROJECT Tab # ###############################
# ########################################################################
self.project_tab = QtWidgets.QWidget() self.project_tab = QtWidgets.QWidget()
self.project_tab.setObjectName("project_tab") self.project_tab.setObjectName("project_tab")
@ -830,7 +863,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.notebook.addTab(self.project_tab, _("Project")) self.notebook.addTab(self.project_tab, _("Project"))
self.project_frame.setDisabled(False) self.project_frame.setDisabled(False)
# ## Selected # ## # ########################################################################
# ########################## SELECTED Tab # ##############################
# ########################################################################
self.selected_tab = QtWidgets.QWidget() self.selected_tab = QtWidgets.QWidget()
self.selected_tab.setObjectName("selected_tab") self.selected_tab.setObjectName("selected_tab")
self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab) self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
@ -839,7 +874,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.selected_tab_layout.addWidget(self.selected_scroll_area) self.selected_tab_layout.addWidget(self.selected_scroll_area)
self.notebook.addTab(self.selected_tab, _("Selected")) self.notebook.addTab(self.selected_tab, _("Selected"))
# ## Tool # ## # ########################################################################
# ########################## TOOL Tab # ##################################
# ########################################################################
self.tool_tab = QtWidgets.QWidget() self.tool_tab = QtWidgets.QWidget()
self.tool_tab.setObjectName("tool_tab") self.tool_tab.setObjectName("tool_tab")
self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab) self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
@ -848,6 +885,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.tool_scroll_area = VerticalScrollArea() self.tool_scroll_area = VerticalScrollArea()
self.tool_tab_layout.addWidget(self.tool_scroll_area) self.tool_tab_layout.addWidget(self.tool_scroll_area)
# ########################################################################
# ########################## RIGHT Widget # ##############################
# ########################################################################
self.right_widget = QtWidgets.QWidget() self.right_widget = QtWidgets.QWidget()
self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
self.splitter.addWidget(self.right_widget) self.splitter.addWidget(self.right_widget)
@ -855,7 +895,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.right_lay = QtWidgets.QVBoxLayout() self.right_lay = QtWidgets.QVBoxLayout()
self.right_lay.setContentsMargins(0, 0, 0, 0) self.right_lay.setContentsMargins(0, 0, 0, 0)
self.right_widget.setLayout(self.right_lay) self.right_widget.setLayout(self.right_lay)
# self.plot_tab_area = FCTab()
# ########################################################################
# ########################## PLOT AREA Tab # #############################
# ########################################################################
self.plot_tab_area = FCDetachableTab2(protect=False, protect_by_name=[_('Plot Area')]) self.plot_tab_area = FCDetachableTab2(protect=False, protect_by_name=[_('Plot Area')])
self.plot_tab_area.useOldIndex(True) self.plot_tab_area.useOldIndex(True)
@ -874,9 +917,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
self.plot_tab_area.protectTab(0) self.plot_tab_area.protectTab(0)
# ##################################### ## # ########################################################################
# ## HERE WE BUILD THE PREF. TAB AREA # ## # ########################## PREFERENCES AREA Tab # ######################
# ##################################### ## # ########################################################################
self.preferences_tab = QtWidgets.QWidget() self.preferences_tab = QtWidgets.QWidget()
self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab) self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
self.pref_tab_layout.setContentsMargins(2, 2, 2, 2) self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
@ -1014,9 +1057,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
"which is the file storing the working default preferences.")) "which is the file storing the working default preferences."))
self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button) self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
# ################################################# # ########################################################################
# ## HERE WE BUILD THE SHORTCUTS LIST. TAB AREA ### # #################### SHORTCUT LIST AREA Tab # ##########################
# ################################################# # ########################################################################
self.shortcuts_tab = QtWidgets.QWidget() self.shortcuts_tab = QtWidgets.QWidget()
self.sh_tab_layout = QtWidgets.QVBoxLayout() self.sh_tab_layout = QtWidgets.QVBoxLayout()
self.sh_tab_layout.setContentsMargins(2, 2, 2, 2) self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
@ -1750,9 +1793,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
self.sh_hlay.addWidget(self.sh_editor) self.sh_hlay.addWidget(self.sh_editor)
# ########################################################### ## # ########################################################################
# # ## HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS # ## # ########################## PLOT AREA CONTEXT MENU # ###################
# ########################################################### ## # ########################################################################
self.popMenu = FCMenu() self.popMenu = FCMenu()
self.popmenu_disable = self.popMenu.addAction(QtGui.QIcon('share/disable32.png'), _("Toggle Visibility")) self.popmenu_disable = self.popMenu.addAction(QtGui.QIcon('share/disable32.png'), _("Toggle Visibility"))
@ -1841,106 +1884,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.popmenu_move = self.popMenu.addAction(QtGui.QIcon('share/move32.png'), _("Move")) self.popmenu_move = self.popMenu.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
self.popmenu_properties = self.popMenu.addAction(QtGui.QIcon('share/properties32.png'), _("Properties")) self.popmenu_properties = self.popMenu.addAction(QtGui.QIcon('share/properties32.png'), _("Properties"))
# ################################### # ########################################################################
# ## Here we build the CNCJob Tab ### # ########################## INFO BAR # ##################################
# ################################### # ########################################################################
# self.cncjob_tab = QtWidgets.QWidget()
# self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
# self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
# self.cncjob_tab.setLayout(self.cncjob_tab_layout)
# self.cncjob_tab = QtWidgets.QWidget()
#
# self.c_temp_layout = QtWidgets.QVBoxLayout(self.cncjob_tab)
# self.c_temp_layout.setContentsMargins(0, 0, 0, 0)
#
# self.cncjob_frame = QtWidgets.QFrame()
# self.cncjob_frame.setContentsMargins(0, 0, 0, 0)
# self.c_temp_layout.addWidget(self.cncjob_frame)
#
# self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_frame)
# self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
# self.cncjob_frame.setLayout(self.cncjob_tab_layout)
#
# self.code_editor = FCTextAreaExtended()
# stylesheet = """
# QTextEdit { selection-background-color:yellow;
# selection-color:black;
# }
# """
#
# self.code_editor.setStyleSheet(stylesheet)
#
# self.buttonPreview = QtWidgets.QPushButton(_('Print Preview'))
# self.buttonPreview.setToolTip(_("Open a OS standard Preview Print window."))
# self.buttonPrint = QtWidgets.QPushButton(_('Print Code'))
# self.buttonPrint.setToolTip(_("Open a OS standard Print window."))
#
# self.buttonFind = QtWidgets.QPushButton(_('Find in Code'))
# self.buttonFind.setToolTip(_("Will search and highlight in yellow the string in the Find box."))
# self.buttonFind.setMinimumWidth(100)
#
# self.buttonPreview.setMinimumWidth(100)
#
# self.entryFind = FCEntry()
# self.entryFind.setToolTip(_("Find box. Enter here the strings to be searched in the text."))
#
# self.buttonReplace = QtWidgets.QPushButton(_('Replace With'))
# self.buttonReplace.setToolTip(_("Will replace the string from the Find box with the one in the Replace box."))
#
# self.buttonReplace.setMinimumWidth(100)
#
# self.entryReplace = FCEntry()
# self.entryReplace.setToolTip(_("String to replace the one in the Find box throughout the text."))
#
# self.sel_all_cb = QtWidgets.QCheckBox(_('All'))
# self.sel_all_cb.setToolTip(_("When checked it will replace all instances in the 'Find' box\n"
# "with the text in the 'Replace' box.."))
#
# self.button_copy_all = QtWidgets.QPushButton(_('Copy All'))
# self.button_copy_all.setToolTip(_("Will copy all the text in the Code Editor to the clipboard."))
#
# self.button_copy_all.setMinimumWidth(100)
#
# self.buttonOpen = QtWidgets.QPushButton(_('Open Code'))
# self.buttonOpen.setToolTip(_("Will open a text file in the editor."))
#
# self.buttonSave = QtWidgets.QPushButton(_('Save Code'))
# self.buttonSave.setToolTip(_("Will save the text in the editor into a file."))
#
# self.buttonRun = QtWidgets.QPushButton(_('Run Code'))
# self.buttonRun.setToolTip(_("Will run the TCL commands found in the text file, one by one."))
#
# self.buttonRun.hide()
# self.cncjob_tab_layout.addWidget(self.code_editor, 0, 0, 1, 5)
#
# cnc_tab_lay_1 = QtWidgets.QHBoxLayout()
# # cnc_tab_lay_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
# cnc_tab_lay_1.addWidget(self.buttonFind)
# cnc_tab_lay_1.addWidget(self.entryFind)
# cnc_tab_lay_1.addWidget(self.buttonReplace)
# cnc_tab_lay_1.addWidget(self.entryReplace)
# cnc_tab_lay_1.addWidget(self.sel_all_cb)
# cnc_tab_lay_1.addWidget(self.button_copy_all)
# self.cncjob_tab_layout.addLayout(cnc_tab_lay_1, 1, 0, 1, 5)
#
# cnc_tab_lay_3 = QtWidgets.QHBoxLayout()
# cnc_tab_lay_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
# cnc_tab_lay_3.addWidget(self.buttonPreview)
# cnc_tab_lay_3.addWidget(self.buttonPrint)
# self.cncjob_tab_layout.addLayout(cnc_tab_lay_3, 2, 0, 1, 1, QtCore.Qt.AlignLeft)
#
# cnc_tab_lay_4 = QtWidgets.QHBoxLayout()
# cnc_tab_lay_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
# cnc_tab_lay_4.addWidget(self.buttonOpen)
# cnc_tab_lay_4.addWidget(self.buttonSave)
# cnc_tab_lay_4.addWidget(self.buttonRun)
#
# self.cncjob_tab_layout.addLayout(cnc_tab_lay_4, 2, 4, 1, 1)
# #################################
# ## Build InfoBar is done here ###
# #################################
self.infobar = self.statusBar() self.infobar = self.statusBar()
self.fcinfo = FlatCAMInfoBar() self.fcinfo = FlatCAMInfoBar()
self.infobar.addWidget(self.fcinfo, stretch=1) self.infobar.addWidget(self.fcinfo, stretch=1)
@ -1967,10 +1913,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.progress_bar.setMaximum(100) self.progress_bar.setMaximum(100)
# infobar.addWidget(self.progress_bar) # infobar.addWidget(self.progress_bar)
# ########################################################################### # ########################################################################
# ####### Set the APP ICON and the WINDOW TITLE and GEOMETRY ################ # ########################## SET GUI Elements # ##########################
# ########################################################################### # ########################################################################
self.app_icon = QtGui.QIcon() self.app_icon = QtGui.QIcon()
self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16)) self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24)) self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
@ -1991,19 +1936,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.units = "" self.units = ""
self.setAcceptDrops(True) self.setAcceptDrops(True)
# # restore the Toolbar State from file # ########################################################################
# try: # ########################## Build GUI # #################################
# with open(self.app.data_path + '\gui_state.config', 'rb') as stream: # ########################################################################
# self.restoreState(QtCore.QByteArray(stream.read()))
# log.debug("FlatCAMGUI.__init__() --> UI state restored.")
# except IOError:
# log.debug("FlatCAMGUI.__init__() --> UI state not restored. IOError")
# pass
# ################### ##
# ## INITIALIZE GUI # ##
# ################### ##
self.grid_snap_btn.setCheckable(True) self.grid_snap_btn.setCheckable(True)
self.corner_snap_btn.setCheckable(True) self.corner_snap_btn.setCheckable(True)
self.update_obj_btn.setEnabled(False) self.update_obj_btn.setEnabled(False)
@ -2103,8 +2038,18 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.lock_toolbar(lock=lock_state) self.lock_toolbar(lock=lock_state)
self.lock_action.triggered[bool].connect(self.lock_toolbar) self.lock_action.triggered[bool].connect(self.lock_toolbar)
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%% GUI Building FINISHED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def eventFilter(self, obj, event): def eventFilter(self, obj, event):
# filter the ToolTips display based on a Preferences setting """
Filter the ToolTips display based on a Preferences setting
:param obj:
:param event: QT event to filter
:return:
"""
if self.general_defaults_form.general_gui_set_group.toggle_tooltips_cb.get_value() is False: if self.general_defaults_form.general_gui_set_group.toggle_tooltips_cb.get_value() is False:
if event.type() == QtCore.QEvent.ToolTip: if event.type() == QtCore.QEvent.ToolTip:
return True return True
@ -2114,6 +2059,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
return False return False
def populate_toolbars(self): def populate_toolbars(self):
"""
Will populate the App Toolbars with theie actions
:return: None
"""
# ## File Toolbar # ## # ## File Toolbar # ##
self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'), self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
@ -2314,6 +2263,13 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.snap_magnet.setDisabled(True) self.snap_magnet.setDisabled(True)
def keyPressEvent(self, event): def keyPressEvent(self, event):
"""
Key event handler for the entire app.
Some of the key events are also treated locally in the FlatCAM editors
:param event: QT event
:return:
"""
modifiers = QtWidgets.QApplication.keyboardModifiers() modifiers = QtWidgets.QApplication.keyboardModifiers()
active = self.app.collection.get_active() active = self.app.collection.get_active()
selected = self.app.collection.get_selected() selected = self.app.collection.get_selected()
@ -2568,10 +2524,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.app.on_deselect_all() self.app.on_deselect_all()
# if in full screen, exit to normal view # if in full screen, exit to normal view
self.showNormal() if self.app.toggle_fscreen is True:
self.app.restore_toolbar_view() self.app.on_fullscreen(disable=True)
self.splitter_left.setVisible(True)
self.app.toggle_fscreen = False
# try to disconnect the slot from Set Origin # try to disconnect the slot from Set Origin
try: try:
@ -3538,6 +3492,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
class FlatCAMActivityView(QtWidgets.QWidget): class FlatCAMActivityView(QtWidgets.QWidget):
"""
This class create and control the activity icon displayed in the App status bar
"""
def __init__(self, movie="share/active.gif", icon='share/active_static.png', parent=None): def __init__(self, movie="share/active.gif", icon='share/active_static.png', parent=None):
super().__init__(parent=parent) super().__init__(parent=parent)
@ -3577,6 +3534,9 @@ class FlatCAMActivityView(QtWidgets.QWidget):
class FlatCAMInfoBar(QtWidgets.QWidget): class FlatCAMInfoBar(QtWidgets.QWidget):
"""
This class create a place to display the App messages in the Status Bar
"""
def __init__(self, parent=None): def __init__(self, parent=None):
super(FlatCAMInfoBar, self).__init__(parent=parent) super(FlatCAMInfoBar, self).__init__(parent=parent)
@ -3625,6 +3585,9 @@ class FlatCAMInfoBar(QtWidgets.QWidget):
class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon): class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
"""
This class create the Sys Tray icon for the app
"""
def __init__(self, app, icon, headless=None, parent=None): def __init__(self, app, icon, headless=None, parent=None):
# QtWidgets.QSystemTrayIcon.__init__(self, icon, parent) # QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)

View File

@ -315,6 +315,7 @@ class Film(FlatCAMTool):
if type_of_film == 'neg': if type_of_film == 'neg':
self.boundary_label.show() self.boundary_label.show()
self.boundary_entry.show() self.boundary_entry.show()
self.punch_cb.set_value(False) # required so the self.punch_frame it's hidden also by the signal emitted
self.punch_cb.hide() self.punch_cb.hide()
else: else:
self.boundary_label.hide() self.boundary_label.hide()

View File

@ -59,15 +59,19 @@ class ToolOptimal(FlatCAMTool):
"Gerber object for which to find the minimum distance between copper features." "Gerber object for which to find the minimum distance between copper features."
) )
self.title_res_label = QtWidgets.QLabel('<b>%s</b>' % _("Minimum distance between copper features")) self.title_res_label = QtWidgets.QLabel('<b>%s:</b>' % _("Minimum distance"))
self.title_res_label.setToolTip(_("Display minimum distance between copper features."))
self.result_label = QtWidgets.QLabel('%s:' % _("Determined")) self.result_label = QtWidgets.QLabel('%s:' % _("Determined"))
self.show_res = QtWidgets.QLabel('%s' % '') self.result_entry = FCEntry()
self.result_entry.setReadOnly(True)
self.units_lbl = QtWidgets.QLabel(self.units) self.units_lbl = QtWidgets.QLabel(self.units.lower())
self.units_lbl.setDisabled(True)
self.freq_label = QtWidgets.QLabel('%s:' % _("Occurring")) self.freq_label = QtWidgets.QLabel('%s:' % _("Occurring"))
self.freq_label.setToolTip(_("How many times this minimum is found.")) self.freq_label.setToolTip(_("How many times this minimum is found."))
self.freq_res = QtWidgets.QLabel('%s' % '') self.freq_entry = FCEntry()
self.freq_entry.setReadOnly(True)
self.precision_label = QtWidgets.QLabel('%s:' % _("Precision")) self.precision_label = QtWidgets.QLabel('%s:' % _("Precision"))
self.precision_label.setToolTip(_("Number of decimals kept for found distances.")) self.precision_label.setToolTip(_("Number of decimals kept for found distances."))
@ -76,12 +80,12 @@ class ToolOptimal(FlatCAMTool):
self.precision_spinner.set_range(2, 10) self.precision_spinner.set_range(2, 10)
self.precision_spinner.setWrapping(True) self.precision_spinner.setWrapping(True)
self.locations_cb = FCCheckBox(_("Locations")) self.locations_cb = FCCheckBox(_("Minimum points coordinates"))
self.locations_cb.setToolTip(_("Locations where minimum distance was found.")) self.locations_cb.setToolTip(_("Coordinates for points where minimum distance was found."))
self.locations_textb = FCTextArea(parent=self) self.locations_textb = FCTextArea(parent=self)
self.locations_textb.setReadOnly(True) self.locations_textb.setReadOnly(True)
self.locations_textb.setToolTip(_("Locations where minimum distance was found.")) self.locations_textb.setToolTip(_("Coordinates for points where minimum distance was found."))
stylesheet = """ stylesheet = """
QTextEdit { selection-background-color:yellow; QTextEdit { selection-background-color:yellow;
selection-color:black; selection-color:black;
@ -90,10 +94,18 @@ class ToolOptimal(FlatCAMTool):
self.locations_textb.setStyleSheet(stylesheet) self.locations_textb.setStyleSheet(stylesheet)
self.locate_button = QtWidgets.QPushButton(_("Jump to selected position"))
self.locate_button.setToolTip(
_("Select a position in the Locations text box and then\n"
"click this button.")
)
self.locate_button.setMinimumWidth(60)
self.locate_button.setDisabled(True)
hlay = QtWidgets.QHBoxLayout() hlay = QtWidgets.QHBoxLayout()
hlay.addWidget(self.show_res) hlay.addWidget(self.result_entry)
hlay.addStretch() # hlay.addStretch()
hlay.addWidget(self.units_lbl) hlay.addWidget(self.units_lbl)
form_lay.addRow(QtWidgets.QLabel("")) form_lay.addRow(QtWidgets.QLabel(""))
@ -103,11 +115,14 @@ class ToolOptimal(FlatCAMTool):
form_lay.addRow(QtWidgets.QLabel("")) form_lay.addRow(QtWidgets.QLabel(""))
form_lay.addRow(self.title_res_label) form_lay.addRow(self.title_res_label)
form_lay.addRow(self.result_label, hlay) form_lay.addRow(self.result_label, hlay)
form_lay.addRow(self.freq_label, self.freq_res) form_lay.addRow(self.freq_label, self.freq_entry)
form_lay.addRow(self.locations_cb) form_lay.addRow(self.locations_cb)
form_lay.addRow(self.locations_textb) form_lay.addRow(self.locations_textb)
form_lay.addRow(self.locate_button)
self.calculate_button = QtWidgets.QPushButton(_("Find Distance")) self.loc_ois = OptionalHideInputSection(self.locations_cb, [self.locations_textb, self.locate_button])
self.calculate_button = QtWidgets.QPushButton(_("Find Minimum"))
self.calculate_button.setToolTip( self.calculate_button.setToolTip(
_("Calculate the minimum distance between copper features,\n" _("Calculate the minimum distance between copper features,\n"
"this will allow the determination of the right tool to\n" "this will allow the determination of the right tool to\n"
@ -116,45 +131,17 @@ class ToolOptimal(FlatCAMTool):
self.calculate_button.setMinimumWidth(60) self.calculate_button.setMinimumWidth(60)
self.layout.addWidget(self.calculate_button) self.layout.addWidget(self.calculate_button)
self.locate_button = QtWidgets.QPushButton(_("Locate position"))
self.locate_button.setToolTip(
_("Select a position in the Locations text box and then\n"
"click this button.")
)
self.locate_button.setMinimumWidth(60)
self.layout.addWidget(self.locate_button)
self.locate_button.setDisabled(True)
self.decimals = 4 self.decimals = 4
self.selected_text = '' self.selected_text = ''
# self.dt_label = QtWidgets.QLabel("<b>%s:</b>" % _('Alignment Drill Diameter'))
# self.dt_label.setToolTip(
# _("Diameter of the drill for the "
# "alignment holes.")
# )
# self.layout.addWidget(self.dt_label)
#
# hlay = QtWidgets.QHBoxLayout()
# self.layout.addLayout(hlay)
#
# self.drill_dia = FCEntry()
# self.dd_label = QtWidgets.QLabel('%s:' % _("Drill dia"))
# self.dd_label.setToolTip(
# _("Diameter of the drill for the "
# "alignment holes.")
# )
# hlay.addWidget(self.dd_label)
# hlay.addWidget(self.drill_dia)
# ## Signals
self.calculate_button.clicked.connect(self.find_minimum_distance) self.calculate_button.clicked.connect(self.find_minimum_distance)
self.locate_button.clicked.connect(self.on_locate_position) self.locate_button.clicked.connect(self.on_locate_position)
self.update_text.connect(self.on_update_text) self.update_text.connect(self.on_update_text)
self.locations_textb.cursorPositionChanged.connect(self.on_textbox_clicked) self.locations_textb.cursorPositionChanged.connect(self.on_textbox_clicked)
self.locations_cb.stateChanged.connect(self.on_location_cb)
self.layout.addStretch()
# ## Signals self.layout.addStretch()
def install(self, icon=None, separator=None, **kwargs): def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='ALT+O', **kwargs) FlatCAMTool.install(self, icon, separator, shortcut='ALT+O', **kwargs)
@ -162,7 +149,9 @@ class ToolOptimal(FlatCAMTool):
def run(self, toggle=True): def run(self, toggle=True):
self.app.report_usage("ToolOptimal()") self.app.report_usage("ToolOptimal()")
self.show_res.setText('') self.result_entry.set_value(0.0)
self.freq_entry.set_value('0')
if toggle: if toggle:
# if the splitter is hidden, display it, else hide it but only if the current widget is the same # if the splitter is hidden, display it, else hide it but only if the current widget is the same
if self.app.ui.splitter.sizes()[0] == 0: if self.app.ui.splitter.sizes()[0] == 0:
@ -202,8 +191,8 @@ class ToolOptimal(FlatCAMTool):
self.locations_textb.setVisible(False) self.locations_textb.setVisible(False)
self.locate_button.setVisible(False) self.locate_button.setVisible(False)
self.show_res.setText('') self.result_entry.set_value(0.0)
self.freq_res.setText('') self.freq_entry.set_value('0')
self.reset_fields() self.reset_fields()
def find_minimum_distance(self): def find_minimum_distance(self):
@ -296,11 +285,11 @@ class ToolOptimal(FlatCAMTool):
min_list = list(min_dict.keys()) min_list = list(min_dict.keys())
min_dist = min(min_list) min_dist = min(min_list)
min_dist_string = '%.*f' % (self.decimals, float(min_dist)) min_dist_string = '%.*f' % (self.decimals, float(min_dist))
self.show_res.setText(min_dist_string) self.result_entry.set_Value(min_dist_string)
freq = len(min_dict[min_dist]) freq = len(min_dict[min_dist])
freq = '%d' % int(freq) freq = '%d' % int(freq)
self.freq_res.setText(freq) self.freq_entry.set_value(freq)
self.update_text.emit(min_dict[min_dist]) self.update_text.emit(min_dict[min_dist])
@ -350,14 +339,6 @@ class ToolOptimal(FlatCAMTool):
self.selected_text = cursor.selectedText() self.selected_text = cursor.selectedText()
def on_location_cb(self, state):
if state:
self.locations_textb.setVisible(True)
self.locate_button.setVisible(True)
else:
self.locations_textb.setVisible(False)
self.locate_button.setVisible(False)
def reset_fields(self): def reset_fields(self):
self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.gerber_object_combo.setCurrentIndex(0) self.gerber_object_combo.setCurrentIndex(0)