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

This commit is contained in:
Marius Stanciu 2019-02-14 01:21:24 +02:00 committed by Marius S
parent e091fd232d
commit 3a05ebaffb
4 changed files with 42 additions and 2 deletions

View File

@ -1076,6 +1076,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
self.tot_slot_cnt = 0 self.tot_slot_cnt = 0
self.tool_row_slots = 0 self.tool_row_slots = 0
# variable to store the distance travelled
self.travel_distance = 0.0
self.multigeo = False self.multigeo = False
@staticmethod @staticmethod
@ -4523,6 +4526,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
''' '''
self.exc_cnc_tools = {} self.exc_cnc_tools = {}
# for now it show if the plot will be done for multi-tool CNCJob (True) or for single tool # 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 # (like the one in the TCL Command), False
self.multitool = False self.multitool = False
@ -4682,6 +4686,18 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
# Fill form fields only on object create # Fill form fields only on object create
self.to_form() 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 # 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"]) self.ui.cncplot_method_combo.set_value(self.app.defaults["cncjob_plot_kind"])

View File

@ -1199,7 +1199,7 @@ class CNCObjectUI(ObjectUI):
self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>") self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
self.custom_box.addWidget(self.plot_options_label) 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( self.cncplot_method_label.setToolTip(
"This selects the kind of geometries on the canvas to plot.\n" "This selects the kind of geometries on the canvas to plot.\n"
"Those can be either of type 'Travel' which means the moves\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(name_label)
self.name_hlay.addWidget(self.name_entry) 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 = QtWidgets.QGridLayout()
f_lay.setColumnStretch(1, 1) f_lay.setColumnStretch(1, 1)
f_lay.setColumnStretch(2, 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_label, 0, 0)
f_lay.addWidget(self.cncplot_method_combo, 0, 1) f_lay.addWidget(self.cncplot_method_combo, 0, 1)
f_lay.addWidget(QtWidgets.QLabel(''), 0, 2) 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('') e1_lbl = QtWidgets.QLabel('')
self.custom_box.addWidget(e1_lbl) self.custom_box.addWidget(e1_lbl)

View File

@ -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 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. - 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.

View File

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