Преглед изворни кода

- added progress display in status bar for generating CNCJob from Geometry objects

Marius Stanciu пре 6 година
родитељ
комит
053ceb3c24
3 измењених фајлова са 74 додато и 16 уклоњено
  1. 11 1
      FlatCAMObj.py
  2. 1 0
      README.md
  3. 62 15
      camlib.py

+ 11 - 1
FlatCAMObj.py

@@ -4529,6 +4529,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 })
 
                 spindledir = self.app.defaults['geometry_spindledir']
+                tool_solid_geometry = self.solid_geometry
 
                 job_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"]
                 job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"]
@@ -4570,10 +4571,19 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 # object is the source of gcode
                 job_obj.toolchange_xy_type = "geometry"
 
+                self.app.inform.emit('[success] %s' % _("G-Code parsing in progress..."))
                 dia_cnc_dict['gcode_parsed'] = job_obj.gcode_parse()
+                self.app.inform.emit('[success] %s' % _("G-Code parsing finished..."))
 
                 # TODO this serve for bounding box creation only; should be optimized
-                dia_cnc_dict['solid_geometry'] = cascaded_union([geo['geom'] for geo in dia_cnc_dict['gcode_parsed']])
+                # commented this; there is no need for the actual GCode geometry - the original one will serve as well
+                # for bounding box values
+                # dia_cnc_dict['solid_geometry'] = cascaded_union([geo['geom'] for geo in dia_cnc_dict['gcode_parsed']])
+                try:
+                    dia_cnc_dict['solid_geometry'] = tool_solid_geometry
+                    self.app.inform.emit('[success] %s' % _("Finished G-Code processing..."))
+                except Exception as e:
+                    self.app.inform.emit('[ERROR] %s' % _("G-Code processing failed with error: %s") % str(e))
 
                 app_obj.progress.emit(80)
 

+ 1 - 0
README.md

@@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
 - added percentage display for work done in Paint Tool
 - some fixes and prepared the activity monitor area to receive updated texts
 - added progress display in status bar for generating CNCJob from Excellon objects
+- added progress display in status bar for generating CNCJob from Geometry objects
 
 5.09.2019
 

+ 62 - 15
camlib.py

@@ -5480,12 +5480,13 @@ class CNCjob(Geometry):
                                     loc_nr += 1
                                     disp_number = int(np.interp(loc_nr, [0, geo_len], [0, 99]))
 
-                                    if disp_number > old_disp_number and disp_number <= 100:
+                                    if old_disp_number < disp_number <= 100:
                                         self.app.inform.emit(
-                                            '%s: %s. %s: %d%%' % (_("Starting G-Code for tool with diameter"),
-                                                                  str(current_tooldia),
-                                                                  _("Progress"),
-                                                                  disp_number)
+                                            '%s: %s%s. %s: %d%%' % (_("Starting G-Code for tool with diameter"),
+                                                                    str(current_tooldia),
+                                                                    str(self.units),
+                                                                    _("Progress"),
+                                                                    disp_number)
                                         )
                                         old_disp_number = disp_number
 
@@ -5611,12 +5612,13 @@ class CNCjob(Geometry):
                                     loc_nr += 1
                                     disp_number = int(np.interp(loc_nr, [0, geo_len], [0, 99]))
 
-                                    if disp_number > old_disp_number and disp_number <= 100:
+                                    if old_disp_number < disp_number <= 100:
                                         self.app.inform.emit(
-                                            '%s: %s. %s: %d%%' % (_("Starting G-Code for tool with diameter"),
-                                                                  str(current_tooldia),
-                                                                  _("Progress"),
-                                                                  disp_number)
+                                            '%s: %s%s. %s: %d%%' % (_("Starting G-Code for tool with diameter"),
+                                                                    str(current_tooldia),
+                                                                    str(self.units),
+                                                                    _("Progress"),
+                                                                    disp_number)
                                         )
                                         old_disp_number = disp_number
 
@@ -5703,12 +5705,13 @@ class CNCjob(Geometry):
                                 loc_nr += 1
                                 disp_number = int(np.interp(loc_nr, [0, geo_len], [0, 99]))
 
-                                if disp_number > old_disp_number and disp_number <= 100:
+                                if old_disp_number < disp_number <= 100:
                                     self.app.inform.emit(
-                                        '%s: %s. %s: %d%%' % (_("Starting G-Code for tool with diameter"),
-                                                              str(current_tooldia),
-                                                              _("Progress"),
-                                                              disp_number)
+                                        '%s: %s%s. %s: %d%%' % (_("Starting G-Code for tool with diameter"),
+                                                                str(current_tooldia),
+                                                                str(self.units),
+                                                                _("Progress"),
+                                                                disp_number)
                                     )
                                     old_disp_number = disp_number
                         else:
@@ -5930,6 +5933,17 @@ class CNCjob(Geometry):
         path_count = 0
         current_pt = (0, 0)
 
+        # variables to display the percentage of work done
+        geo_len = len(flat_geometry)
+        disp_number = 0
+        old_disp_number = 0
+        log.warning("Number of paths for which to generate GCode: %s" % str(geo_len))
+
+        if self.units == 'MM':
+            current_tooldia = float('%.2f' % float(self.tooldia))
+        else:
+            current_tooldia = float('%.4f' % float(self.tooldia))
+
         pt, geo = storage.nearest(current_pt)
 
         try:
@@ -5971,6 +5985,17 @@ class CNCjob(Geometry):
                 current_pt = geo.coords[-1]
 
                 pt, geo = storage.nearest(current_pt) # Next
+
+                disp_number = int(np.interp(path_count, [0, geo_len], [0, 99]))
+                if old_disp_number < disp_number <= 100:
+                    self.app.inform.emit(
+                        '%s: %s%s. %s: %d%%' % (_("Starting G-Code for tool with diameter"),
+                                                str(current_tooldia),
+                                                str(self.units),
+                                                _("Progress"),
+                                                disp_number)
+                    )
+                    old_disp_number = disp_number
         except StopIteration:  # Nothing found in storage.
             pass
 
@@ -6227,6 +6252,17 @@ class CNCjob(Geometry):
         log.debug("Starting G-Code...")
         self.app.inform.emit(_("Starting G-Code..."))
 
+        # variables to display the percentage of work done
+        geo_len = len(flat_geometry)
+        disp_number = 0
+        old_disp_number = 0
+        log.warning("Number of paths for which to generate GCode: %s" % str(geo_len))
+
+        if self.units == 'MM':
+            current_tooldia = float('%.2f' % float(self.tooldia))
+        else:
+            current_tooldia = float('%.4f' % float(self.tooldia))
+
         path_count = 0
         current_pt = (0, 0)
         pt, geo = storage.nearest(current_pt)
@@ -6268,6 +6304,17 @@ class CNCjob(Geometry):
                 current_pt = geo.coords[-1]
 
                 pt, geo = storage.nearest(current_pt) # Next
+
+                disp_number = int(np.interp(path_count, [0, geo_len], [0, 99]))
+                if old_disp_number < disp_number <= 100:
+                    self.app.inform.emit(
+                        '%s: %s%s. %s: %d%%' % (_("Starting G-Code for tool with diameter"),
+                                                str(current_tooldia),
+                                                str(self.units),
+                                                _("Progress"),
+                                                disp_number)
+                    )
+                    old_disp_number = disp_number
         except StopIteration:  # Nothing found in storage.
             pass