- in Markers Plugin replaced the Margin parameters with the Offset parameters that now can be referenced either to the edge of the bounding box (effectively replacing the old Margin parameter) or to the center of the bounding box

- Distance Plugin Ui was upgraded
- updated the language strings
This commit is contained in:
Marius Stanciu
2021-10-10 01:37:09 +03:00
parent 1c42efdcdf
commit aef9d97dd7
32 changed files with 28627 additions and 27682 deletions

View File

@@ -9,7 +9,7 @@ from PyQt6 import QtWidgets, QtCore
from appTool import AppTool
from appGUI.VisPyVisuals import *
from appGUI.GUIElements import FCEntry, FCButton, FCCheckBox, FCLabel, VerticalScrollArea, FCGridLayout
from appGUI.GUIElements import FCEntry, FCButton, FCCheckBox, FCLabel, VerticalScrollArea, FCGridLayout, FCFrame
from shapely.geometry import Point, MultiLineString, Polygon
@@ -161,13 +161,15 @@ class Distance(AppTool):
# snap center works only for Gerber and Execellon Editor's
if self.original_call_source == 'exc_editor' or self.original_call_source == 'grb_editor':
self.ui.snap_center_cb.show()
self.ui.param_label.show()
self.ui.par_frame.show()
snap_center = self.app.defaults['tools_dist_snap_center']
self.on_snap_toggled(snap_center)
self.ui.snap_center_cb.toggled.connect(self.on_snap_toggled)
else:
self.ui.snap_center_cb.hide()
self.ui.param_label.hide()
self.ui.par_frame.hide()
try:
self.ui.snap_center_cb.toggled.disconnect(self.on_snap_toggled)
except (TypeError, AttributeError):
@@ -488,7 +490,7 @@ class Distance(AppTool):
# )
self.app.ui.update_location_labels(dx=None, dy=None, x=pos[0], y=pos[1])
units = self.app.app_units.lower()
# units = self.app.app_units.lower()
# self.app.plotcanvas.text_hud.text = \
# 'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX: \t{:<.4f} [{:s}]\nY: \t{:<.4f} [{:s}]'.format(
# 0.0000, units, 0.0000, units, pos[0], units, pos[1], units)
@@ -578,42 +580,41 @@ class DistUI:
title_label = FCLabel("<font size=4><b>%s</b></font><br>" % self.pluginName)
self.layout.addWidget(title_label)
# ## Form Layout
grid0 = FCGridLayout(v_spacing=5, h_spacing=3)
self.layout.addLayout(grid0)
# #############################################################################################################
# Parameters Frame
# #############################################################################################################
self.param_label = FCLabel('<span style="color:blue;"><b>%s</b></span>' % _('Parameters'))
self.layout.addWidget(self.param_label)
self.units_label = FCLabel('%s:' % _("Units"))
self.units_label.setToolTip(_("Those are the units in which the distance is measured."))
self.units_value = FCLabel("%s" % str({'mm': _("METRIC (mm)"), 'in': _("INCH (in)")}[self.units]))
self.units_value.setDisabled(True)
self.par_frame = FCFrame()
self.layout.addWidget(self.par_frame)
grid0.addWidget(self.units_label, 0, 0)
grid0.addWidget(self.units_value, 0, 1)
grid0.addWidget(FCLabel(""), 2, 0, 1, 2)
param_grid = FCGridLayout(v_spacing=5, h_spacing=3)
self.par_frame.setLayout(param_grid)
self.snap_center_cb = FCCheckBox(_("Snap to center"))
self.snap_center_cb.setToolTip(
_("Mouse cursor will snap to the center of the pad/drill\n"
"when it is hovering over the geometry of the pad/drill.")
)
grid0.addWidget(self.snap_center_cb, 4, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 6, 0, 1, 2)
param_grid.addWidget(self.snap_center_cb, 0, 0, 1, 2)
# #############################################################################################################
# Coordinates
# Coordinates Frame
# #############################################################################################################
coords_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _('Coordinates'))
grid0.addWidget(coords_label, 4, 0, 1, 2)
self.coords_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _('Coordinates'))
self.layout.addWidget(self.coords_label)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 6, 0, 1, 2)
coords_frame = FCFrame()
self.layout.addWidget(coords_frame)
coords_grid = FCGridLayout(v_spacing=5, h_spacing=3)
coords_frame.setLayout(coords_grid)
# separator_line = QtWidgets.QFrame()
# separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
# separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
# param_grid.addWidget(separator_line, 6, 0, 1, 2)
self.start_label = FCLabel("%s:" % _('Start point'))
self.start_label.setToolTip(_("This is measuring Start point coordinates."))
@@ -623,8 +624,9 @@ class DistUI:
self.start_entry.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight | QtCore.Qt.AlignmentFlag.AlignVCenter)
self.start_entry.setToolTip(_("This is measuring Start point coordinates."))
grid0.addWidget(self.start_label, 8, 0)
grid0.addWidget(self.start_entry, 8, 1)
coords_grid.addWidget(self.start_label, 0, 0)
coords_grid.addWidget(self.start_entry, 0, 1)
coords_grid.addWidget(FCLabel("%s" % self.units), 0, 2)
self.stop_label = FCLabel("%s:" % _('End point'))
self.stop_label.setToolTip(_("This is the measuring Stop point coordinates."))
@@ -634,13 +636,14 @@ class DistUI:
self.stop_entry.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight | QtCore.Qt.AlignmentFlag.AlignVCenter)
self.stop_entry.setToolTip(_("This is the measuring Stop point coordinates."))
grid0.addWidget(self.stop_label, 10, 0)
grid0.addWidget(self.stop_entry, 10, 1)
coords_grid.addWidget(self.stop_label, 2, 0)
coords_grid.addWidget(self.stop_entry, 2, 1)
coords_grid.addWidget(FCLabel("%s" % self.units), 2, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 12, 0, 1, 2)
coords_grid.addWidget(separator_line, 4, 0, 1, 3)
self.distance_x_label = FCLabel('%s:' % _("Dx"))
self.distance_x_label.setToolTip(_("This is the distance measured over the X axis."))
@@ -650,8 +653,9 @@ class DistUI:
self.distance_x_entry.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight | QtCore.Qt.AlignmentFlag.AlignVCenter)
self.distance_x_entry.setToolTip(_("This is the distance measured over the X axis."))
grid0.addWidget(self.distance_x_label, 14, 0)
grid0.addWidget(self.distance_x_entry, 14, 1)
coords_grid.addWidget(self.distance_x_label, 6, 0)
coords_grid.addWidget(self.distance_x_entry, 6, 1)
coords_grid.addWidget(FCLabel("%s" % self.units), 6, 2)
self.distance_y_label = FCLabel('%s:' % _("Dy"))
self.distance_y_label.setToolTip(_("This is the distance measured over the Y axis."))
@@ -661,8 +665,9 @@ class DistUI:
self.distance_y_entry.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight | QtCore.Qt.AlignmentFlag.AlignVCenter)
self.distance_y_entry.setToolTip(_("This is the distance measured over the Y axis."))
grid0.addWidget(self.distance_y_label, 16, 0)
grid0.addWidget(self.distance_y_entry, 16, 1)
coords_grid.addWidget(self.distance_y_label, 8, 0)
coords_grid.addWidget(self.distance_y_entry, 8, 1)
coords_grid.addWidget(FCLabel("%s" % self.units), 8, 2)
self.angle_label = FCLabel('%s:' % _("Angle"))
self.angle_label.setToolTip(_("This is orientation angle of the measuring line."))
@@ -672,32 +677,41 @@ class DistUI:
self.angle_entry.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight | QtCore.Qt.AlignmentFlag.AlignVCenter)
self.angle_entry.setToolTip(_("This is orientation angle of the measuring line."))
grid0.addWidget(self.angle_label, 18, 0)
grid0.addWidget(self.angle_entry, 18, 1)
coords_grid.addWidget(self.angle_label, 10, 0)
coords_grid.addWidget(self.angle_entry, 10, 1)
coords_grid.addWidget(FCLabel("%s" % "°"), 10, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 20, 0, 1, 2)
# #############################################################################################################
# Coordinates Frame
# #############################################################################################################
self.res_label = FCLabel('<span style="color:red;"><b>%s</b></span>' % _('Results'))
self.layout.addWidget(self.res_label)
res_label = FCLabel('<span style="color:red;"><b>%s</b></span>' % _('Results'))
grid0.addWidget(res_label, 22, 0, 1, 2)
res_frame = FCFrame()
self.layout.addWidget(res_frame)
res_grid = FCGridLayout(v_spacing=5, h_spacing=3)
res_frame.setLayout(res_grid)
self.total_distance_label = FCLabel("<b>%s:</b>" % _('DISTANCE'))
self.total_distance_label.setToolTip(_("This is the point to point Euclidian distance."))
self.total_distance_entry = FCEntry()
self.total_distance_entry.setReadOnly(True)
self.total_distance_entry.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight | QtCore.Qt.AlignmentFlag.AlignVCenter)
self.total_distance_entry.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight |
QtCore.Qt.AlignmentFlag.AlignVCenter)
self.total_distance_entry.setToolTip(_("This is the point to point Euclidian distance."))
grid0.addWidget(self.total_distance_label, 24, 0)
grid0.addWidget(self.total_distance_entry, 24, 1)
res_grid.addWidget(self.total_distance_label, 0, 0)
res_grid.addWidget(self.total_distance_entry, 0, 1)
res_grid.addWidget(FCLabel("%s" % self.units), 0, 2)
# Buttons
self.measure_btn = FCButton(_("Measure"))
# self.measure_btn.setFixedWidth(70)
self.layout.addWidget(self.measure_btn)
FCGridLayout.set_common_column_size([param_grid, coords_grid, res_grid], 0)
self.layout.addStretch(1)
# #################################### FINSIHED GUI ###########################

View File

@@ -968,9 +968,8 @@ class FidoUI:
par_frame = FCFrame()
self.tools_box.addWidget(par_frame)
# ## Grid Layout
grid_par = FCGridLayout(v_spacing=5, h_spacing=3)
par_frame.setLayout(grid_par)
param_grid = FCGridLayout(v_spacing=5, h_spacing=3)
par_frame.setLayout(param_grid)
# DIAMETER #
self.size_label = FCLabel('%s:' % _("Size"))
@@ -985,8 +984,8 @@ class FidoUI:
self.fid_size_entry.setWrapping(True)
self.fid_size_entry.setSingleStep(0.1)
grid_par.addWidget(self.size_label, 2, 0)
grid_par.addWidget(self.fid_size_entry, 2, 1)
param_grid.addWidget(self.size_label, 2, 0)
param_grid.addWidget(self.fid_size_entry, 2, 1)
# MARGIN #
self.margin_label = FCLabel('%s:' % _("Margin"))
@@ -998,8 +997,8 @@ class FidoUI:
self.margin_entry.set_precision(self.decimals)
self.margin_entry.setSingleStep(0.1)
grid_par.addWidget(self.margin_label, 4, 0)
grid_par.addWidget(self.margin_entry, 4, 1)
param_grid.addWidget(self.margin_label, 4, 0)
param_grid.addWidget(self.margin_entry, 4, 1)
# Position for second fiducial #
self.pos_radio = RadioSet([
@@ -1014,13 +1013,13 @@ class FidoUI:
"- 'Down' - the order is: bottom-left, bottom-right, top-right.\n"
"- 'None' - there is no second fiducial. The order is: bottom-left, top-right.")
)
grid_par.addWidget(self.pos_label, 6, 0)
grid_par.addWidget(self.pos_radio, 6, 1)
param_grid.addWidget(self.pos_label, 6, 0)
param_grid.addWidget(self.pos_radio, 6, 1)
self.separator_line = QtWidgets.QFrame()
self.separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
self.separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid_par.addWidget(self.separator_line, 8, 0, 1, 2)
param_grid.addWidget(self.separator_line, 8, 0, 1, 2)
# Fiducial type #
self.fid_type_label = FCLabel('%s:' % _("Fiducial Type"))
@@ -1034,8 +1033,8 @@ class FidoUI:
self.fid_type_combo = FCComboBox2()
self.fid_type_combo.addItems([_('Circular'), _("Cross"), _("Chess")])
grid_par.addWidget(self.fid_type_label, 10, 0)
grid_par.addWidget(self.fid_type_combo, 10, 1)
param_grid.addWidget(self.fid_type_label, 10, 0)
param_grid.addWidget(self.fid_type_combo, 10, 1)
# Line Thickness #
self.line_thickness_label = FCLabel('%s:' % _("Line thickness"))
@@ -1047,13 +1046,13 @@ class FidoUI:
self.line_thickness_entry.set_precision(self.decimals)
self.line_thickness_entry.setSingleStep(0.1)
grid_par.addWidget(self.line_thickness_label, 12, 0)
grid_par.addWidget(self.line_thickness_entry, 12, 1)
param_grid.addWidget(self.line_thickness_label, 12, 0)
param_grid.addWidget(self.line_thickness_entry, 12, 1)
# separator_line_1 = QtWidgets.QFrame()
# separator_line_1.setFrameShape(QtWidgets.QFrame.Shape.HLine)
# separator_line_1.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
# grid_par.addWidget(separator_line_1, 14, 0, 1, 2)
# param_grid.addWidget(separator_line_1, 14, 0, 1, 2)
# #############################################################################################################
# Selection Frame
@@ -1081,7 +1080,7 @@ class FidoUI:
grid_sel.addWidget(self.mode_label, 0, 0)
grid_sel.addWidget(self.mode_radio, 0, 1)
FCGridLayout.set_common_column_size([grid_sel, grid_par, grid_par], 0)
FCGridLayout.set_common_column_size([grid_sel, param_grid, param_grid], 0)
# ## Insert Copper Fiducial
self.add_cfid_button = FCButton(_("Add Fiducial"))

View File

@@ -30,7 +30,7 @@ if '_' not in builtins.__dict__:
log = logging.getLogger('base')
class ToolCorners(AppTool):
class ToolMarkers(AppTool):
def __init__(self, app):
AppTool.__init__(self, app)
@@ -48,7 +48,7 @@ class ToolCorners(AppTool):
# #############################################################################
# ######################### Tool GUI ##########################################
# #############################################################################
self.ui = CornersUI(layout=self.layout, app=self.app)
self.ui = MarkersUI(layout=self.layout, app=self.app)
self.pluginName = self.ui.pluginName
self.connect_signals_at_init()
@@ -95,7 +95,7 @@ class ToolCorners(AppTool):
pass
def run(self, toggle=True):
self.app.defaults.report_usage("ToolCorners()")
self.app.defaults.report_usage("ToolMarkers()")
if toggle:
# if the splitter is hidden, display it
@@ -173,16 +173,17 @@ class ToolCorners(AppTool):
self.units = self.app.app_units
self.clear_ui(self.layout)
self.ui = CornersUI(layout=self.layout, app=self.app)
self.ui = MarkersUI(layout=self.layout, app=self.app)
self.pluginName = self.ui.pluginName
self.connect_signals_at_init()
self.ui.thick_entry.set_value(self.app.defaults["tools_markers_thickness"])
self.ui.l_entry.set_value(float(self.app.defaults["tools_markers_length"]))
self.ui.marginx_entry.set_value(float(self.app.defaults["tools_markers_marginx"]))
self.ui.marginy_entry.set_value(float(self.app.defaults["tools_markers_marginy"]))
self.ui.margin_link_button.setChecked(True)
self.ui.ref_radio.set_value(self.app.defaults["tools_markers_reference"])
self.ui.offset_x_entry.set_value(float(self.app.defaults["tools_markers_offset_x"]))
self.ui.offset_y_entry.set_value(float(self.app.defaults["tools_markers_offset_y"]))
self.ui.offset_link_button.setChecked(True)
self.ui.on_link_checked(True)
self.ui.toggle_all_cb.set_value(False)
@@ -273,16 +274,14 @@ class ToolCorners(AppTool):
self.ui.type_label.setDisabled(False)
self.ui.type_radio.setDisabled(False)
self.ui.marginx_label.setDisabled(False)
self.ui.marginx_entry.setDisabled(False)
self.ui.off_frame.setDisabled(False)
else:
self.ui.locs_label.setDisabled(True)
self.ui.loc_frame.setDisabled(True)
self.ui.type_label.setDisabled(True)
self.ui.type_radio.setDisabled(True)
self.ui.marginx_label.setDisabled(True)
self.ui.marginx_entry.setDisabled(True)
self.ui.off_frame.setDisabled(True)
self.ui.type_radio.set_value('c')
def add_markers(self):
@@ -312,7 +311,7 @@ class ToolCorners(AppTool):
try:
self.grb_object = model_index.internalPointer().obj
except Exception as e:
log.error("ToolCorners.add_markers() --> %s" % str(e))
log.error("ToolMarkers.add_markers() --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
self.app.call_source = "app"
return
@@ -347,7 +346,7 @@ class ToolCorners(AppTool):
try:
self.grb_object = model_index.internalPointer().obj
except Exception as e:
log.error("ToolCorners.add_markers() --> %s" % str(e))
log.error("ToolMarkers.add_markers() --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
self.on_exit()
return
@@ -379,15 +378,72 @@ class ToolCorners(AppTool):
return return_val
# def offset_location_from_bb_center(self, pt):
# """
# Will offset a set of x, y coordinates
# from the center of the source object bounding box.
#
# :param pt: x, y coordinates of a location point
# :type pt: tuple
# :return: an offseted point pt from the center of the bounding box
# """
def offset_values(self, offset_reference=None, offset_x=None, offset_y=None):
"""
Will offset a set of x, y coordinates depending on the chosen reference
:param offset_reference: can be 'c' = center of the bounding box or 'e' = edge of the bounding box
:type offset_reference: str
:param offset_x: value to offset on X axis
:type offset_x: float
:param offset_y: value to offset on Y axis
:type offset_y: float
:return: a tuple of offsets (x, y)
:rtype: tuple
"""
if offset_reference is None:
offset_reference = self.ui.ref_radio.get_value()
if offset_x is None:
offset_x = self.ui.offset_x_entry.get_value()
if offset_y is None:
offset_y = self.ui.offset_y_entry.get_value()
if offset_reference == 'c': # reference from the bounding box center
# get the Gerber object on which the corner marker will be inserted
selection_index = self.ui.object_combo.currentIndex()
model_index = self.app.collection.index(selection_index, 0, self.ui.object_combo.rootModelIndex())
try:
self.grb_object = model_index.internalPointer().obj
except Exception as e:
log.error("ToolMarkers.add_markers() --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
self.on_exit()
return
xmin, ymin, xmax, ymax = self.grb_object.bounds()
center_x = xmin + (xmax - xmin) / 2
center_y = ymin + (ymax - ymin) / 2
offset_x -= center_x
offset_y -= center_y
return offset_x, offset_y
def create_marker_geometry(self, points_storage):
"""
Will create the marker geometry in the specified points.
:param points_storage: a dictionary holding the marker locations
:type points_storage: dict
:return: a list of Shapely lines
:rtype: list
"""
marker_type = self.ui.type_radio.get_value()
line_thickness = self.ui.thick_entry.get_value()
margin_x = self.ui.marginx_entry.get_value()
margin_y = self.ui.marginy_entry.get_value()
line_length = self.ui.l_entry.get_value() / 2.0
mode = self.ui.mode_radio.get_value()
offset_x, offset_y = self.offset_values()
geo_list = []
if not points_storage:
@@ -398,8 +454,8 @@ class ToolCorners(AppTool):
for key in points_storage:
if key == 'tl':
pt = points_storage[key]
x = pt[0] - margin_x - line_thickness / 2.0
y = pt[1] + margin_y + line_thickness / 2.0
x = pt[0] - offset_x - line_thickness / 2.0
y = pt[1] + offset_y + line_thickness / 2.0
if marker_type == 's':
line_geo_hor = LineString([
(x, y), (x + line_length, y)
@@ -418,8 +474,8 @@ class ToolCorners(AppTool):
geo_list.append(line_geo_vert)
if key == 'tr':
pt = points_storage[key]
x = pt[0] + margin_x + line_thickness / 2.0
y = pt[1] + margin_y + line_thickness / 2.0
x = pt[0] + offset_x + line_thickness / 2.0
y = pt[1] + offset_y + line_thickness / 2.0
if marker_type == 's':
line_geo_hor = LineString([
(x, y), (x - line_length, y)
@@ -438,8 +494,8 @@ class ToolCorners(AppTool):
geo_list.append(line_geo_vert)
if key == 'bl':
pt = points_storage[key]
x = pt[0] - margin_x - line_thickness / 2.0
y = pt[1] - margin_y - line_thickness / 2.0
x = pt[0] - offset_x - line_thickness / 2.0
y = pt[1] - offset_y - line_thickness / 2.0
if marker_type == 's':
line_geo_hor = LineString([
(x, y), (x + line_length, y)
@@ -458,8 +514,8 @@ class ToolCorners(AppTool):
geo_list.append(line_geo_vert)
if key == 'br':
pt = points_storage[key]
x = pt[0] + margin_x + line_thickness / 2.0
y = pt[1] - margin_y - line_thickness / 2.0
x = pt[0] + offset_x + line_thickness / 2.0
y = pt[1] - offset_y - line_thickness / 2.0
if marker_type == 's':
line_geo_hor = LineString([
(x, y), (x - line_length, y)
@@ -689,9 +745,6 @@ class ToolCorners(AppTool):
return
line_thickness = self.ui.thick_entry.get_value()
margin_x = self.ui.marginx_entry.get_value()
margin_y = self.ui.marginy_entry.get_value()
tl_state = self.ui.tl_cb.get_value()
tr_state = self.ui.tr_cb.get_value()
bl_state = self.ui.bl_cb.get_value()
@@ -704,7 +757,7 @@ class ToolCorners(AppTool):
try:
self.grb_object = model_index.internalPointer().obj
except Exception as e:
log.error("ToolCorners.add_markers() --> %s" % str(e))
log.error("ToolMarkers.add_markers() --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
self.app.call_source = "app"
return
@@ -716,35 +769,36 @@ class ToolCorners(AppTool):
return
xmin, ymin, xmax, ymax = self.grb_object.bounds()
offset_x, offset_y = self.offset_values()
# list of (x,y) tuples. Store here the drill coordinates
drill_list = []
if 'manual' not in self.points:
if tl_state:
x = xmin - margin_x - line_thickness / 2.0
y = ymax + margin_y + line_thickness / 2.0
x = xmin - offset_x - line_thickness / 2.0
y = ymax + offset_y + line_thickness / 2.0
drill_list.append(
Point((x, y))
)
if tr_state:
x = xmax + margin_x + line_thickness / 2.0
y = ymax + margin_y + line_thickness / 2.0
x = xmax + offset_x + line_thickness / 2.0
y = ymax + offset_y + line_thickness / 2.0
drill_list.append(
Point((x, y))
)
if bl_state:
x = xmin - margin_x - line_thickness / 2.0
y = ymin - margin_y - line_thickness / 2.0
x = xmin - offset_x - line_thickness / 2.0
y = ymin - offset_y - line_thickness / 2.0
drill_list.append(
Point((x, y))
)
if br_state:
x = xmax + margin_x + line_thickness / 2.0
y = ymin - margin_y - line_thickness / 2.0
x = xmax + offset_x + line_thickness / 2.0
y = ymin - offset_y - line_thickness / 2.0
drill_list.append(
Point((x, y))
)
@@ -800,9 +854,6 @@ class ToolCorners(AppTool):
return
line_thickness = self.ui.thick_entry.get_value()
margin_x = self.ui.marginx_entry.get_value()
margin_y = self.ui.marginy_entry.get_value()
tl_state = self.ui.tl_cb.get_value()
tr_state = self.ui.tr_cb.get_value()
bl_state = self.ui.bl_cb.get_value()
@@ -815,7 +866,7 @@ class ToolCorners(AppTool):
try:
self.grb_object = model_index.internalPointer().obj
except Exception as e:
log.error("ToolCorners.add_markers() --> %s" % str(e))
log.error("ToolMarkers.add_markers() --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
self.app.call_source = "app"
return
@@ -827,35 +878,36 @@ class ToolCorners(AppTool):
return
xmin, ymin, xmax, ymax = self.grb_object.bounds()
offset_x, offset_y = self.offset_values()
# list of (x,y) tuples. Store here the drill coordinates
drill_list = []
if 'manual' not in self.points:
if tl_state:
x = xmin - margin_x - line_thickness / 2.0
y = ymax + margin_y + line_thickness / 2.0
x = xmin - offset_x - line_thickness / 2.0
y = ymax + offset_y + line_thickness / 2.0
drill_list.append(
Point((x, y))
)
if tr_state:
x = xmax + margin_x + line_thickness / 2.0
y = ymax + margin_y + line_thickness / 2.0
x = xmax + offset_x + line_thickness / 2.0
y = ymax + offset_y + line_thickness / 2.0
drill_list.append(
Point((x, y))
)
if bl_state:
x = xmin - margin_x - line_thickness / 2.0
y = ymin - margin_y - line_thickness / 2.0
x = xmin - offset_x - line_thickness / 2.0
y = ymin - offset_y - line_thickness / 2.0
drill_list.append(
Point((x, y))
)
if br_state:
x = xmax + margin_x + line_thickness / 2.0
y = ymin - margin_y - line_thickness / 2.0
x = xmax + offset_x + line_thickness / 2.0
y = ymin - offset_y - line_thickness / 2.0
drill_list.append(
Point((x, y))
)
@@ -926,7 +978,7 @@ class ToolCorners(AppTool):
try:
new_grb_obj = model_index.internalPointer().obj
except Exception as e:
self.app.log.error("ToolCorners.on_insert_markers_in_external_objects() Gerber --> %s" % str(e))
self.app.log.error("ToolMarkers.on_insert_markers_in_external_objects() Gerber --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
self.app.call_source = "app"
return
@@ -941,7 +993,7 @@ class ToolCorners(AppTool):
try:
new_geo_obj = self.app.collection.get_by_name(geo_obj_name)
except Exception as e:
self.app.log.error("ToolCorners.on_insert_markers_in_external_objects() Geometry --> %s" % str(e))
self.app.log.error("ToolMarkers.on_insert_markers_in_external_objects() Geometry --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Geometry object available."))
self.app.call_source = "app"
return
@@ -992,7 +1044,7 @@ class ToolCorners(AppTool):
self.grb_object.options['xmax'] = c
self.grb_object.options['ymax'] = d
except Exception as e:
log.error("ToolCorners.on_exit() copper_obj bounds error --> %s" % str(e))
log.error("ToolMarkers.on_exit() copper_obj bounds error --> %s" % str(e))
self.app.call_source = "app"
self.app.ui.notebook.setDisabled(False)
@@ -1067,7 +1119,7 @@ class ToolCorners(AppTool):
self.handle_manual_placement()
class CornersUI:
class MarkersUI:
pluginName = _("Markers")
@@ -1158,7 +1210,7 @@ class CornersUI:
])
param_grid.addWidget(self.type_label, 2, 0)
param_grid.addWidget(self.type_radio, 2, 1, 1, 2)
param_grid.addWidget(self.type_radio, 2, 1)
# Thickness #
self.thick_label = FCLabel('%s:' % _("Thickness"))
@@ -1172,7 +1224,7 @@ class CornersUI:
self.thick_entry.setSingleStep(10 ** -self.decimals)
param_grid.addWidget(self.thick_label, 4, 0)
param_grid.addWidget(self.thick_entry, 4, 1, 1, 2)
param_grid.addWidget(self.thick_entry, 4, 1)
# Length #
self.l_label = FCLabel('%s:' % _("Length"))
@@ -1185,41 +1237,70 @@ class CornersUI:
self.l_entry.setSingleStep(10 ** -self.decimals)
param_grid.addWidget(self.l_label, 6, 0)
param_grid.addWidget(self.l_entry, 6, 1, 1, 2)
param_grid.addWidget(self.l_entry, 6, 1)
# Margin X #
self.marginx_label = FCLabel('%s X:' % _("Margin"))
self.marginx_label.setToolTip(
_("Bounding box margin.")
# #############################################################################################################
# Offset Frame
# #############################################################################################################
self.offset_title_label = FCLabel('<span style="color:magenta;"><b>%s</b></span>' % _('Offset'))
self.offset_title_label.setToolTip(_("Offset locations from the set reference."))
self.tools_box.addWidget(self.offset_title_label)
self.off_frame = FCFrame()
self.tools_box.addWidget(self.off_frame)
off_grid = FCGridLayout(v_spacing=5, h_spacing=3)
self.off_frame.setLayout(off_grid)
# Offset Reference
self.ref_label = FCLabel('%s:' % _("Reference"))
self.ref_label.setToolTip(
_("Reference for offseting the marker locations.\n"
"- Edge - referenced from the bounding box edge\n"
"- Center - referenced from the bounding box center")
)
self.marginx_entry = FCDoubleSpinner(callback=self.confirmation_message)
self.marginx_entry.set_range(-10000.0000, 10000.0000)
self.marginx_entry.set_precision(self.decimals)
self.marginx_entry.setSingleStep(0.1)
param_grid.addWidget(self.marginx_label, 8, 0)
param_grid.addWidget(self.marginx_entry, 8, 1)
self.ref_radio = RadioSet([
{"label": _("Edge"), "value": "e"},
{"label": _("Center"), "value": "c"},
])
# Margin Y #
self.marginy_label = FCLabel('%s Y:' % _("Margin"))
self.marginy_label.setToolTip(
_("Bounding box margin.")
off_grid.addWidget(self.ref_label, 0, 0)
off_grid.addWidget(self.ref_radio, 0, 1, 1, 2)
# Offset X #
self.offset_x_label = FCLabel('%s X:' % _("Offset"))
self.offset_x_label.setToolTip(
_("Offset on the X axis.")
)
self.marginy_entry = FCDoubleSpinner(callback=self.confirmation_message)
self.marginy_entry.set_range(-10000.0000, 10000.0000)
self.marginy_entry.set_precision(self.decimals)
self.marginy_entry.setSingleStep(0.1)
self.offset_x_entry = FCDoubleSpinner(callback=self.confirmation_message)
self.offset_x_entry.set_range(-10000.0000, 10000.0000)
self.offset_x_entry.set_precision(self.decimals)
self.offset_x_entry.setSingleStep(0.1)
param_grid.addWidget(self.marginy_label, 9, 0)
param_grid.addWidget(self.marginy_entry, 9, 1)
off_grid.addWidget(self.offset_x_label, 2, 0)
off_grid.addWidget(self.offset_x_entry, 2, 1)
# Offset Y #
self.offset_y_label = FCLabel('%s Y:' % _("Offset"))
self.offset_y_label.setToolTip(
_("Offset on the Y axis.")
)
self.offset_y_entry = FCDoubleSpinner(callback=self.confirmation_message)
self.offset_y_entry.set_range(-10000.0000, 10000.0000)
self.offset_y_entry.set_precision(self.decimals)
self.offset_y_entry.setSingleStep(0.1)
off_grid.addWidget(self.offset_y_label, 3, 0)
off_grid.addWidget(self.offset_y_entry, 3, 1)
# Margin link
self.margin_link_button = QtWidgets.QToolButton()
self.margin_link_button.setIcon(QtGui.QIcon(self.app.resource_location + '/link32.png'))
self.margin_link_button.setSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding,
self.offset_link_button = QtWidgets.QToolButton()
self.offset_link_button.setIcon(QtGui.QIcon(self.app.resource_location + '/link32.png'))
self.offset_link_button.setSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding,
QtWidgets.QSizePolicy.Policy.Expanding)
self.margin_link_button.setCheckable(True)
param_grid.addWidget(self.margin_link_button, 8, 2, 2, 1)
self.offset_link_button.setCheckable(True)
off_grid.addWidget(self.offset_link_button, 2, 2, 2, 1)
# #############################################################################################################
# Locations Frame
@@ -1263,7 +1344,6 @@ class CornersUI:
# #############################################################################################################
# Selection Frame
# #############################################################################################################
# Selection
self.mode_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _("Selection"))
self.tools_box.addWidget(self.mode_label)
@@ -1415,7 +1495,7 @@ class CornersUI:
""")
self.tools_box.addWidget(self.insert_markers_button)
FCGridLayout.set_common_column_size([grid_sel, param_grid, grid_loc, grid_drill, insert_grid], 0)
FCGridLayout.set_common_column_size([grid_sel, param_grid, off_grid, grid_loc, grid_drill, insert_grid], 0)
self.layout.addStretch(1)
@@ -1438,23 +1518,23 @@ class CornersUI:
# Signals
self.margin_link_button.clicked.connect(self.on_link_checked)
self.marginx_entry.returnPressed.connect(self.on_marginx_edited)
self.offset_link_button.clicked.connect(self.on_link_checked)
self.offset_x_entry.returnPressed.connect(self.on_marginx_edited)
def on_link_checked(self, checked):
if checked:
self.marginx_label.set_value('%s:' % _("Margin"))
self.marginy_label.setDisabled(True)
self.marginy_entry.setDisabled(True)
self.marginy_entry.set_value(self.marginx_entry.get_value())
self.offset_x_label.set_value('%s:' % _("Offset"))
self.offset_y_label.setDisabled(True)
self.offset_y_entry.setDisabled(True)
self.offset_y_entry.set_value(self.offset_x_entry.get_value())
else:
self.marginx_label.set_value('%s X:' % _("Margin"))
self.marginy_label.setDisabled(False)
self.marginy_entry.setDisabled(False)
self.offset_x_label.set_value('%s X:' % _("Offset"))
self.offset_y_label.setDisabled(False)
self.offset_y_entry.setDisabled(False)
def on_marginx_edited(self):
if self.margin_link_button.isChecked():
self.marginy_entry.set_value(self.marginx_entry.get_value())
if self.offset_link_button.isChecked():
self.offset_y_entry.set_value(self.offset_x_entry.get_value())
def confirmation_message(self, accepted, minval, maxval):
if accepted is False:

View File

@@ -44,5 +44,5 @@ from appPlugins.ToolTransform import ToolTransform
from appPlugins.ToolPunchGerber import ToolPunchGerber
from appPlugins.ToolInvertGerber import ToolInvertGerber
from appPlugins.ToolCorners import ToolCorners
from appPlugins.ToolMarkers import ToolMarkers
from appPlugins.ToolEtchCompensation import ToolEtchCompensation