diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 3139bd92..5fd31fc9 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -3547,15 +3547,7 @@ class App(QtCore.QObject): ymaxlist = [] if not obj_list: - self.inform.emit("[warning_notcl] No object selected.") - msg = "Please Select an object to flip!" - warningbox = QtWidgets.QMessageBox() - warningbox.setText(msg) - warningbox.setWindowTitle("Warning ...") - warningbox.setWindowIcon(QtGui.QIcon('share/warning.png')) - warningbox.setStandardButtons(QtWidgets.QMessageBox.Ok) - warningbox.setDefaultButton(QtWidgets.QMessageBox.Ok) - warningbox.exec_() + self.inform.emit("[warning_notcl] No object selected to Flip on Y axis.") else: try: # first get a bounding box to fit all @@ -3592,15 +3584,7 @@ class App(QtCore.QObject): ymaxlist = [] if not obj_list: - self.inform.emit("[warning_notcl] No object selected.") - msg = "Please Select an object to flip!" - warningbox = QtWidgets.QMessageBox() - warningbox.setText(msg) - warningbox.setWindowTitle("Warning ...") - warningbox.setWindowIcon(QtGui.QIcon('share/warning.png')) - warningbox.setStandardButtons(QtWidgets.QMessageBox.Ok) - warningbox.setDefaultButton(QtWidgets.QMessageBox.Ok) - warningbox.exec_() + self.inform.emit("[warning_notcl] No object selected to Flip on X axis.") else: try: # first get a bounding box to fit all @@ -3637,15 +3621,7 @@ class App(QtCore.QObject): ymaxlist = [] if not obj_list: - self.inform.emit("[warning_notcl] No object selected.") - msg = "Please Select an object to rotate!" - warningbox = QtWidgets.QMessageBox() - warningbox.setText(msg) - warningbox.setWindowTitle("Warning ...") - warningbox.setWindowIcon(QtGui.QIcon('share/warning.png')) - warningbox.setStandardButtons(QtWidgets.QMessageBox.Ok) - warningbox.setDefaultButton(QtWidgets.QMessageBox.Ok) - warningbox.exec_() + self.inform.emit("[warning_notcl] No object selected to Rotate.") else: if silent is False: rotatebox = FCInputDialog(title="Transform", text="Enter the Angle value:", @@ -3687,15 +3663,7 @@ class App(QtCore.QObject): yminlist = [] if not obj_list: - self.inform.emit("[warning_notcl] No object selected.") - msg = "Please Select an object to skew/shear!" - warningbox = QtWidgets.QMessageBox() - warningbox.setText(msg) - warningbox.setWindowTitle("Warning ...") - warningbox.setWindowIcon(QtGui.QIcon('share/warning.png')) - warningbox.setStandardButtons(QtWidgets.QMessageBox.Ok) - warningbox.setDefaultButton(QtWidgets.QMessageBox.Ok) - warningbox.exec_() + self.inform.emit("[warning_notcl] No object selected to Skew/Shear on X axis.") else: skewxbox = FCInputDialog(title="Transform", text="Enter the Angle value:", min=-360, max=360, decimals=3) @@ -3722,15 +3690,7 @@ class App(QtCore.QObject): yminlist = [] if not obj_list: - self.inform.emit("[warning_notcl] No object selected.") - msg = "Please Select an object to skew/shear!" - warningbox = QtWidgets.QMessageBox() - warningbox.setText(msg) - warningbox.setWindowTitle("Warning ...") - warningbox.setWindowIcon(QtGui.QIcon('share/warning.png')) - warningbox.setStandardButtons(QtWidgets.QMessageBox.Ok) - warningbox.setDefaultButton(QtWidgets.QMessageBox.Ok) - warningbox.exec_() + self.inform.emit("[warning_notcl] No object selected to Skew/Shear on Y axis.") else: skewybox = FCInputDialog(title="Transform", text="Enter the Angle value:", min=-360, max=360, decimals=3) @@ -4028,7 +3988,6 @@ class App(QtCore.QObject): return def on_shortcut_list(self): - # add the tab if it was closed self.ui.plot_tab_area.addTab(self.ui.shortcuts_tab, "Key Shortcut List") @@ -4040,77 +3999,6 @@ class App(QtCore.QObject): self.ui.plot_tab_area.setCurrentWidget(self.ui.shortcuts_tab) self.ui.show() - msg = '''Shortcut list
-
-~: Show Shortcut List
-
-1: Zoom Fit
-2: Zoom Out
-3: Zoom In
-A: Draw an Arc (when in Edit Mode)
-C: Copy Geo Item (when in Edit Mode)
-E: Edit Object (if selected)
-G: Grid On/Off
-J: Jump to Coordinates
-L: New Excellon
-M: Move Obj
-M: Move Geo Item (when in Edit Mode)
-N: New Geometry
-N: Draw a Polygon (when in Edit Mode)
-O: Set Origin
-O: Draw a Circle (when in Edit Mode)
-Q: Change Units
-P: Open Properties Tool
-P: Draw a Path (when in Edit Mode)
-R: Rotate by 90 degree CW
-R: Draw Rectangle (when in Edit Mode)
-S: Shell Toggle
-V: View Fit
-X: Flip on X_axis
-Y: Flip on Y_axis
-
-Space: En(Dis)able Obj Plot
-CTRL+A: Select All
-CTRL+C: Copy Obj
-CTRL+E: Open Excellon File
-CTRL+G: Open Gerber File
-CTRL+N: New Project
-CTRL+M: Measurement Tool
-CTRL+O: Open Project
-CTRL+S: Save Project As
-CTRL+S: Save Object and Exit Editor (when in Edit Mode)
-
-SHIFT+C: Copy Obj_Name
-SHIFT+G: Toggle the axis
-SHIFT+P: Open Preferences Window
-SHIFT+R: Rotate by 90 degree CCW
-SHIFT+S: Run a Script
-SHIFT+W: Toggle the workspace
-SHIFT+X: Skew on X axis
-SHIFT+Y: Skew on Y axis
-
-ALT+C: Calculators Tool
-ALT+D: 2-Sided PCB Tool
-ALT+L: Film PCB Tool
-ALT+N: Non-Copper Clearing Tool
-ALT+P: Paint Area Tool
-ALT+R: Transformation Tool
-ALT+U: Cutout PCB Tool
-ALT+F10: Toggle Full Screen
-
-F1: Open Online Manual
-F2: Open Online Tutorials
-Del: Delete Obj -''' - - helpbox = QtWidgets.QMessageBox() - helpbox.setText(msg) - helpbox.setWindowTitle("Help") - helpbox.setWindowIcon(QtGui.QIcon('share/help.png')) - helpbox.setStandardButtons(QtWidgets.QMessageBox.Ok) - helpbox.setDefaultButton(QtWidgets.QMessageBox.Ok) - helpbox.exec_() - def on_copy_name(self): obj = self.collection.get_active() try: diff --git a/FlatCAMGUI.py b/FlatCAMGUI.py index 0057922a..12fdbacb 100644 --- a/FlatCAMGUI.py +++ b/FlatCAMGUI.py @@ -624,8 +624,102 @@ class FlatCAMGUI(QtWidgets.QMainWindow): ### HERE WE BUILD THE SHORTCUTS LIST. TAB AREA ### ######################################## self.shortcuts_tab = QtWidgets.QWidget() - self.sh_tab_layout = QtWidgets.QVBoxLayout(self.shortcuts_tab) + self.sh_tab_layout = QtWidgets.QVBoxLayout() self.sh_tab_layout.setContentsMargins(2, 2, 2, 2) + self.shortcuts_tab.setLayout(self.sh_tab_layout) + + self.sh_hlay = QtWidgets.QHBoxLayout() + self.sh_title = QtWidgets.QTextEdit( + 'Shortcut Key List') + self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) + self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame) + self.sh_title.setMaximumHeight(30) + font = self.sh_title.font() + font.setPointSize(12) + self.sh_title.setFont(font) + + self.sh_tab_layout.addWidget(self.sh_title) + self.sh_tab_layout.addLayout(self.sh_hlay) + + self.app_sh_msg = '''Shortcut list
+
+~: Show Shortcut List
+
+1: Zoom Fit
+2: Zoom Out
+3: Zoom In
+E: Edit Object (if selected)
+G: Grid On/Off
+J: Jump to Coordinates
+L: New Excellon
+M: Move Obj
+N: New Geometry
+O: Set Origin
+Q: Change Units
+P: Open Properties Tool
+R: Rotate by 90 degree CW
+S: Shell Toggle
+V: View Fit
+X: Flip on X_axis
+Y: Flip on Y_axis
+
+Space: En(Dis)able Obj Plot
+CTRL+A: Select All
+CTRL+C: Copy Obj
+CTRL+E: Open Excellon File
+CTRL+G: Open Gerber File
+CTRL+N: New Project
+CTRL+M: Measurement Tool
+CTRL+O: Open Project
+CTRL+S: Save Project As
+
+SHIFT+C: Copy Obj_Name
+SHIFT+G: Toggle the axis
+SHIFT+P: Open Preferences Window
+SHIFT+R: Rotate by 90 degree CCW
+SHIFT+S: Run a Script
+SHIFT+W: Toggle the workspace
+SHIFT+X: Skew on X axis
+SHIFT+Y: Skew on Y axis
+
+ALT+C: Calculators Tool
+ALT+D: 2-Sided PCB Tool
+ALT+L: Film PCB Tool
+ALT+N: Non-Copper Clearing Tool
+ALT+P: Paint Area Tool
+ALT+R: Transformation Tool
+ALT+U: Cutout PCB Tool
+ALT+F10: Toggle Full Screen
+
+F1: Open Online Manual
+F2: Open Online Tutorials
+Del: Delete Obj +''' + self.sh_app = QtWidgets.QTextEdit() + self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) + + self.sh_app.setText(self.app_sh_msg) + self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + self.sh_hlay.addWidget(self.sh_app) + + self.editor_sh_msg = '''A: Draw an Arc (when in Edit Mode)
+C: Copy Geo Item (when in Edit Mode)
+M: Move Geo Item (when in Edit Mode)
+N: Draw a Polygon (when in Edit Mode)
+O: Draw a Circle (when in Edit Mode)
+P: Draw a Path (when in Edit Mode)
+R: Draw Rectangle (when in Edit Mode)
+
+CTRL+S: Save Object and Exit Editor (when in Edit Mode)
+
+Space: Rotate Geometry
+ENTER: Finish drawing for certain tools
+ ''' + self.sh_editor = QtWidgets.QTextEdit() + self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) + self.sh_editor.setText(self.editor_sh_msg) + self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + self.sh_hlay.addWidget(self.sh_editor) ############################################################## diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 9799487f..f1fe3a18 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -3855,7 +3855,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): gcodet_re_string = r'(?=.*(\=\s*[-\+]?\d*\.\d*))' self.g_t_re = re.compile(gcodet_re_string) - gcodenr_re_string = r'([+-]?\d*\.\d*)' + gcodenr_re_string = r'([+-]?\d*\.\d+)' self.g_nr_re = re.compile(gcodenr_re_string) # Attributes to be included in serialization diff --git a/GUIElements.py b/GUIElements.py index 88decd41..837c0a05 100644 --- a/GUIElements.py +++ b/GUIElements.py @@ -929,7 +929,12 @@ class FCDetachableTab(QtWidgets.QTabWidget): drag.setMimeData(mimeData) # screen = QScreen(self.parentWidget().currentWidget().winId()) # Create the appearance of dragging the tab content - pixmap = self.parent().widget(self.tabAt(self.dragStartPos)).grab() + try: + pixmap = self.parent().widget(self.tabAt(self.dragStartPos)).grab() + except Exception as e: + log.debug("GUIElements.FCDetachable. FCTabBar.mouseMoveEvent() --> %s" % str(e)) + return + targetPixmap = QtGui.QPixmap(pixmap.size()) targetPixmap.fill(QtCore.Qt.transparent) painter = QtGui.QPainter(targetPixmap) diff --git a/README.md b/README.md index 4619c7b5..e2ccb395 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ CAD program, and create G-Code for Isolation routing. - remade the way FlatCAM saves the GUI position data from a file (previously) to use PyQt QSettings - added a 'theme' combo selection in Edit -> Preferences. Two themes are available: standard and compact. - some code cleanup +- fixed a source of possible errors in DetachableTab Widget. +- fixed gcode conversion/scale (on units change) when multiple values are found on each line +- replaced the pop-up window for the shortcut list with a new detachable tab +- removed the pop-up messages from the rotate, skew, flip commands 30.01.2019 diff --git a/camlib.py b/camlib.py index dee4591e..3b2981a5 100644 --- a/camlib.py +++ b/camlib.py @@ -5957,14 +5957,14 @@ class CNCjob(Geometry): if units == 'IN': line = line.replace("mm", "in") - # find any number in header and convert it - match_nr = self.g_nr_re.search(line) - if match_nr: - new_nr = float(match_nr.group()) * xfactor - # replace the updated string - line = line.replace(match_nr.group(), - ('%.*f' % (self.app.defaults["cncjob_coords_decimals"], new_nr)) - ) + # find any float number in header (even multiple on the same line) and convert it + numbers_in_header = re.findall(self.g_nr_re, line) + if numbers_in_header: + for nr in numbers_in_header: + new_nr = float(nr) * xfactor + # replace the updated string + line = line.replace(nr, ('%.*f' % (self.app.defaults["cncjob_coords_decimals"], new_nr)) + ) # this scales all the X and Y and Z and F values and also the Tool Dia in the toolchange message if header_stop is True: