Added "connect" option for painting polygons.
This commit is contained in:
parent
0b26a90175
commit
f6d9901365
|
@ -651,7 +651,9 @@ class GeometryOptionsGroupUI(OptionsGroupUI):
|
||||||
)
|
)
|
||||||
self.layout.addWidget(self.plot_cb)
|
self.layout.addWidget(self.plot_cb)
|
||||||
|
|
||||||
|
# ------------------------------
|
||||||
## Create CNC Job
|
## Create CNC Job
|
||||||
|
# ------------------------------
|
||||||
self.cncjob_label = QtGui.QLabel('<b>Create CNC Job:</b>')
|
self.cncjob_label = QtGui.QLabel('<b>Create CNC Job:</b>')
|
||||||
self.cncjob_label.setToolTip(
|
self.cncjob_label.setToolTip(
|
||||||
"Create a CNC Job object\n"
|
"Create a CNC Job object\n"
|
||||||
|
@ -711,7 +713,9 @@ class GeometryOptionsGroupUI(OptionsGroupUI):
|
||||||
self.cncspindlespeed_entry = IntEntry(allow_empty=True)
|
self.cncspindlespeed_entry = IntEntry(allow_empty=True)
|
||||||
grid1.addWidget(self.cncspindlespeed_entry, 4, 1)
|
grid1.addWidget(self.cncspindlespeed_entry, 4, 1)
|
||||||
|
|
||||||
|
# ------------------------------
|
||||||
## Paint area
|
## Paint area
|
||||||
|
# ------------------------------
|
||||||
self.paint_label = QtGui.QLabel('<b>Paint Area:</b>')
|
self.paint_label = QtGui.QLabel('<b>Paint Area:</b>')
|
||||||
self.paint_label.setToolTip(
|
self.paint_label.setToolTip(
|
||||||
"Creates tool paths to cover the\n"
|
"Creates tool paths to cover the\n"
|
||||||
|
@ -756,19 +760,44 @@ class GeometryOptionsGroupUI(OptionsGroupUI):
|
||||||
self.paintmargin_entry = LengthEntry()
|
self.paintmargin_entry = LengthEntry()
|
||||||
grid2.addWidget(self.paintmargin_entry, 2, 1)
|
grid2.addWidget(self.paintmargin_entry, 2, 1)
|
||||||
|
|
||||||
|
# Method
|
||||||
|
methodlabel = QtGui.QLabel('Method:')
|
||||||
|
methodlabel.setToolTip(
|
||||||
|
"Algorithm to paint the polygon:<BR>"
|
||||||
|
"<B>Standard</B>: Fixed step inwards.<BR>"
|
||||||
|
"<B>Seed-based</B>: Outwards from seed."
|
||||||
|
)
|
||||||
|
grid2.addWidget(methodlabel, 3, 0)
|
||||||
|
self.paintmethod_combo = RadioSet([
|
||||||
|
{"label": "Standard", "value": "standard"},
|
||||||
|
{"label": "Seed-based", "value": "seed"},
|
||||||
|
{"label": "Straight lines", "value": "lines"}
|
||||||
|
], orientation='vertical')
|
||||||
|
grid2.addWidget(self.paintmethod_combo, 3, 1)
|
||||||
|
|
||||||
|
# Connect lines
|
||||||
|
pathconnectlabel = QtGui.QLabel("Connect:")
|
||||||
|
pathconnectlabel.setToolTip(
|
||||||
|
"Draw lines between resulting\n"
|
||||||
|
"segments to minimize tool lifts."
|
||||||
|
)
|
||||||
|
grid2.addWidget(pathconnectlabel, 4, 0)
|
||||||
|
self.pathconnect_cb = FCCheckBox()
|
||||||
|
grid2.addWidget(self.pathconnect_cb, 4, 1)
|
||||||
|
|
||||||
# Polygon selection
|
# Polygon selection
|
||||||
selectlabel = QtGui.QLabel('Selection:')
|
selectlabel = QtGui.QLabel('Selection:')
|
||||||
selectlabel.setToolTip(
|
selectlabel.setToolTip(
|
||||||
"How to select the polygons to paint."
|
"How to select the polygons to paint."
|
||||||
)
|
)
|
||||||
grid2.addWidget(selectlabel, 3, 0)
|
grid2.addWidget(selectlabel, 5, 0)
|
||||||
# grid3 = QtGui.QGridLayout()
|
# grid3 = QtGui.QGridLayout()
|
||||||
self.selectmethod_combo = RadioSet([
|
self.selectmethod_combo = RadioSet([
|
||||||
{"label": "Single", "value": "single"},
|
{"label": "Single", "value": "single"},
|
||||||
{"label": "All", "value": "all"},
|
{"label": "All", "value": "all"},
|
||||||
# {"label": "Rectangle", "value": "rectangle"}
|
# {"label": "Rectangle", "value": "rectangle"}
|
||||||
])
|
])
|
||||||
grid2.addWidget(self.selectmethod_combo, 3, 1)
|
grid2.addWidget(self.selectmethod_combo, 5, 1)
|
||||||
|
|
||||||
|
|
||||||
class CNCJobOptionsGroupUI(OptionsGroupUI):
|
class CNCJobOptionsGroupUI(OptionsGroupUI):
|
||||||
|
|
|
@ -1210,6 +1210,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
"paintoverlap": 0.15,
|
"paintoverlap": 0.15,
|
||||||
"paintmargin": 0.01,
|
"paintmargin": 0.01,
|
||||||
"paintmethod": "standard",
|
"paintmethod": "standard",
|
||||||
|
"pathconnect": True,
|
||||||
"multidepth": False,
|
"multidepth": False,
|
||||||
"depthperpass": 0.002,
|
"depthperpass": 0.002,
|
||||||
"selectmethod": "single"
|
"selectmethod": "single"
|
||||||
|
@ -1242,6 +1243,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
"paintoverlap": self.ui.paintoverlap_entry,
|
"paintoverlap": self.ui.paintoverlap_entry,
|
||||||
"paintmargin": self.ui.paintmargin_entry,
|
"paintmargin": self.ui.paintmargin_entry,
|
||||||
"paintmethod": self.ui.paintmethod_combo,
|
"paintmethod": self.ui.paintmethod_combo,
|
||||||
|
"pathconnect": self.ui.pathconnect_cb,
|
||||||
"multidepth": self.ui.mpass_cb,
|
"multidepth": self.ui.mpass_cb,
|
||||||
"depthperpass": self.ui.maxdepth_entry,
|
"depthperpass": self.ui.maxdepth_entry,
|
||||||
"selectmethod": self.ui.selectmethod_combo
|
"selectmethod": self.ui.selectmethod_combo
|
||||||
|
@ -1259,7 +1261,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
overlap = self.options["paintoverlap"]
|
overlap = self.options["paintoverlap"]
|
||||||
|
|
||||||
if self.options["selectmethod"] == "all":
|
if self.options["selectmethod"] == "all":
|
||||||
self.paint_poly_all(tooldia, overlap)
|
self.paint_poly_all(tooldia, overlap,
|
||||||
|
connect=self.option["pathconnect"])
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.options["selectmethod"] == "single":
|
if self.options["selectmethod"] == "single":
|
||||||
|
@ -1270,11 +1273,13 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
self.app.info("Painting polygon...")
|
self.app.info("Painting polygon...")
|
||||||
self.app.plotcanvas.mpl_disconnect(subscription)
|
self.app.plotcanvas.mpl_disconnect(subscription)
|
||||||
point = [event.xdata, event.ydata]
|
point = [event.xdata, event.ydata]
|
||||||
self.paint_poly_single_click(point, tooldia, overlap)
|
self.paint_poly_single_click(point, tooldia, overlap,
|
||||||
|
connect=self.options["pathconnect"])
|
||||||
|
|
||||||
subscription = self.app.plotcanvas.mpl_connect('button_press_event', doit)
|
subscription = self.app.plotcanvas.mpl_connect('button_press_event', doit)
|
||||||
|
|
||||||
def paint_poly_single_click(self, inside_pt, tooldia, overlap, outname=None):
|
def paint_poly_single_click(self, inside_pt, tooldia, overlap,
|
||||||
|
outname=None, connect=True):
|
||||||
"""
|
"""
|
||||||
Paints a polygon selected by clicking on its interior.
|
Paints a polygon selected by clicking on its interior.
|
||||||
|
|
||||||
|
@ -1310,16 +1315,16 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
||||||
if self.options["paintmethod"] == "seed":
|
if self.options["paintmethod"] == "seed":
|
||||||
# Type(cp) == FlatCAMRTreeStorage | None
|
# Type(cp) == FlatCAMRTreeStorage | None
|
||||||
cp = self.clear_polygon2(poly.buffer(-self.options["paintmargin"]),
|
cp = self.clear_polygon2(poly.buffer(-self.options["paintmargin"]),
|
||||||
tooldia, overlap=overlap)
|
tooldia, overlap=overlap, connect=connect)
|
||||||
|
|
||||||
elif self.options["paintmethod"] == "lines":
|
elif self.options["paintmethod"] == "lines":
|
||||||
# Type(cp) == FlatCAMRTreeStorage | None
|
# Type(cp) == FlatCAMRTreeStorage | None
|
||||||
cp = self.clear_polygon3(poly.buffer(-self.options["paintmargin"]),
|
cp = self.clear_polygon3(poly.buffer(-self.options["paintmargin"]),
|
||||||
tooldia, overlap=overlap)
|
tooldia, overlap=overlap, connect=connect)
|
||||||
else:
|
else:
|
||||||
# Type(cp) == FlatCAMRTreeStorage | None
|
# Type(cp) == FlatCAMRTreeStorage | None
|
||||||
cp = self.clear_polygon(poly.buffer(-self.options["paintmargin"]),
|
cp = self.clear_polygon(poly.buffer(-self.options["paintmargin"]),
|
||||||
tooldia, overlap=overlap)
|
tooldia, overlap=overlap, connect=connect)
|
||||||
|
|
||||||
if cp is not None:
|
if cp is not None:
|
||||||
geo_obj.solid_geometry = list(cp.get_objects())
|
geo_obj.solid_geometry = list(cp.get_objects())
|
||||||
|
|
|
@ -16,6 +16,8 @@ class RadioSet(QtGui.QWidget):
|
||||||
* 'value': The value returned is selected
|
* 'value': The value returned is selected
|
||||||
|
|
||||||
:param choices: List of choices. See description.
|
:param choices: List of choices. See description.
|
||||||
|
:param orientation: 'horizontal' (default) of 'vertical'.
|
||||||
|
:param parent: Qt parent widget.
|
||||||
:type choices: list
|
:type choices: list
|
||||||
"""
|
"""
|
||||||
super(RadioSet, self).__init__(parent)
|
super(RadioSet, self).__init__(parent)
|
||||||
|
|
17
ObjectUI.py
17
ObjectUI.py
|
@ -385,6 +385,7 @@ class GeometryObjectUI(ObjectUI):
|
||||||
|
|
||||||
# Method
|
# Method
|
||||||
methodlabel = QtGui.QLabel('Method:')
|
methodlabel = QtGui.QLabel('Method:')
|
||||||
|
methodlabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
|
||||||
methodlabel.setToolTip(
|
methodlabel.setToolTip(
|
||||||
"Algorithm to paint the polygon:<BR>"
|
"Algorithm to paint the polygon:<BR>"
|
||||||
"<B>Standard</B>: Fixed step inwards.<BR>"
|
"<B>Standard</B>: Fixed step inwards.<BR>"
|
||||||
|
@ -395,22 +396,32 @@ class GeometryObjectUI(ObjectUI):
|
||||||
{"label": "Standard", "value": "standard"},
|
{"label": "Standard", "value": "standard"},
|
||||||
{"label": "Seed-based", "value": "seed"},
|
{"label": "Seed-based", "value": "seed"},
|
||||||
{"label": "Straight lines", "value": "lines"}
|
{"label": "Straight lines", "value": "lines"}
|
||||||
])
|
], orientation='vertical')
|
||||||
grid2.addWidget(self.paintmethod_combo, 3, 1)
|
grid2.addWidget(self.paintmethod_combo, 3, 1)
|
||||||
|
|
||||||
|
# Connect lines
|
||||||
|
pathconnectlabel = QtGui.QLabel("Connect:")
|
||||||
|
pathconnectlabel.setToolTip(
|
||||||
|
"Draw lines between resulting\n"
|
||||||
|
"segments to minimize tool lifts."
|
||||||
|
)
|
||||||
|
grid2.addWidget(pathconnectlabel, 4, 0)
|
||||||
|
self.pathconnect_cb = FCCheckBox()
|
||||||
|
grid2.addWidget(self.pathconnect_cb, 4, 1)
|
||||||
|
|
||||||
# Polygon selection
|
# Polygon selection
|
||||||
selectlabel = QtGui.QLabel('Selection:')
|
selectlabel = QtGui.QLabel('Selection:')
|
||||||
selectlabel.setToolTip(
|
selectlabel.setToolTip(
|
||||||
"How to select the polygons to paint."
|
"How to select the polygons to paint."
|
||||||
)
|
)
|
||||||
grid2.addWidget(selectlabel, 4, 0)
|
grid2.addWidget(selectlabel, 5, 0)
|
||||||
#grid3 = QtGui.QGridLayout()
|
#grid3 = QtGui.QGridLayout()
|
||||||
self.selectmethod_combo = RadioSet([
|
self.selectmethod_combo = RadioSet([
|
||||||
{"label": "Single", "value": "single"},
|
{"label": "Single", "value": "single"},
|
||||||
{"label": "All", "value": "all"},
|
{"label": "All", "value": "all"},
|
||||||
#{"label": "Rectangle", "value": "rectangle"}
|
#{"label": "Rectangle", "value": "rectangle"}
|
||||||
])
|
])
|
||||||
grid2.addWidget(self.selectmethod_combo, 4, 1)
|
grid2.addWidget(self.selectmethod_combo, 5, 1)
|
||||||
|
|
||||||
# GO Button
|
# GO Button
|
||||||
self.generate_paint_button = QtGui.QPushButton('Generate')
|
self.generate_paint_button = QtGui.QPushButton('Generate')
|
||||||
|
|
14
camlib.py
14
camlib.py
|
@ -475,7 +475,7 @@ class Geometry(object):
|
||||||
return boundary.difference(self.solid_geometry)
|
return boundary.difference(self.solid_geometry)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clear_polygon(polygon, tooldia, overlap=0.15):
|
def clear_polygon(polygon, tooldia, overlap=0.15, connect=True):
|
||||||
"""
|
"""
|
||||||
Creates geometry inside a polygon for a tool to cover
|
Creates geometry inside a polygon for a tool to cover
|
||||||
the whole area.
|
the whole area.
|
||||||
|
@ -543,13 +543,14 @@ class Geometry(object):
|
||||||
break
|
break
|
||||||
|
|
||||||
# Optimization: Reduce lifts
|
# Optimization: Reduce lifts
|
||||||
log.debug("Reducing tool lifts...")
|
if connect:
|
||||||
geoms = Geometry.paint_connect(geoms, polygon, tooldia)
|
log.debug("Reducing tool lifts...")
|
||||||
|
geoms = Geometry.paint_connect(geoms, polygon, tooldia)
|
||||||
|
|
||||||
return geoms
|
return geoms
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clear_polygon2(polygon, tooldia, seedpoint=None, overlap=0.15):
|
def clear_polygon2(polygon, tooldia, seedpoint=None, overlap=0.15, connect=True):
|
||||||
"""
|
"""
|
||||||
Creates geometry inside a polygon for a tool to cover
|
Creates geometry inside a polygon for a tool to cover
|
||||||
the whole area.
|
the whole area.
|
||||||
|
@ -622,8 +623,9 @@ class Geometry(object):
|
||||||
# geoms = Geometry.path_connect(geoms)
|
# geoms = Geometry.path_connect(geoms)
|
||||||
|
|
||||||
# Optimization: Reduce lifts
|
# Optimization: Reduce lifts
|
||||||
log.debug("Reducing tool lifts...")
|
if connect:
|
||||||
geoms = Geometry.paint_connect(geoms, polygon, tooldia)
|
log.debug("Reducing tool lifts...")
|
||||||
|
geoms = Geometry.paint_connect(geoms, polygon, tooldia)
|
||||||
|
|
||||||
return geoms
|
return geoms
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue