- in CNCJob UI Autolevelling: prepared the app for bilinear interpolation

- in CNCJob UI Autolevelling: fixes in the UI
This commit is contained in:
Marius Stanciu
2020-09-03 12:48:50 +03:00
committed by Marius
parent 743885cf0f
commit af3d855285
2 changed files with 181 additions and 106 deletions

View File

@@ -12,7 +12,8 @@ CHANGELOG for FlatCAM beta
- in CNCJob UI Autolevelling: changed the UI a bit - in CNCJob UI Autolevelling: changed the UI a bit
- added a bilinear interpolation calculation class from: https://github.com/pmav99/interpolation - added a bilinear interpolation calculation class from: https://github.com/pmav99/interpolation
- in CNCJob UI Autolevelling: made sure that the grid can't have less than 2 rows and 2 columns when using the bilinear interpolation or 1 row and 1 column when using the Voronoi polygons - in CNCJob UI Autolevelling: made sure that the grid can't have less than 2 rows and 2 columns when using the bilinear interpolation or 1 row and 1 column when using the Voronoi polygons
- in CNCJob UI Autolevelling: prepared the app for bilinear interpolation
- in CNCJob UI Autolevelling: fixes in the UI
2.09.2020 2.09.2020

View File

@@ -190,12 +190,12 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.append_snippet = '' self.append_snippet = ''
self.prepend_snippet = '' self.prepend_snippet = ''
self.gc_header = self.gcode_header() self.gc_header = self.gcode_header()
self.gc_start = '' self.gc_start = ''
self.gc_end = '' self.gc_end = ''
''' '''
dictionary of dictionaries to store the informations for the autolevelling dictionary of dictionaries to store the information's for the autolevelling
format: format when using Voronoi diagram:
{ {
id: { id: {
'point': Shapely Point 'point': Shapely Point
@@ -204,16 +204,24 @@ class CNCJobObject(FlatCAMObj, CNCjob):
} }
} }
''' '''
self.al_geometry_dict = {} self.al_voronoi_geo_storage = {}
'''
list of (x, y, x) tuples to store the information's for the autolevelling
format when using bilinear interpolation:
[(x0, y0, z0), (x1, y1, z1), ...]
'''
self.al_bilinear_geo_storage = []
self.solid_geo = None self.solid_geo = None
self.grbl_ser_port = None self.grbl_ser_port = None
self.pressed_button = None self.pressed_button = None
if self.app.is_legacy is False: if self.app.is_legacy is False:
self.voronoi_shapes = ShapeCollection(parent=self.app.plotcanvas.view.scene, layers=1) self.probing_shapes = ShapeCollection(parent=self.app.plotcanvas.view.scene, layers=1)
else: else:
self.voronoi_shapes = ShapeCollectionLegacy(obj=self, app=self.app, name=name + "_voronoi_shapes") self.probing_shapes = ShapeCollectionLegacy(obj=self, app=self.app, name=name + "_voronoi_shapes")
# Attributes to be included in serialization # Attributes to be included in serialization
# Always append to it because it carries contents # Always append to it because it carries contents
@@ -428,10 +436,10 @@ class CNCJobObject(FlatCAMObj, CNCjob):
def build_al_table(self): def build_al_table(self):
tool_idx = 0 tool_idx = 0
n = len(self.al_geometry_dict) n = len(self.al_voronoi_geo_storage)
self.ui.al_probe_points_table.setRowCount(n) self.ui.al_probe_points_table.setRowCount(n)
for id_key, value in self.al_geometry_dict.items(): for id_key, value in self.al_voronoi_geo_storage.items():
tool_idx += 1 tool_idx += 1
row_no = tool_idx - 1 row_no = tool_idx - 1
@@ -573,7 +581,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.ui.al_mode_radio.activated_custom.connect(self.on_mode_radio) self.ui.al_mode_radio.activated_custom.connect(self.on_mode_radio)
self.ui.al_method_radio.activated_custom.connect(self.on_method_radio) self.ui.al_method_radio.activated_custom.connect(self.on_method_radio)
self.ui.al_controller_combo.currentIndexChanged.connect(self.on_controller_change) self.ui.al_controller_combo.currentIndexChanged.connect(self.on_controller_change)
self.ui.plot_probing_pts_cb.stateChanged.connect(self.show_voronoi_diagram) self.ui.plot_probing_pts_cb.stateChanged.connect(self.show_probing_geo)
# GRBL # GRBL
self.ui.com_search_button.clicked.connect(self.on_grbl_search_ports) self.ui.com_search_button.clicked.connect(self.on_grbl_search_ports)
self.ui.add_bd_button.clicked.connect(self.on_grbl_add_baudrate) self.ui.add_bd_button.clicked.connect(self.on_grbl_add_baudrate)
@@ -644,6 +652,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.ui.al_mode_radio.set_value(self.options['al_mode']) self.ui.al_mode_radio.set_value(self.options['al_mode'])
self.on_controller_change() self.on_controller_change()
self.on_mode_radio(val=self.options['al_mode'])
self.on_method_radio(val=self.options['al_method']) self.on_method_radio(val=self.options['al_method'])
# def on_cnc_custom_parameters(self, signal_text): # def on_cnc_custom_parameters(self, signal_text):
@@ -699,7 +708,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.ui.al_probe_points_table.setRowCount(0) self.ui.al_probe_points_table.setRowCount(0)
# reset the al dict # reset the al dict
self.al_geometry_dict.clear() self.al_voronoi_geo_storage.clear()
xmin, ymin, xmax, ymax = self.solid_geo.bounds xmin, ymin, xmax, ymax = self.solid_geo.bounds
@@ -726,39 +735,47 @@ class CNCJobObject(FlatCAMObj, CNCjob):
new_y += dy new_y += dy
pt_id = 0 pt_id = 0
pts_list = [] vor_pts_list = []
bl_pts_list = []
for point in points: for point in points:
pt_id += 1 pt_id += 1
pt = Point(point) pt = Point(point)
pts_list.append(pt) vor_pts_list.append(pt)
bl_pts_list.append((point[0], point[1], 0.0))
new_dict = { new_dict = {
'point': pt, 'point': pt,
'geo': None, 'geo': None,
'height': 0.0 'height': 0.0
} }
self.al_geometry_dict[pt_id] = deepcopy(new_dict) self.al_voronoi_geo_storage[pt_id] = deepcopy(new_dict)
self.calculate_voronoi_diagram(pts=pts_list)
# generate Probing GCode al_method = self.ui.al_method_radio.get_value()
self.probing_gcode_text = self.probing_gcode() if al_method == 'v':
self.generate_voronoi_geometry(pts=vor_pts_list)
# generate Probing GCode
self.probing_gcode_text = self.probing_gcode(storage=self.al_voronoi_geo_storage)
else:
self.generate_bilinear_geometry(pts=bl_pts_list)
# generate Probing GCode
self.probing_gcode_text = self.probing_gcode(storage=self.al_bilinear_geo_storage)
self.build_al_table_sig.emit() self.build_al_table_sig.emit()
if self.ui.plot_probing_pts_cb.get_value(): if self.ui.plot_probing_pts_cb.get_value():
self.show_voronoi_diagram(state=True, reset=True) self.show_probing_geo(state=True, reset=True)
else: else:
# clear probe shapes # clear probe shapes
self.plot_voronoi(None, False) self.plot_probing_geo(None, False)
else: else:
f_probe_pt = Point([xmin, xmin]) f_probe_pt = Point([xmin, xmin])
int_keys = [int(k) for k in self.al_geometry_dict.keys()] int_keys = [int(k) for k in self.al_voronoi_geo_storage.keys()]
new_id = max(int_keys) + 1 if int_keys else 1 new_id = max(int_keys) + 1 if int_keys else 1
new_dict = { new_dict = {
'point': f_probe_pt, 'point': f_probe_pt,
'geo': None, 'geo': None,
'height': 0.0 'height': 0.0
} }
self.al_geometry_dict[new_id] = deepcopy(new_dict) self.al_voronoi_geo_storage[new_id] = deepcopy(new_dict)
radius = 0.3 if self.units == 'MM' else 0.012 radius = 0.3 if self.units == 'MM' else 0.012
fprobe_pt_buff = f_probe_pt.buffer(radius) fprobe_pt_buff = f_probe_pt.buffer(radius)
@@ -782,40 +799,59 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.build_al_table_sig.emit() self.build_al_table_sig.emit()
if self.ui.plot_probing_pts_cb.get_value(): if self.ui.plot_probing_pts_cb.get_value():
self.show_voronoi_diagram(state=True, reset=True) self.show_probing_geo(state=True, reset=True)
else: else:
# clear probe shapes # clear probe shapes
self.plot_voronoi(None, False) self.plot_probing_geo(None, False)
self.plot_voronoi(geometry=fprobe_pt_buff, visibility=True, custom_color="#0000FFFA") self.plot_probing_geo(geometry=fprobe_pt_buff, visibility=True, custom_color="#0000FFFA")
def show_voronoi_diagram(self, state, reset=False): def show_probing_geo(self, state, reset=False):
if reset: if reset:
self.voronoi_shapes.clear(update=True) self.probing_shapes.clear(update=True)
points_geo = [] points_geo = []
poly_geo = [] poly_geo = []
# create the geometry al_method = self.ui.al_method_radio.get_value()
radius = 0.1 if self.units == 'MM' else 0.004 # voronoi diagram
for pt in self.al_geometry_dict: if al_method == 'v':
if not self.al_geometry_dict[pt]['geo']: # create the geometry
continue radius = 0.1 if self.units == 'MM' else 0.004
for pt in self.al_voronoi_geo_storage:
if not self.al_voronoi_geo_storage[pt]['geo']:
continue
p_geo = self.al_geometry_dict[pt]['point'].buffer(radius) p_geo = self.al_voronoi_geo_storage[pt]['point'].buffer(radius)
s_geo = self.al_geometry_dict[pt]['geo'].buffer(0.0000001) s_geo = self.al_voronoi_geo_storage[pt]['geo'].buffer(0.0000001)
points_geo.append(p_geo) points_geo.append(p_geo)
poly_geo.append(s_geo) poly_geo.append(s_geo)
if not points_geo and not poly_geo: if not points_geo and not poly_geo:
return return
self.plot_voronoi(geometry=points_geo, visibility=state, custom_color='#000000FF') self.plot_probing_geo(geometry=points_geo, visibility=state, custom_color='#000000FF')
self.plot_voronoi(geometry=poly_geo, visibility=state) self.plot_probing_geo(geometry=poly_geo, visibility=state)
# bilinear interpolation
elif al_method == 'b':
radius = 0.1 if self.units == 'MM' else 0.004
for pt in self.al_bilinear_geo_storage:
def plot_voronoi(self, geometry, visibility, custom_color=None): x_pt = pt[0]
y_pt = pt[1]
p_geo = Point([x_pt, y_pt]).buffer(radius)
if p_geo.is_valid:
points_geo.append(p_geo)
if not points_geo:
return
self.plot_probing_geo(geometry=points_geo, visibility=state, custom_color='#000000FF')
def plot_probing_geo(self, geometry, visibility, custom_color=None):
if visibility: if visibility:
if self.app.is_legacy is False: if self.app.is_legacy is False:
def random_color(): def random_color():
@@ -839,44 +875,44 @@ class CNCJobObject(FlatCAMObj, CNCjob):
return new_color return new_color
try: try:
if self.app.is_legacy is False: # if self.app.is_legacy is False:
color = "#0000FFFE" # color = "#0000FFFE"
else: # else:
color = "#0000FFFE" # color = "#0000FFFE"
# for sh in points_geo: # for sh in points_geo:
# self.add_voronoi_shape(shape=sh, color=color, face_color=color, visible=True) # self.add_probing_shape(shape=sh, color=color, face_color=color, visible=True)
edge_color = "#000000FF" edge_color = "#000000FF"
try: try:
for sh in geometry: for sh in geometry:
if custom_color is None: if custom_color is None:
self.add_voronoi_shape(shape=sh, color=edge_color, face_color=random_color(), visible=True) self.add_probing_shape(shape=sh, color=edge_color, face_color=random_color(), visible=True)
else: else:
self.add_voronoi_shape(shape=sh, color=custom_color, face_color=custom_color, visible=True) self.add_probing_shape(shape=sh, color=custom_color, face_color=custom_color, visible=True)
except TypeError: except TypeError:
if custom_color is None: if custom_color is None:
self.add_voronoi_shape( self.add_probing_shape(
shape=geometry, color=edge_color, face_color=random_color(), visible=True) shape=geometry, color=edge_color, face_color=random_color(), visible=True)
else: else:
self.add_voronoi_shape( self.add_probing_shape(
shape=geometry, color=custom_color, face_color=custom_color, visible=True) shape=geometry, color=custom_color, face_color=custom_color, visible=True)
self.voronoi_shapes.redraw() self.probing_shapes.redraw()
except (ObjectDeleted, AttributeError): except (ObjectDeleted, AttributeError):
self.voronoi_shapes.clear(update=True) self.probing_shapes.clear(update=True)
except Exception as e: except Exception as e:
log.debug("CNCJobObject.plot_voronoi() --> %s" % str(e)) log.debug("CNCJobObject.plot_probing_geo() --> %s" % str(e))
else: else:
self.voronoi_shapes.clear(update=True) self.probing_shapes.clear(update=True)
def add_voronoi_shape(self, **kwargs): def add_probing_shape(self, **kwargs):
if self.deleted: if self.deleted:
raise ObjectDeleted() raise ObjectDeleted()
else: else:
key = self.voronoi_shapes.add(tolerance=self.drawing_tolerance, layer=0, **kwargs) key = self.probing_shapes.add(tolerance=self.drawing_tolerance, layer=0, **kwargs)
return key return key
def calculate_voronoi_diagram(self, pts): def generate_voronoi_geometry(self, pts):
env = self.solid_geo.envelope env = self.solid_geo.envelope
fact = 1 if self.units == 'MM' else 0.039 fact = 1 if self.units == 'MM' else 0.039
env = env.buffer(fact) env = env.buffer(fact)
@@ -886,10 +922,10 @@ class CNCJobObject(FlatCAMObj, CNCjob):
pts_union = MultiPoint(pts) pts_union = MultiPoint(pts)
voronoi_union = voronoi_diagram(geom=pts_union, envelope=env) voronoi_union = voronoi_diagram(geom=pts_union, envelope=env)
except Exception as e: except Exception as e:
log.debug("CNCJobObject.calculate_voronoi_diagram() --> %s" % str(e)) log.debug("CNCJobObject.generate_voronoi_geometry() --> %s" % str(e))
for pt_index in range(len(pts)): for pt_index in range(len(pts)):
new_pts[pt_index] = affinity.translate( new_pts[pt_index] = affinity.translate(
new_pts[pt_index], random.random() * 1e-09, random.random() * 1e-09) new_pts[pt_index], random.random() * 1e-09, random.random() * 1e-09)
pts_union = MultiPoint(new_pts) pts_union = MultiPoint(new_pts)
try: try:
@@ -901,10 +937,13 @@ class CNCJobObject(FlatCAMObj, CNCjob):
for p in voronoi_union: for p in voronoi_union:
new_voronoi.append(p.intersection(env)) new_voronoi.append(p.intersection(env))
for pt_key in list(self.al_geometry_dict.keys()): for pt_key in list(self.al_voronoi_geo_storage.keys()):
for poly in new_voronoi: for poly in new_voronoi:
if self.al_geometry_dict[pt_key]['point'].within(poly): if self.al_voronoi_geo_storage[pt_key]['point'].within(poly):
self.al_geometry_dict[pt_key]['geo'] = poly self.al_voronoi_geo_storage[pt_key]['geo'] = poly
def generate_bilinear_geometry(self, pts):
self.al_bilinear_geo_storage = pts
# To be called after clicking on the plot. # To be called after clicking on the plot.
def on_mouse_click_release(self, event): def on_mouse_click_release(self, event):
@@ -940,14 +979,14 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.app.inform.emit(_("Point is not within the object area. Choose another point.")) self.app.inform.emit(_("Point is not within the object area. Choose another point."))
return return
int_keys = [int(k) for k in self.al_geometry_dict.keys()] int_keys = [int(k) for k in self.al_voronoi_geo_storage.keys()]
new_id = max(int_keys) + 1 if int_keys else 1 new_id = max(int_keys) + 1 if int_keys else 1
new_dict = { new_dict = {
'point': probe_pt, 'point': probe_pt,
'geo': None, 'geo': None,
'height': 0.0 'height': 0.0
} }
self.al_geometry_dict[new_id] = deepcopy(new_dict) self.al_voronoi_geo_storage[new_id] = deepcopy(new_dict)
# rebuild the al table # rebuild the al table
self.build_al_table_sig.emit() self.build_al_table_sig.emit()
@@ -955,7 +994,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
radius = 0.3 if self.units == 'MM' else 0.012 radius = 0.3 if self.units == 'MM' else 0.012
probe_pt_buff = probe_pt.buffer(radius) probe_pt_buff = probe_pt.buffer(radius)
self.plot_voronoi(geometry=probe_pt_buff, visibility=True, custom_color="#0000FFFA") self.plot_probing_geo(geometry=probe_pt_buff, visibility=True, custom_color="#0000FFFA")
self.app.inform.emit(_("Added a Probe Point... Click again to add another or right click to finish ...")) self.app.inform.emit(_("Added a Probe Point... Click again to add another or right click to finish ..."))
@@ -982,9 +1021,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.app.inform.emit(_("Finished adding Probe Points...")) self.app.inform.emit(_("Finished adding Probe Points..."))
pts_list = [] pts_list = []
for k in self.al_geometry_dict: for k in self.al_voronoi_geo_storage:
pts_list.append(self.al_geometry_dict[k]['point']) pts_list.append(self.al_voronoi_geo_storage[k]['point'])
self.calculate_voronoi_diagram(pts=pts_list) self.generate_voronoi_geometry(pts=pts_list)
self.probing_gcode_text = self.probing_gcode() self.probing_gcode_text = self.probing_gcode()
@@ -992,10 +1031,10 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.build_al_table_sig.emit() self.build_al_table_sig.emit()
if self.ui.plot_probing_pts_cb.get_value(): if self.ui.plot_probing_pts_cb.get_value():
self.show_voronoi_diagram(state=True, reset=True) self.show_probing_geo(state=True, reset=True)
else: else:
# clear probe shapes # clear probe shapes
self.plot_voronoi(None, False) self.plot_probing_geo(None, False)
def on_key_press(self, event): def on_key_press(self, event):
# events out of the self.app.collection view (it's about Project Tab) are of type int # events out of the self.app.collection view (it's about Project Tab) are of type int
@@ -1057,12 +1096,30 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# Jump to coords # Jump to coords
if key == QtCore.Qt.Key_J or key == 'J': if key == QtCore.Qt.Key_J or key == 'J':
l_x, l_y = self.app.on_jump_to() self.app.on_jump_to()
def on_autolevelling(self, state): def on_autolevelling(self, state):
self.ui.al_frame.show() if state else self.ui.al_frame.hide() self.ui.al_frame.show() if state else self.ui.al_frame.hide()
self.app.defaults["cncjob_al_status"] = True if state else False self.app.defaults["cncjob_al_status"] = True if state else False
gcode_levelled = ''
def line_autolevell(self, gcode_line):
al_method = self.ui.al_method_radio.get_value()
coords = ()
if al_method == 'v':
self.autolevell_voronoi(gcode_line, coords)
elif al_method == 'b':
self.autolevell_bilinear(gcode_line, coords)
def autolevell_bilinear(self, gcode_line, coords):
pass
def autolevell_voronoi(self, gcode_line, coords):
pass
def on_show_al_table(self, state): def on_show_al_table(self, state):
self.ui.al_probe_points_table.show() if state else self.ui.al_probe_points_table.hide() self.ui.al_probe_points_table.show() if state else self.ui.al_probe_points_table.hide()
@@ -1071,10 +1128,10 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.ui.al_probe_points_table.setRowCount(0) self.ui.al_probe_points_table.setRowCount(0)
# reset the al dict # reset the al dict
self.al_geometry_dict.clear() self.al_voronoi_geo_storage.clear()
# reset Voronoi Shapes # reset Voronoi Shapes
self.voronoi_shapes.clear(update=True) self.probing_shapes.clear(update=True)
# build AL table # build AL table
self.build_al_table() self.build_al_table()
@@ -1123,9 +1180,12 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# therefore no Probing GCode was genrated (it is different for GRBL on how it gets it's Probing GCode # therefore no Probing GCode was genrated (it is different for GRBL on how it gets it's Probing GCode
if not self.probing_gcode_text or self.probing_gcode_text == '': if not self.probing_gcode_text or self.probing_gcode_text == '':
# generate Probing GCode # generate Probing GCode
self.probing_gcode_text = self.probing_gcode() al_method = self.ui.al_method_radio.get_value()
storage = self.al_voronoi_geo_storage if al_method == 'v' else self.al_bilinear_geo_storage
self.probing_gcode_text = self.probing_gcode(storage=storage)
def on_grbl_list_serial_ports(self): @staticmethod
def on_grbl_list_serial_ports():
""" """
Lists serial port names. Lists serial port names.
From here: https://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python From here: https://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python
@@ -1306,12 +1366,12 @@ class CNCJobObject(FlatCAMObj, CNCjob):
def send_grbl_block(self, command, echo=True): def send_grbl_block(self, command, echo=True):
stripped_cmd = command.strip() stripped_cmd = command.strip()
for l in stripped_cmd.split('\n'): for grbl_line in stripped_cmd.split('\n'):
if echo: if echo:
self.app.inform_shell[str, bool].emit(l, False) self.app.inform_shell[str, bool].emit(grbl_line, False)
# Send Gcode block to GRBL # Send Gcode block to GRBL
snd = l + '\n' snd = grbl_line + '\n'
self.grbl_ser_port.write(snd.encode('utf-8')) self.grbl_ser_port.write(snd.encode('utf-8'))
grbl_out = self.grbl_ser_port.readlines() grbl_out = self.grbl_ser_port.readlines()
@@ -1324,7 +1384,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
def on_grbl_get_parameter(self, param): def on_grbl_get_parameter(self, param):
if '$' in param: if '$' in param:
param = param.replace('$','') param = param.replace('$', '')
snd = '$$\n' snd = '$$\n'
self.grbl_ser_port.write(snd.encode('utf-8')) self.grbl_ser_port.write(snd.encode('utf-8'))
@@ -1414,8 +1474,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.send_grbl_command(command=cmd) self.send_grbl_command(command=cmd)
self.app.inform.emit("%s" % _("GRBL paused.")) self.app.inform.emit("%s" % _("GRBL paused."))
def probing_gcode(self): def probing_gcode(self, storage):
""" """
:param storage: either a dict of dicts (voronoi) or a list of tuples (bilinear)
:return: Probing GCode :return: Probing GCode
:rtype: str :rtype: str
""" """
@@ -1425,15 +1486,27 @@ class CNCJobObject(FlatCAMObj, CNCjob):
time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now()) time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
coords = [] coords = []
for id_key, value in self.al_geometry_dict.items(): al_method = self.ui.al_method_radio.get_value()
x = value['point'].x if al_method == 'v':
y = value['point'].y for id_key, value in storage.items():
coords.append( x = value['point'].x
( y = value['point'].y
self.app.dec_format(x, dec=self.app.decimals), coords.append(
self.app.dec_format(y, dec=self.app.decimals) (
self.app.dec_format(x, dec=self.app.decimals),
self.app.dec_format(y, dec=self.app.decimals)
)
)
else:
for pt in storage:
x = pt[0]
y = pt[1]
coords.append(
(
self.app.dec_format(x, dec=self.app.decimals),
self.app.dec_format(y, dec=self.app.decimals)
)
) )
)
pr_travel = self.ui.ptravelz_entry.get_value() pr_travel = self.ui.ptravelz_entry.get_value()
probe_fr = self.ui.feedrate_probe_entry.get_value() probe_fr = self.ui.feedrate_probe_entry.get_value()
@@ -1523,7 +1596,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# finish the GCode # finish the GCode
p_gcode += 'M2' p_gcode += 'M2'
return p_gcode return p_gcode
def on_save_probing_gcode(self): def on_save_probing_gcode(self):
lines = StringIO(self.probing_gcode_text) lines = StringIO(self.probing_gcode_text)
@@ -1649,7 +1722,6 @@ class CNCJobObject(FlatCAMObj, CNCjob):
:return: :return:
:rtype: :rtype:
""" """
stream = ''
try: try:
if filename: if filename:
@@ -1663,19 +1735,20 @@ class CNCJobObject(FlatCAMObj, CNCjob):
return return
idx = 0 idx = 0
for line in stream: if stream is not None and stream != '':
if line != '': for line in stream:
idx += 1 if line != '':
line = line.replace(' ', ',').replace('\n', '').split(',') idx += 1
if idx not in self.al_geometry_dict: line = line.replace(' ', ',').replace('\n', '').split(',')
self.al_geometry_dict[idx] = {} if idx not in self.al_voronoi_geo_storage:
self.al_geometry_dict[idx]['height'] = float(line[2]) self.al_voronoi_geo_storage[idx] = {}
if 'point' not in self.al_geometry_dict[idx]: self.al_voronoi_geo_storage[idx]['height'] = float(line[2])
x = float(line[0]) if 'point' not in self.al_voronoi_geo_storage[idx]:
y = float(line[1]) x = float(line[0])
self.al_geometry_dict[idx]['point'] = Point((x, y)) y = float(line[1])
self.al_voronoi_geo_storage[idx]['point'] = Point((x, y))
self.build_al_table_sig.emit() self.build_al_table_sig.emit()
def on_grbl_autolevel(self): def on_grbl_autolevel(self):
# show the Shell Dock # show the Shell Dock
@@ -1693,9 +1766,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
cmd = 'G90\n' cmd = 'G90\n'
self.send_grbl_command(command=cmd) self.send_grbl_command(command=cmd)
for pt_key in self.al_geometry_dict: for pt_key in self.al_voronoi_geo_storage:
x = str(self.al_geometry_dict[pt_key]['point'].x) x = str(self.al_voronoi_geo_storage[pt_key]['point'].x)
y = str(self.al_geometry_dict[pt_key]['point'].y) y = str(self.al_voronoi_geo_storage[pt_key]['point'].y)
cmd = 'G0 Z%s\n' % pr_travelz cmd = 'G0 Z%s\n' % pr_travelz
self.send_grbl_command(command=cmd) self.send_grbl_command(command=cmd)
@@ -2225,7 +2298,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# if self.ui.toolchange_cb.get_value(): # if self.ui.toolchange_cb.get_value():
# self.ui.toolchange_cb.set_value(False) # self.ui.toolchange_cb.set_value(False)
# self.app.inform.emit('[WARNING_NOTCL] %s' % # self.app.inform.emit('[WARNING_NOTCL] %s' %
# _("The used preprocessor file has to have in it's name: 'toolchange_custom'")) # _("The used preprocessor file has to have in it's name: 'toolchange_custom'")
# )
# except KeyError: # except KeyError:
# try: # try:
# for key in self.cnc_tools: # for key in self.cnc_tools:
@@ -2383,7 +2457,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
try: try:
if self.app.is_legacy is False: if self.app.is_legacy is False:
if self.ui.annotation_cb.get_value() and self.ui.plot_cb.get_value(): if self.ui.annotation_cb.get_value() and self.ui.plot_cb.get_value():
self.plot_annotations(obj=self, visible=True) self.plot_annotations(obj=self, visible=True)
else: else:
self.plot_annotations(obj=self, visible=False) self.plot_annotations(obj=self, visible=False)