From 12dad1792a953fe563dfd66d2c98d1f6b5db3b64 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 10 Oct 2021 03:11:13 +0300 Subject: [PATCH] - in 2Sided Plugin: adding cumulative alignment points using the Ctrl+Shift+LMB now detects if it is a new start in adding alignment drill points - in 2Sided Plugin: duplicated set of coordinates in Alignment Drills are removed - in 2Sided Plugin: Shift+LMB will add automatically the clicked coordinates in the Alignment Drills location --- CHANGELOG.md | 11 +++-- .../tools/Tools2sidedPrefGroupUI.py | 2 +- appPlugins/ToolDblSided.py | 48 ++++++++++++++----- appTool.py | 4 ++ 4 files changed, 49 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9591a6fb..f2af20d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ CHANGELOG for FlatCAM beta - in Markers Plugin replaced the Margin parameters with the Offset parameters that now can be referenced either to the edge of the bounding box (effectively replacing the old Margin parameter) or to the center of the bounding box - Distance Plugin Ui was upgraded - updated the language strings +- in 2Sided Plugin: adding cumulative alignment points using the Ctrl+Shift+LMB now detects if it is a new start in adding alignment drill points +- in 2Sided Plugin: duplicated set of coordinates in Alignment Drills are removed +- in 2Sided Plugin: Shift+LMB will add automatically the clicked coordinates in the Alignment Drills location 9.10.2021 @@ -40,7 +43,7 @@ CHANGELOG for FlatCAM beta - code cleanup - in "Punch Gerber" and "Extract" Plugins - make sure that the aperture markings are deleted on Reset Tool click and upon finishing the Plugin main function - in Punch Gerber Plugin the object is no longer populated automatically with the generated object -- in Corner Markers Plugin fixed the position of "drills in locations" and for Checking Exceloon; the source object is no longer auto-updated to the latest one since we have to always work on the original object +- in Corner Markers Plugin fixed the position of "drills in locations" and for Checking Excellon; the source object is no longer auto-updated to the latest one since we have to always work on the original object 5.10.2021 @@ -54,7 +57,7 @@ CHANGELOG for FlatCAM beta - fixed a typo in the Object UI - in 2Sided Plugin advanced mode fixed the bounds calculation: if no object is selected on canvas then the object selected in Source Object is used - in 2Sided Plugin added a new typ of alignment drills: manual. This mode will no longer add pairs of drill holes mirrored against reference but only add in place drill holes -- in 2Sided Plugin clicking LMB and also pressing CTRL+Shift will add the click coordinates to the Drll Alignment Coordinates +- in 2Sided Plugin clicking LMB and also pressing CTRL+Shift will add the click coordinates to the Drill Alignment Coordinates - added support for all Plugins to handle the LMB click release event without connect/reconnect of the mouse events - code refactoring in app_Main file - in 2Sided Plugin, deleting the last drill alignment coordinates will update the clipboard values too @@ -70,7 +73,7 @@ CHANGELOG for FlatCAM beta 2.10.2021 -- in Preferences, more Plugins preferences UI is upgraded to the new look +- in Preferences, more Plugins preferences UI are upgraded to the new look - In Paint Plugin fixed the Area select mode to work with Geometry object created by the Geometry Editor - in Paint Plugin some changes in the way the source object is autoloaded - in Paint, NCC and Cutout Plugins when using a mode that require to be terminated (by mouse RMB or ESC key) the notebook UI element is disabled until this is done @@ -96,7 +99,7 @@ CHANGELOG for FlatCAM beta - changed the circle resolution back to the default of 16 since this value is good for fast rendering of Gerber files - added a shortcut to select all apertures in the Gerber Editor (Ctrl+A) - other minor fixes -- added a shortcut to select all apertures in the Excellon Editor (Ctrl+A) +- added a shortcut to select all tools in the Excellon Editor (Ctrl+A) - in Cutout Plugin simplified the UI - Gerber Extra Buffering is now OFf by default. For those cases where the Gerber file is not rendered correctly it will need to be activated. It has a performance penalty so it will no longer be enabled by default for everybody. - Gerber UI in Preferences is now updated diff --git a/appGUI/preferences/tools/Tools2sidedPrefGroupUI.py b/appGUI/preferences/tools/Tools2sidedPrefGroupUI.py index 32d6b301..f3f62dc8 100644 --- a/appGUI/preferences/tools/Tools2sidedPrefGroupUI.py +++ b/appGUI/preferences/tools/Tools2sidedPrefGroupUI.py @@ -53,7 +53,7 @@ class Tools2sidedPrefGroupUI(OptionsGroupUI): param_grid.addWidget(self.drill_dia_entry, 0, 1) # ## Alignment Axis - self.align_type_label = FCLabel('%s:' % _("Align Axis")) + self.align_type_label = FCLabel('%s:' % _("Type")) self.align_type_label.setToolTip( _("The content of the Excellon file.\n" "X - Pairs of drill holes mirrored vertically from reference point\n" diff --git a/appPlugins/ToolDblSided.py b/appPlugins/ToolDblSided.py index d3dddd5e..1e3f4973 100644 --- a/appPlugins/ToolDblSided.py +++ b/appPlugins/ToolDblSided.py @@ -454,12 +454,35 @@ class DblSidedTool(AppTool): # if modifiers == QtCore.Qt.KeyboardModifier.ShiftModifier: # clip_val = self.app.clipboard.text() # self.ui.point_entry.set_value(clip_val) + clip_val = self.app.clipboard.text() + if modifiers == QtCore.Qt.KeyboardModifier.ControlModifier | QtCore.Qt.KeyboardModifier.ShiftModifier: - clip_val = self.app.clipboard.text().replace("[", '').replace("]", '') + alignment_holes = self.ui.alignment_holes.get_value() + try: + eval_clip_val = eval(clip_val) + except Exception as err: + self.app.log.debug("DblSidedTool.on_mouse_plugin_click_release() --> %s" % str(err)) + return + + if alignment_holes == '' or alignment_holes is None: + if isinstance(eval_clip_val, list): + altered_clip_val = str(eval_clip_val[-1]) + self.app.clipboard.setText(altered_clip_val) + else: + altered_clip_val = clip_val + else: + if isinstance(eval_clip_val, list): + # remove duplicates + clean_eval_clip = set(eval_clip_val) + # convert to string + clip_val = str(list(clean_eval_clip)) + altered_clip_val = clip_val.replace("[", '').replace("]", '') + + self.ui.alignment_holes.set_value(altered_clip_val) + self.drill_values = altered_clip_val + elif modifiers == QtCore.Qt.KeyboardModifier.ShiftModifier: self.ui.alignment_holes.set_value(clip_val) - else: - return - self.drill_values = clip_val + self.drill_values = clip_val def on_exit(self, cancelled=None): self.app.call_source = "app" @@ -534,7 +557,7 @@ class DblSidedTool(AppTool): # adjust the clipboard content too try: old_clipb = eval(self.app.clipboard.text()) - except Exception as err: + except Exception: # self.log.error("App.on_mouse_and_key_modifiers() --> %s" % str(err)) old_clipb = None @@ -1085,13 +1108,16 @@ class DsidedUI: grid4.addWidget(self.align_ref_label_val, 6, 1) # ## Alignment holes - self.ah_label = FCLabel("%s:" % _('Alignment Drill Coordinates')) + self.ah_label = FCLabel("%s:" % _('Drill Coordinates')) self.ah_label.setToolTip( - _("Alignment holes (x1, y1), (x2, y2), ... " - "on one side of the mirror axis. For each set of (x, y) coordinates\n" - "entered here, a pair of drills will be created:\n\n" - "- one drill at the coordinates from the field\n" - "- one drill in mirror position over the axis selected above in the 'Align Axis'.") + _("Alignment holes (x1, y1), (x2, y2), ... \n" + "If the type is X or Y then for each pair of coordinates\n" + "two drill points will be added: one with the given coordinates,\n" + "and the other will be mirrored as set in the 'Mirror' section.\n" + "If the type is 'Manual' then no mirror point is generated.\n" + "\n" + "Shift + mouse click will add one set of coordinates.\n" + "Ctrl + Shift + mouse click will accumulate sets of coordinates. ") ) grid4.addWidget(self.ah_label, 8, 0, 1, 2) diff --git a/appTool.py b/appTool.py index b8eabc76..8e9efac0 100644 --- a/appTool.py +++ b/appTool.py @@ -295,6 +295,10 @@ class AppTool(QtWidgets.QWidget): s_storage.clear() s_storage.redraw() + def on_mouse_plugin_click_release(self): + # this should be implemented in the descendents, the Plugin classes + pass + def confirmation_message(self, accepted, minval, maxval): if accepted is False: self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%.*f, %.*f]' % (_("Edited value is out of range"),