- new feature: added ability to edit MultiGeo geometry (geometry from Paint Tool)

This commit is contained in:
Marius Stanciu 2019-03-28 21:11:37 +02:00
parent 18b636bf03
commit 6d9eb10a59
3 changed files with 35 additions and 13 deletions

View File

@ -2195,14 +2195,17 @@ class App(QtCore.QObject):
edited_object = self.collection.get_active()
if isinstance(edited_object, FlatCAMGeometry):
# for now, if the Geometry is MultiGeo do not allow the editing
if edited_object.multigeo is True:
self.inform.emit(_("[WARNING_NOTCL] Editing a MultiGeo Geometry is not possible for the moment."))
return
# store the Geometry Editor Toolbar visibility before entering in the Editor
self.geo_editor.toolbar_old_state = True if self.ui.geo_edit_toolbar.isVisible() else False
self.geo_editor.edit_fcgeometry(edited_object)
if edited_object.multigeo is True:
edited_tools = [int(x.text()) for x in edited_object.ui.geo_tools_table.selectedItems()]
if len(edited_tools) > 1:
self.inform.emit(_("[WARNING_NOTCL] Simultanoeus editing of tools geometry in a MultiGeo Geometry "
"is not possible.\n Edit only one geometry at a time."))
self.geo_editor.edit_fcgeometry(edited_object, multigeo_tool=edited_tools[0])
else:
self.geo_editor.edit_fcgeometry(edited_object)
# we set the notebook to hidden
self.ui.splitter.setSizes([0, 1])

View File

@ -2148,7 +2148,7 @@ class FCRectangle(FCShapeTool):
# self.geometry = LinearRing([p1, (p2[0], p1[1]), p2, (p1[0], p2[1])])
self.geometry = DrawToolShape(Polygon([p1, (p2[0], p1[1]), p2, (p1[0], p2[1])]))
self.complete = True
self.draw_app.app.inform.emit("_([success]Done. Rectangle completed.")
self.draw_app.app.inform.emit(_("[success]Done. Rectangle completed."))
class FCPolygon(FCShapeTool):
@ -3364,6 +3364,9 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.x = None # Current mouse cursor pos
self.y = None
# if we edit a multigeo geometry store here the tool number
self.multigeo_tool = None
# Current snapped mouse pos
self.snap_x = None
self.snap_y = None
@ -3645,7 +3648,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.storage = FlatCAMGeoEditor.make_storage()
self.replot()
def edit_fcgeometry(self, fcgeometry):
def edit_fcgeometry(self, fcgeometry, multigeo_tool=None):
"""
Imports the geometry from the given FlatCAM Geometry object
into the editor.
@ -3669,7 +3672,15 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.select_tool("select")
# Link shapes into editor.
for shape in fcgeometry.flatten():
if multigeo_tool:
self.multigeo_tool = multigeo_tool
geo_to_edit = fcgeometry.flatten(geometry=fcgeometry.tools[self.multigeo_tool]['solid_geometry'])
self.app.inform.emit(_("[WARNING] Editing MultiGeo Geometry, tool: {tool} with diameter: {dia}").
format(tool=self.multigeo_tool, dia=fcgeometry.tools[self.multigeo_tool]['tooldia']))
else:
geo_to_edit = fcgeometry.flatten()
for shape in geo_to_edit:
if shape is not None: # TODO: Make flatten never create a None
if type(shape) == Polygon:
self.add_shape(DrawToolShape(shape.exterior))
@ -4233,10 +4244,17 @@ class FlatCAMGeoEditor(QtCore.QObject):
:param fcgeometry: FlatCAMGeometry
:return: None
"""
fcgeometry.solid_geometry = []
# for shape in self.shape_buffer:
for shape in self.storage.get_objects():
fcgeometry.solid_geometry.append(shape.geo)
if self.multigeo_tool:
fcgeometry.tools[self.multigeo_tool]['solid_geometry'] = []
# for shape in self.shape_buffer:
for shape in self.storage.get_objects():
fcgeometry.tools[self.multigeo_tool]['solid_geometry'].append(shape.geo)
self.multigeo_tool = None
else:
fcgeometry.solid_geometry = []
# for shape in self.shape_buffer:
for shape in self.storage.get_objects():
fcgeometry.solid_geometry.append(shape.geo)
# re-enable all the widgets in the Selected Tab that were disabled after entering in Edit Geometry Mode
sel_tab_widget_list = self.app.ui.selected_tab.findChildren(QtWidgets.QWidget)

View File

@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
28.03.2019
- About 45% progress in German translation
- new feature: added ability to edit MultiGeo geometry (geometry from Paint Tool)
27.03.2019