- In Excellon Editor, Drill Array Plugin, upgraded the UI and work in progress for the features

This commit is contained in:
Marius Stanciu
2022-04-30 03:52:57 +03:00
committed by Marius
parent b4c300b2eb
commit 6592fc5cde
9 changed files with 427 additions and 548 deletions

View File

@@ -9,6 +9,7 @@ from camlib import distance, arc, AppRTreeStorage
from appEditors.exc_plugins.ExcDrillPlugin import *
from appEditors.exc_plugins.ExcSlotPlugin import ExcSlotEditorTool
from appEditors.exc_plugins.ExcDrillArrayPlugin import ExcDrillArrayEditorTool
from appGUI.GUIElements import FCEntry, FCTable, FCDoubleSpinner, RadioSet, FCSpinner, FCButton, FCLabel, GLay
from appEditors.AppGeoEditor import FCShapeTool, DrawTool, DrawToolShape, DrawToolUtilityShape, AppGeoEditor
@@ -58,7 +59,6 @@ class SelectEditorExc(FCShapeTool):
self.sel_storage = AppExcEditor.make_storage()
self.draw_app.ui.resize_frame.hide()
self.draw_app.ui.array_frame.hide()
self.draw_app.ui.slot_array_frame.hide()
# make sure that the cursor text from the DrillAdd is deleted
@@ -506,10 +506,11 @@ class DrillArray(FCShapeTool):
def __init__(self, draw_app):
DrawTool.__init__(self, draw_app)
self.name = 'drill_array'
self.draw_app.ui.array_frame.show()
self.draw_app = draw_app
self.app = self.draw_app.app
self.selected_dia = None
self.drill_axis = 'X'
self.drill_array = 'linear' # 'linear'
self.drill_array_size = None
@@ -549,19 +550,64 @@ class DrillArray(FCShapeTool):
self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_drill_array.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
# #############################################################################################################
# Plugin UI
# #############################################################################################################
self.darray_tool = ExcDrillArrayEditorTool(self.app, self.draw_app, plugin_name=_("Drill Array"))
self.ui = self.darray_tool.ui
self.darray_tool.run()
geo = self.utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y), static=True)
if isinstance(geo, DrawToolShape) and geo.geo is not None:
self.draw_app.draw_utility_geometry(geo=geo)
self.draw_app.app.inform.emit(_("Click on target location ..."))
if self.app.use_3d_engine:
self.draw_app.app.plotcanvas.view.camera.zoom_callback = self.draw_cursor_data
self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x))
# Switch notebook to Properties page
self.draw_app.app.ui.notebook.setCurrentWidget(self.draw_app.app.ui.properties_tab)
self.darray_tool.length = self.draw_app.last_length
if not self.draw_app.snap_x:
self.draw_app.snap_x = 0.0
if not self.draw_app.snap_y:
self.draw_app.snap_y = 0.0
self.app.ui.notebook.setTabText(2, _("Drill Array"))
if self.app.ui.splitter.sizes()[0] == 0:
self.app.ui.splitter.setSizes([1, 1])
self.set_plugin_ui()
# Signals
try:
self.ui.add_btn.clicked.disconnect()
except (AttributeError, TypeError):
pass
self.ui.add_btn.clicked.connect(self.on_add_drill_array)
# self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x))
def set_plugin_ui(self):
curr_row = self.draw_app.ui.tools_table_exc.currentRow()
tool_dia = float(self.draw_app.ui.tools_table_exc.item(curr_row, 1).text())
self.ui.dia_entry.set_value(tool_dia)
self.ui.x_entry.set_value(float(self.draw_app.snap_x))
self.ui.y_entry.set_value(float(self.draw_app.snap_y))
self.ui.array_type_radio.set_value('linear')
self.ui.on_array_type_radio(val=self.ui.array_type_radio.get_value())
self.ui.array_size_entry.set_value(self.draw_app.last_darray_size)
self.ui.axis_radio.set_value(self.draw_app.last_darray_lin_dir)
self.ui.pitch_entry.set_value(self.draw_app.last_darray_pitch)
self.ui.linear_angle_spinner.set_value(self.draw_app.last_darray_lin_angle)
self.ui.array_dir_radio.set_value(self.draw_app.last_darray_circ_dir)
self.ui.angle_entry.set_value(self.draw_app.last_darray_circ_angle)
def click(self, point):
self.draw_app.last_length = self.darray_tool.length
self.ui.x_entry.set_value(float(self.draw_app.snap_x))
self.ui.y_entry.set_value(float(self.draw_app.snap_y))
if self.drill_array == 'linear': # 'Linear'
self.make()
@@ -584,15 +630,15 @@ class DrillArray(FCShapeTool):
self.origin = origin
def utility_geometry(self, data=None, static=None):
self.drill_axis = self.draw_app.ui.drill_axis_radio.get_value()
self.drill_direction = self.draw_app.ui.drill_array_dir_radio.get_value()
self.drill_array = self.draw_app.ui.array_type_radio.get_value()
self.drill_axis = self.ui.axis_radio.get_value()
self.drill_direction = self.ui.array_dir_radio.get_value()
self.drill_array = self.ui.array_type_radio.get_value()
try:
self.drill_array_size = int(self.draw_app.ui.drill_array_size_entry.get_value())
self.drill_array_size = int(self.ui.array_size_entry.get_value())
try:
self.drill_pitch = float(self.draw_app.ui.drill_pitch_entry.get_value())
self.drill_linear_angle = float(self.draw_app.ui.linear_angle_spinner.get_value())
self.drill_angle = float(self.draw_app.ui.drill_angle_entry.get_value())
self.drill_pitch = float(self.ui.pitch_entry.get_value())
self.drill_linear_angle = float(self.ui.linear_angle_spinner.get_value())
self.drill_angle = float(self.ui.angle_entry.get_value())
except TypeError:
self.draw_app.app.inform.emit('[ERROR_NOTCL] %s' %
_("The value is not Float. Check for comma instead of dot separator."))
@@ -677,8 +723,8 @@ class DrillArray(FCShapeTool):
log.error("DrillArray.utility_geometry -- circular -> %s" % str(e))
def circular_util_shape(self, radius, angle):
self.drill_direction = self.draw_app.ui.drill_array_dir_radio.get_value()
self.drill_angle = self.draw_app.ui.drill_angle_entry.get_value()
self.drill_direction = self.ui.array_dir_radio.get_value()
self.drill_angle = self.ui.angle_entry.get_value()
circular_geo = []
if self.drill_direction == 'CW':
@@ -778,10 +824,59 @@ class DrillArray(FCShapeTool):
self.complete = True
self.draw_app.app.inform.emit('[success] %s' % _("Done."))
self.draw_app.in_action = False
self.draw_app.ui.array_frame.hide()
self.draw_app.app.jump_signal.disconnect()
def draw_cursor_data(self, pos=None, delete=False):
if pos is None:
pos = self.draw_app.snap_x, self.draw_app.snap_y
if delete:
if self.draw_app.app.use_3d_engine:
self.draw_app.app.plotcanvas.text_cursor.parent = None
self.draw_app.app.plotcanvas.view.camera.zoom_callback = lambda *args: None
return
if not self.points:
self.points = self.draw_app.snap_x, self.draw_app.snap_y
# font size
qsettings = QtCore.QSettings("Open Source", "FlatCAM")
if qsettings.contains("hud_font_size"):
fsize = qsettings.value('hud_font_size', type=int)
else:
fsize = 8
x = pos[0]
y = pos[1]
try:
length = abs(np.sqrt((x - self.points[0]) ** 2 + (y - self.points[1]) ** 2))
except IndexError:
length = self.draw_app.app.dec_format(0.0, self.draw_app.app.decimals)
x_dec = str(self.draw_app.app.dec_format(x, self.draw_app.app.decimals)) if x else '0.0'
y_dec = str(self.draw_app.app.dec_format(y, self.draw_app.app.decimals)) if y else '0.0'
length_dec = str(self.draw_app.app.dec_format(length, self.draw_app.app.decimals)) if length else '0.0'
units = self.draw_app.app.app_units.lower()
l1_txt = 'X: %s [%s]' % (x_dec, units)
l2_txt = 'Y: %s [%s]' % (y_dec, units)
l3_txt = 'L: %s [%s]' % (length_dec, units)
cursor_text = '%s\n%s\n\n%s' % (l1_txt, l2_txt, l3_txt)
if self.draw_app.app.use_3d_engine:
new_pos = self.draw_app.app.plotcanvas.translate_coords_2((x, y))
x, y, __, ___ = self.draw_app.app.plotcanvas.translate_coords((new_pos[0]+30, new_pos[1]))
# text
self.draw_app.app.plotcanvas.text_cursor.font_size = fsize
self.draw_app.app.plotcanvas.text_cursor.text = cursor_text
self.draw_app.app.plotcanvas.text_cursor.pos = x, y
self.draw_app.app.plotcanvas.text_cursor.anchors = 'left', 'top'
if self.draw_app.app.plotcanvas.text_cursor.parent is None:
self.draw_app.app.plotcanvas.text_cursor.parent = self.draw_app.app.plotcanvas.view.scene
def on_key(self, key):
key_modifier = QtWidgets.QApplication.keyboardModifiers()
@@ -797,21 +892,78 @@ class DrillArray(FCShapeTool):
elif mod_key is None:
# Toggle Drill Array Direction
if key == QtCore.Qt.Key.Key_Space:
if self.draw_app.ui.drill_axis_radio.get_value() == 'X':
self.draw_app.ui.drill_axis_radio.set_value('Y')
elif self.draw_app.ui.drill_axis_radio.get_value() == 'Y':
self.draw_app.ui.drill_axis_radio.set_value('A')
elif self.draw_app.ui.drill_axis_radio.get_value() == 'A':
self.draw_app.ui.drill_axis_radio.set_value('X')
if self.ui.axis_radio.get_value() == 'X':
self.ui.axis_radio.set_value('Y')
elif self.ui.axis_radio.get_value() == 'Y':
self.ui.axis_radio.set_value('A')
elif self.ui.axis_radio.get_value() == 'A':
self.ui.axis_radio.set_value('X')
# ## Utility geometry (animated)
self.draw_app.update_utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y))
# Jump to coords
if key == QtCore.Qt.Key.Key_J or key == 'J':
self.draw_app.app.on_jump_to()
if key in [str(i) for i in range(10)] + ['.', ',', '+', '-', '/', '*'] or \
key in [QtCore.Qt.Key.Key_0, QtCore.Qt.Key.Key_1, QtCore.Qt.Key.Key_2,
QtCore.Qt.Key.Key_3, QtCore.Qt.Key.Key_4, QtCore.Qt.Key.Key_5, QtCore.Qt.Key.Key_6,
QtCore.Qt.Key.Key_7, QtCore.Qt.Key.Key_8, QtCore.Qt.Key.Key_9, QtCore.Qt.Key.Key_Minus,
QtCore.Qt.Key.Key_Plus, QtCore.Qt.Key.Key_Comma, QtCore.Qt.Key.Key_Period,
QtCore.Qt.Key.Key_Slash, QtCore.Qt.Key.Key_Asterisk]:
try:
# VisPy keys
if self.darray_tool.length == self.draw_app.last_length:
self.darray_tool.length = str(key.name)
else:
self.darray_tool.length = str(self.darray_tool.length) + str(key.name)
except AttributeError:
# Qt keys
if self.darray_tool.length == self.draw_app.last_length:
self.darray_tool.length = chr(key)
else:
self.darray_tool.length = str(self.darray_tool.length) + chr(key)
if key == 'Enter' or key == QtCore.Qt.Key.Key_Return or key == QtCore.Qt.Key.Key_Enter:
if self.darray_tool.length != 0:
target_length = self.darray_tool.length
if target_length is None:
self.darray_tool.length = 0.0
return _("Failed.")
first_pt = self.ui.x_entry.get_value(), self.ui.y_entry.get_value()
last_pt = self.draw_app.snap_x, self.draw_app.snap_y
seg_length = math.sqrt((last_pt[0] - first_pt[0]) ** 2 + (last_pt[1] - first_pt[1]) ** 2)
if seg_length == 0.0:
return
try:
new_x = first_pt[0] + (last_pt[0] - first_pt[0]) / seg_length * target_length
new_y = first_pt[1] + (last_pt[1] - first_pt[1]) / seg_length * target_length
except ZeroDivisionError as err:
self.clean_up()
return '[ERROR_NOTCL] %s %s' % (_("Failed."), str(err).capitalize())
if first_pt != (new_x, new_y):
self.draw_app.app.on_jump_to(custom_location=(new_x, new_y), fit_center=False)
self.add_drill_array(drill_pos=(new_x, new_y))
def add_drill_array(self, array_pos):
pass
def on_add_drill_array(self):
pass
def clean_up(self):
self.draw_app.selected = []
self.draw_app.ui.tools_table_exc.clearSelection()
self.draw_app.plot_all()
if self.draw_app.app.use_3d_engine:
self.draw_app.app.plotcanvas.text_cursor.parent = None
self.draw_app.app.plotcanvas.view.camera.zoom_callback = lambda *args: None
try:
self.draw_app.app.jump_signal.disconnect()
except (TypeError, AttributeError):
@@ -896,10 +1048,10 @@ class SlotAdd(FCShapeTool):
self.draw_app.app.inform.emit(_("Click to place ..."))
def set_plugin_ui(self):
self.ui.slot_length_entry.set_value(float(self.app.options['excellon_editor_slot_length']))
self.ui.slot_axis_radio.set_value(self.app.options['excellon_editor_slot_direction'])
self.ui.slot_length_entry.set_value(self.draw_app.last_slot_length)
self.ui.slot_direction_radio.set_value(self.draw_app.last_slot_direction)
self.ui.on_slot_angle_radio()
self.ui.slot_angle_spinner.set_value(float(self.app.options['excellon_editor_slot_angle']))
self.ui.slot_angle_spinner.set_value(self.draw_app.last_slot_angle)
curr_row = self.draw_app.ui.tools_table_exc.currentRow()
tool_dia = float(self.draw_app.ui.tools_table_exc.item(curr_row, 1).text())
@@ -927,7 +1079,7 @@ class SlotAdd(FCShapeTool):
slot_length = float(self.ui.slot_length_entry.get_value())
slot_angle = float(self.ui.slot_angle_spinner.get_value())
if self.ui.slot_axis_radio.get_value() == 'X':
if self.ui.slot_direction_radio.get_value() == 'X':
self.half_width = slot_length / 2.0
self.half_height = self.radius
else:
@@ -967,7 +1119,7 @@ class SlotAdd(FCShapeTool):
geo.append(pt)
geo.append(p4)
if self.ui.slot_axis_radio.get_value() == 'A':
if self.ui.slot_direction_radio.get_value() == 'A':
return rotate(geom=Polygon(geo), angle=-slot_angle)
else:
return Polygon(geo)
@@ -1028,6 +1180,10 @@ class SlotAdd(FCShapeTool):
except (TypeError, AttributeError):
pass
self.draw_app.last_slot_length = self.ui.slot_length_entry.get_value()
self.draw_app.last_slot_direction = self.ui.slot_direction_radio.get_value()
self.draw_app.last_slot_angle = self.ui.slot_angle_spinner.get_value()
self.draw_app.app.inform.emit('[success] %s' % _("Done."))
def draw_cursor_data(self, pos=None, delete=False):
@@ -1087,12 +1243,12 @@ class SlotAdd(FCShapeTool):
# Toggle Pad Direction
if key == QtCore.Qt.Key.Key_Space:
if self.ui.slot_axis_radio.get_value() == 'X':
self.ui.slot_axis_radio.set_value('Y')
elif self.ui.slot_axis_radio.get_value() == 'Y':
self.ui.slot_axis_radio.set_value('A')
elif self.ui.slot_axis_radio.get_value() == 'A':
self.ui.slot_axis_radio.set_value('X')
if self.ui.slot_direction_radio.get_value() == 'X':
self.ui.slot_direction_radio.set_value('Y')
elif self.ui.slot_direction_radio.get_value() == 'Y':
self.ui.slot_direction_radio.set_value('A')
elif self.ui.slot_direction_radio.get_value() == 'A':
self.ui.slot_direction_radio.set_value('X')
# ## Utility geometry (animated)
self.draw_app.update_utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y))
@@ -1182,9 +1338,6 @@ class SlotArray(FCShapeTool):
self.name = 'slot_array'
self.draw_app = draw_app
self.draw_app.ui.slot_frame.show()
self.draw_app.ui.slot_array_frame.show()
self.selected_dia = None
try:
self.draw_app.app.inform.emit(_("Click to place ..."))
@@ -1412,7 +1565,7 @@ class SlotArray(FCShapeTool):
_("Value is missing or wrong format. Add it and retry."))
return
if self.draw_app.ui.slot_axis_radio.get_value() == 'X':
if self.draw_app.ui.slot_direction_radio.get_value() == 'X':
self.half_width = slot_length / 2.0
self.half_height = self.radius
else:
@@ -1479,7 +1632,7 @@ class SlotArray(FCShapeTool):
# this function return one slot in the slot array and the following will rotate that one slot around it's
# center if the radio value is "A".
if self.draw_app.ui.slot_axis_radio.get_value() == 'A':
if self.draw_app.ui.slot_direction_radio.get_value() == 'A':
return rotate(Polygon(geo), -slot_angle)
else:
return Polygon(geo)
@@ -1588,12 +1741,12 @@ class SlotArray(FCShapeTool):
elif mod_key is None:
# Toggle Pad Direction
if key == QtCore.Qt.Key.Key_Space:
if self.draw_app.ui.slot_axis_radio.get_value() == 'X':
self.draw_app.ui.slot_axis_radio.set_value('Y')
elif self.draw_app.ui.slot_axis_radio.get_value() == 'Y':
self.draw_app.ui.slot_axis_radio.set_value('A')
elif self.draw_app.ui.slot_axis_radio.get_value() == 'A':
self.draw_app.ui.slot_axis_radio.set_value('X')
if self.draw_app.ui.slot_direction_radio.get_value() == 'X':
self.draw_app.ui.slot_direction_radio.set_value('Y')
elif self.draw_app.ui.slot_direction_radio.get_value() == 'Y':
self.draw_app.ui.slot_direction_radio.set_value('A')
elif self.draw_app.ui.slot_direction_radio.get_value() == 'A':
self.draw_app.ui.slot_direction_radio.set_value('X')
# ## Utility geometry (animated)
self.draw_app.update_utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y))
@@ -2147,8 +2300,22 @@ class AppExcEditor(QtCore.QObject):
self.snap_y = None
self.clicked_pos = None
# #############################################################################################################
# Plugin Attributes
# #############################################################################################################
self.last_length = 0.0
self.last_darray_type = None
self.last_darray_size = None
self.last_darray_lin_dir = None
self.last_darray_circ_dir = None
self.last_darray_pitch = None
self.last_darray_lin_angle = None
self.last_darray_circ_angle = None
self.last_slot_length = None
self.last_slot_direction = None
self.last_slot_angle = None
self.complete = False
self.editor_options = {
@@ -2210,11 +2377,8 @@ class AppExcEditor(QtCore.QObject):
self.ui.tools_table_exc.cellPressed.connect(self.on_row_selected)
self.ui.tools_table_exc.selectionModel().selectionChanged.connect(self.on_table_selection)
self.ui.array_type_radio.activated_custom.connect(self.on_array_type_radio)
self.ui.slot_array_type_radio.activated_custom.connect(self.on_slot_array_type_radio)
self.ui.drill_axis_radio.activated_custom.connect(self.on_linear_angle_radio)
self.ui.slot_array_axis_radio.activated_custom.connect(self.on_slot_array_linear_angle_radio)
self.app.ui.exc_add_array_drill_menuitem.triggered.connect(self.exc_add_drill_array)
@@ -2312,12 +2476,18 @@ class AppExcEditor(QtCore.QObject):
# Init appGUI
self.ui.addtool_entry.set_value(float(self.app.options['excellon_editor_newdia']))
self.ui.drill_array_size_entry.set_value(int(self.app.options['excellon_editor_array_size']))
self.ui.drill_axis_radio.set_value(self.app.options['excellon_editor_lin_dir'])
self.ui.drill_pitch_entry.set_value(float(self.app.options['excellon_editor_lin_pitch']))
self.ui.linear_angle_spinner.set_value(float(self.app.options['excellon_editor_lin_angle']))
self.ui.drill_array_dir_radio.set_value(self.app.options['excellon_editor_circ_dir'])
self.ui.drill_angle_entry.set_value(float(self.app.options['excellon_editor_circ_angle']))
self.last_darray_type = 'linear'
self.last_darray_size = int(self.app.options['excellon_editor_array_size'])
self.last_darray_lin_dir = self.app.options['excellon_editor_lin_dir']
self.last_darray_circ_dir = self.app.options['excellon_editor_circ_dir']
self.last_darray_pitch = float(self.app.options['excellon_editor_lin_pitch'])
self.last_darray_lin_angle = float(self.app.options['excellon_editor_lin_angle'])
self.last_darray_circ_angle = float(self.app.options['excellon_editor_circ_angle'])
self.last_slot_length = self.app.options['excellon_editor_slot_length']
self.last_slot_direction = self.app.options['excellon_editor_slot_direction']
self.last_slot_angle = self.app.options['excellon_editor_slot_angle']
self.ui.slot_array_size_entry.set_value(int(self.app.options['excellon_editor_slot_array_size']))
self.ui.slot_array_axis_radio.set_value(self.app.options['excellon_editor_slot_lin_dir'])
@@ -2326,11 +2496,8 @@ class AppExcEditor(QtCore.QObject):
self.ui.slot_array_direction_radio.set_value(self.app.options['excellon_editor_slot_circ_dir'])
self.ui.slot_array_angle_entry.set_value(float(self.app.options['excellon_editor_slot_circ_angle']))
self.ui.array_type_radio.set_value('linear')
self.on_array_type_radio(val=self.ui.array_type_radio.get_value())
self.ui.slot_array_type_radio.set_value('linear')
self.on_slot_array_type_radio(val=self.ui.slot_array_type_radio.get_value())
self.on_linear_angle_radio()
self.on_slot_array_linear_angle_radio()
# Show/Hide Advanced Options
@@ -4187,17 +4354,6 @@ class AppExcEditor(QtCore.QObject):
if unsel_shape in self.selected:
self.selected.remove(unsel_shape)
def on_array_type_radio(self, val):
if val == 'linear':
self.ui.array_circular_frame.hide()
self.ui.array_linear_frame.show()
self.app.inform.emit(_("Click to place ..."))
else:
self.delete_utility_geometry()
self.ui.array_circular_frame.show()
self.ui.array_linear_frame.hide()
self.app.inform.emit(_("Click on the circular array Center position"))
def on_slot_array_type_radio(self, val):
if val == 'linear':
self.ui.slot_array_circular_frame.hide()
@@ -4209,15 +4365,6 @@ class AppExcEditor(QtCore.QObject):
self.ui.slot_array_linear_frame.hide()
self.app.inform.emit(_("Click on the circular array Center position"))
def on_linear_angle_radio(self):
val = self.ui.drill_axis_radio.get_value()
if val == 'A':
self.ui.linear_angle_spinner.show()
self.ui.linear_angle_label.show()
else:
self.ui.linear_angle_spinner.hide()
self.ui.linear_angle_label.hide()
def on_slot_array_linear_angle_radio(self):
val = self.ui.slot_array_axis_radio.get_value()
if val == 'A':
@@ -4505,146 +4652,6 @@ class AppExcEditorUI:
self.resize_frame.hide()
# #############################################################################################################
# ################################## Add DRILL Array ##########################################################
# #############################################################################################################
# add a frame and inside add a grid box layout. Inside this grid layout I add
# all the add drill array widgets
# this way I can hide/show the frame
self.array_frame = QtWidgets.QFrame()
self.array_frame.setContentsMargins(0, 0, 0, 0)
self.ui_vertical_lay.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)
# Type of Drill Array
self.drill_array_label = FCLabel('%s' % _("Add Drill Array"), bold=True)
self.drill_array_label.setToolTip(
_("Add an array of drills (linear or circular array)")
)
self.array_grid.addWidget(self.drill_array_label, 0, 0, 1, 2)
# Array Type
array_type_lbl = FCLabel('%s:' % _("Type"))
array_type_lbl.setToolTip(
_("Select the type of drills 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)
# Set the number of drill holes in the drill array
self.drill_array_size_label = FCLabel('%s:' % _('Number'))
self.drill_array_size_label.setToolTip(_("Specify how many drills to be in the array."))
self.drill_array_size_entry = FCSpinner(policy=False)
self.drill_array_size_entry.set_range(1, 10000)
self.array_grid.addWidget(self.drill_array_size_label, 4, 0)
self.array_grid.addWidget(self.drill_array_size_entry, 4, 1)
# #############################################################################################################
# ###################### LINEAR Drill Array ###################################################################
# #############################################################################################################
self.array_linear_frame = QtWidgets.QFrame()
self.array_linear_frame.setContentsMargins(0, 0, 0, 0)
self.array_grid.addWidget(self.array_linear_frame, 6, 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.drill_axis_label = FCLabel('%s:' % _('Direction'))
self.drill_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.drill_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}])
self.lin_grid.addWidget(self.drill_axis_label, 0, 0)
self.lin_grid.addWidget(self.drill_axis_radio, 0, 1)
# Linear Drill Array pitch distance
self.drill_pitch_label = FCLabel('%s:' % _('Pitch'))
self.drill_pitch_label.setToolTip(
_("Pitch = Distance between elements of the array.")
)
self.drill_pitch_entry = FCDoubleSpinner(policy=False)
self.drill_pitch_entry.set_precision(self.decimals)
self.drill_pitch_entry.set_range(0.0000, 10000.0000)
self.lin_grid.addWidget(self.drill_pitch_label, 2, 0)
self.lin_grid.addWidget(self.drill_pitch_entry, 2, 1)
# Linear Drill 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)
# #############################################################################################################
# ###################### CIRCULAR Drill Array #################################################################
# #############################################################################################################
self.array_circular_frame = QtWidgets.QFrame()
self.array_circular_frame.setContentsMargins(0, 0, 0, 0)
self.array_grid.addWidget(self.array_circular_frame, 8, 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.drill_array_dir_lbl = FCLabel('%s:' % _('Direction'))
self.drill_array_dir_lbl.setToolTip(_("Direction for circular array.\n"
"Can be CW = clockwise or CCW = counter clockwise."))
self.drill_array_dir_radio = RadioSet([{'label': _('CW'), 'value': 'CW'},
{'label': _('CCW'), 'value': 'CCW'}])
self.circ_grid.addWidget(self.drill_array_dir_lbl, 0, 0)
self.circ_grid.addWidget(self.drill_array_dir_radio, 0, 1)
# Array Angle
self.drill_array_angle_lbl = FCLabel('%s:' % _('Angle'))
self.drill_array_angle_lbl.setToolTip(_("Angle at which each element in circular array is placed."))
self.drill_angle_entry = FCDoubleSpinner(policy=False)
self.drill_angle_entry.set_precision(self.decimals)
self.drill_angle_entry.setSingleStep(1.0)
self.drill_angle_entry.setRange(-360.00, 360.00)
self.circ_grid.addWidget(self.drill_array_angle_lbl, 2, 0)
self.circ_grid.addWidget(self.drill_angle_entry, 2, 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, 10, 0, 1, 2)
# #############################################################################################################
# ##################################### ADDING SLOT ARRAY ####################################################
# #############################################################################################################
@@ -4799,12 +4806,6 @@ class AppExcEditorUI:
# #############################################################################################################
# ###################### INIT Excellon Editor UI ##############################################################
# #############################################################################################################
self.linear_angle_spinner.hide()
self.linear_angle_label.hide()
self.array_linear_frame.hide()
self.array_circular_frame.hide()
self.array_frame.hide()
self.slot_array_linear_angle_spinner.hide()
self.slot_array_linear_angle_label.hide()
self.slot_array_frame.hide()

View File

@@ -18,7 +18,7 @@ class ExcDrillArrayEditorTool(AppTool):
self.decimals = app.decimals
self.plugin_name = plugin_name
self.ui = ExcDrillArrayEditorUI(layout=self.layout, copy_class=self, plugin_name=plugin_name)
self.ui = ExcDrillArrayEditorUI(layout=self.layout, darray_class=self, plugin_name=plugin_name)
self.connect_signals_at_init()
self.set_tool_ui()
@@ -72,8 +72,7 @@ class ExcDrillArrayEditorTool(AppTool):
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')
@@ -81,16 +80,6 @@ class ExcDrillArrayEditorTool(AppTool):
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()
@@ -108,7 +97,7 @@ class ExcDrillArrayEditorTool(AppTool):
self.ui.project_line_entry.set_value(val)
def hide_tool(self):
self.ui.copy_frame.hide()
self.ui.darray_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")
@@ -116,12 +105,12 @@ class ExcDrillArrayEditorTool(AppTool):
class ExcDrillArrayEditorUI:
def __init__(self, layout, copy_class, plugin_name):
def __init__(self, layout, darray_class, plugin_name):
self.pluginName = plugin_name
self.copy_class = copy_class
self.decimals = self.copy_class.app.decimals
self.darray_class = darray_class
self.decimals = self.darray_class.app.decimals
self.layout = layout
self.app = self.copy_class.app
self.app = self.darray_class.app
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName))
@@ -135,57 +124,74 @@ class ExcDrillArrayEditorUI:
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)
self.darray_frame = QtWidgets.QFrame()
self.darray_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.darray_frame)
self.editor_vbox = QtWidgets.QVBoxLayout()
self.editor_vbox.setContentsMargins(0, 0, 0, 0)
self.darray_frame.setLayout(self.editor_vbox)
# Grid Layout
grid0 = GLay(v_spacing=5, h_spacing=3)
self.copy_tool_box.addLayout(grid0)
# Position
self.tool_lbl = FCLabel('%s' % _("Tool Diameter"), bold=True, color='blue')
self.editor_vbox.addWidget(self.tool_lbl)
# #############################################################################################################
# Diameter Frame
# #############################################################################################################
dia_frame = FCFrame()
self.editor_vbox.addWidget(dia_frame)
# 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)
dia_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0])
dia_frame.setLayout(dia_grid)
self.clear_btn = FCButton(_("Clear"))
grid0.addWidget(self.clear_btn, 2, 0, 1, 2)
# 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')
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)
dia_grid.addWidget(self.dia_lbl, 0, 0)
dia_grid.addWidget(self.dia_entry, 0, 1)
dia_grid.addWidget(self.dia_unit, 0, 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'}
])
# 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)
grid0.addWidget(self.mode_label, 6, 0)
grid0.addWidget(self.mode_radio, 6, 1)
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.array_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.array_frame)
self.editor_vbox.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
@@ -207,7 +213,6 @@ class ExcDrillArrayEditorUI:
self.array_type_radio = RadioSet([
{'label': _('Linear'), 'value': 'linear'},
{'label': _('2D'), 'value': '2D'},
{'label': _('Circular'), 'value': 'circular'}
])
@@ -278,129 +283,6 @@ class ExcDrillArrayEditorUI:
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 #################################################################
# #############################################################################################################
@@ -437,22 +319,42 @@ class ExcDrillArrayEditorUI:
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)
# #############################################################################################################
# Projection Frame
# #############################################################################################################
pro_frame = FCFrame()
self.editor_vbox.addWidget(pro_frame)
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)
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.darray_class.app.resource_location + '/trash32.png'))
pro_grid.addWidget(self.clear_btn, 0, 2)
# #############################################################################################################
# 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, pro_grid, pos_grid, self.array_grid, self.lin_grid, self.circ_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:
@@ -467,79 +369,24 @@ class ExcDrillArrayEditorUI:
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':
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.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.app.inform.emit(_("Click on the circular array Center position"))
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)
self.array_size_entry.setDisabled(False)
def on_linear_angle_radio(self, val):
if val == 'A':
self.linear_angle_spinner.show()
self.linear_angle_label.show()
self.linear_angle_spinner.setEnabled(True)
self.linear_angle_label.setEnabled(True)
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()
self.linear_angle_spinner.setEnabled(False)
self.linear_angle_label.setEnabled(False)

View File

@@ -90,7 +90,7 @@ class ExcDrillEditorTool(AppTool):
self.ui.project_line_entry.set_value(val)
def hide_tool(self):
self.ui.path_tool_frame.hide()
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")
@@ -116,12 +116,12 @@ class ExcDrillEditorUI:
self.layout.addWidget(title_label)
# this way I can hide/show the frame
self.path_tool_frame = QtWidgets.QFrame()
self.path_tool_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.path_tool_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.path_tool_frame.setLayout(self.editor_vbox)
self.drill_tool_frame.setLayout(self.editor_vbox)
# Position
self.tool_lbl = FCLabel('%s' % _("Tool Diameter"), bold=True, color='blue')

View File

@@ -72,8 +72,6 @@ class ExcSlotArrayEditorTool(AppTool):
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')
@@ -108,7 +106,7 @@ class ExcSlotArrayEditorTool(AppTool):
self.ui.project_line_entry.set_value(val)
def hide_tool(self):
self.ui.copy_frame.hide()
self.ui.sarray_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")
@@ -116,12 +114,12 @@ class ExcSlotArrayEditorTool(AppTool):
class ExcSlotArrayEditorUI:
def __init__(self, layout, copy_class, plugin_name):
def __init__(self, layout, sarray_class, plugin_name):
self.pluginName = plugin_name
self.copy_class = copy_class
self.decimals = self.copy_class.app.decimals
self.ed_class = sarray_class
self.decimals = self.ed_class.app.decimals
self.layout = layout
self.app = self.copy_class.app
self.app = self.ed_class.app
# Title
title_label = FCLabel("%s" % ('Editor ' + self.pluginName))
@@ -135,16 +133,71 @@ class ExcSlotArrayEditorUI:
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)
self.sarray_frame = QtWidgets.QFrame()
self.sarray_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.sarray_frame)
self.editor_vbox = QtWidgets.QVBoxLayout()
self.editor_vbox.setContentsMargins(0, 0, 0, 0)
self.sarray_frame.setLayout(self.editor_vbox)
# Grid Layout
grid0 = GLay(v_spacing=5, h_spacing=3)
self.copy_tool_box.addLayout(grid0)
# Position
self.tool_lbl = FCLabel('%s' % _("Tool 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"))
@@ -152,29 +205,12 @@ class ExcSlotArrayEditorUI:
_("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)
pro_grid.addWidget(self.project_line_lbl, 0, 0)
pro_grid.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)
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)
# #############################################################################################################
# ######################################## Add Array ##########################################################
@@ -443,13 +479,12 @@ class ExcSlotArrayEditorUI:
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
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)
@@ -467,13 +502,6 @@ class ExcSlotArrayEditorUI:
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()
@@ -492,7 +520,7 @@ class ExcSlotArrayEditorUI:
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 ..."))
self.app.inform.emit(_("Click to place ..."))
else:
if val == 'linear':
self.array_circular_frame.hide()
@@ -501,7 +529,7 @@ class ExcSlotArrayEditorUI:
self.spacing_frame.hide()
self.offset_frame.hide()
self.app.inform.emit(_("Click on reference location ..."))
self.app.inform.emit(_("Click to place ..."))
else: # 'circular'
self.array_circular_frame.show()
self.array_linear_frame.hide()

View File

@@ -212,12 +212,12 @@ class ExcSlotEditorUI:
"- 'Angle' - a custom angle for the slot inclination")
)
self.slot_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}])
self.slot_direction_radio = RadioSet([{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}])
par_grid.addWidget(self.slot_axis_label, 4, 0)
par_grid.addWidget(self.slot_axis_radio, 4, 1)
par_grid.addWidget(self.slot_direction_radio, 4, 1)
# Slot custom angle
self.slot_angle_label = FCLabel('%s:' % _('Angle'))
@@ -267,10 +267,10 @@ class ExcSlotEditorUI:
self.layout.addStretch(1)
# Signals
self.slot_axis_radio.activated_custom.connect(self.on_slot_angle_radio)
self.slot_direction_radio.activated_custom.connect(self.on_slot_angle_radio)
def on_slot_angle_radio(self):
val = self.slot_axis_radio.get_value()
val = self.slot_direction_radio.get_value()
if val == 'A':
self.slot_angle_spinner.setEnabled(True)
self.slot_angle_label.setEnabled(True)