- in Geometry Editor - added a new feature: Simplification. It will greatly reduce the number of vertex points in a geometry element selected in the Geometry Table thus potentially greatly reducing the resulting GCode number of lines

This commit is contained in:
Marius Stanciu
2020-11-27 02:05:04 +02:00
committed by Marius
parent 49c26f06de
commit e79a53012a
4 changed files with 73 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ CHANGELOG for FlatCAM beta
- in Geometry Editor - made sure that the edited Geometry do not contain Shapely Points and that when adding shapes, that the geometry of that shapes is valid and non empty and it is not a Shapely Point - in Geometry Editor - made sure that the edited Geometry do not contain Shapely Points and that when adding shapes, that the geometry of that shapes is valid and non empty and it is not a Shapely Point
- in Geometry Editor - added new information's (length, coordinates and vertex points number) for the geometric element selected in the Geometry Table - in Geometry Editor - added new information's (length, coordinates and vertex points number) for the geometric element selected in the Geometry Table
- in Geometry Editor - added more parameters displayed for the geometric elements selected in the Geometry Table: is_valid, is_empty, is_ccw, is_simple, is_ring - in Geometry Editor - added more parameters displayed for the geometric elements selected in the Geometry Table: is_valid, is_empty, is_ccw, is_simple, is_ring
- in Geometry Editor - added a new feature: Simplification. It will greatly reduce the number of vertex points in a geometry element selected in the Geometry Table thus potentially greatly reducing the resulting GCode number of lines
26.11.2020 26.11.2020

View File

@@ -3392,12 +3392,17 @@ class AppGeoEditor(QtCore.QObject):
self.geo_font.setBold(True) self.geo_font.setBold(True)
self.geo_parent = self.tw.invisibleRootItem() self.geo_parent = self.tw.invisibleRootItem()
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 3, 0, 1, 2)
# Parameters Title # Parameters Title
param_title = FCLabel('<b>%s</b>:' % _("Parameters")) param_title = FCLabel('<b>%s</b>:' % _("Parameters"))
param_title.setToolTip( param_title.setToolTip(
_("Geometry parameters.") _("Geometry parameters.")
) )
grid0.addWidget(param_title, 4, 0) grid0.addWidget(param_title, 4, 0, 1, 2)
# Is Valid # Is Valid
is_valid_lbl = FCLabel('<b>%s</b>:' % _("Is Valid")) is_valid_lbl = FCLabel('<b>%s</b>:' % _("Is Valid"))
@@ -3463,6 +3468,47 @@ class AppGeoEditor(QtCore.QObject):
grid0.addWidget(vertex_lbl, 22, 0) grid0.addWidget(vertex_lbl, 22, 0)
grid0.addWidget(self.geo_vertex_entry, 22, 1) grid0.addWidget(self.geo_vertex_entry, 22, 1)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 23, 0, 1, 2)
# Simplification
simplif_lbl = FCLabel('<b>%s</b>:' % _("Simplification"))
simplif_lbl.setToolTip(
_("Simplify a geometry element by reducing its vertex points number.")
)
grid0.addWidget(simplif_lbl, 24, 0, 1, 2)
simplification_tol_lbl = FCLabel('<b>%s</b>:' % _("Tolerance"))
simplification_tol_lbl.setToolTip(
_("All points in the simplified object will be\n"
"within the tolerance distance of the original geometry.")
)
self.geo_tol_entry = FCDoubleSpinner()
self.geo_tol_entry.set_precision(self.decimals)
self.geo_tol_entry.setSingleStep(0.001)
self.geo_tol_entry.setWrapping(True)
self.geo_tol_entry.set_range(-10000.0000, 10000.0000)
self.geo_tol_entry.set_value(10 ** -self.decimals)
grid0.addWidget(simplification_tol_lbl, 26, 0)
grid0.addWidget(self.geo_tol_entry, 26, 1)
self.simplification_btn = FCButton(_("Simplify"))
self.simplification_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/simplify32.png'))
self.simplification_btn.setToolTip(
_("Simplify a geometry element by reducing its vertex points number.")
)
self.simplification_btn.setStyleSheet("""
QPushButton
{
font-weight: bold;
}
""")
grid0.addWidget(self.simplification_btn, 27, 0, 1, 2)
layout.addStretch() layout.addStretch()
# Editor # Editor
@@ -3618,6 +3664,8 @@ class AppGeoEditor(QtCore.QObject):
self.transform_complete.connect(self.on_transform_complete) self.transform_complete.connect(self.on_transform_complete)
self.simplification_btn.clicked.connect(self.on_simplification_click)
# Event signals disconnect id holders # Event signals disconnect id holders
self.mp = None self.mp = None
self.mm = None self.mm = None
@@ -3817,6 +3865,29 @@ class AppGeoEditor(QtCore.QObject):
self.replot() self.replot()
def on_simplification_click(self):
selected_shapes = []
selected_shapes_geos = []
tol = self.geo_tol_entry.get_value()
selected_tree_items = self.tw.selectedItems()
for sel in selected_tree_items:
for obj_shape in self.storage.get_objects():
try:
if id(obj_shape) == int(sel.text(0)):
selected_shapes.append(obj_shape)
selected_shapes_geos.append(obj_shape.geo.simplify(tolerance=tol))
except ValueError:
pass
for shape in selected_shapes:
self.delete_shape(shape=shape)
for geo in selected_shapes_geos:
self.add_shape(DrawToolShape(geo))
self.build_ui_sig.emit()
def activate(self): def activate(self):
# adjust the status of the menu entries related to the editor # adjust the status of the menu entries related to the editor
self.app.ui.menueditedit.setDisabled(True) self.app.ui.menueditedit.setDisabled(True)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B