- added a new tool in the Geometry Editor named Explode which is the opposite of Union Tool: it will explode the polygons into lines

This commit is contained in:
Marius Stanciu
2019-10-06 01:32:21 +03:00
committed by Marius
parent 8413885d87
commit da09202f5f
6 changed files with 91 additions and 11 deletions

View File

@@ -775,6 +775,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.geo_edit_toolbar.addSeparator()
self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), _('Polygon Union'))
self.geo_explode_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/explode32.png'), _('Polygon Explode'))
self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
_('Polygon Intersection'))
self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'),
@@ -2174,6 +2176,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.geo_edit_toolbar.addSeparator()
self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), _('Polygon Union'))
self.geo_explode_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/explode32.png'), _('Polygon Explode'))
self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
_('Polygon Intersection'))
self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'),

View File

@@ -810,7 +810,8 @@ class ShapeCollectionLegacy:
self.axes = self.app.plotcanvas.new_axes(axes_name)
def add(self, shape=None, color=None, face_color=None, alpha=None, visible=True,
update=False, layer=1, tolerance=0.01, obj=None, gcode_parsed=None, tool_tolerance=None, tooldia=None):
update=False, layer=1, tolerance=0.01, obj=None, gcode_parsed=None, tool_tolerance=None, tooldia=None,
linewidth=None):
"""
This function will add shapes to the shape collection
@@ -826,6 +827,7 @@ class ShapeCollectionLegacy:
:param gcode_parsed: not used; just for compatibility with VIsPy canvas
:param tool_tolerance: just for compatibility with VIsPy canvas
:param tooldia:
:param linewidth: the width of the line
:return:
"""
self._color = color[:-2] if color is not None else None
@@ -853,6 +855,7 @@ class ShapeCollectionLegacy:
self.shape_dict.update({
'color': self._color,
'face_color': self._face_color,
'linewidth': linewidth,
'alpha': self._alpha,
'shape': sh
})
@@ -865,6 +868,7 @@ class ShapeCollectionLegacy:
self.shape_dict.update({
'color': self._color,
'face_color': self._face_color,
'linewidth': linewidth,
'alpha': self._alpha,
'shape': shape
})
@@ -928,15 +932,21 @@ class ShapeCollectionLegacy:
elif obj_type == 'geometry':
if type(local_shapes[element]['shape']) == Polygon:
x, y = local_shapes[element]['shape'].exterior.coords.xy
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
self.axes.plot(x, y, local_shapes[element]['color'],
linestyle='-',
linewidth=local_shapes[element]['linewidth'])
for ints in local_shapes[element]['shape'].interiors:
x, y = ints.coords.xy
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
self.axes.plot(x, y, local_shapes[element]['color'],
linestyle='-',
linewidth=local_shapes[element]['linewidth'])
elif type(local_shapes[element]['shape']) == LineString or \
type(local_shapes[element]['shape']) == LinearRing:
x, y = local_shapes[element]['shape'].coords.xy
self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-')
self.axes.plot(x, y, local_shapes[element]['color'],
linestyle='-',
linewidth=local_shapes[element]['linewidth'])
elif obj_type == 'gerber':
if self.obj.options["multicolored"]:

View File

@@ -235,7 +235,7 @@ class ShapeCollectionVisual(CompoundVisual):
self.freeze()
def add(self, shape=None, color=None, face_color=None, alpha=None, visible=True,
update=False, layer=1, tolerance=0.01):
update=False, layer=1, tolerance=0.01, linewidth=None):
"""
Adds shape to collection
:return:
@@ -253,6 +253,8 @@ class ShapeCollectionVisual(CompoundVisual):
Layer number. 0 - lowest.
:param tolerance: float
Geometry simplifying tolerance
:param linewidth: int
Not used, for compatibility
:return: int
Index of shape
"""