From beda0df4a47653660fd9e0c1927a63a6a64662ab Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 23 Aug 2019 19:30:33 +0300 Subject: [PATCH] - for all the tools launched rom toolbar the behavior is modified: first click it will launch the tool; second click: if the Tool tab has focus it will close the tool but if another tab is selected, the tool will have focus - modified the NCC Tool and Paint Tool to work multiple times after first launch --- README.md | 2 ++ flatcamTools/ToolCalculators.py | 7 ++++++- flatcamTools/ToolCutOut.py | 7 ++++++- flatcamTools/ToolDblSided.py | 7 ++++++- flatcamTools/ToolFilm.py | 7 ++++++- flatcamTools/ToolImage.py | 7 ++++++- flatcamTools/ToolNonCopperClear.py | 23 +++++++++++++++++------ flatcamTools/ToolPaint.py | 25 ++++++++++++++++++++++--- flatcamTools/ToolPanelize.py | 7 ++++++- flatcamTools/ToolPcbWizard.py | 7 ++++++- flatcamTools/ToolProperties.py | 7 ++++++- flatcamTools/ToolSolderPaste.py | 7 ++++++- flatcamTools/ToolSub.py | 7 ++++++- flatcamTools/ToolTransform.py | 7 ++++++- 14 files changed, 107 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 4ab4ccbb..cefd03a4 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ CAD program, and create G-Code for Isolation routing. - fixed a bug in Excellon Editor that made that the selection of drills is always cumulative - in Paint Tool added ability to add multiple zones to paint when Area option is checked and the modifier key is pressed (either CTRL or SHIFT as set in Preferences). Right click of the mouse is an additional way to finish the job. - in Paint Tool and NCC Tool, for the Area option, now mouse panning is allowed while adding areas to process +- for all the tools launched rom toolbar the behavior is modified: first click it will launch the tool; second click: if the Tool tab has focus it will close the tool but if another tab is selected, the tool will have focus +- modified the NCC Tool and Paint Tool to work multiple times after first launch 22.08.2019 diff --git a/flatcamTools/ToolCalculators.py b/flatcamTools/ToolCalculators.py index 17081246..b3dae275 100644 --- a/flatcamTools/ToolCalculators.py +++ b/flatcamTools/ToolCalculators.py @@ -243,7 +243,12 @@ class ToolCalculator(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolCutOut.py b/flatcamTools/ToolCutOut.py index 552614a3..29aab7fd 100644 --- a/flatcamTools/ToolCutOut.py +++ b/flatcamTools/ToolCutOut.py @@ -319,7 +319,12 @@ class CutOut(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolDblSided.py b/flatcamTools/ToolDblSided.py index a8cd5a05..ec3d4716 100644 --- a/flatcamTools/ToolDblSided.py +++ b/flatcamTools/ToolDblSided.py @@ -288,7 +288,12 @@ class DblSidedTool(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolFilm.py b/flatcamTools/ToolFilm.py index d2ca9940..450b7213 100644 --- a/flatcamTools/ToolFilm.py +++ b/flatcamTools/ToolFilm.py @@ -190,7 +190,12 @@ class Film(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolImage.py b/flatcamTools/ToolImage.py index 43a658d3..9fadcea4 100644 --- a/flatcamTools/ToolImage.py +++ b/flatcamTools/ToolImage.py @@ -157,7 +157,12 @@ class ToolImage(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py index 0682098b..5b62ee4c 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/flatcamTools/ToolNonCopperClear.py @@ -411,7 +411,12 @@ class NonCopperClear(FlatCAMTool, Gerber): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: @@ -1189,8 +1194,6 @@ class NonCopperClear(FlatCAMTool, Gerber): # focus on Selected Tab self.app.ui.notebook.setCurrentWidget(self.app.ui.selected_tab) - self.tools_frame.hide() - self.app.ui.notebook.setTabText(2, _("Tools")) # Promise object with the new name self.app.collection.promise(name) @@ -1343,9 +1346,6 @@ class NonCopperClear(FlatCAMTool, Gerber): # reset the variable for next use app_obj.poly_not_cleared = False - self.tools_frame.hide() - app_obj.ui.notebook.setTabText(2, "Tools") - # Promise object with the new name self.app.collection.promise(name) @@ -1365,3 +1365,14 @@ class NonCopperClear(FlatCAMTool, Gerber): def reset_fields(self): self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) + + def reset_usage(self): + self.obj_name = "" + self.ncc_obj = None + self.bound_obj = None + + self.first_click = False + self.cursor_pos = None + self.mouse_is_dragging = False + + self.sel_rect = [] diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py index fcc16d81..3abbef87 100644 --- a/flatcamTools/ToolPaint.py +++ b/flatcamTools/ToolPaint.py @@ -432,7 +432,12 @@ class ToolPaint(FlatCAMTool, Gerber): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: @@ -444,6 +449,17 @@ class ToolPaint(FlatCAMTool, Gerber): self.app.ui.notebook.setTabText(2, _("Paint Tool")) + def reset_usage(self): + self.obj_name = "" + self.paint_obj = None + self.bound_obj = None + + self.first_click = False + self.cursor_pos = None + self.mouse_is_dragging = False + + self.sel_rect = [] + def on_radio_selection(self): if self.selectmethod_combo.get_value() == "ref": self.box_combo.show() @@ -878,6 +894,10 @@ class ToolPaint(FlatCAMTool, Gerber): self.build_ui() def on_paint_button_click(self): + + # init values for the next usage + self.reset_usage() + self.app.report_usage(_("geometry_on_paint_button")) # self.app.call_source = 'paint' @@ -1653,8 +1673,7 @@ class ToolPaint(FlatCAMTool, Gerber): target_geo = [obj.solid_geometry] else: target_geo = obj.solid_geometry - print(target_geo) - print(sel_obj) + for poly in target_geo: new_pol = poly.intersection(sel_obj) geo_to_paint.append(new_pol) diff --git a/flatcamTools/ToolPanelize.py b/flatcamTools/ToolPanelize.py index 48df13bc..ea7fd4c7 100644 --- a/flatcamTools/ToolPanelize.py +++ b/flatcamTools/ToolPanelize.py @@ -259,7 +259,12 @@ class Panelize(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolPcbWizard.py b/flatcamTools/ToolPcbWizard.py index 1bdcf054..7afec009 100644 --- a/flatcamTools/ToolPcbWizard.py +++ b/flatcamTools/ToolPcbWizard.py @@ -179,7 +179,12 @@ class PcbWizard(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolProperties.py b/flatcamTools/ToolProperties.py index d0264803..40ca330f 100644 --- a/flatcamTools/ToolProperties.py +++ b/flatcamTools/ToolProperties.py @@ -77,7 +77,12 @@ class Properties(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolSolderPaste.py b/flatcamTools/ToolSolderPaste.py index 3ac90247..726d2e16 100644 --- a/flatcamTools/ToolSolderPaste.py +++ b/flatcamTools/ToolSolderPaste.py @@ -436,7 +436,12 @@ class SolderPaste(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolSub.py b/flatcamTools/ToolSub.py index 015e98de..5125a9e0 100644 --- a/flatcamTools/ToolSub.py +++ b/flatcamTools/ToolSub.py @@ -205,7 +205,12 @@ class ToolSub(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: diff --git a/flatcamTools/ToolTransform.py b/flatcamTools/ToolTransform.py index 0dc5d10e..54744231 100644 --- a/flatcamTools/ToolTransform.py +++ b/flatcamTools/ToolTransform.py @@ -385,7 +385,12 @@ class ToolTransform(FlatCAMTool): else: try: if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName: - self.app.ui.splitter.setSizes([0, 1]) + # if tab is populated with the tool but it does not have the focus, focus on it + if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab: + # focus on Tool Tab + self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab) + else: + self.app.ui.splitter.setSizes([0, 1]) except AttributeError: pass else: