Explorar el Código

- added a Copy All button in the Code Editor, clicking this button will copy all text in the editor to the clipboard
- added a 'Milling Type' radio button in Geometry Editor Preferences to contorl the type of geometry will be generated in the Geo Editor (for conventional milling or for the climb milling)
- added the functionality to allow climb/conventional milling selection for the geometry created in the Geometry Editor
- now any Geometry that is edited in Geometry editor will have coordinates ordered such that the resulting Gcode will allow the selected milling type in the 'Milling Type' radio button in Geometry Editor Preferences (which depends also of the spindle direction)
- some strings update
- French Google-translation at 100%
- German Google-translation update to 100%

Marius Stanciu hace 6 años
padre
commit
0f91d4dff0

+ 8 - 0
FlatCAMApp.py

@@ -657,6 +657,7 @@ class App(QtCore.QObject):
 
             # Geometry Editor
             "geometry_editor_sel_limit": self.ui.geometry_defaults_form.geometry_editor_group.sel_limit_entry,
+            "geometry_editor_milling_type": self.ui.geometry_defaults_form.geometry_editor_group.milling_type_radio,
 
             # CNCJob General
             "cncjob_plot": self.ui.cncjob_defaults_form.cncjob_gen_group.plot_cb,
@@ -1064,6 +1065,7 @@ class App(QtCore.QObject):
 
             # Geometry Editor
             "geometry_editor_sel_limit": 30,
+            "geometry_editor_milling_type": "cl",
 
             # CNC Job General
             "cncjob_plot": True,
@@ -1976,6 +1978,7 @@ class App(QtCore.QObject):
         self.ui.buttonPreview.clicked.connect(self.handlePreview)
         self.ui.buttonFind.clicked.connect(self.handleFindGCode)
         self.ui.buttonReplace.clicked.connect(self.handleReplaceGCode)
+        self.ui.button_copy_all.clicked.connect(self.handleCopyAll)
 
         # portability changed signal
         self.ui.general_defaults_form.general_app_group.portability_cb.stateChanged.connect(self.on_portable_checked)
@@ -6548,6 +6551,11 @@ class App(QtCore.QObject):
             # Mark end of undo block
             cursor.endEditBlock()
 
+    def handleCopyAll(self):
+        text = self.ui.code_editor.toPlainText()
+        self.clipboard.setText(text)
+        self.inform.emit(_("Code Editor content copied to clipboard ..."))
+
     def handleRunCode(self):
         # trying to run a Tcl command without having the Shell open will create some warnings because the Tcl Shell
         # tries to print on a hidden widget, therefore show the dock if hidden

+ 9 - 6
FlatCAMObj.py

@@ -5918,20 +5918,23 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
                 if "toolchange_probe" in ppg.lower():
                     probe_pp = True
                     break
-        except Exception as e:
-            log.debug("FlatCAMCNCJob.gcode_header() error: --> %s" % str(e))
+        except KeyError:
+            # log.debug("FlatCAMCNCJob.gcode_header() error: --> %s" % str(e))
+            pass
 
         try:
             if self.options['ppname_e'] == 'marlin' or self.options['ppname_e'] == 'Repetier':
                 marlin = True
-        except Exception as e:
-            log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
+        except KeyError:
+            # log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
+            pass
 
         try:
             if "toolchange_probe" in self.options['ppname_e'].lower():
                 probe_pp = True
-        except Exception as e:
-            log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
+        except KeyError:
+            # log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
+            pass
 
         if marlin is True:
             gcode = ';Marlin(Repetier) G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date:    %s\n' % \

+ 10 - 0
README.md

@@ -11,6 +11,16 @@ CAD program, and create G-Code for Isolation routing.
 
 25.09.2019
 
+- added a Copy All button in the Code Editor, clicking this button will copy all text in the editor to the clipboard
+- added a 'Milling Type' radio button in Geometry Editor Preferences to contorl the type of geometry will be generated in the Geo Editor (for conventional milling or for the climb milling)
+- added the functionality to allow climb/conventional milling selection for the geometry created in the Geometry Editor
+- now any Geometry that is edited in Geometry editor will have coordinates ordered such that the resulting Gcode will allow the selected milling type in the 'Milling Type' radio button in Geometry Editor Preferences (which depends also of the spindle direction)
+- some strings update
+- French Google-translation at 100%
+- German Google-translation update to 100%
+
+25.09.2019
+
 - French translation at 33%
 - fixed the 'Jump To' function to work in legacy graphic engine
 - in legacy graphic engine fixed the mouse cursor shape when grid snapping is ON, such that it fits with the shape from the OpenGL graphic engine

+ 96 - 12
flatcamEditors/FlatCAMGeoEditor.py

@@ -17,10 +17,11 @@ from camlib import *
 from FlatCAMTool import FlatCAMTool
 from flatcamGUI.ObjectUI import LengthEntry, RadioSet
 
-from shapely.geometry import LineString, LinearRing, MultiLineString
+from shapely.geometry import LineString, LinearRing, MultiLineString, Polygon, MultiPolygon
 # from shapely.geometry import mapping
 from shapely.ops import cascaded_union, unary_union
 import shapely.affinity as affinity
+from shapely.geometry.polygon import orient
 
 from numpy import arctan2, Inf, array, sqrt, sign, dot
 from numpy.linalg import norm as numpy_norm
@@ -3562,19 +3563,33 @@ class FlatCAMGeoEditor(QtCore.QObject):
 
         self.select_tool("select")
 
+        if self.app.defaults['geometry_spindledir'] == 'CW':
+            if self.app.defaults['geometry_editor_milling_type'] == 'cl':
+                milling_type = 1    # CCW motion = climb milling (spindle is rotating CW)
+            else:
+                milling_type = -1   # CW motion = conventional milling (spindle is rotating CW)
+        else:
+            if self.app.defaults['geometry_editor_milling_type'] == 'cl':
+                milling_type = -1    # CCW motion = climb milling (spindle is rotating CCW)
+            else:
+                milling_type = 1   # CW motion = conventional milling (spindle is rotating CCW)
+
         # Link shapes into editor.
         if multigeo_tool:
             self.multigeo_tool = multigeo_tool
-            geo_to_edit = fcgeometry.flatten(geometry=fcgeometry.tools[self.multigeo_tool]['solid_geometry'])
-            self.app.inform.emit('[WARNING_NOTCL] %s: %s %s: %s' %
-                                 (_("Editing MultiGeo Geometry, tool"),
-                                 str(self.multigeo_tool),
-                                 _("with diameter"),
-                                 str(fcgeometry.tools[self.multigeo_tool]['tooldia'])
-                                 )
-                                 )
+            geo_to_edit = self.flatten(geometry=fcgeometry.tools[self.multigeo_tool]['solid_geometry'],
+                                       orient_val=milling_type)
+            self.app.inform.emit(
+                '[WARNING_NOTCL] %s: %s %s: %s' % (
+                    _("Editing MultiGeo Geometry, tool"),
+                    str(self.multigeo_tool),
+                    _("with diameter"),
+                    str(fcgeometry.tools[self.multigeo_tool]['tooldia'])
+                )
+            )
         else:
-            geo_to_edit = fcgeometry.flatten()
+            geo_to_edit = self.flatten(geometry=fcgeometry.solid_geometry,
+                                       orient_val=milling_type)
 
         for shape in geo_to_edit:
             if shape is not None:  # TODO: Make flatten never create a None
@@ -3672,7 +3687,6 @@ class FlatCAMGeoEditor(QtCore.QObject):
                     self.app.defaults["global_point_clipboard_format"] % (self.pos[0], self.pos[1]))
                 return
 
-
             # Selection with left mouse button
             if self.active_tool is not None and event.button == 1:
 
@@ -4055,8 +4069,37 @@ class FlatCAMGeoEditor(QtCore.QObject):
     def on_shape_complete(self):
         self.app.log.debug("on_shape_complete()")
 
+        geom = self.active_tool.geometry.geo
+
+        if self.app.defaults['geometry_editor_milling_type'] == 'cl':
+            # reverse the geometry coordinates direction to allow creation of Gcode for  climb milling
+            try:
+                pl = []
+                for p in geom:
+                    if p is not None:
+                        if isinstance(p, Polygon):
+                            pl.append(Polygon(p.exterior.coords[::-1], p.interiors))
+                        elif isinstance(p, LinearRing):
+                            pl.append(Polygon(p.coords[::-1]))
+                        # elif isinstance(p, LineString):
+                        #     pl.append(LineString(p.coords[::-1]))
+                geom = MultiPolygon(pl)
+            except TypeError:
+                if isinstance(geom, Polygon) and geom is not None:
+                    geom = Polygon(geom.exterior.coords[::-1], geom.interiors)
+                elif isinstance(geom, LinearRing) and geom is not None:
+                    geom = Polygon(geom.coords[::-1])
+                elif isinstance(geom, LineString) and geom is not None:
+                    geom = LineString(geom.coords[::-1])
+                else:
+                    log.debug("FlatCAMGeoEditor.on_shape_complete() Error --> Unexpected Geometry %s" %
+                              type(geom))
+            except Exception as e:
+                log.debug("FlatCAMGeoEditor.on_shape_complete() Error --> %s" % str(e))
+                return 'fail'
+
         # Add shape
-        self.add_shape(self.active_tool.geometry)
+        self.add_shape(DrawToolShape(geom))
 
         # Remove any utility shapes
         self.delete_utility_geometry()
@@ -4641,6 +4684,47 @@ class FlatCAMGeoEditor(QtCore.QObject):
             '[success] %s' % _("Paint done."))
         self.replot()
 
+    def flatten(self, geometry, orient_val=1, reset=True, pathonly=False):
+        """
+        Creates a list of non-iterable linear geometry objects.
+        Polygons are expanded into its exterior and interiors if specified.
+
+        Results are placed in self.flat_geometry
+
+        :param geometry: Shapely type or list or list of list of such.
+        :param orient_val: will orient the exterior coordinates CW if 1 and CCW for else (whatever else means ...)
+        https://shapely.readthedocs.io/en/stable/manual.html#polygons
+        :param reset: Clears the contents of self.flat_geometry.
+        :param pathonly: Expands polygons into linear elements.
+        """
+
+        if reset:
+            self.flat_geo = []
+
+        # ## If iterable, expand recursively.
+        try:
+            for geo in geometry:
+                if geo is not None:
+                    self.flatten(geometry=geo,
+                                 orient_val=orient_val,
+                                 reset=False,
+                                 pathonly=pathonly)
+
+        # ## Not iterable, do the actual indexing and add.
+        except TypeError:
+            if type(geometry) == Polygon:
+                geometry = orient(geometry, orient_val)
+
+            if pathonly and type(geometry) == Polygon:
+                self.flat_geo.append(geometry.exterior)
+                self.flatten(geometry=geometry.interiors,
+                             reset=False,
+                             pathonly=True)
+            else:
+                self.flat_geo.append(geometry)
+
+        return self.flat_geo
+
 
 def distance(pt1, pt2):
     return sqrt((pt1[0] - pt2[0]) ** 2 + (pt1[1] - pt2[1]) ** 2)

+ 7 - 0
flatcamGUI/FlatCAMGUI.py

@@ -1844,6 +1844,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.buttonReplace.setToolTip(_("Will replace the string from the Find box with the one in the Replace box."))
 
         self.buttonReplace.setMinimumWidth(100)
+
         self.entryReplace = FCEntry()
         self.entryReplace.setToolTip(_("String to replace the one in the Find box throughout the text."))
 
@@ -1851,6 +1852,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.sel_all_cb.setToolTip(_("When checked it will replace all instances in the 'Find' box\n"
                                      "with the text in the 'Replace' box.."))
 
+        self.button_copy_all = QtWidgets.QPushButton(_('Copy All'))
+        self.button_copy_all.setToolTip(_("Will copy all the text in the Code Editor to the clipboard."))
+
+        self.button_copy_all.setMinimumWidth(100)
+
         self.buttonOpen = QtWidgets.QPushButton(_('Open Code'))
         self.buttonOpen.setToolTip(_("Will open a text file in the editor."))
 
@@ -1870,6 +1876,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         cnc_tab_lay_1.addWidget(self.buttonReplace)
         cnc_tab_lay_1.addWidget(self.entryReplace)
         cnc_tab_lay_1.addWidget(self.sel_all_cb)
+        cnc_tab_lay_1.addWidget(self.button_copy_all)
         self.cncjob_tab_layout.addLayout(cnc_tab_lay_1, 1, 0, 1, 5)
 
         cnc_tab_lay_3 = QtWidgets.QHBoxLayout()

+ 10 - 6
flatcamGUI/PlotCanvasLegacy.py

@@ -982,14 +982,18 @@ class ShapeCollectionLegacy:
                             log.debug("ShapeCollectionLegacy.redraw() --> %s" % str(e))
                     else:
                         if isinstance(local_shapes[element]['shape'], Polygon):
-                            x, y = local_shapes[element]['shape'].exterior.xy
-                            self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
-                            for ints in local_shapes[element]['shape'].interiors:
-                                x, y = ints.coords.xy
+                            ext_shape = local_shapes[element]['shape'].exterior
+                            if ext_shape is not None:
+                                x, y = ext_shape.xy
                                 self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
+                            for ints in local_shapes[element]['shape'].interiors:
+                                if ints is not None:
+                                    x, y = ints.coords.xy
+                                    self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
                         else:
-                            x, y = local_shapes[element]['shape'].coords.xy
-                            self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
+                            if local_shapes[element]['shape'] is not None:
+                                x, y = local_shapes[element]['shape'].coords.xy
+                                self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
 
         self.app.plotcanvas.auto_adjust_axes()
 

+ 12 - 0
flatcamGUI/PreferencesUI.py

@@ -2954,6 +2954,18 @@ class GeometryEditorPrefGroupUI(OptionsGroupUI):
         grid0.addWidget(self.sel_limit_label, 0, 0)
         grid0.addWidget(self.sel_limit_entry, 0, 1)
 
+        # Milling Type
+        milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
+        milling_type_label.setToolTip(
+            _("Milling type:\n"
+              "- climb / best for precision milling and to reduce tool usage\n"
+              "- conventional / useful when there is no backlash compensation")
+        )
+        self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
+                                            {'label': _('Conv.'), 'value': 'cv'}])
+        grid0.addWidget(milling_type_label, 1, 0)
+        grid0.addWidget(self.milling_type_radio, 1, 1)
+
         self.layout.addStretch()
 
 

+ 3 - 3
flatcamTools/ToolMove.py

@@ -177,7 +177,7 @@ class ToolMove(FlatCAMTool):
                                 self.replot_signal.emit(obj_list)
                             except Exception as e:
                                 proc.done()
-                                self.app.inform.emit('[ERROR_NOTCL] %s --> %s' % (_('ToolMove.on_left_click()'), str(e)))
+                                self.app.inform.emit('[ERROR_NOTCL] %s --> %s' % ('ToolMove.on_left_click()', str(e)))
                                 return "fail"
 
                         proc.done()
@@ -194,8 +194,8 @@ class ToolMove(FlatCAMTool):
 
                 except TypeError as e:
                     log.debug("ToolMove.on_left_click() --> %s" % str(e))
-                    self.app.inform.emit('[ERROR_NOTCL] %s' %
-                                         _('ToolMove.on_left_click() --> Error when mouse left click.'))
+                    self.app.inform.emit('[ERROR_NOTCL] ToolMove.on_left_click() --> %s' %
+                                         _('Error when mouse left click.'))
                     return
 
             self.clicked_move = 1

+ 1 - 1
flatcamTools/ToolNonCopperClear.py

@@ -1065,7 +1065,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
         # init values for the next usage
         self.reset_usage()
 
-        self.app.report_usage(_("on_paint_button_click"))
+        self.app.report_usage("on_paint_button_click")
 
         try:
             self.overlap = float(self.ncc_overlap_entry.get_value())

+ 2 - 2
flatcamTools/ToolPaint.py

@@ -917,7 +917,7 @@ class ToolPaint(FlatCAMTool, Gerber):
         # init values for the next usage
         self.reset_usage()
 
-        self.app.report_usage(_("on_paint_button_click"))
+        self.app.report_usage("on_paint_button_click")
         # self.app.call_source = 'paint'
 
         # #####################################################
@@ -1490,7 +1490,7 @@ class ToolPaint(FlatCAMTool, Gerber):
             except Exception as e:
                 proc.done()
                 self.app.inform.emit('[ERROR_NOTCL] %s --> %s' %
-                                     (_('PaintTool.paint_poly()'),
+                                     ('PaintTool.paint_poly()',
                                       str(e)))
                 return
             proc.done()

+ 1 - 1
flatcamTools/ToolSolderPaste.py

@@ -1355,7 +1355,7 @@ class SolderPaste(FlatCAMTool):
         except Exception as e:
             log.debug('ToolSolderPaste.on_view_gcode() -->%s' % str(e))
             self.app.inform.emit('[ERROR] %s --> %s' %
-                                 (_('ToolSolderPaste.on_view_gcode()'), str(e)))
+                                 ('ToolSolderPaste.on_view_gcode()', str(e)))
             return
 
         self.app.ui.code_editor.moveCursor(QtGui.QTextCursor.Start)

BIN
locale/de/LC_MESSAGES/strings.mo


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 305 - 315
locale/de/LC_MESSAGES/strings.po


BIN
locale/fr/LC_MESSAGES/strings.mo


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 225 - 225
locale/fr/LC_MESSAGES/strings.po


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio