From 8c57a53e3b638011e3818526a1257f37c75e620f Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 9 Oct 2021 00:34:30 +0300 Subject: [PATCH] - fixed some recently introduced issues for the Milling and Drilling Plugins; those plugins did not had the pluginName defined in the Plugin UI - in the canvas context menu added the menu for color changing - when doing color changing now only Gerber and Excellon objects can have the colors changed --- CHANGELOG.md | 6 +++++ appGUI/MainGUI.py | 49 ++++++++++++++++++++++++++++++++++++++ appPlugins/ToolDrilling.py | 2 ++ appPlugins/ToolMilling.py | 2 ++ app_Main.py | 26 ++++++++++++++++---- 5 files changed, 80 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0f1cbb9..7a0702db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ CHANGELOG for FlatCAM beta ================================================= +9.10.2021 + +- fixed some recently introduced issues for the Milling and Drilling Plugins; those plugins did not had the pluginName defined in the Plugin UI +- in the canvas context menu added the menu for color changing +- when doing color changing now only Gerber and Excellon objects can have the colors changed + 8.10.2021 - the Plugins object combo boxes are no longer updated on object selection on Project tab generally but only for the Plugin that is current, if any diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index b4135101..ddaa0523 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -1683,9 +1683,11 @@ class MainGUI(QtWidgets.QMainWindow): QtGui.QIcon(self.app.resource_location + '/file16.png'), _("Project")) self.popMenu.addSeparator() + # Grids self.cmenu_gridmenu = self.popMenu.addMenu( QtGui.QIcon(self.app.resource_location + '/grid32_menu.png'), _("Grids")) + # View self.cmenu_viewmenu = self.popMenu.addMenu( QtGui.QIcon(self.app.resource_location + '/view64.png'), _("View")) self.zoomfit = self.cmenu_viewmenu.addAction( @@ -1694,6 +1696,53 @@ class MainGUI(QtWidgets.QMainWindow): QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("Clear Plot")) self.replot = self.cmenu_viewmenu.addAction( QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("Replot")) + + self.popMenu.addSeparator() + + # Set colors + self.pop_menucolor = self.popMenu.addMenu( + QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Set Color')) + + self.pop_menu_red = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/red32.png'), _('Red')) + + self.pop_menu_blue = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/blue32.png'), _('Blue')) + + self.pop_menu_yellow = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/yellow32.png'), _('Yellow')) + + self.pop_menu_green = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/green32.png'), _('Green')) + + self.pop_menu_purple = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/violet32.png'), _('Purple')) + + self.pop_menu_brown = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/brown32.png'), _('Brown')) + + self.pop_menu_brown = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/indigo32.png'), _('Indigo')) + + self.pop_menu_brown = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/white32.png'), _('White')) + + self.pop_menu_brown = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/black32.png'), _('Black')) + + self.pop_menucolor.addSeparator() + + self.pop_menu_custom = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Custom')) + + self.pop_menucolor.addSeparator() + + self.pop_menu_custom = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Opacity')) + + self.pop_menu_custom = self.pop_menucolor.addAction( + QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Default')) + self.popMenu.addSeparator() self.g_editor_cmenu = self.popMenu.addMenu( diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index 9f21e50a..78188f31 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -2255,6 +2255,8 @@ class ToolDrilling(AppTool, Excellon): class DrillingUI: + pluginName = _("Drilling") + def __init__(self, layout, app, name): self.app = app self.decimals = self.app.decimals diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index 53002d61..a1ad9ddd 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -3532,6 +3532,8 @@ class ToolMilling(AppTool, Excellon): class MillingUI: + pluginName = _("Milling") + def __init__(self, layout, app, name): self.app = app self.decimals = self.app.decimals diff --git a/app_Main.py b/app_Main.py index 6a1fb22d..fddb0f6b 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2244,15 +2244,21 @@ class App(QtCore.QObject): self.ui.popmenu_disable.triggered.connect(lambda: self.toggle_plots(self.collection.get_selected())) self.ui.popmenu_panel_toggle.triggered.connect(self.ui.on_toggle_notebook) + # New self.ui.popmenu_new_geo.triggered.connect(lambda: self.app_obj.new_geometry_object()) self.ui.popmenu_new_grb.triggered.connect(lambda: self.app_obj.new_gerber_object()) self.ui.popmenu_new_exc.triggered.connect(lambda: self.app_obj.new_excellon_object()) self.ui.popmenu_new_prj.triggered.connect(lambda: self.f_handlers.on_file_new_project()) + # View self.ui.zoomfit.triggered.connect(self.on_zoom_fit) self.ui.clearplot.triggered.connect(self.clear_plots) self.ui.replot.triggered.connect(self.plot_all) + # Colors + for act in self.ui.pop_menucolor.actions(): + act.triggered.connect(self.on_set_color_action_triggered) + self.ui.popmenu_copy.triggered.connect(self.on_copy_command) self.ui.popmenu_delete.triggered.connect(self.on_delete) self.ui.popmenu_edit.triggered.connect(self.object2editor) @@ -7501,6 +7507,15 @@ class App(QtCore.QObject): self.populate_cmenu_grids() self.ui.popMenu.popup(self.cursor.pos()) + # if at least one object is Gerber or Excellon enable color changes + sel_obj_list = self.collection.get_selected() + self.ui.pop_menucolor.setDisabled(True) + if sel_obj_list: + for obj in sel_obj_list: + if obj.kind in ["gerber", "excellon"]: + self.ui.pop_menucolor.setDisabled(False) + break + def selection_area_handler(self, start_pos, end_pos, sel_type): """ Called when the mouse selects by dragging left mouse button on canvas. @@ -8938,12 +8953,13 @@ class App(QtCore.QObject): new_line_color = color_variant("#dedede", 0.7) for sel_obj in sel_obj_list: - sel_obj.fill_color = new_color - sel_obj.outline_color = new_line_color + if sel_obj.kind in ["excellon", "gerber"]: + sel_obj.fill_color = new_color + sel_obj.outline_color = new_line_color - sel_obj.shapes.redraw( - update_colors=(new_color, new_line_color) - ) + sel_obj.shapes.redraw( + update_colors=(new_color, new_line_color) + ) self.set_obj_color_in_preferences_dict(sel_obj_list, new_color, new_line_color)