- finished adding in Paint Tool the usage of an external object to set the extent of th area painted. For simple shapes (single Polygon) the shape can be anything, for the rest will be a convex hull of the reference object

- modified NCC tool so for simple objects (single Polygon) the external object used as reference can have any shape, for the other types of objects the copper cleared area will be the convex hull of the reference object
- modified the strings of the app wherever they contained the char seq <b> </b> so it is not included in the translated string
This commit is contained in:
Marius Stanciu
2019-08-18 14:17:46 +03:00
parent 762d949461
commit 36586aecce
10 changed files with 132 additions and 79 deletions

View File

@@ -44,7 +44,7 @@ class DblSidedTool(FlatCAMTool):
self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.gerber_object_combo.setCurrentIndex(1)
self.botlay_label = QtWidgets.QLabel(_("<b>GERBER:</b>"))
self.botlay_label = QtWidgets.QLabel("<b>%s:</b>" % _("GERBER"))
self.botlay_label.setToolTip(
"Gerber to be mirrored."
)
@@ -68,7 +68,7 @@ class DblSidedTool(FlatCAMTool):
self.exc_object_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex()))
self.exc_object_combo.setCurrentIndex(1)
self.excobj_label = QtWidgets.QLabel(_("<b>EXCELLON:</b>"))
self.excobj_label = QtWidgets.QLabel("<b>%s:</b>" % _("EXCELLON"))
self.excobj_label.setToolTip(
_("Excellon Object to be mirrored.")
)
@@ -92,7 +92,7 @@ class DblSidedTool(FlatCAMTool):
self.geo_object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
self.geo_object_combo.setCurrentIndex(1)
self.geoobj_label = QtWidgets.QLabel(_("<b>GEOMETRY</b>:"))
self.geoobj_label = QtWidgets.QLabel("<b>%s</b>:" % _("GEOMETRY"))
self.geoobj_label.setToolTip(
_("Geometry Obj to be mirrored.")
)

View File

@@ -10,10 +10,10 @@ from FlatCAMTool import FlatCAMTool
from copy import copy, deepcopy
from ObjectCollection import *
import time
from shapely.geometry import base
import gettext
import FlatCAMTranslation as fcTranslate
from shapely.geometry import base
import builtins
fcTranslate.apply_language('strings')
@@ -860,12 +860,16 @@ class NonCopperClear(FlatCAMTool, Gerber):
return "Could not retrieve object: %s" % self.obj_name
# Prepare non-copper polygons
geo_n = self.bound_obj.solid_geometry
try:
if not isinstance(self.bound_obj.solid_geometry, MultiPolygon):
if isinstance(geo_n, MultiPolygon):
env_obj = geo_n.convex_hull
elif (isinstance(geo_n, MultiPolygon) and len(geo_n) == 1) or \
(isinstance(geo_n, list) and len(geo_n) == 1) and isinstance(geo_n[0], Polygon):
env_obj = cascaded_union(self.bound_obj.solid_geometry)
else:
env_obj = cascaded_union(self.bound_obj.solid_geometry)
env_obj = env_obj.convex_hull
else:
env_obj = self.bound_obj.solid_geometry.convex_hull
bounding_box = env_obj.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre)
except Exception as e:
log.debug("NonCopperClear.on_ncc() --> %s" % str(e))

View File

@@ -9,6 +9,7 @@
from FlatCAMTool import FlatCAMTool
from copy import copy, deepcopy
from ObjectCollection import *
from shapely.geometry import base
import gettext
import FlatCAMTranslation as fcTranslate
@@ -238,19 +239,27 @@ class ToolPaint(FlatCAMTool, Gerber):
selectlabel.setToolTip(
_("How to select the polygons to paint.<BR>"
"Options:<BR>"
"- <B>Single</B>: left mouse click on the polygon to be painted.<BR>"
"- <B>Area</B>: left mouse click to start selection of the area to be painted.<BR>"
"- <B>All</B>: paint all polygons.<BR>"
"- <B>Ref</B>: paint an area described by an external reference object.")
"- <B>Single Polygons</B>: left mouse click on the polygon to be painted.<BR>"
"- <B>Area Selection</B>: left mouse click to start selection of the area to be painted.<BR>"
"- <B>All Polygons</B>: paint all polygons.<BR>"
"- <B>Reference Object</B>: paint an area described by an external reference object.")
)
grid3.addWidget(selectlabel, 7, 0)
# grid3 = QtWidgets.QGridLayout()
self.selectmethod_combo = RadioSet([
{"label": _("Single"), "value": "single"},
{"label": _("Area"), "value": "area"},
{"label": _("All"), "value": "all"},
{"label": _("Ref."), "value": "ref"}
])
{"label": _("Single Polygon"), "value": "single"},
{"label": _("Area Selection"), "value": "area"},
{"label": _("All Polygons"), "value": "all"},
{"label": _("Reference Object"), "value": "ref"}
], orientation='vertical', stretch=False)
self.selectmethod_combo.setToolTip(
_("How to select the polygons to paint.<BR>"
"Options:<BR>"
"- <B>Single Polygons</B>: left mouse click on the polygon to be painted.<BR>"
"- <B>Area Selection</B>: left mouse click to start selection of the area to be painted.<BR>"
"- <B>All Polygons</B>: paint all polygons.<BR>"
"- <B>Reference Object</B>: paint an area described by an external reference object.")
)
grid3.addWidget(self.selectmethod_combo, 7, 1)
grid4 = QtWidgets.QGridLayout()
@@ -950,6 +959,38 @@ class ToolPaint(FlatCAMTool, Gerber):
self.app.plotcanvas.vis_connect('mouse_press', on_mouse_press)
self.app.plotcanvas.vis_connect('mouse_move', on_mouse_move)
elif select_method == 'ref':
self.bound_obj_name = self.box_combo.currentText()
# Get source object.
try:
self.bound_obj = self.app.collection.get_by_name(self.bound_obj_name)
except Exception as e:
self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.obj_name)
return "Could not retrieve object: %s" % self.obj_name
geo = self.bound_obj.solid_geometry
try:
if isinstance(geo, MultiPolygon):
env_obj = geo.convex_hull
elif (isinstance(geo, MultiPolygon) and len(geo) == 1) or \
(isinstance(geo, list) and len(geo) == 1) and isinstance(geo[0], Polygon):
env_obj = cascaded_union(self.bound_obj.solid_geometry)
else:
env_obj = cascaded_union(self.bound_obj.solid_geometry)
env_obj = env_obj.convex_hull
sel_rect = env_obj.buffer(distance=0.0000001, join_style=base.JOIN_STYLE.mitre)
except Exception as e:
log.debug("ToolPaint.on_paint_button_click() --> %s" % str(e))
self.app.inform.emit(_("[ERROR_NOTCL] No object available."))
return
self.paint_poly_area(obj=self.paint_obj,
sel_obj=sel_rect,
outname=o_name,
overlap=overlap,
connect=connect,
contour=contour)
def paint_poly(self, obj, inside_pt, tooldia, overlap, outname=None, connect=True, contour=True):
"""
Paints a polygon selected by clicking on its interior.

View File

@@ -83,7 +83,7 @@ class Panelize(FlatCAMTool):
# Type of box Panel object
self.reference_radio = RadioSet([{'label': _('Object'), 'value': 'object'},
{'label': _('Bounding Box'), 'value': 'bbox'}])
self.box_label = QtWidgets.QLabel(_("<b>Penelization Reference:</b>"))
self.box_label = QtWidgets.QLabel("<b>%s:</b>" % _("Penelization Reference"))
self.box_label.setToolTip(
_("Choose the reference for panelization:\n"
"- Object = the bounding box of a different object\n"
@@ -131,7 +131,7 @@ class Panelize(FlatCAMTool):
form_layout.addRow(self.box_combo_label, self.box_combo)
form_layout.addRow(QtWidgets.QLabel(""))
panel_data_label = QtWidgets.QLabel(_("<b>Panel Data:</b>"))
panel_data_label = QtWidgets.QLabel("<b>%s:</b>" % _("Panel Data"))
panel_data_label.setToolTip(
_("This informations will shape the resulting panel.\n"
"The number of rows and columns will set how many\n"
@@ -180,7 +180,7 @@ class Panelize(FlatCAMTool):
# Type of resulting Panel object
self.panel_type_radio = RadioSet([{'label': _('Gerber'), 'value': 'gerber'},
{'label': _('Geo'), 'value': 'geometry'}])
self.panel_type_label = QtWidgets.QLabel(_("<b>Panel Type:</b>"))
self.panel_type_label = QtWidgets.QLabel("<b>%s:</b>" % _("Panel Type"))
self.panel_type_label.setToolTip(
_("Choose the type of object for the panel object:\n"
"- Geometry\n"

View File

@@ -48,7 +48,7 @@ class PcbWizard(FlatCAMTool):
self.layout.addWidget(title_label)
self.layout.addWidget(QtWidgets.QLabel(""))
self.layout.addWidget(QtWidgets.QLabel(_("<b>Load files:</b>")))
self.layout.addWidget(QtWidgets.QLabel("<b>%s:</b>" % _("Load files")))
# Form Layout
form_layout = QtWidgets.QFormLayout()
@@ -84,7 +84,7 @@ class PcbWizard(FlatCAMTool):
self.tools_table.setVisible(False)
self.layout.addWidget(QtWidgets.QLabel(""))
self.layout.addWidget(QtWidgets.QLabel(_("<b>Excellon format:</b>")))
self.layout.addWidget(QtWidgets.QLabel("<b>%s:</b>" % _("Excellon format")))
# Form Layout
form_layout1 = QtWidgets.QFormLayout()
self.layout.addLayout(form_layout1)

View File

@@ -52,7 +52,7 @@ class ToolSub(FlatCAMTool):
form_layout = QtWidgets.QFormLayout()
self.tools_box.addLayout(form_layout)
self.gerber_title = QtWidgets.QLabel(_("<b>Gerber Objects</b>"))
self.gerber_title = QtWidgets.QLabel("<b>%s</b>" % _("Gerber Objects"))
form_layout.addRow(self.gerber_title)
# Target Gerber Object
@@ -98,7 +98,7 @@ class ToolSub(FlatCAMTool):
form_geo_layout = QtWidgets.QFormLayout()
self.tools_box.addLayout(form_geo_layout)
self.geo_title = QtWidgets.QLabel(_("<b>Geometry Objects</b>"))
self.geo_title = QtWidgets.QLabel("<b>%s</b>" % _("Geometry Objects"))
form_geo_layout.addRow(self.geo_title)
# Target Geometry Object