Просмотр исходного кода

- added total travel distance for CNCJob object created from Excellon Object in the CNCJob Selected tab

Marius Stanciu 7 лет назад
Родитель
Сommit
3a05ebaffb
4 измененных файлов с 42 добавлено и 2 удалено
  1. 16 0
      FlatCAMObj.py
  2. 19 1
      ObjectUI.py
  3. 4 0
      README.md
  4. 3 1
      camlib.py

+ 16 - 0
FlatCAMObj.py

@@ -1076,6 +1076,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
         self.tot_slot_cnt = 0
         self.tool_row_slots = 0
 
+        # variable to store the distance travelled
+        self.travel_distance = 0.0
+
         self.multigeo = False
 
     @staticmethod
@@ -4523,6 +4526,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
        '''
         self.exc_cnc_tools = {}
 
+
         # for now it show if the plot will be done for multi-tool CNCJob (True) or for single tool
         # (like the one in the TCL Command), False
         self.multitool = False
@@ -4682,6 +4686,18 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         # Fill form fields only on object create
         self.to_form()
 
+        # this means that the object that created this CNCJob was an Excellon
+        try:
+            if self.travel_distance:
+                self.ui.t_distance_label.show()
+                self.ui.t_distance_entry.setVisible(True)
+                self.ui.t_distance_entry.setDisabled(True)
+                self.ui.t_distance_entry.set_value('%.4f' % float(self.travel_distance))
+                self.ui.units_label.setText(str(self.units).lower())
+                self.ui.units_label.setDisabled(True)
+        except AttributeError:
+            pass
+
         # set the kind of geometries are plotted by default with plot2() from camlib.CNCJob
         self.ui.cncplot_method_combo.set_value(self.app.defaults["cncjob_plot_kind"])
 

+ 19 - 1
ObjectUI.py

@@ -1199,7 +1199,7 @@ class CNCObjectUI(ObjectUI):
         self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
         self.custom_box.addWidget(self.plot_options_label)
 
-        self.cncplot_method_label = QtWidgets.QLabel("Plot kind:")
+        self.cncplot_method_label = QtWidgets.QLabel("<b>Plot kind:</b>")
         self.cncplot_method_label.setToolTip(
             "This selects the kind of geometries on the canvas to plot.\n"
             "Those can be either of type 'Travel' which means the moves\n"
@@ -1222,6 +1222,18 @@ class CNCObjectUI(ObjectUI):
         self.name_hlay.addWidget(name_label)
         self.name_hlay.addWidget(self.name_entry)
 
+        self.t_distance_label = QtWidgets.QLabel("<b>Travelled dist.:</b>")
+        self.t_distance_label.setToolTip(
+            "This is the total travelled distance on X-Y plane.\n"
+            "In current units."
+        )
+        self.t_distance_entry = FCEntry()
+        self.t_distance_entry.setToolTip(
+            "This is the total travelled distance on X-Y plane.\n"
+            "In current units."
+        )
+        self.units_label = QtWidgets.QLabel()
+
         f_lay = QtWidgets.QGridLayout()
         f_lay.setColumnStretch(1, 1)
         f_lay.setColumnStretch(2, 1)
@@ -1230,6 +1242,12 @@ class CNCObjectUI(ObjectUI):
         f_lay.addWidget(self.cncplot_method_label, 0, 0)
         f_lay.addWidget(self.cncplot_method_combo, 0, 1)
         f_lay.addWidget(QtWidgets.QLabel(''), 0, 2)
+        f_lay.addWidget(self.t_distance_label, 1, 0)
+        f_lay.addWidget(self.t_distance_entry, 1, 1)
+        f_lay.addWidget(self.units_label, 1, 2)
+
+        self.t_distance_label.hide()
+        self.t_distance_entry.setVisible(False)
 
         e1_lbl = QtWidgets.QLabel('')
         self.custom_box.addWidget(e1_lbl)

+ 4 - 0
README.md

@@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
 
 =================================================
 
+14.02.2019
+
+- added total travel distance for CNCJob object created from Excellon Object in the CNCJob Selected tab
+
 13.02.2019
 
 - added new parameter for Excellon Object in Preferences: Fast Retract. If the checkbox is checked then after reaching the drill depth, the drill bit will be raised out of the hole asap.

+ 3 - 1
camlib.py

@@ -4946,6 +4946,8 @@ class CNCjob(Geometry):
         measured_distance += abs(distance_euclidian(self.oldx, self.oldy, 0, 0))
         log.debug("The total travel distance including travel to end position is: %s" %
                   str(measured_distance) + '\n')
+        self.travel_distance = measured_distance
+
         self.gcode = gcode
         return 'OK'
 
@@ -5558,7 +5560,7 @@ class CNCjob(Geometry):
                 return "fail"
 
             gobj = self.codes_split(line)
-            print(gobj)
+
             ## Units
             if 'G' in gobj and (gobj['G'] == 20.0 or gobj['G'] == 21.0):
                 self.units = {20.0: "IN", 21.0: "MM"}[gobj['G']]