- in Geometry Editor - made sure that selecting shapes on canvas will update the UI - final fix
This commit is contained in:
committed by
Marius Stanciu
parent
4f46620e7e
commit
bdabd6cfdf
@@ -12,6 +12,7 @@ CHANGELOG for FlatCAM beta
|
|||||||
- in Geometry Editor - improvements and some issues are solved
|
- in Geometry Editor - improvements and some issues are solved
|
||||||
- in Geometry Editor - improvement in update of the whole Geometry Editor UI on shape selection on canvas
|
- in Geometry Editor - improvement in update of the whole Geometry Editor UI on shape selection on canvas
|
||||||
- in Geometry Editor - fixed multiple plotting for the same selection
|
- in Geometry Editor - fixed multiple plotting for the same selection
|
||||||
|
- in Geometry Editor - made sure that selecting shapes on canvas will update the UI - final fix
|
||||||
|
|
||||||
28.11.2020
|
28.11.2020
|
||||||
|
|
||||||
|
|||||||
@@ -2669,6 +2669,8 @@ class FCSelect(DrawTool):
|
|||||||
self.draw_app.tw.itemClicked.connect(self.draw_app.on_tree_geo_click)
|
self.draw_app.tw.itemClicked.connect(self.draw_app.on_tree_geo_click)
|
||||||
|
|
||||||
# self.draw_app.tw.itemClicked.emit(self.draw_app.tw.currentItem(), 0)
|
# self.draw_app.tw.itemClicked.emit(self.draw_app.tw.currentItem(), 0)
|
||||||
|
self.draw_app.update_ui()
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def clean_up(self):
|
def clean_up(self):
|
||||||
@@ -3865,105 +3867,108 @@ class AppGeoEditor(QtCore.QObject):
|
|||||||
def on_geo_elem_selected(self):
|
def on_geo_elem_selected(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_tree_geo_click(self):
|
def update_ui(self):
|
||||||
self.selected = []
|
self.selected = []
|
||||||
last_obj_shape = None
|
last_obj_shape = None
|
||||||
|
|
||||||
try:
|
selected_tree_items = self.tw.selectedItems()
|
||||||
selected_tree_items = self.tw.selectedItems()
|
for sel in selected_tree_items:
|
||||||
for sel in selected_tree_items:
|
for obj_shape in self.storage.get_objects():
|
||||||
for obj_shape in self.storage.get_objects():
|
try:
|
||||||
try:
|
if id(obj_shape) == int(sel.text(0)):
|
||||||
if id(obj_shape) == int(sel.text(0)):
|
self.selected.append(obj_shape)
|
||||||
self.selected.append(obj_shape)
|
last_obj_shape = obj_shape
|
||||||
last_obj_shape = obj_shape
|
except ValueError:
|
||||||
except ValueError:
|
pass
|
||||||
pass
|
|
||||||
|
|
||||||
if last_obj_shape:
|
if last_obj_shape:
|
||||||
last_sel_geo = last_obj_shape.geo
|
last_sel_geo = last_obj_shape.geo
|
||||||
|
|
||||||
self.is_valid_entry.set_value(last_sel_geo.is_valid)
|
self.is_valid_entry.set_value(last_sel_geo.is_valid)
|
||||||
self.is_empty_entry.set_value(last_sel_geo.is_empty)
|
self.is_empty_entry.set_value(last_sel_geo.is_empty)
|
||||||
|
|
||||||
if last_sel_geo.geom_type == 'MultiLineString':
|
if last_sel_geo.geom_type == 'MultiLineString':
|
||||||
length = last_sel_geo.length
|
length = last_sel_geo.length
|
||||||
self.is_simple_entry.set_value(last_sel_geo.is_simple)
|
self.is_simple_entry.set_value(last_sel_geo.is_simple)
|
||||||
self.is_ring_entry.set_value(last_sel_geo.is_ring)
|
self.is_ring_entry.set_value(last_sel_geo.is_ring)
|
||||||
self.is_ccw_entry.set_value('None')
|
self.is_ccw_entry.set_value('None')
|
||||||
|
|
||||||
coords = ''
|
coords = ''
|
||||||
vertex_nr = 0
|
vertex_nr = 0
|
||||||
for idx, line in enumerate(last_sel_geo):
|
for idx, line in enumerate(last_sel_geo):
|
||||||
line_coords = list(line.coords)
|
line_coords = list(line.coords)
|
||||||
vertex_nr += len(line_coords)
|
vertex_nr += len(line_coords)
|
||||||
coords += 'Line %s\n' % str(idx)
|
coords += 'Line %s\n' % str(idx)
|
||||||
coords += str(line_coords) + '\n'
|
coords += str(line_coords) + '\n'
|
||||||
|
|
||||||
elif last_sel_geo.geom_type in ['LinearRing', 'LineString']:
|
elif last_sel_geo.geom_type in ['LinearRing', 'LineString']:
|
||||||
length = last_sel_geo.length
|
length = last_sel_geo.length
|
||||||
coords = list(last_sel_geo.coords)
|
coords = list(last_sel_geo.coords)
|
||||||
vertex_nr = len(coords)
|
vertex_nr = len(coords)
|
||||||
self.is_simple_entry.set_value(last_sel_geo.is_simple)
|
self.is_simple_entry.set_value(last_sel_geo.is_simple)
|
||||||
self.is_ring_entry.set_value(last_sel_geo.is_ring)
|
self.is_ring_entry.set_value(last_sel_geo.is_ring)
|
||||||
if last_sel_geo.geom_type == 'LinearRing':
|
if last_sel_geo.geom_type == 'LinearRing':
|
||||||
self.is_ccw_entry.set_value(last_sel_geo.is_ccw)
|
self.is_ccw_entry.set_value(last_sel_geo.is_ccw)
|
||||||
elif last_sel_geo.geom_type == 'Polygon':
|
elif last_sel_geo.geom_type == 'Polygon':
|
||||||
length = last_sel_geo.exterior.length
|
length = last_sel_geo.exterior.length
|
||||||
coords = list(last_sel_geo.exterior.coords)
|
coords = list(last_sel_geo.exterior.coords)
|
||||||
vertex_nr = len(coords)
|
vertex_nr = len(coords)
|
||||||
self.is_simple_entry.set_value(last_sel_geo.is_simple)
|
self.is_simple_entry.set_value(last_sel_geo.is_simple)
|
||||||
self.is_ring_entry.set_value(last_sel_geo.is_ring)
|
self.is_ring_entry.set_value(last_sel_geo.is_ring)
|
||||||
if last_sel_geo.exterior.geom_type == 'LinearRing':
|
if last_sel_geo.exterior.geom_type == 'LinearRing':
|
||||||
self.is_ccw_entry.set_value(last_sel_geo.exterior.is_ccw)
|
self.is_ccw_entry.set_value(last_sel_geo.exterior.is_ccw)
|
||||||
|
else:
|
||||||
|
length = 0.0
|
||||||
|
coords = 'None'
|
||||||
|
vertex_nr = 0
|
||||||
|
|
||||||
|
if self.geo_zoom.get_value():
|
||||||
|
xmin, ymin, xmax, ymax = last_sel_geo.bounds
|
||||||
|
if xmin == xmax and ymin != ymax:
|
||||||
|
xmin = ymin
|
||||||
|
xmax = ymax
|
||||||
|
elif xmin != xmax and ymin == ymax:
|
||||||
|
ymin = xmin
|
||||||
|
ymax = xmax
|
||||||
|
|
||||||
|
if self.app.is_legacy is False:
|
||||||
|
rect = Rect(xmin, ymin, xmax, ymax)
|
||||||
|
rect.left, rect.right = xmin, xmax
|
||||||
|
rect.bottom, rect.top = ymin, ymax
|
||||||
|
# Lock updates in other threads
|
||||||
|
self.shapes.lock_updates()
|
||||||
|
|
||||||
|
# adjust the view camera to be slightly bigger than the bounds so the shape collection can be
|
||||||
|
# seen clearly otherwise the shape collection boundary will have no border
|
||||||
|
dx = rect.right - rect.left
|
||||||
|
dy = rect.top - rect.bottom
|
||||||
|
x_factor = dx * 0.02
|
||||||
|
y_factor = dy * 0.02
|
||||||
|
|
||||||
|
rect.left -= x_factor
|
||||||
|
rect.bottom -= y_factor
|
||||||
|
rect.right += x_factor
|
||||||
|
rect.top += y_factor
|
||||||
|
|
||||||
|
self.app.plotcanvas.view.camera.rect = rect
|
||||||
|
self.shapes.unlock_updates()
|
||||||
else:
|
else:
|
||||||
length = 0.0
|
width = xmax - xmin
|
||||||
coords = 'None'
|
height = ymax - ymin
|
||||||
vertex_nr = 0
|
xmin -= 0.05 * width
|
||||||
|
xmax += 0.05 * width
|
||||||
|
ymin -= 0.05 * height
|
||||||
|
ymax += 0.05 * height
|
||||||
|
self.app.plotcanvas.adjust_axes(xmin, ymin, xmax, ymax)
|
||||||
|
|
||||||
if self.geo_zoom.get_value():
|
self.geo_len_entry.set_value(length, decimals=self.decimals)
|
||||||
xmin, ymin, xmax, ymax = last_sel_geo.bounds
|
self.geo_coords_entry.setText(str(coords))
|
||||||
if xmin == xmax and ymin != ymax:
|
self.geo_vertex_entry.set_value(vertex_nr)
|
||||||
xmin = ymin
|
|
||||||
xmax = ymax
|
|
||||||
elif xmin != xmax and ymin == ymax:
|
|
||||||
ymin = xmin
|
|
||||||
ymax = xmax
|
|
||||||
|
|
||||||
if self.app.is_legacy is False:
|
def on_tree_geo_click(self):
|
||||||
rect = Rect(xmin, ymin, xmax, ymax)
|
|
||||||
rect.left, rect.right = xmin, xmax
|
|
||||||
rect.bottom, rect.top = ymin, ymax
|
|
||||||
# Lock updates in other threads
|
|
||||||
self.shapes.lock_updates()
|
|
||||||
|
|
||||||
# adjust the view camera to be slightly bigger than the bounds so the shape collection can be
|
|
||||||
# seen clearly otherwise the shape collection boundary will have no border
|
|
||||||
dx = rect.right - rect.left
|
|
||||||
dy = rect.top - rect.bottom
|
|
||||||
x_factor = dx * 0.02
|
|
||||||
y_factor = dy * 0.02
|
|
||||||
|
|
||||||
rect.left -= x_factor
|
|
||||||
rect.bottom -= y_factor
|
|
||||||
rect.right += x_factor
|
|
||||||
rect.top += y_factor
|
|
||||||
|
|
||||||
self.app.plotcanvas.view.camera.rect = rect
|
|
||||||
self.shapes.unlock_updates()
|
|
||||||
else:
|
|
||||||
width = xmax - xmin
|
|
||||||
height = ymax - ymin
|
|
||||||
xmin -= 0.05 * width
|
|
||||||
xmax += 0.05 * width
|
|
||||||
ymin -= 0.05 * height
|
|
||||||
ymax += 0.05 * height
|
|
||||||
self.app.plotcanvas.adjust_axes(xmin, ymin, xmax, ymax)
|
|
||||||
|
|
||||||
self.geo_len_entry.set_value(length, decimals=self.decimals)
|
|
||||||
self.geo_coords_entry.setText(str(coords))
|
|
||||||
self.geo_vertex_entry.set_value(vertex_nr)
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.update_ui()
|
||||||
self.plot_all()
|
self.plot_all()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.log.debug("APpGeoEditor.on_tree_selection_change() -> %s" % str(e))
|
self.app.log.debug("APpGeoEditor.on_tree_selection_change() -> %s" % str(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user