From d464c1e18aa350f35b630c88e5e7ed7cbd0780d1 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 8 Mar 2021 02:10:04 +0200 Subject: [PATCH] - modified the CNCJob UI to add a shortcut button for the Levelling Plugin --- CHANGELOG.md | 5 +- appGUI/MainGUI.py | 114 ++++++++++++++++++------------------ appGUI/ObjectUI.py | 48 ++++++++++----- appObjects/FlatCAMCNCJob.py | 2 + 4 files changed, 96 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eb9b784..5a8c1162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,10 @@ CHANGELOG for FlatCAM beta 7.03.2021 -- Levelling Tool - mare sure that there are no duplicate seed points when creating Voronoi polygons -- Levelling Tool - fix of missing variable declaration (forgot to take everything when I moved the functionality from the CNCJob class to its own class) +- Levelling Plugin - mare sure that there are no duplicate seed points when creating Voronoi polygons +- Levelling Plugin - fix of missing variable declaration (forgot to take everything when I moved the functionality from the CNCJob class to its own class) - made sure that possible temporary drawn shapes are deleted when the UI of the Plugin that created them is closed (by closing it in the Plugin Tab) +- modified the CNCJob UI to add a shortcut button for the Levelling Plugin 6.03.2021 diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index b5d87423..ce549cf8 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -1076,81 +1076,81 @@ class MainGUI(QtWidgets.QMainWindow): # ########################## Tools Toolbar# ############################## # ######################################################################## self.drill_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/extract_drill32.png'), _("Drilling Tool")) + QtGui.QIcon(self.app.resource_location + '/extract_drill32.png'), _("Drilling")) self.mill_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/milling_tool32.png'), _("Milling Tool")) + QtGui.QIcon(self.app.resource_location + '/milling_tool32.png'), _("Milling")) self.level_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/level32.png'), _("Levelling Tool")) + QtGui.QIcon(self.app.resource_location + '/level32.png'), _("Levelling")) self.level_btn.setDisabled(True) self.level_btn.setToolTip("DISABLED. Work in progress!") self.toolbarplugins.addSeparator() self.isolation_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/iso_16.png'), _("Isolation Tool")) + QtGui.QIcon(self.app.resource_location + '/iso_16.png'), _("Isolation")) self.follow_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/follow32.png'), _("Follow Tool")) + QtGui.QIcon(self.app.resource_location + '/follow32.png'), _("Follow")) self.ncc_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/ncc32.png'), _("NCC Tool")) + QtGui.QIcon(self.app.resource_location + '/ncc32.png'), _("NCC")) self.paint_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool")) + QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint")) self.toolbarplugins.addSeparator() self.cutout_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/cut32.png'), _("Cutout Tool")) + QtGui.QIcon(self.app.resource_location + '/cut32.png'), _("Cutout")) self.panelize_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool")) + QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel")) self.film_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/film32.png'), _("Film Tool")) + QtGui.QIcon(self.app.resource_location + '/film32.png'), _("Film")) self.dblsided_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2-Sided Tool")) + QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2-Sided")) self.toolbarplugins.addSeparator() self.align_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects Tool")) + QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects")) # self.sub_btn = self.toolbarplugins.addAction( # QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool")) self.toolbarplugins.addSeparator() self.extract_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/extract32.png'), _("Extract Tool")) + QtGui.QIcon(self.app.resource_location + '/extract32.png'), _("Extract")) self.copperfill_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool")) + QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving")) self.corners_tool_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/corners_32.png'), _("Corner Markers Tool")) + QtGui.QIcon(self.app.resource_location + '/corners_32.png'), _("Corner Markers")) self.punch_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/punch32.png'), _("Punch Gerber Tool")) + QtGui.QIcon(self.app.resource_location + '/punch32.png'), _("Punch Gerber")) self.calculators_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool")) + QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators")) self.toolbarplugins.addSeparator() # self.solder_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste Tool")) + # QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste")) # self.sub_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool")) + # QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract")) # self.rules_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules Tool")) + # QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules")) # self.optimal_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal Tool")) + # QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal")) # self.transform_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool")) + # QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform")) # self.qrcode_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool")) + # QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode")) # self.align_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects Tool")) + # QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects")) # self.fiducials_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool")) + # QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials")) # self.cal_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool")) + # QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration")) # self.invert_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/invert32.png'), _("Invert Gerber Tool")) + # QtGui.QIcon(self.app.resource_location + '/invert32.png'), _("Invert Gerber")) # self.etch_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/etch_32.png'), _("Etch Compensation Tool")) + # QtGui.QIcon(self.app.resource_location + '/etch_32.png'), _("Etch Compensation")) # ######################################################################## # ########################## Excellon Editor Toolbar# #################### @@ -2295,81 +2295,81 @@ class MainGUI(QtWidgets.QMainWindow): # ######################### Tools Toolbar ################################# # ######################################################################### self.drill_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/extract_drill32.png'), _("Drilling Tool")) + QtGui.QIcon(self.app.resource_location + '/extract_drill32.png'), _("Drilling")) self.mill_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/milling_tool32.png'), _("Milling Tool")) + QtGui.QIcon(self.app.resource_location + '/milling_tool32.png'), _("Milling")) self.level_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/level32.png'), _("Levelling Tool")) + QtGui.QIcon(self.app.resource_location + '/level32.png'), _("Levelling")) self.level_btn.setDisabled(True) self.level_btn.setToolTip("DISABLED. Work in progress!") self.toolbarplugins.addSeparator() self.isolation_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/iso_16.png'), _("Isolation Tool")) + QtGui.QIcon(self.app.resource_location + '/iso_16.png'), _("Isolation")) self.follow_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/follow32.png'), _("Follow Tool")) + QtGui.QIcon(self.app.resource_location + '/follow32.png'), _("Follow")) self.ncc_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/ncc32.png'), _("NCC Tool")) + QtGui.QIcon(self.app.resource_location + '/ncc32.png'), _("NCC")) self.paint_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool")) + QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint")) self.toolbarplugins.addSeparator() self.cutout_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/cut32.png'), _("Cutout Tool")) + QtGui.QIcon(self.app.resource_location + '/cut32.png'), _("Cutout")) self.panelize_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool")) + QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel")) self.film_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/film32.png'), _("Film Tool")) + QtGui.QIcon(self.app.resource_location + '/film32.png'), _("Film")) self.dblsided_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2-Sided Tool")) + QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2-Sided")) self.toolbarplugins.addSeparator() self.align_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects Tool")) + QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects")) # self.sub_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool")) + # QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract")) self.toolbarplugins.addSeparator() self.extract_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/extract32.png'), _("Extract Tool")) + QtGui.QIcon(self.app.resource_location + '/extract32.png'), _("Extract")) self.copperfill_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool")) + QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving")) self.corners_tool_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/corners_32.png'), _("Corner Markers Tool")) + QtGui.QIcon(self.app.resource_location + '/corners_32.png'), _("Corner Markers")) self.punch_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/punch32.png'), _("Punch Gerber Tool")) + QtGui.QIcon(self.app.resource_location + '/punch32.png'), _("Punch Gerber")) self.calculators_btn = self.toolbarplugins.addAction( - QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool")) + QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators")) self.toolbarplugins.addSeparator() # self.solder_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste Tool")) + # QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste")) # self.sub_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool")) + # QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract")) # self.rules_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules Tool")) + # QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules")) # self.optimal_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal Tool")) + # QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal")) # self.transform_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool")) + # QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform")) # self.qrcode_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool")) + # QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode")) # self.align_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects Tool")) + # QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects")) # self.fiducials_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool")) + # QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials")) # self.cal_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool")) + # QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration")) # self.invert_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/invert32.png'), _("Invert Gerber Tool")) + # QtGui.QIcon(self.app.resource_location + '/invert32.png'), _("Invert Gerber")) # self.etch_btn = self.toolbarplugins.addAction( - # QtGui.QIcon(self.app.resource_location + '/etch_32.png'), _("Etch Compensation Tool")) + # QtGui.QIcon(self.app.resource_location + '/etch_32.png'), _("Etch Compensation")) # ######################################################################## # ################### Excellon Editor Toolbar ############################ diff --git a/appGUI/ObjectUI.py b/appGUI/ObjectUI.py index f650ce79..c89f3bf4 100644 --- a/appGUI/ObjectUI.py +++ b/appGUI/ObjectUI.py @@ -2146,11 +2146,6 @@ class CNCObjectUI(ObjectUI): ) self.custom_box.addWidget(self.updateplot_button) - separator_line = QtWidgets.QFrame() - separator_line.setFrameShape(QtWidgets.QFrame.HLine) - separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.custom_box.addWidget(separator_line) - # CNC Code snippets self.snippets_cb = FCCheckBox(_("Use CNC Code Snippets")) self.snippets_cb.setToolTip( @@ -2159,25 +2154,50 @@ class CNCObjectUI(ObjectUI): ) self.custom_box.addWidget(self.snippets_cb) + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + self.custom_box.addWidget(separator_line) + + # ############################################################################################################# + # ###################### PLUGINS ########################################################################## + # ############################################################################################################# + + self.tool_lbl = FCLabel('%s' % _("Plugins")) + self.custom_box.addWidget(self.tool_lbl) + + # Levelling Tool - will process the generated GCode using a Height Map generating levelled GCode + self.autolevel_button = FCButton(_('Levelling')) + self.autolevel_button.setIcon(QtGui.QIcon(self.app.resource_location + '/level32.png')) + self.autolevel_button.setToolTip( + _("Generate CNC Code with auto-levelled paths.") + ) + self.autolevel_button.setStyleSheet(""" + QPushButton + { + font-weight: bold; + } + """) + self.custom_box.addWidget(self.autolevel_button) + # self.autolevel_button.setDisabled(True) + # self.autolevel_button.setToolTip("DISABLED. Work in progress!") + # ############################################################################################################# # ## Export G-Code ## # ############################################################################################################# - self.export_gcode_label = FCLabel("%s:" % _("Export CNC Code")) - self.export_gcode_label.setToolTip( - _("Export and save G-Code to\n" - "make this object to a file.") - ) - self.custom_box.addWidget(self.export_gcode_label) + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + self.custom_box.addWidget(separator_line) g_export_lay = QtWidgets.QHBoxLayout() self.custom_box.addLayout(g_export_lay) # Save Button - self.export_gcode_button = FCButton(_('Save CNC Code')) + self.export_gcode_button = FCButton(_('Save')) self.export_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) self.export_gcode_button.setToolTip( - _("Opens dialog to save G-Code\n" - "file.") + _("Opens dialog to save CNC Code file.") ) self.export_gcode_button.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) g_export_lay.addWidget(self.export_gcode_button) diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 300b5b53..1e833b01 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -484,6 +484,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): # Include CNC Job Snippets changed self.ui.snippets_cb.toggled.connect(self.on_update_source_file) + self.ui.autolevel_button.clicked.connect(lambda: self.app.levelling_tool.run(toggle=True)) + # ###################################### END Signal connections ############################################### # #############################################################################################################