- small fixes

This commit is contained in:
Marius Stanciu
2020-09-03 01:36:21 +03:00
committed by Marius
parent 06c526db39
commit 12012c8e49

View File

@@ -742,37 +742,20 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.probing_gcode_text = self.probing_gcode() self.probing_gcode_text = self.probing_gcode()
else: else:
found = False f_probe_pt = Point([xmin, xmin])
# add the first point in the origin, only once (if not added yet. int_keys = [int(k) for k in self.al_geometry_dict.keys()]
orig_point = Point([xmin, xmin]) new_id = max(int_keys) + 1 if int_keys else 1
for k in self.al_geometry_dict: new_dict = {
if self.al_geometry_dict[k]['point'] == orig_point: 'point': f_probe_pt,
found = True 'geo': None,
break 'height': 0.0
}
self.al_geometry_dict[new_id] = deepcopy(new_dict)
if found is False: radius = 0.3 if self.units == 'MM' else 0.012
f_probe_pt = orig_point fprobe_pt_buff = f_probe_pt.buffer(radius)
if not self.al_geometry_dict:
new_dict = {
'point': f_probe_pt,
'geo': None,
'height': 0.0
}
self.al_geometry_dict[1] = deepcopy(new_dict)
else:
int_keys = [int(k) for k in self.al_geometry_dict.keys()]
new_id = max(int_keys) + 1
new_dict = {
'point': f_probe_pt,
'geo': None,
'height': 0.0
}
self.al_geometry_dict[new_id] = deepcopy(new_dict)
radius = 0.3 if self.units == 'MM' else 0.012 self.plot_voronoi(geometry=fprobe_pt_buff, visibility=True, custom_color="#0000FFFA")
fprobe_pt_buff = f_probe_pt.buffer(radius)
self.plot_voronoi(geometry=fprobe_pt_buff, visibility=True, custom_color="#0000FFFA")
self.app.inform.emit(_("Click on canvas to add a Probe Point...")) self.app.inform.emit(_("Click on canvas to add a Probe Point..."))
self.app.defaults['global_selection_shape'] = False self.app.defaults['global_selection_shape'] = False
@@ -794,6 +777,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.build_al_table_sig.emit() self.build_al_table_sig.emit()
if self.ui.voronoi_cb.get_value(): if self.ui.voronoi_cb.get_value():
self.show_voronoi_diagram(state=True, reset=True) self.show_voronoi_diagram(state=True, reset=True)
else:
# clear probe shapes
self.plot_voronoi(None, False)
def show_voronoi_diagram(self, state, reset=False): def show_voronoi_diagram(self, state, reset=False):
@@ -818,9 +804,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
if not points_geo and not poly_geo: if not points_geo and not poly_geo:
return return
self.plot_voronoi(geometry=poly_geo, visibility=state)
self.plot_voronoi(geometry=points_geo, visibility=state, custom_color='#000000FF') self.plot_voronoi(geometry=points_geo, visibility=state, custom_color='#000000FF')
self.plot_voronoi(geometry=poly_geo, visibility=state)
def plot_voronoi(self, geometry, visibility, custom_color=None): def plot_voronoi(self, geometry, visibility, custom_color=None):
if visibility: if visibility:
@@ -947,22 +932,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
if not self.al_geometry_dict: int_keys = [int(k) for k in self.al_geometry_dict.keys()]
new_dict = { new_id = max(int_keys) + 1 if int_keys else 1
'point': probe_pt, new_dict = {
'geo': None, 'point': probe_pt,
'height': 0.0 'geo': None,
} 'height': 0.0
self.al_geometry_dict[1] = deepcopy(new_dict) }
else: self.al_geometry_dict[new_id] = deepcopy(new_dict)
int_keys = [int(k) for k in self.al_geometry_dict.keys()]
new_id = max(int_keys) + 1
new_dict = {
'point': probe_pt,
'geo': None,
'height': 0.0
}
self.al_geometry_dict[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()
@@ -1006,8 +983,11 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# rebuild the al table # rebuild the al table
self.build_al_table_sig.emit() self.build_al_table_sig.emit()
# clear probe shapes if self.ui.voronoi_cb.get_value():
self.plot_voronoi(None, False) self.show_voronoi_diagram(state=True, reset=True)
else:
# clear probe shapes
self.plot_voronoi(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