- overwritten the Beta_8.995 branch with the Gerber_Editor_Upgrade branch

This commit is contained in:
Marius Stanciu
2023-05-24 18:07:05 +03:00
parent c23d0c4ed6
commit 63071a9bae
214 changed files with 22249 additions and 6251 deletions

View File

@@ -0,0 +1,258 @@
from PyQt6 import QtWidgets
from appTool import AppToolEditor
from appEditors.grb_plugins.GrbCommon import DrawToolShape
from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCButton, FCFrame, GLay, FCDoubleSpinner, FCComboBox
from copy import deepcopy
import traceback
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
class BufferEditorTool(AppToolEditor):
"""
Simple input for buffer distance.
"""
def __init__(self, app, draw_app):
AppToolEditor.__init__(self, app)
self.draw_app = draw_app
self.decimals = app.decimals
self.ui = BufferEditorUI(layout=self.layout, buffer_class=self)
self.connect_signals_at_init()
self.set_tool_ui()
def connect_signals_at_init(self):
# Signals
pass
def run(self):
self.app.defaults.report_usage("Geo Editor ToolBuffer()")
super().run()
# if the splitter us hidden, display it
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
try:
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
except RuntimeError:
self.app.ui.plugin_tab = QtWidgets.QWidget()
self.app.ui.plugin_tab.setObjectName("plugin_tab")
self.app.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.app.ui.plugin_tab)
self.app.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2)
self.app.ui.plugin_scroll_area = VerticalScrollArea()
self.app.ui.plugin_tab_layout.addWidget(self.app.ui.plugin_scroll_area)
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
# self.app.ui.notebook.callback_on_close = self.on_tab_close
self.app.ui.notebook.setTabText(2, _("Buffer"))
def set_tool_ui(self):
# Init appGUI
self.ui.buffer_distance_entry.set_value(self.draw_app.app.options['gerber_editor_buff_f'])
def on_tab_close(self):
self.draw_app.select_tool("select")
self.app.ui.notebook.callback_on_close = lambda: None
def on_buffer(self):
try:
buffer_distance = float(self.ui.buffer_distance_entry.get_value())
except ValueError:
# try to convert comma to decimal point. if it's still not working error message and return
try:
buffer_distance = float(self.ui.buffer_distance_entry.get_value().replace(',', '.'))
self.ui.buffer_distance_entry.set_value(buffer_distance)
except ValueError:
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("Buffer distance value is missing or wrong format. Add it and retry."))
return
# the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment
# I populated the combobox such that the index coincide with the join styles value (which is really an INT)
join_style = self.ui.buffer_corner_cb.currentIndex() + 1
self.buffer(buffer_distance, join_style)
# def on_buffer_int(self):
# try:
# buffer_distance = float(self.ui.buffer_distance_entry.get_value())
# except ValueError:
# # try to convert comma to decimal point. if it's still not working error message and return
# try:
# buffer_distance = float(self.ui.buffer_distance_entry.get_value().replace(',', '.'))
# self.ui.buffer_distance_entry.set_value(buffer_distance)
# except ValueError:
# self.app.inform.emit('[WARNING_NOTCL] %s' %
# _("Buffer distance value is missing or wrong format. Add it and retry."))
# return
# # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment
# # I populated the combobox such that the index coincide with the join styles value (which is really an INT)
# join_style = self.ui.buffer_corner_cb.currentIndex() + 1
# self.buffer_int(buffer_distance, join_style)
#
# def on_buffer_ext(self):
# try:
# buffer_distance = float(self.ui.buffer_distance_entry.get_value())
# except ValueError:
# # try to convert comma to decimal point. if it's still not working error message and return
# try:
# buffer_distance = float(self.ui.buffer_distance_entry.get_value().replace(',', '.'))
# self.ui.buffer_distance_entry.set_value(buffer_distance)
# except ValueError:
# self.app.inform.emit('[WARNING_NOTCL] %s' %
# _("Buffer distance value is missing or wrong format. Add it and retry."))
# return
# # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment
# # I populated the combobox such that the index coincide with the join styles value (which is really an INT)
# join_style = self.ui.buffer_corner_cb.currentIndex() + 1
# self.buffer_ext(buffer_distance, join_style)
def buffer(self, buff_value, join_style):
self.app.log.debug("AppGerberEditor.BufferEditorTool.buffer()")
def buffer_recursion(geom_el, selection):
if type(geom_el) == list:
geoms = []
for local_geom in geom_el:
geoms.append(buffer_recursion(local_geom, selection=selection))
return geoms
else:
if geom_el in selection:
geometric_data = geom_el.geo
buffered_geom_el = {}
if 'solid' in geometric_data:
buffered_geom_el['solid'] = geometric_data['solid'].buffer(buff_value, join_style=join_style)
if 'follow' in geometric_data:
buffered_geom_el['follow'] = geometric_data['follow'].buffer(buff_value, join_style=join_style)
if 'clear' in geometric_data:
buffered_geom_el['clear'] = geometric_data['clear'].buffer(buff_value, join_style=join_style)
return DrawToolShape(buffered_geom_el)
else:
return geom_el
if not self.draw_app.ui.apertures_table.selectedItems():
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("No aperture to buffer. Select at least one aperture and try again."))
return
rows_list = set()
for x in self.draw_app.ui.apertures_table.selectedItems():
rows_list.add(x.row())
for row in rows_list:
try:
apcode = int(self.draw_app.ui.apertures_table.item(row, 1).text())
target_geo = self.draw_app.storage_dict[apcode]['geometry']
buffered_geo = buffer_recursion(target_geo, self.draw_app.selected)
self.draw_app.storage_dict[apcode]['geometry'] = deepcopy(buffered_geo)
except Exception as e:
self.app.log.error(
"AppGerberEditor.BufferEditorTool.buffer() --> %s\n%s" % (str(e)), str(traceback.print_exc()))
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Failed."))
return
self.draw_app.plot_all()
self.app.inform.emit('[success] %s' % _("Done."))
def hide_tool(self):
self.ui.buffer_tool_frame.hide()
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
class BufferEditorUI:
pluginName = _("Buffer")
def __init__(self, layout, buffer_class):
self.buffer_class = buffer_class
self.decimals = self.buffer_class.app.decimals
self.layout = layout
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName), size=16, bold=True)
title_label.setToolTip(
_("Buffer a aperture in the aperture list")
)
self.layout.addWidget(title_label)
self.param_label = FCLabel('%s' % _("Parameters"), color='blue', bold=True)
self.layout.addWidget(self.param_label)
# this way I can hide/show the frame
self.buffer_tool_frame = QtWidgets.QFrame()
self.buffer_tool_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.buffer_tool_frame)
self.buffer_tools_box = QtWidgets.QVBoxLayout()
self.buffer_tools_box.setContentsMargins(0, 0, 0, 0)
self.buffer_tool_frame.setLayout(self.buffer_tools_box)
# #############################################################################################################
# Tool Params Frame
# #############################################################################################################
tool_par_frame = FCFrame()
self.buffer_tools_box.addWidget(tool_par_frame)
# Grid Layout
param_grid = GLay(v_spacing=5, h_spacing=3)
tool_par_frame.setLayout(param_grid)
# Buffer distance
self.buffer_distance_entry = FCDoubleSpinner()
self.buffer_distance_entry.set_precision(self.decimals)
self.buffer_distance_entry.set_range(0.0000, 10000.0000)
param_grid.addWidget(FCLabel('%s:' % _("Buffer distance")), 0, 0)
param_grid.addWidget(self.buffer_distance_entry, 0, 1)
self.buffer_corner_lbl = FCLabel('%s:' % _("Buffer corner"))
self.buffer_corner_lbl.setToolTip(
_("There are 3 types of corners:\n"
" - 'Round': the corner is rounded for exterior buffer.\n"
" - 'Square': the corner is met in a sharp angle for exterior buffer.\n"
" - 'Beveled': the corner is a line that directly connects the features meeting in the corner")
)
self.buffer_corner_cb = FCComboBox()
self.buffer_corner_cb.addItem(_("Round"))
self.buffer_corner_cb.addItem(_("Square"))
self.buffer_corner_cb.addItem(_("Beveled"))
param_grid.addWidget(self.buffer_corner_lbl, 2, 0)
param_grid.addWidget(self.buffer_corner_cb, 2, 1)
# Buttons
# hlay = QtWidgets.QHBoxLayout()
# self.buffer_tools_box.addLayout(hlay)
#
# self.buffer_int_button = FCButton(_("Buffer Interior"))
# hlay.addWidget(self.buffer_int_button)
# self.buffer_ext_button = FCButton(_("Buffer Exterior"))
# hlay.addWidget(self.buffer_ext_button)
hlay1 = QtWidgets.QHBoxLayout()
self.buffer_tools_box.addLayout(hlay1)
self.buffer_button = FCButton(_("Full Buffer"))
hlay1.addWidget(self.buffer_button)
self.layout.addStretch(1)

View File

@@ -0,0 +1,158 @@
# ###########################################################################################
# THE UNUSED LIBS MAY BE USED FURTHER AWAY BY IMPORTING FROM THIS FILE - DON'T REMOVE THEM
# ###########################################################################################
from PyQt6.QtCore import Qt
from shapely import MultiLineString, Polygon
import numpy as np
import logging
log = logging.getLogger('base')
class DrawToolShape(object):
"""
Encapsulates "shapes" under a common class.
"""
tolerance = None
@staticmethod
def get_pts(o):
"""
Returns a list of all points in the object, where
the object can be a Polygon, Not a polygon, or a list
of such. Search is done recursively.
:param o: geometric object
:return: List of points
:rtype: list
"""
pts = []
# ## Iterable: descend into each item.
try:
for sub_o in o:
pts += DrawToolShape.get_pts(sub_o)
# Non-iterable
except TypeError:
if o is None:
return
# DrawToolShape: descend into .geo.
if isinstance(o, DrawToolShape):
pts += DrawToolShape.get_pts(o.geo)
# ## Descend into .exerior and .interiors
elif type(o) == Polygon:
pts += DrawToolShape.get_pts(o.exterior)
for i in o.interiors:
pts += DrawToolShape.get_pts(i)
elif type(o) == MultiLineString:
for line in o:
pts += DrawToolShape.get_pts(line)
# ## Has .coords: list them.
else:
if DrawToolShape.tolerance is not None:
pts += list(o.simplify(DrawToolShape.tolerance).coords)
else:
pts += list(o.coords)
return pts
def __init__(self, geo=None):
# Shapely type or list of such
self.geo = geo
self.utility = False
class DrawToolUtilityShape(DrawToolShape):
"""
Utility shapes are temporary geometry in the editor
to assist in the creation of shapes. For example it
will show the outline of a rectangle from the first
point to the current mouse pointer before the second
point is clicked and the final geometry is created.
"""
def __init__(self, geo=None):
super(DrawToolUtilityShape, self).__init__(geo=geo)
self.utility = True
class DrawTool(object):
"""
Abstract Class representing a tool in the drawing
program. Can generate geometry, including temporary
utility geometry that is updated on user clicks
and mouse motion.
"""
def __init__(self, draw_app):
self.draw_app = draw_app
self.complete = False
self.points = []
self.geometry = None # DrawToolShape or None
def click(self, point):
"""
:param point: [x, y] Coordinate pair.
"""
return ""
def click_release(self, point):
"""
:param point: [x, y] Coordinate pair.
"""
return ""
def on_key(self, key):
# Jump to coords
if key == Qt.Key.Key_J or key == 'J':
self.draw_app.app.on_jump_to()
def utility_geometry(self, data=None):
return None
@staticmethod
def bounds(obj):
def bounds_rec(o):
if type(o) is list:
minx = np.Inf
miny = np.Inf
maxx = -np.Inf
maxy = -np.Inf
for k in o:
try:
minx_, miny_, maxx_, maxy_ = bounds_rec(k)
except Exception as e:
log.error("camlib.Gerber.bounds() --> %s" % str(e))
return
minx = min(minx, minx_)
miny = min(miny, miny_)
maxx = max(maxx, maxx_)
maxy = max(maxy, maxy_)
return minx, miny, maxx, maxy
else:
# it's a Shapely object, return it's bounds
if 'solid' in o.geo:
return o.geo['solid'].bounds
return bounds_rec(obj)
class ShapeToolEditorGrb(DrawTool):
"""
Abstract class for tools that create a shape.
"""
def __init__(self, draw_app):
DrawTool.__init__(self, draw_app)
self.name = None
def make(self):
pass

View File

@@ -0,0 +1,545 @@
from PyQt6 import QtGui, QtWidgets
from appTool import AppToolEditor
from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCButton, FCFrame, GLay, NumericalEvalEntry, RadioSet, \
FCSpinner, FCDoubleSpinner
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
class CopyEditorTool(AppToolEditor):
"""
Simple input for buffer distance.
"""
def __init__(self, app, draw_app, plugin_name):
AppToolEditor.__init__(self, app)
self.draw_app = draw_app
self.decimals = app.decimals
self.plugin_name = plugin_name
self.ui = CopyEditorUI(layout=self.layout, copy_class=self, plugin_name=plugin_name)
self.connect_signals_at_init()
self.set_tool_ui()
def connect_signals_at_init(self):
# Signals
self.ui.clear_btn.clicked.connect(self.on_clear)
def disconnect_signals(self):
# Signals
try:
self.ui.clear_btn.clicked.disconnect()
except (TypeError, AttributeError):
pass
def run(self):
self.app.defaults.report_usage("Geo Editor CopyTool()")
AppToolEditor.run(self)
# if the splitter us hidden, display it
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
try:
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
except RuntimeError:
self.app.ui.plugin_tab = QtWidgets.QWidget()
self.app.ui.plugin_tab.setObjectName("plugin_tab")
self.app.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.app.ui.plugin_tab)
self.app.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2)
self.app.ui.plugin_scroll_area = VerticalScrollArea()
self.app.ui.plugin_tab_layout.addWidget(self.app.ui.plugin_scroll_area)
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
# self.app.ui.notebook.callback_on_close = self.on_tab_close
self.app.ui.notebook.setTabText(2, self.plugin_name)
def set_tool_ui(self):
# Init appGUI
self.length = 0.0
self.ui.mode_radio.set_value('n')
self.ui.on_copy_mode(self.ui.mode_radio.get_value())
self.ui.array_type_radio.set_value('linear')
self.ui.on_array_type_radio(self.ui.array_type_radio.get_value())
self.ui.axis_radio.set_value('X')
self.ui.on_linear_angle_radio(self.ui.axis_radio.get_value())
self.ui.array_dir_radio.set_value('CW')
self.ui.placement_radio.set_value('s')
self.ui.on_placement_radio(self.ui.placement_radio.get_value())
self.ui.spacing_rows.set_value(0)
self.ui.spacing_columns.set_value(0)
self.ui.rows.set_value(1)
self.ui.columns.set_value(1)
self.ui.offsetx_entry.set_value(0)
self.ui.offsety_entry.set_value(0)
def on_tab_close(self):
self.disconnect_signals()
self.hide_tool()
# self.app.ui.notebook.callback_on_close = lambda: None
def on_clear(self):
self.set_tool_ui()
@property
def length(self):
return self.ui.project_line_entry.get_value()
@length.setter
def length(self, val):
self.ui.project_line_entry.set_value(val)
def hide_tool(self):
self.ui.copy_frame.hide()
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
if self.draw_app.active_tool.name != 'select':
self.draw_app.select_tool("select")
class CopyEditorUI:
def __init__(self, layout, copy_class, plugin_name):
self.pluginName = plugin_name
self.copy_class = copy_class
self.decimals = self.copy_class.app.decimals
self.layout = layout
self.app = self.copy_class.app
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName), size=16, bold=True)
self.layout.addWidget(title_label)
# this way I can hide/show the frame
self.copy_frame = QtWidgets.QFrame()
self.copy_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.copy_frame)
self.copy_tool_box = QtWidgets.QVBoxLayout()
self.copy_tool_box.setContentsMargins(0, 0, 0, 0)
self.copy_frame.setLayout(self.copy_tool_box)
# Grid Layout
grid0 = GLay(v_spacing=5, h_spacing=3)
self.copy_tool_box.addLayout(grid0)
# Project distance
self.project_line_lbl = FCLabel('%s:' % _("Projection"))
self.project_line_lbl.setToolTip(
_("Length of the current segment/move.")
)
self.project_line_entry = NumericalEvalEntry(border_color='#0069A9')
grid0.addWidget(self.project_line_lbl, 0, 0)
grid0.addWidget(self.project_line_entry, 0, 1)
self.clear_btn = FCButton(_("Clear"))
grid0.addWidget(self.clear_btn, 2, 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, 4, 0, 1, 2)
# Type of Array
self.mode_label = FCLabel('%s:' % _("Mode"), bold=True)
self.mode_label.setToolTip(
_("Single copy or special (array of copies)")
)
self.mode_radio = RadioSet([
{'label': _('Single'), 'value': 'n'},
{'label': _('Array'), 'value': 'a'}
])
grid0.addWidget(self.mode_label, 6, 0)
grid0.addWidget(self.mode_radio, 6, 1)
# #############################################################################################################
# ######################################## Add Array ##########################################################
# #############################################################################################################
# add a frame and inside add a grid box layout.
self.array_frame = FCFrame()
# self.array_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.array_frame)
self.array_grid = GLay(v_spacing=5, h_spacing=3)
# self.array_grid.setContentsMargins(0, 0, 0, 0)
self.array_frame.setLayout(self.array_grid)
# Set the number of items in the array
self.array_size_label = FCLabel('%s:' % _('Size'))
self.array_size_label.setToolTip(_("Specify how many items to be in the array."))
self.array_size_entry = FCSpinner(policy=False)
self.array_size_entry.set_range(1, 100000)
self.array_grid.addWidget(self.array_size_label, 2, 0)
self.array_grid.addWidget(self.array_size_entry, 2, 1)
# Array Type
array_type_lbl = FCLabel('%s:' % _("Type"))
array_type_lbl.setToolTip(
_("Select the type of array to create.\n"
"It can be Linear X(Y) or Circular")
)
self.array_type_radio = RadioSet([
{'label': _('Linear'), 'value': 'linear'},
{'label': _('2D'), 'value': '2D'},
{'label': _('Circular'), 'value': 'circular'}
])
self.array_grid.addWidget(array_type_lbl, 4, 0)
self.array_grid.addWidget(self.array_type_radio, 4, 1)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.array_grid.addWidget(separator_line, 6, 0, 1, 2)
# #############################################################################################################
# ############################ LINEAR Array ###################################################################
# #############################################################################################################
self.array_linear_frame = QtWidgets.QFrame()
self.array_linear_frame.setContentsMargins(0, 0, 0, 0)
self.array_grid.addWidget(self.array_linear_frame, 8, 0, 1, 2)
self.lin_grid = GLay(v_spacing=5, h_spacing=3)
self.lin_grid.setContentsMargins(0, 0, 0, 0)
self.array_linear_frame.setLayout(self.lin_grid)
# Linear Drill Array direction
self.axis_label = FCLabel('%s:' % _('Direction'))
self.axis_label.setToolTip(
_("Direction on which the linear array is oriented:\n"
"- 'X' - horizontal axis \n"
"- 'Y' - vertical axis or \n"
"- 'Angle' - a custom angle for the array inclination")
)
self.axis_radio = RadioSet([
{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}
])
self.lin_grid.addWidget(self.axis_label, 0, 0)
self.lin_grid.addWidget(self.axis_radio, 0, 1)
# Linear Array pitch distance
self.pitch_label = FCLabel('%s:' % _('Pitch'))
self.pitch_label.setToolTip(
_("Pitch = Distance between elements of the array.")
)
self.pitch_entry = FCDoubleSpinner(policy=False)
self.pitch_entry.set_precision(self.decimals)
self.pitch_entry.set_range(0.0000, 10000.0000)
self.lin_grid.addWidget(self.pitch_label, 2, 0)
self.lin_grid.addWidget(self.pitch_entry, 2, 1)
# Linear Array angle
self.linear_angle_label = FCLabel('%s:' % _('Angle'))
self.linear_angle_label.setToolTip(
_("Angle at which the linear array is placed.\n"
"The precision is of max 2 decimals.\n"
"Min value is: -360.00 degrees.\n"
"Max value is: 360.00 degrees.")
)
self.linear_angle_spinner = FCDoubleSpinner(policy=False)
self.linear_angle_spinner.set_precision(self.decimals)
self.linear_angle_spinner.setSingleStep(1.0)
self.linear_angle_spinner.setRange(-360.00, 360.00)
self.lin_grid.addWidget(self.linear_angle_label, 4, 0)
self.lin_grid.addWidget(self.linear_angle_spinner, 4, 1)
# #############################################################################################################
# ################################ 2D Array ###################################################################
# #############################################################################################################
self.two_dim_array_frame = QtWidgets.QFrame()
self.two_dim_array_frame.setContentsMargins(0, 0, 0, 0)
self.array_grid.addWidget(self.two_dim_array_frame, 10, 0, 1, 2)
self.dd_grid = GLay(v_spacing=5, h_spacing=3)
self.dd_grid.setContentsMargins(0, 0, 0, 0)
self.two_dim_array_frame.setLayout(self.dd_grid)
# 2D placement
self.place_label = FCLabel('%s:' % _('Placement'))
self.place_label.setToolTip(
_("Placement of array items:\n"
"'Spacing' - define space between rows and columns \n"
"'Offset' - each row (and column) will be placed at a multiple of a value, from origin")
)
self.placement_radio = RadioSet([
{'label': _('Spacing'), 'value': 's'},
{'label': _('Offset'), 'value': 'o'}
])
self.dd_grid.addWidget(self.place_label, 0, 0)
self.dd_grid.addWidget(self.placement_radio, 0, 1)
# Rows
self.rows = FCSpinner(callback=self.confirmation_message_int)
self.rows.set_range(0, 10000)
self.rows_label = FCLabel('%s:' % _("Rows"))
self.rows_label.setToolTip(
_("Number of rows")
)
self.dd_grid.addWidget(self.rows_label, 2, 0)
self.dd_grid.addWidget(self.rows, 2, 1)
# Columns
self.columns = FCSpinner(callback=self.confirmation_message_int)
self.columns.set_range(0, 10000)
self.columns_label = FCLabel('%s:' % _("Columns"))
self.columns_label.setToolTip(
_("Number of columns")
)
self.dd_grid.addWidget(self.columns_label, 4, 0)
self.dd_grid.addWidget(self.columns, 4, 1)
# ------------------------------------------------
# ############## Spacing Frame #################
# ------------------------------------------------
self.spacing_frame = QtWidgets.QFrame()
self.spacing_frame.setContentsMargins(0, 0, 0, 0)
self.dd_grid.addWidget(self.spacing_frame, 6, 0, 1, 2)
self.s_grid = GLay(v_spacing=5, h_spacing=3)
self.s_grid.setContentsMargins(0, 0, 0, 0)
self.spacing_frame.setLayout(self.s_grid)
# Spacing Rows
self.spacing_rows = FCDoubleSpinner(callback=self.confirmation_message)
self.spacing_rows.set_range(0, 9999)
self.spacing_rows.set_precision(4)
self.spacing_rows_label = FCLabel('%s:' % _("Spacing rows"))
self.spacing_rows_label.setToolTip(
_("Spacing between rows.\n"
"In current units.")
)
self.s_grid.addWidget(self.spacing_rows_label, 0, 0)
self.s_grid.addWidget(self.spacing_rows, 0, 1)
# Spacing Columns
self.spacing_columns = FCDoubleSpinner(callback=self.confirmation_message)
self.spacing_columns.set_range(0, 9999)
self.spacing_columns.set_precision(4)
self.spacing_columns_label = FCLabel('%s:' % _("Spacing cols"))
self.spacing_columns_label.setToolTip(
_("Spacing between columns.\n"
"In current units.")
)
self.s_grid.addWidget(self.spacing_columns_label, 2, 0)
self.s_grid.addWidget(self.spacing_columns, 2, 1)
# ------------------------------------------------
# ############## Offset Frame ##################
# ------------------------------------------------
self.offset_frame = QtWidgets.QFrame()
self.offset_frame.setContentsMargins(0, 0, 0, 0)
self.dd_grid.addWidget(self.offset_frame, 8, 0, 1, 2)
self.o_grid = GLay(v_spacing=5, h_spacing=3)
self.o_grid.setContentsMargins(0, 0, 0, 0)
self.offset_frame.setLayout(self.o_grid)
# Offset X Value
self.offsetx_label = FCLabel('%s X:' % _("Offset"))
self.offsetx_label.setToolTip(
_("'Offset' - each row (and column) will be placed at a multiple of a value, from origin")
)
self.offsetx_entry = FCDoubleSpinner(policy=False)
self.offsetx_entry.set_precision(self.decimals)
self.offsetx_entry.set_range(0.0000, 10000.0000)
self.o_grid.addWidget(self.offsetx_label, 0, 0)
self.o_grid.addWidget(self.offsetx_entry, 0, 1)
# Offset Y Value
self.offsety_label = FCLabel('%s Y:' % _("Offset"))
self.offsety_label.setToolTip(
_("'Offset' - each row (and column) will be placed at a multiple of a value, from origin")
)
self.offsety_entry = FCDoubleSpinner(policy=False)
self.offsety_entry.set_precision(self.decimals)
self.offsety_entry.set_range(0.0000, 10000.0000)
self.o_grid.addWidget(self.offsety_label, 2, 0)
self.o_grid.addWidget(self.offsety_entry, 2, 1)
# #############################################################################################################
# ############################ CIRCULAR Array #################################################################
# #############################################################################################################
self.array_circular_frame = QtWidgets.QFrame()
self.array_circular_frame.setContentsMargins(0, 0, 0, 0)
self.array_grid.addWidget(self.array_circular_frame, 12, 0, 1, 2)
self.circ_grid = GLay(v_spacing=5, h_spacing=3)
self.circ_grid.setContentsMargins(0, 0, 0, 0)
self.array_circular_frame.setLayout(self.circ_grid)
# Array Direction
self.array_dir_lbl = FCLabel('%s:' % _('Direction'))
self.array_dir_lbl.setToolTip(
_("Direction for circular array.\n"
"Can be CW = clockwise or CCW = counter clockwise."))
self.array_dir_radio = RadioSet([
{'label': _('CW'), 'value': 'CW'},
{'label': _('CCW'), 'value': 'CCW'}])
self.circ_grid.addWidget(self.array_dir_lbl, 0, 0)
self.circ_grid.addWidget(self.array_dir_radio, 0, 1)
# Array Angle
self.array_angle_lbl = FCLabel('%s:' % _('Angle'))
self.array_angle_lbl.setToolTip(_("Angle at which each element in circular array is placed."))
self.angle_entry = FCDoubleSpinner(policy=False)
self.angle_entry.set_precision(self.decimals)
self.angle_entry.setSingleStep(1.0)
self.angle_entry.setRange(-360.00, 360.00)
self.circ_grid.addWidget(self.array_angle_lbl, 2, 0)
self.circ_grid.addWidget(self.angle_entry, 2, 1)
# Buttons
self.add_button = FCButton(_("Add"))
self.add_button.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
self.layout.addWidget(self.add_button)
GLay.set_common_column_size([
grid0, self.array_grid, self.lin_grid, self.dd_grid, self.circ_grid, self.s_grid, self.o_grid
], 0)
self.layout.addStretch(1)
# Signals
self.mode_radio.activated_custom.connect(self.on_copy_mode)
self.array_type_radio.activated_custom.connect(self.on_array_type_radio)
self.axis_radio.activated_custom.connect(self.on_linear_angle_radio)
self.placement_radio.activated_custom.connect(self.on_placement_radio)
def confirmation_message(self, accepted, minval, maxval):
if accepted is False:
self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%.*f, %.*f]' % (_("Edited value is out of range"),
self.decimals,
minval,
self.decimals,
maxval), False)
def confirmation_message_int(self, accepted, minval, maxval):
if accepted is False:
self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%d, %d]' %
(_("Edited value is out of range"), minval, maxval), False)
def on_copy_mode(self, val):
if val == 'n':
self.array_frame.hide()
self.app.inform.emit(_("Click on reference location ..."))
else:
self.array_frame.show()
def on_array_type_radio(self, val):
if val == '2D':
self.array_circular_frame.hide()
self.array_linear_frame.hide()
self.two_dim_array_frame.show()
if self.placement_radio.get_value() == 's':
self.spacing_frame.show()
self.offset_frame.hide()
else:
self.spacing_frame.hide()
self.offset_frame.show()
self.array_size_entry.setDisabled(True)
self.on_rows_cols_value_changed()
self.rows.valueChanged.connect(self.on_rows_cols_value_changed)
self.columns.valueChanged.connect(self.on_rows_cols_value_changed)
self.app.inform.emit(_("Click on reference location ..."))
else:
if val == 'linear':
self.array_circular_frame.hide()
self.array_linear_frame.show()
self.two_dim_array_frame.hide()
self.spacing_frame.hide()
self.offset_frame.hide()
self.app.inform.emit(_("Click on reference location ..."))
else: # 'circular'
self.array_circular_frame.show()
self.array_linear_frame.hide()
self.two_dim_array_frame.hide()
self.spacing_frame.hide()
self.offset_frame.hide()
self.app.inform.emit(_("Click on the circular array Center position"))
self.array_size_entry.setDisabled(False)
try:
self.rows.valueChanged.disconnect()
except (TypeError, AttributeError):
pass
try:
self.columns.valueChanged.disconnect()
except (TypeError, AttributeError):
pass
def on_rows_cols_value_changed(self):
new_size = self.rows.get_value() * self.columns.get_value()
if new_size == 0:
new_size = 1
self.array_size_entry.set_value(new_size)
def on_linear_angle_radio(self, val):
if val == 'A':
self.linear_angle_spinner.show()
self.linear_angle_label.show()
else:
self.linear_angle_spinner.hide()
self.linear_angle_label.hide()
def on_placement_radio(self, val):
if val == 's':
self.spacing_frame.show()
self.offset_frame.hide()
else:
self.spacing_frame.hide()
self.offset_frame.show()

View File

@@ -0,0 +1,366 @@
from PyQt6 import QtWidgets, QtGui
from appTool import AppToolEditor
from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCButton, FCFrame, GLay, NumericalEvalEntry, \
FCDoubleSpinner, FCSpinner, RadioSet
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
class GrbPadArrayEditorTool(AppToolEditor):
"""
Create an array of drill holes
"""
def __init__(self, app, draw_app, plugin_name):
AppToolEditor.__init__(self, app)
self.draw_app = draw_app
self.decimals = app.decimals
self.plugin_name = plugin_name
self.ui = GrbPadArrayEditorUI(layout=self.layout, parray_class=self, plugin_name=plugin_name)
self.connect_signals_at_init()
def connect_signals_at_init(self):
# Signals
pass
def disconnect_signals(self):
# Signals
pass
def run(self):
self.app.defaults.report_usage("Exc Editor ArrayTool()")
super().run()
# if the splitter us hidden, display it
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
try:
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
except RuntimeError:
self.app.ui.plugin_tab = QtWidgets.QWidget()
self.app.ui.plugin_tab.setObjectName("plugin_tab")
self.app.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.app.ui.plugin_tab)
self.app.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2)
self.app.ui.plugin_scroll_area = VerticalScrollArea()
self.app.ui.plugin_tab_layout.addWidget(self.app.ui.plugin_scroll_area)
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
# self.app.ui.notebook.callback_on_close = self.on_tab_close
self.app.ui.notebook.setTabText(2, self.plugin_name)
def set_tool_ui(self):
# Init appGUI
self.ui.array_type_radio.set_value('linear')
self.ui.on_array_type_radio(self.ui.array_type_radio.get_value())
self.ui.axis_radio.set_value('X')
self.ui.on_linear_angle_radio(self.ui.axis_radio.get_value())
self.ui.array_dir_radio.set_value('CW')
def on_tab_close(self):
self.disconnect_signals()
self.hide_tool()
# self.app.ui.notebook.callback_on_close = lambda: None
def on_clear(self):
self.set_tool_ui()
def hide_tool(self):
self.ui.parray_frame.hide()
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
if self.draw_app.active_tool.name != 'select':
self.draw_app.select_tool("select")
class GrbPadArrayEditorUI:
def __init__(self, layout, parray_class, plugin_name):
self.pluginName = plugin_name
self.parray_class = parray_class
self.decimals = self.parray_class.app.decimals
self.layout = layout
self.app = self.parray_class.app
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName), size=16, bold=True)
self.layout.addWidget(title_label)
# this way I can hide/show the frame
self.parray_frame = QtWidgets.QFrame()
self.parray_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.parray_frame)
self.editor_vbox = QtWidgets.QVBoxLayout()
self.editor_vbox.setContentsMargins(0, 0, 0, 0)
self.parray_frame.setLayout(self.editor_vbox)
# Position
self.tool_lbl = FCLabel('%s' % _("Diameter"), bold=True, color='blue')
self.editor_vbox.addWidget(self.tool_lbl)
# #############################################################################################################
# Diameter Frame
# #############################################################################################################
dia_frame = FCFrame()
self.editor_vbox.addWidget(dia_frame)
dia_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0])
dia_frame.setLayout(dia_grid)
# Dia Value
self.dia_lbl = FCLabel('%s:' % _("Value"))
self.dia_entry = NumericalEvalEntry(border_color='#0069A9')
self.dia_entry.setDisabled(True)
self.dia_unit = FCLabel('%s' % 'mm')
dia_grid.addWidget(self.dia_lbl, 0, 0)
dia_grid.addWidget(self.dia_entry, 0, 1)
dia_grid.addWidget(self.dia_unit, 0, 2)
# Position
self.pos_lbl = FCLabel('%s' % _("Position"), bold=True, color='red')
self.editor_vbox.addWidget(self.pos_lbl)
# #############################################################################################################
# Position Frame
# #############################################################################################################
pos_frame = FCFrame()
self.editor_vbox.addWidget(pos_frame)
pos_grid = GLay(v_spacing=5, h_spacing=3)
pos_frame.setLayout(pos_grid)
# X Pos
self.x_lbl = FCLabel('%s:' % _("X"))
self.x_entry = FCDoubleSpinner()
self.x_entry.set_precision(self.decimals)
self.x_entry.set_range(-10000.0000, 10000.0000)
pos_grid.addWidget(self.x_lbl, 2, 0)
pos_grid.addWidget(self.x_entry, 2, 1)
# Y Pos
self.y_lbl = FCLabel('%s:' % _("Y"))
self.y_entry = FCDoubleSpinner()
self.y_entry.set_precision(self.decimals)
self.y_entry.set_range(-10000.0000, 10000.0000)
pos_grid.addWidget(self.y_lbl, 4, 0)
pos_grid.addWidget(self.y_entry, 4, 1)
# Position
self.par_lbl = FCLabel('%s' % _("Parameters"), bold=True, color='purple')
self.editor_vbox.addWidget(self.par_lbl)
# #############################################################################################################
# ######################################## Add Array ##########################################################
# #############################################################################################################
# add a frame and inside add a grid box layout.
self.array_frame = FCFrame()
self.editor_vbox.addWidget(self.array_frame)
self.array_grid = GLay(v_spacing=5, h_spacing=3)
self.array_frame.setLayout(self.array_grid)
# Array Type
array_type_lbl = FCLabel('%s:' % _("Type"))
array_type_lbl.setToolTip(
_("Select the type of array to create.\n"
"It can be Linear X(Y) or Circular")
)
self.array_type_radio = RadioSet([
{'label': _('Linear'), 'value': 'linear'},
{'label': _('Circular'), 'value': 'circular'}
])
self.array_grid.addWidget(array_type_lbl, 2, 0)
self.array_grid.addWidget(self.array_type_radio, 2, 1)
# Array Size
self.array_size_label = FCLabel('%s:' % _('Size'))
self.array_size_label.setToolTip(_("Specify how many items to be in the array."))
self.array_size_entry = FCSpinner(policy=False)
self.array_size_entry.set_range(1, 100000)
self.array_grid.addWidget(self.array_size_label, 4, 0)
self.array_grid.addWidget(self.array_size_entry, 4, 1)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.array_grid.addWidget(separator_line, 6, 0, 1, 2)
# #############################################################################################################
# ############################ LINEAR Array ###################################################################
# #############################################################################################################
self.array_linear_frame = QtWidgets.QFrame()
self.array_linear_frame.setContentsMargins(0, 0, 0, 0)
self.array_grid.addWidget(self.array_linear_frame, 8, 0, 1, 2)
self.lin_grid = GLay(v_spacing=5, h_spacing=3)
self.lin_grid.setContentsMargins(0, 0, 0, 0)
self.array_linear_frame.setLayout(self.lin_grid)
# Linear Drill Array direction
self.axis_label = FCLabel('%s:' % _('Direction'))
self.axis_label.setToolTip(
_("Direction on which the linear array is oriented:\n"
"- 'X' - horizontal axis \n"
"- 'Y' - vertical axis or \n"
"- 'Angle' - a custom angle for the array inclination")
)
self.axis_radio = RadioSet([
{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}
])
self.lin_grid.addWidget(self.axis_label, 0, 0)
self.lin_grid.addWidget(self.axis_radio, 0, 1)
# Linear Array pitch distance
self.pitch_label = FCLabel('%s:' % _('Pitch'))
self.pitch_label.setToolTip(
_("Pitch = Distance between elements of the array.")
)
self.pitch_entry = FCDoubleSpinner(policy=False)
self.pitch_entry.set_precision(self.decimals)
self.pitch_entry.set_range(0.0000, 10000.0000)
self.lin_grid.addWidget(self.pitch_label, 2, 0)
self.lin_grid.addWidget(self.pitch_entry, 2, 1)
# Linear Array angle
self.linear_angle_label = FCLabel('%s:' % _('Angle'))
self.linear_angle_label.setToolTip(
_("Angle at which the linear array is placed.\n"
"The precision is of max 2 decimals.\n"
"Min value is: -360.00 degrees.\n"
"Max value is: 360.00 degrees.")
)
self.linear_angle_entry = FCDoubleSpinner(policy=False)
self.linear_angle_entry.set_precision(self.decimals)
self.linear_angle_entry.setSingleStep(1.0)
self.linear_angle_entry.setRange(-360.00, 360.00)
self.lin_grid.addWidget(self.linear_angle_label, 4, 0)
self.lin_grid.addWidget(self.linear_angle_entry, 4, 1)
# #############################################################################################################
# ############################ CIRCULAR Array #################################################################
# #############################################################################################################
self.array_circular_frame = QtWidgets.QFrame()
self.array_circular_frame.setContentsMargins(0, 0, 0, 0)
self.array_grid.addWidget(self.array_circular_frame, 12, 0, 1, 2)
self.circ_grid = GLay(v_spacing=5, h_spacing=3)
self.circ_grid.setContentsMargins(0, 0, 0, 0)
self.array_circular_frame.setLayout(self.circ_grid)
# Array Direction
self.array_dir_lbl = FCLabel('%s:' % _('Direction'))
self.array_dir_lbl.setToolTip(
_("Direction for circular array.\n"
"Can be CW = clockwise or CCW = counter clockwise."))
self.array_dir_radio = RadioSet([
{'label': _('CW'), 'value': 'CW'},
{'label': _('CCW'), 'value': 'CCW'}])
self.circ_grid.addWidget(self.array_dir_lbl, 0, 0)
self.circ_grid.addWidget(self.array_dir_radio, 0, 1)
# Array Angle
self.circular_angle_lbl = FCLabel('%s:' % _('Angle'))
self.circular_angle_lbl.setToolTip(_("Angle at which each element in circular array is placed."))
self.circular_angle_entry = FCDoubleSpinner(policy=False)
self.circular_angle_entry.set_precision(self.decimals)
self.circular_angle_entry.setSingleStep(1.0)
self.circular_angle_entry.setRange(-360.00, 360.00)
self.circ_grid.addWidget(self.circular_angle_lbl, 2, 0)
self.circ_grid.addWidget(self.circular_angle_entry, 2, 1)
# Radius
self.radius_lbl = FCLabel('%s:' % _('Radius'))
self.radius_lbl.setToolTip(_("Array radius."))
self.radius_entry = FCDoubleSpinner(policy=False)
self.radius_entry.set_precision(self.decimals)
self.radius_entry.setSingleStep(1.0)
self.radius_entry.setRange(-10000.0000, 10000.000)
self.circ_grid.addWidget(self.radius_lbl, 4, 0)
self.circ_grid.addWidget(self.radius_entry, 4, 1)
# #############################################################################################################
# Buttons
# #############################################################################################################
self.add_btn = FCButton(_("Add"))
self.add_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
self.layout.addWidget(self.add_btn)
GLay.set_common_column_size([dia_grid, pos_grid, self.array_grid, self.lin_grid, self.circ_grid], 0)
self.layout.addStretch(1)
# Signals
self.array_type_radio.activated_custom.connect(self.on_array_type_radio)
self.axis_radio.activated_custom.connect(self.on_linear_angle_radio)
def confirmation_message(self, accepted, minval, maxval):
if accepted is False:
self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%.*f, %.*f]' % (_("Edited value is out of range"),
self.decimals,
minval,
self.decimals,
maxval), False)
def confirmation_message_int(self, accepted, minval, maxval):
if accepted is False:
self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%d, %d]' %
(_("Edited value is out of range"), minval, maxval), False)
def on_array_type_radio(self, val):
if val == 'linear':
self.array_circular_frame.hide()
self.array_linear_frame.show()
self.app.inform.emit(_("Click to place ..."))
else: # 'circular'
self.array_circular_frame.show()
self.array_linear_frame.hide()
self.app.inform.emit(_("Click on the circular array Center position"))
self.array_size_entry.setDisabled(False)
def on_linear_angle_radio(self, val):
if val == 'A':
self.linear_angle_entry.setEnabled(True)
self.linear_angle_label.setEnabled(True)
else:
self.linear_angle_entry.setEnabled(False)
self.linear_angle_label.setEnabled(False)

View File

@@ -0,0 +1,203 @@
from PyQt6 import QtWidgets, QtGui
from appTool import AppToolEditor
from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCButton, FCFrame, GLay, FCDoubleSpinner, \
NumericalEvalEntry
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
class PadEditorTool(AppToolEditor):
"""
Simple input for buffer distance.
"""
def __init__(self, app, draw_app, plugin_name):
AppToolEditor.__init__(self, app)
self.draw_app = draw_app
self.decimals = app.decimals
self.plugin_name = plugin_name
self.ui = PadEditorUI(layout=self.layout, pad_class=self, plugin_name=plugin_name)
self.connect_signals_at_init()
self.set_tool_ui()
def connect_signals_at_init(self):
# Signals
self.ui.clear_btn.clicked.connect(self.on_clear)
def disconnect_signals(self):
# Signals
try:
self.ui.clear_btn.clicked.disconnect()
except (TypeError, AttributeError):
pass
def run(self):
self.app.defaults.report_usage("Gerber Editor PadEditorTool()")
super().run()
# if the splitter us hidden, display it
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
try:
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
except RuntimeError:
self.app.ui.plugin_tab = QtWidgets.QWidget()
self.app.ui.plugin_tab.setObjectName("plugin_tab")
self.app.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.app.ui.plugin_tab)
self.app.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2)
self.app.ui.plugin_scroll_area = VerticalScrollArea()
self.app.ui.plugin_tab_layout.addWidget(self.app.ui.plugin_scroll_area)
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
# self.app.ui.notebook.callback_on_close = self.on_tab_close
self.app.ui.notebook.setTabText(2, self.plugin_name)
def set_tool_ui(self):
# Init appGUI
self.length = 0.0
def on_tab_close(self):
self.disconnect_signals()
self.hide_tool()
# self.app.ui.notebook.callback_on_close = lambda: None
def on_clear(self):
self.set_tool_ui()
@property
def length(self):
return self.ui.project_line_entry.get_value()
@length.setter
def length(self, val):
self.ui.project_line_entry.set_value(val)
def hide_tool(self):
self.ui.pad_tool_frame.hide()
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
if self.draw_app.active_tool.name != 'select':
self.draw_app.select_tool("select")
class PadEditorUI:
def __init__(self, layout, pad_class, plugin_name):
self.pluginName = plugin_name
self.ed_class = pad_class
self.decimals = self.ed_class.app.decimals
self.layout = layout
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName), size=16, bold=True)
self.layout.addWidget(title_label)
# this way I can hide/show the frame
self.pad_tool_frame = QtWidgets.QFrame()
self.pad_tool_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.pad_tool_frame)
self.editor_vbox = QtWidgets.QVBoxLayout()
self.editor_vbox.setContentsMargins(0, 0, 0, 0)
self.pad_tool_frame.setLayout(self.editor_vbox)
# Position
self.tool_lbl = FCLabel('%s' % _("Diameter"), bold=True, color='blue')
self.editor_vbox.addWidget(self.tool_lbl)
# #############################################################################################################
# Diameter Frame
# #############################################################################################################
dia_frame = FCFrame()
self.editor_vbox.addWidget(dia_frame)
dia_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0])
dia_frame.setLayout(dia_grid)
# Dia Value
self.dia_lbl = FCLabel('%s:' % _("Value"))
self.dia_entry = NumericalEvalEntry(border_color='#0069A9')
self.dia_entry.setDisabled(True)
self.dia_unit = FCLabel('%s' % 'mm')
dia_grid.addWidget(self.dia_lbl, 0, 0)
dia_grid.addWidget(self.dia_entry, 0, 1)
dia_grid.addWidget(self.dia_unit, 0, 2)
# Position
self.pos_lbl = FCLabel('%s' % _("Position"), bold=True, color='red')
self.editor_vbox.addWidget(self.pos_lbl)
# #############################################################################################################
# Position Frame
# #############################################################################################################
pos_frame = FCFrame()
self.editor_vbox.addWidget(pos_frame)
pos_grid = GLay(v_spacing=5, h_spacing=3)
pos_frame.setLayout(pos_grid)
# X Pos
self.x_lbl = FCLabel('%s:' % _("X"))
self.x_entry = FCDoubleSpinner()
self.x_entry.set_precision(self.decimals)
self.x_entry.set_range(-10000.0000, 10000.0000)
pos_grid.addWidget(self.x_lbl, 2, 0)
pos_grid.addWidget(self.x_entry, 2, 1)
# Y Pos
self.y_lbl = FCLabel('%s:' % _("Y"))
self.y_entry = FCDoubleSpinner()
self.y_entry.set_precision(self.decimals)
self.y_entry.set_range(-10000.0000, 10000.0000)
pos_grid.addWidget(self.y_lbl, 4, 0)
pos_grid.addWidget(self.y_entry, 4, 1)
# #############################################################################################################
# Projection Frame
# #############################################################################################################
pro_frame = FCFrame()
self.editor_vbox.addWidget(pro_frame)
pro_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0])
pro_frame.setLayout(pro_grid)
# Project distance
self.project_line_lbl = FCLabel('%s:' % _("Projection"))
self.project_line_lbl.setToolTip(
_("Length of the current segment/move.")
)
self.project_line_entry = NumericalEvalEntry(border_color='#0069A9')
pro_grid.addWidget(self.project_line_lbl, 0, 0)
pro_grid.addWidget(self.project_line_entry, 0, 1)
self.clear_btn = QtWidgets.QToolButton()
self.clear_btn.setIcon(QtGui.QIcon(self.ed_class.app.resource_location + '/trash32.png'))
pro_grid.addWidget(self.clear_btn, 0, 2)
self.add_btn = FCButton(_("Add"))
self.add_btn.setIcon(QtGui.QIcon(self.ed_class.app.resource_location + '/plus32.png'))
self.editor_vbox.addWidget(self.add_btn)
GLay.set_common_column_size([dia_grid, pos_grid, pro_grid], 0)
self.layout.addStretch(1)

View File

@@ -0,0 +1,209 @@
from PyQt6 import QtWidgets, QtGui, QtCore
from appTool import AppToolEditor
from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCButton, FCFrame, GLay, FCTextEdit, FCEntry, \
FCDoubleSpinner
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
class SimplificationTool(AppToolEditor):
"""
Do a shape simplification for the selected geometry.
"""
update_ui = QtCore.pyqtSignal(object, int)
def __init__(self, app, draw_app):
AppToolEditor.__init__(self, app)
self.draw_app = draw_app
self.decimals = app.decimals
self.app = self.draw_app.app
self.ui = SimplificationEditorUI(layout=self.layout, simp_class=self)
self.plugin_name = self.ui.pluginName
self.connect_signals_at_init()
self.set_tool_ui()
def connect_signals_at_init(self):
# Signals
self.update_ui.connect(self.on_update_ui) # noqa
def run(self):
self.app.defaults.report_usage("Geo Editor SimplificationTool()")
super().run()
# if the splitter us hidden, display it
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
try:
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
except RuntimeError:
self.app.ui.plugin_tab = QtWidgets.QWidget()
self.app.ui.plugin_tab.setObjectName("plugin_tab")
self.app.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.app.ui.plugin_tab)
self.app.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2)
self.app.ui.plugin_scroll_area = VerticalScrollArea()
self.app.ui.plugin_tab_layout.addWidget(self.app.ui.plugin_scroll_area)
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
# self.app.ui.notebook.callback_on_close = self.on_tab_close
self.app.ui.notebook.setTabText(2, self.plugin_name)
def set_tool_ui(self):
# Init appGUI
self.ui.geo_tol_entry.set_value(0.01 if self.draw_app.units == 'MM' else 0.0004)
if self.draw_app.selected:
# those are displayed by triggering the signal self.update_ui
self.calculate_coords_vertex()
def on_tab_close(self):
self.draw_app.select_tool("select")
self.app.ui.notebook.callback_on_close = lambda: None
def calculate_coords_vertex(self):
vertex_nr = 0
coords = []
for sha in self.draw_app.selected:
sha_geo = sha.geo
if 'solid' in sha_geo:
sha_geo_solid = sha_geo['solid']
if sha_geo_solid.geom_type == 'Polygon':
sha_geo_solid_coords = list(sha_geo_solid.exterior.coords)
elif sha_geo_solid.geom_type in ['LinearRing', 'LineString']:
sha_geo_solid_coords = list(sha_geo_solid.coords)
else:
sha_geo_solid_coords = []
coords += sha_geo_solid_coords
vertex_nr += len(sha_geo_solid_coords)
self.ui.geo_vertex_entry.set_value(vertex_nr)
self.update_ui.emit(coords, vertex_nr) # noqa
def on_update_ui(self, coords, vertex_nr):
self.ui.geo_coords_entry.set_value(str(coords))
self.ui.geo_vertex_entry.set_value(vertex_nr)
def hide_tool(self):
self.ui.simp_frame.hide()
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
class SimplificationEditorUI:
pluginName = _("Simplification")
def __init__(self, layout, simp_class):
self.simp_class = simp_class
self.app = self.simp_class.app
self.decimals = self.app.decimals
self.layout = layout
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName), size=16, bold=True)
self.layout.addWidget(title_label)
# this way I can hide/show the frame
self.simp_frame = QtWidgets.QFrame()
self.simp_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.simp_frame)
self.simp_tools_box = QtWidgets.QVBoxLayout()
self.simp_tools_box.setContentsMargins(0, 0, 0, 0)
self.simp_frame.setLayout(self.simp_tools_box)
# Grid Layout
grid0 = GLay(v_spacing=5, h_spacing=3)
self.simp_tools_box.addLayout(grid0)
# Coordinates
coords_lbl = FCLabel('%s' % _("Coordinates"), bold=True, color='red')
coords_lbl.setToolTip(
_("The coordinates of the selected geometry element.")
)
grid0.addWidget(coords_lbl, 0, 0, 1, 2)
# #############################################################################################################
# Coordinates Frame
# #############################################################################################################
coors_frame = FCFrame()
grid0.addWidget(coors_frame, 2, 0, 1, 2)
coords_grid = GLay(v_spacing=5, h_spacing=3)
coors_frame.setLayout(coords_grid)
self.geo_coords_entry = FCTextEdit()
self.geo_coords_entry.setPlaceholderText(
_("The coordinates of the selected geometry element.")
)
coords_grid.addWidget(self.geo_coords_entry, 0, 0, 1, 2)
# Vertex Points Number
vertex_lbl = FCLabel('%s:' % _("Vertex Points"), bold=False)
vertex_lbl.setToolTip(
_("The number of vertex points in the selected geometry element.")
)
self.geo_vertex_entry = FCEntry(decimals=self.decimals)
self.geo_vertex_entry.setReadOnly(True)
coords_grid.addWidget(vertex_lbl, 2, 0)
coords_grid.addWidget(self.geo_vertex_entry, 2, 1)
# Simplification Title
par_lbl = FCLabel('%s' % _("Parameters"), bold=True, color='blue')
grid0.addWidget(par_lbl, 4, 0, 1, 2)
# #############################################################################################################
# Parameters Frame
# #############################################################################################################
par_frame = FCFrame()
grid0.addWidget(par_frame, 6, 0, 1, 2)
par_grid = GLay(v_spacing=5, h_spacing=3)
par_frame.setLayout(par_grid)
# Simplification Tolerance
simplification_tol_lbl = FCLabel('%s' % _("Tolerance"), bold=True)
simplification_tol_lbl.setToolTip(
_("All points in the simplified object will be\n"
"within the tolerance distance of the original geometry.")
)
self.geo_tol_entry = FCDoubleSpinner()
self.geo_tol_entry.set_precision(self.decimals)
self.geo_tol_entry.setSingleStep(10 ** -self.decimals)
self.geo_tol_entry.set_range(0.0000, 10000.0000)
par_grid.addWidget(simplification_tol_lbl, 0, 0)
par_grid.addWidget(self.geo_tol_entry, 0, 1)
# Simplification button
self.simplification_btn = FCButton(_("Simplify"), bold=True)
self.simplification_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/simplify32.png'))
self.simplification_btn.setToolTip(
_("Simplify a geometry element by reducing its vertex points number.")
)
self.layout.addWidget(self.simplification_btn)
GLay.set_common_column_size([grid0, coords_grid, par_grid], 0)
self.layout.addStretch(1)

View File

@@ -0,0 +1,203 @@
from PyQt6 import QtWidgets, QtGui
from appTool import AppToolEditor
from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCButton, FCFrame, GLay, NumericalEvalEntry, \
FCDoubleSpinner
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
class GrbTrackEditorTool(AppToolEditor):
"""
Simple input for buffer distance.
"""
def __init__(self, app, draw_app, plugin_name):
AppToolEditor.__init__(self, app)
self.draw_app = draw_app
self.decimals = app.decimals
self.plugin_name = plugin_name
self.ui = GrbTrackEditorUI(layout=self.layout, track_class=self, plugin_name=plugin_name)
self.connect_signals_at_init()
self.set_tool_ui()
def connect_signals_at_init(self):
# Signals
self.ui.clear_btn.clicked.connect(self.on_clear)
def disconnect_signals(self):
# Signals
try:
self.ui.clear_btn.clicked.disconnect()
except (TypeError, AttributeError):
pass
def run(self):
self.app.defaults.report_usage("Geo Editor ToolPath()")
super().run()
# if the splitter us hidden, display it
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
try:
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
except RuntimeError:
self.app.ui.plugin_tab = QtWidgets.QWidget()
self.app.ui.plugin_tab.setObjectName("plugin_tab")
self.app.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.app.ui.plugin_tab)
self.app.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2)
self.app.ui.plugin_scroll_area = VerticalScrollArea()
self.app.ui.plugin_tab_layout.addWidget(self.app.ui.plugin_scroll_area)
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
# self.app.ui.notebook.callback_on_close = self.on_tab_close
self.app.ui.notebook.setTabText(2, self.plugin_name)
def set_tool_ui(self):
# Init appGUI
self.length = 0.0
def on_tab_close(self):
self.disconnect_signals()
self.hide_tool()
# self.app.ui.notebook.callback_on_close = lambda: None
def on_clear(self):
self.set_tool_ui()
@property
def length(self):
return self.ui.project_line_entry.get_value()
@length.setter
def length(self, val):
self.ui.project_line_entry.set_value(val)
def hide_tool(self):
self.ui.drill_tool_frame.hide()
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
if self.draw_app.active_tool.name != 'select':
self.draw_app.select_tool("select")
class GrbTrackEditorUI:
def __init__(self, layout, track_class, plugin_name):
self.pluginName = plugin_name
self.ed_class = track_class
self.decimals = self.ed_class.app.decimals
self.layout = layout
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName), size=16, bold=True)
self.layout.addWidget(title_label)
# this way I can hide/show the frame
self.drill_tool_frame = QtWidgets.QFrame()
self.drill_tool_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.drill_tool_frame)
self.editor_vbox = QtWidgets.QVBoxLayout()
self.editor_vbox.setContentsMargins(0, 0, 0, 0)
self.drill_tool_frame.setLayout(self.editor_vbox)
# Position
self.tool_lbl = FCLabel('%s' % _("Diameter"), bold=True, color='blue')
self.editor_vbox.addWidget(self.tool_lbl)
# #############################################################################################################
# Diameter Frame
# #############################################################################################################
dia_frame = FCFrame()
self.editor_vbox.addWidget(dia_frame)
dia_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0])
dia_frame.setLayout(dia_grid)
# Dia Value
self.dia_lbl = FCLabel('%s:' % _("Value"))
self.dia_entry = NumericalEvalEntry(border_color='#0069A9')
self.dia_entry.setDisabled(True)
self.dia_unit = FCLabel('%s' % 'mm')
dia_grid.addWidget(self.dia_lbl, 0, 0)
dia_grid.addWidget(self.dia_entry, 0, 1)
dia_grid.addWidget(self.dia_unit, 0, 2)
# Position
self.pos_lbl = FCLabel('%s' % _("Position"), bold=True, color='red')
self.editor_vbox.addWidget(self.pos_lbl)
# #############################################################################################################
# Position Frame
# #############################################################################################################
pos_frame = FCFrame()
self.editor_vbox.addWidget(pos_frame)
pos_grid = GLay(v_spacing=5, h_spacing=3)
pos_frame.setLayout(pos_grid)
# X Pos
self.x_lbl = FCLabel('%s:' % _("X"))
self.x_entry = FCDoubleSpinner()
self.x_entry.set_precision(self.decimals)
self.x_entry.set_range(-10000.0000, 10000.0000)
pos_grid.addWidget(self.x_lbl, 2, 0)
pos_grid.addWidget(self.x_entry, 2, 1)
# Y Pos
self.y_lbl = FCLabel('%s:' % _("Y"))
self.y_entry = FCDoubleSpinner()
self.y_entry.set_precision(self.decimals)
self.y_entry.set_range(-10000.0000, 10000.0000)
pos_grid.addWidget(self.y_lbl, 4, 0)
pos_grid.addWidget(self.y_entry, 4, 1)
# #############################################################################################################
# Projection Frame
# #############################################################################################################
pro_frame = FCFrame()
self.editor_vbox.addWidget(pro_frame)
pro_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0])
pro_frame.setLayout(pro_grid)
# Project distance
self.project_line_lbl = FCLabel('%s:' % _("Projection"))
self.project_line_lbl.setToolTip(
_("Length of the current segment/move.")
)
self.project_line_entry = NumericalEvalEntry(border_color='#0069A9')
pro_grid.addWidget(self.project_line_lbl, 0, 0)
pro_grid.addWidget(self.project_line_entry, 0, 1)
self.clear_btn = QtWidgets.QToolButton()
self.clear_btn.setIcon(QtGui.QIcon(self.ed_class.app.resource_location + '/trash32.png'))
pro_grid.addWidget(self.clear_btn, 0, 2)
self.add_btn = FCButton(_("Add"))
self.add_btn.setIcon(QtGui.QIcon(self.ed_class.app.resource_location + '/plus32.png'))
self.editor_vbox.addWidget(self.add_btn)
GLay.set_common_column_size([dia_grid, pos_grid, pro_grid], 0)
self.layout.addStretch(1)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,198 @@
from PyQt6 import QtWidgets, QtGui
from appTool import AppToolEditor
from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCDoubleSpinner, FCFrame, GLay, NumericalEvalEntry
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
class GrbRegionEditorTool(AppToolEditor):
"""
Simple input for buffer distance.
"""
def __init__(self, app, draw_app, plugin_name):
AppToolEditor.__init__(self, app)
self.draw_app = draw_app
self.decimals = app.decimals
self.plugin_name = plugin_name
self.ui = GrbRegionEditorUI(layout=self.layout, reg_class=self, plugin_name=plugin_name)
self.connect_signals_at_init()
self.set_tool_ui()
def connect_signals_at_init(self):
# Signals
self.ui.clear_btn.clicked.connect(self.on_clear)
def disconnect_signals(self):
# Signals
try:
self.ui.clear_btn.clicked.disconnect()
except (TypeError, AttributeError):
pass
def run(self):
self.app.defaults.report_usage("Geo Editor ToolPath()")
super().run()
# if the splitter us hidden, display it
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
try:
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
except RuntimeError:
self.app.ui.plugin_tab = QtWidgets.QWidget()
self.app.ui.plugin_tab.setObjectName("plugin_tab")
self.app.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.app.ui.plugin_tab)
self.app.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2)
self.app.ui.plugin_scroll_area = VerticalScrollArea()
self.app.ui.plugin_tab_layout.addWidget(self.app.ui.plugin_scroll_area)
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
# self.app.ui.notebook.callback_on_close = self.on_tab_close
self.app.ui.notebook.setTabText(2, self.plugin_name)
def set_tool_ui(self):
# Init appGUI
self.length = 0.0
def on_tab_close(self):
self.disconnect_signals()
self.hide_tool()
# self.app.ui.notebook.callback_on_close = lambda: None
def on_clear(self):
self.set_tool_ui()
@property
def length(self):
return self.ui.project_line_entry.get_value()
@length.setter
def length(self, val):
self.ui.project_line_entry.set_value(val)
def hide_tool(self):
self.ui.reg_tool_frame.hide()
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
if self.draw_app.active_tool.name != 'select':
self.draw_app.select_tool("select")
class GrbRegionEditorUI:
def __init__(self, layout, reg_class, plugin_name):
self.pluginName = plugin_name
self.reg_class = reg_class
self.decimals = self.reg_class.app.decimals
self.layout = layout
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName), size=16, bold=True)
self.layout.addWidget(title_label)
# this way I can hide/show the frame
self.reg_tool_frame = QtWidgets.QFrame()
self.reg_tool_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.reg_tool_frame)
self.editor_vbox = QtWidgets.QVBoxLayout()
self.editor_vbox.setContentsMargins(0, 0, 0, 0)
self.reg_tool_frame.setLayout(self.editor_vbox)
# Position
self.tool_lbl = FCLabel('%s' % _("Diameter"), bold=True, color='blue')
self.editor_vbox.addWidget(self.tool_lbl)
# #############################################################################################################
# Diameter Frame
# #############################################################################################################
dia_frame = FCFrame()
self.editor_vbox.addWidget(dia_frame)
dia_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0])
dia_frame.setLayout(dia_grid)
# Dia Value
self.dia_lbl = FCLabel('%s:' % _("Value"))
self.dia_entry = NumericalEvalEntry(border_color='#0069A9')
self.dia_entry.setDisabled(True)
self.dia_unit = FCLabel('%s' % 'mm')
dia_grid.addWidget(self.dia_lbl, 0, 0)
dia_grid.addWidget(self.dia_entry, 0, 1)
dia_grid.addWidget(self.dia_unit, 0, 2)
# Position
self.pos_lbl = FCLabel('%s' % _("Position"), bold=True, color='red')
self.editor_vbox.addWidget(self.pos_lbl)
# #############################################################################################################
# Position Frame
# #############################################################################################################
pos_frame = FCFrame()
self.editor_vbox.addWidget(pos_frame)
pos_grid = GLay(v_spacing=5, h_spacing=3)
pos_frame.setLayout(pos_grid)
# X Pos
self.x_lbl = FCLabel('%s:' % _("X"))
self.x_entry = FCDoubleSpinner()
self.x_entry.set_precision(self.decimals)
self.x_entry.set_range(-10000.0000, 10000.0000)
pos_grid.addWidget(self.x_lbl, 2, 0)
pos_grid.addWidget(self.x_entry, 2, 1)
# Y Pos
self.y_lbl = FCLabel('%s:' % _("Y"))
self.y_entry = FCDoubleSpinner()
self.y_entry.set_precision(self.decimals)
self.y_entry.set_range(-10000.0000, 10000.0000)
pos_grid.addWidget(self.y_lbl, 4, 0)
pos_grid.addWidget(self.y_entry, 4, 1)
# #############################################################################################################
# Projection Frame
# #############################################################################################################
pro_frame = FCFrame()
self.editor_vbox.addWidget(pro_frame)
pro_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0])
pro_frame.setLayout(pro_grid)
# Project distance
self.project_line_lbl = FCLabel('%s:' % _("Projection"))
self.project_line_lbl.setToolTip(
_("Length of the current segment/move.")
)
self.project_line_entry = NumericalEvalEntry(border_color='#0069A9')
pro_grid.addWidget(self.project_line_lbl, 0, 0)
pro_grid.addWidget(self.project_line_entry, 0, 1)
self.clear_btn = QtWidgets.QToolButton()
self.clear_btn.setIcon(QtGui.QIcon(self.reg_class.app.resource_location + '/trash32.png'))
pro_grid.addWidget(self.clear_btn, 0, 2)
GLay.set_common_column_size([dia_grid, pos_grid, pro_grid], 0)
self.layout.addStretch(1)

View File