- in Excellon Editor, finished th upgrade work on the Slot Array Plugin

This commit is contained in:
Marius Stanciu
2022-04-30 16:34:22 +03:00
committed by Marius
parent 092451038e
commit 753b6c6d5d
9 changed files with 464 additions and 595 deletions

View File

@@ -10,6 +10,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 appEditors.exc_plugins.ExcSlotArrayPlugin import ExcSlotArrayEditorTool
from appGUI.GUIElements import FCEntry, FCTable, FCDoubleSpinner, RadioSet, FCSpinner, FCButton, FCLabel, GLay
from appEditors.AppGeoEditor import FCShapeTool, DrawTool, DrawToolShape, DrawToolUtilityShape, AppGeoEditor
@@ -59,7 +60,6 @@ class SelectEditorExc(FCShapeTool):
self.sel_storage = AppExcEditor.make_storage()
self.draw_app.ui.resize_frame.hide()
self.draw_app.ui.slot_array_frame.hide()
# make sure that the cursor text from the DrillAdd is deleted
if self.draw_app.app.plotcanvas.text_cursor.parent and self.draw_app.app.use_3d_engine:
@@ -546,7 +546,6 @@ class DrillArray(FCShapeTool):
QtGui.QGuiApplication.restoreOverrideCursor()
except Exception:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_drill_array.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
@@ -566,7 +565,6 @@ class DrillArray(FCShapeTool):
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))
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:
@@ -619,7 +617,7 @@ class DrillArray(FCShapeTool):
self.flag_for_circ_array = True
self.set_origin(point)
self.draw_app.app.inform.emit(_("Click on the Drill Circular Array Start position"))
self.draw_app.app.inform.emit(_("Click on the Circular Array Start position"))
else:
self.destination = point
self.make()
@@ -1319,33 +1317,16 @@ class SlotArray(FCShapeTool):
DrawTool.__init__(self, draw_app)
self.name = 'slot_array'
self.draw_app = draw_app
self.app = self.draw_app.app
self.selected_dia = None
try:
self.draw_app.app.inform.emit(_("Click to place ..."))
self.selected_dia = self.draw_app.tool2tooldia[self.draw_app.last_tool_selected]
# as a visual marker, select again in tooltable the actual tool that we are using
# remember that it was deselected when clicking on canvas
item = self.draw_app.ui.tools_table_exc.item((self.draw_app.last_tool_selected - 1), 1)
self.draw_app.ui.tools_table_exc.setCurrentItem(item)
except KeyError:
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s' %
_("To add an Slot Array first select a tool in Tool Table"))
return
try:
QtGui.QGuiApplication.restoreOverrideCursor()
except Exception:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_array.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"]
self.half_width = 0.0
self.half_height = 0.0
self.radius = float(self.selected_dia / 2.0)
self.array_radius = 0.0
self.slot_axis = 'X'
self.slot_array = 'linear' # 'linear'
self.slot_array_size = None
@@ -1365,18 +1346,91 @@ class SlotArray(FCShapeTool):
self.pt = []
try:
self.draw_app.app.inform.emit(_("Click to place ..."))
self.selected_dia = self.draw_app.tool2tooldia[self.draw_app.last_tool_selected]
# as a visual marker, select again in tooltable the actual tool that we are using
# remember that it was deselected when clicking on canvas
item = self.draw_app.ui.tools_table_exc.item((self.draw_app.last_tool_selected - 1), 1)
self.draw_app.ui.tools_table_exc.setCurrentItem(item)
except KeyError:
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s' %
_("To add an Slot Array first select a tool in Tool Table"))
return
self.radius = float(self.selected_dia / 2.0)
try:
QtGui.QGuiApplication.restoreOverrideCursor()
except Exception:
pass
self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_array.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
# #############################################################################################################
# Plugin UI
# #############################################################################################################
self.sarray_tool = ExcSlotArrayEditorTool(self.app, self.draw_app, plugin_name=_("Slot Array"))
self.ui = self.sarray_tool.ui
self.sarray_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)
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, _("Slot 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_slot_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))
# Slot set-up
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_entry.set_value(self.draw_app.last_slot_angle)
# Slot Array set-up
self.ui.array_type_radio.set_value(self.draw_app.last_sarray_type)
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_sarray_size)
self.ui.array_axis_radio.set_value(self.draw_app.last_sarray_lin_dir)
self.ui.array_pitch_entry.set_value(self.draw_app.last_sarray_pitch)
self.ui.array_linear_angle_entry.set_value(self.draw_app.last_sarray_lin_angle)
self.ui.array_direction_radio.set_value(self.draw_app.last_sarray_circ_dir)
self.ui.array_angle_entry.set_value(self.draw_app.last_sarray_circ_angle)
self.ui.radius_entry.set_value(self.draw_app.last_sarray_radius)
self.ui.on_slot_array_linear_angle_radio()
def click(self, point):
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.slot_array == 'linear': # 'Linear'
self.make()
@@ -1388,7 +1442,7 @@ class SlotArray(FCShapeTool):
self.flag_for_circ_array = True
self.set_origin(point)
self.draw_app.app.inform.emit(_("Click on the Slot Circular Array Start position"))
self.draw_app.app.inform.emit(_("Click on the Circular Array Start position"))
else:
self.destination = point
self.make()
@@ -1399,22 +1453,14 @@ class SlotArray(FCShapeTool):
self.origin = origin
def utility_geometry(self, data=None, static=None):
self.slot_axis = self.draw_app.ui.slot_array_axis_radio.get_value()
self.slot_direction = self.draw_app.ui.slot_array_direction_radio.get_value()
self.slot_array = self.draw_app.ui.slot_array_type_radio.get_value()
try:
self.slot_array_size = int(self.draw_app.ui.slot_array_size_entry.get_value())
try:
self.slot_pitch = float(self.draw_app.ui.slot_array_pitch_entry.get_value())
self.slot_linear_angle = float(self.draw_app.ui.slot_array_linear_angle_spinner.get_value())
self.slot_angle = float(self.draw_app.ui.slot_array_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."))
return
except Exception:
self.draw_app.app.inform.emit('[ERROR_NOTCL] %s' % _("The value is mistyped. Check the value."))
return
self.slot_axis = self.ui.array_axis_radio.get_value()
self.slot_direction = self.ui.array_direction_radio.get_value()
self.slot_array = self.ui.array_type_radio.get_value()
self.slot_array_size = int(self.ui.array_size_entry.get_value())
self.slot_pitch = float(self.ui.array_pitch_entry.get_value())
self.slot_linear_angle = float(self.ui.array_linear_angle_entry.get_value())
self.slot_angle = float(self.ui.array_angle_entry.get_value())
if self.slot_array == 'linear': # 'Linear'
if data[0] is None and data[1] is None:
@@ -1466,9 +1512,9 @@ class SlotArray(FCShapeTool):
radius = distance((cdx, cdy), self.origin)
except Exception:
radius = 0
if radius == 0:
self.draw_app.delete_utility_geometry()
self.ui.radius_entry.set_value(radius)
if len(self.pt) >= 1 and radius > 0:
try:
@@ -1494,9 +1540,9 @@ class SlotArray(FCShapeTool):
log.error("SlotArray.utility_geometry -- circular -> %s" % str(e))
def circular_util_shape(self, radius, angle):
self.slot_direction = self.draw_app.ui.slot_array_direction_radio.get_value()
self.slot_angle = self.draw_app.ui.slot_array_angle_entry.get_value()
self.slot_array_size = self.draw_app.ui.slot_array_size_entry.get_value()
self.slot_direction = self.ui.array_direction_radio.get_value()
self.slot_angle = self.ui.array_angle_entry.get_value()
self.slot_array_size = self.ui.array_size_entry.get_value()
circular_geo = []
if self.slot_direction == 'CW':
@@ -1528,26 +1574,10 @@ class SlotArray(FCShapeTool):
self.radius = float(self.selected_dia / 2.0)
self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"]
try:
slot_length = float(self.draw_app.ui.slot_length_entry.get_value())
except ValueError:
# try to convert comma to decimal point. if it's still not working error message and return
try:
slot_length = float(self.draw_app.ui.slot_length_entry.get_value().replace(',', '.'))
self.draw_app.ui.slot_length_entry.set_value(slot_length)
except ValueError:
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s' %
_("Value is missing or wrong format. Add it and retry."))
return
slot_length = float(self.ui.slot_length_entry.get_value())
slot_angle = float(self.ui.slot_angle_entry.get_value())
try:
slot_angle = float(self.draw_app.ui.slot_angle_spinner.get_value())
except ValueError:
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s' %
_("Value is missing or wrong format. Add it and retry."))
return
if self.draw_app.ui.slot_direction_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:
@@ -1614,7 +1644,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_direction_radio.get_value() == 'A':
if self.ui.slot_direction_radio.get_value() == 'A':
return rotate(Polygon(geo), -slot_angle)
else:
return Polygon(geo)
@@ -1655,7 +1685,10 @@ class SlotArray(FCShapeTool):
if (self.slot_angle * self.slot_array_size) > 360:
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s' %
_("Too many items for the selected spacing angle."))
self.draw_app.app.jump_signal.disconnect()
try:
self.draw_app.app.jump_signal.disconnect()
except (AttributeError, TypeError):
pass
return
# radius = distance(self.destination, self.origin)
@@ -1694,9 +1727,76 @@ class SlotArray(FCShapeTool):
self.complete = True
self.draw_app.app.inform.emit('[success] %s' % _("Done."))
self.draw_app.in_action = False
self.draw_app.ui.slot_frame.hide()
self.draw_app.ui.slot_array_frame.hide()
self.draw_app.app.jump_signal.disconnect()
# Slot
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_entry.get_value()
# Slot array
self.draw_app.last_sarray_type = self.ui.array_type_radio.get_value()
self.draw_app.last_sarray_size = self.ui.array_size_entry.get_value()
self.draw_app.last_sarray_lin_dir = self.ui.array_axis_radio.get_value()
self.draw_app.last_sarray_circ_dir = self.ui.array_direction_radio.get_value()
self.draw_app.last_sarray_pitch = self.ui.array_pitch_entry.get_value()
self.draw_app.last_sarray_lin_angle = self.ui.array_linear_angle_entry.get_value()
self.draw_app.last_sarray_circ_angle = self.ui.array_angle_entry.get_value()
self.draw_app.last_sarray_radius = self.ui.radius_entry.get_value()
try:
self.draw_app.app.jump_signal.disconnect()
except (AttributeError, TypeError):
pass
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(self.ui.radius_entry.get_value())
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()
@@ -1711,32 +1811,78 @@ class SlotArray(FCShapeTool):
if mod_key == 'Control':
# Toggle Pad Array Direction
if key == QtCore.Qt.Key.Key_Space:
if self.draw_app.ui.slot_array_axis_radio.get_value() == 'X':
self.draw_app.ui.slot_array_axis_radio.set_value('Y')
elif self.draw_app.ui.slot_array_axis_radio.get_value() == 'Y':
self.draw_app.ui.slot_array_axis_radio.set_value('A')
elif self.draw_app.ui.slot_array_axis_radio.get_value() == 'A':
self.draw_app.ui.slot_array_axis_radio.set_value('X')
if self.ui.array_axis_radio.get_value() == 'X':
self.ui.array_axis_radio.set_value('Y')
elif self.ui.array_axis_radio.get_value() == 'Y':
self.ui.array_axis_radio.set_value('A')
elif self.ui.array_axis_radio.get_value() == 'A':
self.ui.array_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))
elif mod_key is None:
# Jump to coords
if key == QtCore.Qt.Key.Key_J or key == 'J':
self.draw_app.app.on_jump_to()
# Toggle Pad Direction
if key == QtCore.Qt.Key.Key_Space:
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')
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))
def add_slot_array(self, array_pos):
self.array_radius = self.ui.radius_entry.get_value()
self.slot_axis = self.ui.array_axis_radio.get_value()
self.slot_direction = self.ui.array_direction_radio.get_value()
self.slot_array = self.ui.array_type_radio.get_value()
self.slot_array_size = int(self.ui.array_size_entry.get_value())
self.slot_pitch = float(self.ui.array_pitch_entry.get_value())
self.slot_linear_angle = float(self.ui.array_linear_angle_entry.get_value())
self.slot_angle = float(self.ui.array_angle_entry.get_value())
curr_pos = self.draw_app.app.geo_editor.snap(array_pos[0], array_pos[1])
self.draw_app.snap_x = curr_pos[0]
self.draw_app.snap_y = curr_pos[1]
self.points = [self.draw_app.snap_x, self.draw_app.snap_y]
self.origin = [self.draw_app.snap_x, self.draw_app.snap_y]
self.destination = ((self.origin[0] + self.array_radius), self.origin[1])
self.flag_for_circ_array = True
self.make()
if self.draw_app.current_storage is not None:
self.draw_app.on_exc_shape_complete(self.draw_app.current_storage)
self.draw_app.build_ui()
if self.draw_app.active_tool.complete:
self.draw_app.on_shape_complete()
self.draw_app.select_tool("drill_select")
self.draw_app.clicked_pos = curr_pos
def on_add_slot_array(self):
x = self.ui.x_entry.get_value()
y = self.ui.y_entry.get_value()
self.add_slot_array(array_pos=(x, y))
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):
@@ -2360,10 +2506,6 @@ 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.slot_array_type_radio.activated_custom.connect(self.on_slot_array_type_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)
self.app.ui.exc_add_drill_menuitem.triggered.connect(self.exc_add_drill)
@@ -2473,16 +2615,14 @@ class AppExcEditor(QtCore.QObject):
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'])
self.ui.slot_array_pitch_entry.set_value(float(self.app.options['excellon_editor_slot_lin_pitch']))
self.ui.slot_array_linear_angle_spinner.set_value(float(self.app.options['excellon_editor_slot_lin_angle']))
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.slot_array_type_radio.set_value('linear')
self.on_slot_array_type_radio(val=self.ui.slot_array_type_radio.get_value())
self.on_slot_array_linear_angle_radio()
self.last_sarray_type = 'linear'
self.last_sarray_size = int(self.app.options['excellon_editor_slot_array_size'])
self.last_sarray_lin_dir = self.app.options['excellon_editor_slot_lin_dir']
self.last_sarray_circ_dir = self.app.options['excellon_editor_slot_circ_dir']
self.last_sarray_pitch = float(self.app.options['excellon_editor_slot_lin_pitch'])
self.last_sarray_lin_angle = float(self.app.options['excellon_editor_slot_lin_angle'])
self.last_sarray_circ_angle = float(self.app.options['excellon_editor_slot_circ_angle'])
self.last_sarray_radius = 0.0
# Show/Hide Advanced Options
app_mode = self.app.options["global_app_level"]
@@ -4338,26 +4478,6 @@ class AppExcEditor(QtCore.QObject):
if unsel_shape in self.selected:
self.selected.remove(unsel_shape)
def on_slot_array_type_radio(self, val):
if val == 'linear':
self.ui.slot_array_circular_frame.hide()
self.ui.slot_array_linear_frame.show()
self.app.inform.emit(_("Click to place ..."))
else:
self.delete_utility_geometry()
self.ui.slot_array_circular_frame.show()
self.ui.slot_array_linear_frame.hide()
self.app.inform.emit(_("Click on the circular array Center position"))
def on_slot_array_linear_angle_radio(self):
val = self.ui.slot_array_axis_radio.get_value()
if val == 'A':
self.ui.slot_array_linear_angle_spinner.show()
self.ui.slot_array_linear_angle_label.show()
else:
self.ui.slot_array_linear_angle_spinner.hide()
self.ui.slot_array_linear_angle_label.hide()
def exc_add_drill(self):
self.select_tool('drill_add')
return
@@ -4636,140 +4756,6 @@ class AppExcEditorUI:
self.resize_frame.hide()
# #############################################################################################################
# ##################################### ADDING SLOT ARRAY ####################################################
# #############################################################################################################
self.slot_array_frame = QtWidgets.QFrame()
self.slot_array_frame.setContentsMargins(0, 0, 0, 0)
self.ui_vertical_lay.addWidget(self.slot_array_frame)
self.slot_array_grid = GLay(v_spacing=5, h_spacing=3)
self.slot_array_grid.setContentsMargins(0, 0, 0, 0)
self.slot_array_frame.setLayout(self.slot_array_grid)
# Slot Array Title
self.slot_array_label = FCLabel('%s' % _("Slot Array Parameters"), bold=True)
self.slot_array_label.setToolTip(
_("Parameters for the array of slots (linear or circular array)")
)
self.slot_array_grid.addWidget(self.slot_array_label, 0, 0, 1, 2)
# Array Type
array_type_lbl = FCLabel('%s:' % _("Type"))
array_type_lbl.setToolTip(
_("Select the type of slot array to create.\n"
"It can be Linear X(Y) or Circular")
)
self.slot_array_type_radio = RadioSet([{'label': _('Linear'), 'value': 'linear'},
{'label': _('Circular'), 'value': 'circular'}])
self.slot_array_grid.addWidget(array_type_lbl, 2, 0)
self.slot_array_grid.addWidget(self.slot_array_type_radio, 2, 1)
# Set the number of slot holes in the slot array
self.slot_array_size_label = FCLabel('%s:' % _('Number'))
self.slot_array_size_label.setToolTip(_("Specify how many slots to be in the array."))
self.slot_array_size_entry = FCSpinner(policy=False)
self.slot_array_size_entry.set_range(0, 10000)
self.slot_array_grid.addWidget(self.slot_array_size_label, 4, 0)
self.slot_array_grid.addWidget(self.slot_array_size_entry, 4, 1)
# #############################################################################################################
# ##################################### Linear SLOT ARRAY ####################################################
# #############################################################################################################
self.slot_array_linear_frame = QtWidgets.QFrame()
self.slot_array_linear_frame.setContentsMargins(0, 0, 0, 0)
self.slot_array_grid.addWidget(self.slot_array_linear_frame, 6, 0, 1, 2)
self.slot_array_lin_grid = GLay(v_spacing=5, h_spacing=3)
self.slot_array_lin_grid.setContentsMargins(0, 0, 0, 0)
self.slot_array_linear_frame.setLayout(self.slot_array_lin_grid)
# Linear Slot Array direction
self.slot_array_axis_label = FCLabel('%s:' % _('Direction'))
self.slot_array_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.slot_array_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}])
self.slot_array_lin_grid.addWidget(self.slot_array_axis_label, 0, 0)
self.slot_array_lin_grid.addWidget(self.slot_array_axis_radio, 0, 1)
# Linear Slot Array pitch distance
self.slot_array_pitch_label = FCLabel('%s:' % _('Pitch'))
self.slot_array_pitch_label.setToolTip(
_("Pitch = Distance between elements of the array.")
)
self.slot_array_pitch_entry = FCDoubleSpinner(policy=False)
self.slot_array_pitch_entry.set_precision(self.decimals)
self.slot_array_pitch_entry.setSingleStep(0.1)
self.slot_array_pitch_entry.setRange(0.0000, 10000.0000)
self.slot_array_lin_grid.addWidget(self.slot_array_pitch_label, 2, 0)
self.slot_array_lin_grid.addWidget(self.slot_array_pitch_entry, 2, 1)
# Linear Slot Array angle
self.slot_array_linear_angle_label = FCLabel('%s:' % _('Angle'))
self.slot_array_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.slot_array_linear_angle_spinner = FCDoubleSpinner(policy=False)
self.slot_array_linear_angle_spinner.set_precision(self.decimals)
self.slot_array_linear_angle_spinner.setSingleStep(1.0)
self.slot_array_linear_angle_spinner.setRange(-360.00, 360.00)
self.slot_array_lin_grid.addWidget(self.slot_array_linear_angle_label, 4, 0)
self.slot_array_lin_grid.addWidget(self.slot_array_linear_angle_spinner, 4, 1)
# #############################################################################################################
# ##################################### Circular SLOT ARRAY ##################################################
# #############################################################################################################
self.slot_array_circular_frame = QtWidgets.QFrame()
self.slot_array_circular_frame.setContentsMargins(0, 0, 0, 0)
self.slot_array_grid.addWidget(self.slot_array_circular_frame, 8, 0, 1, 2)
self.slot_array_circ_grid = GLay(v_spacing=5, h_spacing=3)
self.slot_array_circ_grid.setContentsMargins(0, 0, 0, 0)
self.slot_array_circular_frame.setLayout(self.slot_array_circ_grid)
# Slot Circular Array Direction
self.slot_array_direction_label = FCLabel('%s:' % _('Direction'))
self.slot_array_direction_label.setToolTip(_("Direction for circular array.\n"
"Can be CW = clockwise or CCW = counter clockwise."))
self.slot_array_direction_radio = RadioSet([{'label': _('CW'), 'value': 'CW'},
{'label': _('CCW'), 'value': 'CCW'}])
self.slot_array_circ_grid.addWidget(self.slot_array_direction_label, 0, 0)
self.slot_array_circ_grid.addWidget(self.slot_array_direction_radio, 0, 1)
# Slot Circular Array Angle
self.slot_array_angle_label = FCLabel('%s:' % _('Angle'))
self.slot_array_angle_label.setToolTip(_("Angle at which each element in circular array is placed."))
self.slot_array_angle_entry = FCDoubleSpinner(policy=False)
self.slot_array_angle_entry.set_precision(self.decimals)
self.slot_array_angle_entry.setSingleStep(1)
self.slot_array_angle_entry.setRange(-360.00, 360.00)
self.slot_array_circ_grid.addWidget(self.slot_array_angle_label, 2, 0)
self.slot_array_circ_grid.addWidget(self.slot_array_angle_entry, 2, 1)
self.ui_vertical_lay.addStretch()
layout.addStretch(1)
@@ -4790,9 +4776,7 @@ class AppExcEditorUI:
# #############################################################################################################
# ###################### INIT Excellon Editor UI ##############################################################
# #############################################################################################################
self.slot_array_linear_angle_spinner.hide()
self.slot_array_linear_angle_label.hide()
self.slot_array_frame.hide()
pass
# ############################ FINSIHED GUI ###################################
# #############################################################################

View File

@@ -179,16 +179,6 @@ class ExcDrillArrayEditorUI:
self.array_grid = GLay(v_spacing=5, h_spacing=3)
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(
@@ -201,8 +191,18 @@ class ExcDrillArrayEditorUI:
{'label': _('Circular'), 'value': 'circular'}
])
self.array_grid.addWidget(array_type_lbl, 4, 0)
self.array_grid.addWidget(self.array_type_radio, 4, 1)
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)

View File

@@ -18,21 +18,18 @@ class ExcSlotArrayEditorTool(AppTool):
self.decimals = app.decimals
self.plugin_name = plugin_name
self.ui = ExcSlotArrayEditorUI(layout=self.layout, copy_class=self, plugin_name=plugin_name)
self.ui = ExcSlotArrayEditorUI(layout=self.layout, sarray_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)
pass
def disconnect_signals(self):
# Signals
try:
self.ui.clear_btn.clicked.disconnect()
except (TypeError, AttributeError):
pass
pass
def run(self):
self.app.defaults.report_usage("Exc Editor ArrayTool()")
@@ -71,23 +68,7 @@ class ExcSlotArrayEditorTool(AppTool):
def set_tool_ui(self):
# Init appGUI
self.length = 0.0
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)
pass
def on_tab_close(self):
self.disconnect_signals()
@@ -97,14 +78,6 @@ class ExcSlotArrayEditorTool(AppTool):
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.sarray_frame.hide()
self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab)
@@ -136,6 +109,7 @@ class ExcSlotArrayEditorUI:
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)
@@ -190,65 +164,109 @@ class ExcSlotArrayEditorUI:
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.")
# Slot Parameters
self.slot_label = FCLabel('%s' % _("Slot"), bold=True, color='green')
self.slot_label.setToolTip(
_("Parameters for adding a slot (hole with oval shape)\n"
"either single or as an part of an array.")
)
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.editor_vbox.addWidget(self.slot_label)
# #############################################################################################################
# ######################################## Add Array ##########################################################
# ################################### Parameter Frame #########################################################
# #############################################################################################################
self.slot_frame = FCFrame()
self.editor_vbox.addWidget(self.slot_frame)
slot_grid = GLay(v_spacing=5, h_spacing=3)
self.slot_frame.setLayout(slot_grid)
# Slot length
self.slot_length_label = FCLabel('%s:' % _('Length'))
self.slot_length_label.setToolTip(
_("Length. The length of the slot.")
)
self.slot_length_entry = FCDoubleSpinner(policy=False)
self.slot_length_entry.set_precision(self.decimals)
self.slot_length_entry.setSingleStep(0.1)
self.slot_length_entry.setRange(0.0000, 10000.0000)
slot_grid.addWidget(self.slot_length_label, 2, 0)
slot_grid.addWidget(self.slot_length_entry, 2, 1)
# Slot direction
self.slot_axis_label = FCLabel('%s:' % _('Direction'))
self.slot_axis_label.setToolTip(
_("Direction on which the slot is oriented:\n"
"- 'X' - horizontal axis \n"
"- 'Y' - vertical axis or \n"
"- 'Angle' - a custom angle for the slot inclination")
)
self.slot_direction_radio = RadioSet([{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}])
slot_grid.addWidget(self.slot_axis_label, 4, 0)
slot_grid.addWidget(self.slot_direction_radio, 4, 1)
# Slot custom angle
self.slot_angle_label = FCLabel('%s:' % _('Angle'))
self.slot_angle_label.setToolTip(
_("Angle at which the slot 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.slot_angle_entry = FCDoubleSpinner(policy=False)
self.slot_angle_entry.set_precision(self.decimals)
self.slot_angle_entry.setWrapping(True)
self.slot_angle_entry.setRange(-360.00, 360.00)
self.slot_angle_entry.setSingleStep(1.0)
slot_grid.addWidget(self.slot_angle_label, 6, 0)
slot_grid.addWidget(self.slot_angle_entry, 6, 1)
# Slot Array Title
self.slot_array_label = FCLabel('%s' % _("Parameters"), bold=True, color='purple')
self.slot_array_label.setToolTip(
_("Array parameters.")
)
self.editor_vbox.addWidget(self.slot_array_label)
# #############################################################################################################
# ##################################### ADDING SLOT 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
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"
_("Select the type of slot 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'}
])
{'label': _('Circular'), 'value': 'circular'}])
self.array_grid.addWidget(array_type_lbl, 4, 0)
self.array_grid.addWidget(self.array_type_radio, 4, 1)
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 slots to be in the array."))
self.array_size_entry = FCSpinner(policy=False)
self.array_size_entry.set_range(0, 10000)
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)
@@ -256,238 +274,128 @@ class ExcSlotArrayEditorUI:
self.array_grid.addWidget(separator_line, 6, 0, 1, 2)
# #############################################################################################################
# ############################ LINEAR Array ###################################################################
# ##################################### Linear SLOT 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)
self.array_lin_grid = GLay(v_spacing=5, h_spacing=3)
self.array_lin_grid.setContentsMargins(0, 0, 0, 0)
self.array_linear_frame.setLayout(self.array_lin_grid)
# Linear Drill Array direction
self.axis_label = FCLabel('%s:' % _('Direction'))
self.axis_label.setToolTip(
# Linear Slot Array direction
self.slot_array_axis_label = FCLabel('%s:' % _('Direction'))
self.slot_array_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([
self.array_axis_radio = RadioSet([
{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}
])
{'label': _('Angle'), 'value': 'A'}])
self.lin_grid.addWidget(self.axis_label, 0, 0)
self.lin_grid.addWidget(self.axis_radio, 0, 1)
self.array_lin_grid.addWidget(self.slot_array_axis_label, 0, 0)
self.array_lin_grid.addWidget(self.array_axis_radio, 0, 1)
# Linear Array pitch distance
self.pitch_label = FCLabel('%s:' % _('Pitch'))
self.pitch_label.setToolTip(
# Linear Slot Array pitch distance
self.slot_array_pitch_label = FCLabel('%s:' % _('Pitch'))
self.slot_array_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.array_pitch_entry = FCDoubleSpinner(policy=False)
self.array_pitch_entry.set_precision(self.decimals)
self.array_pitch_entry.setSingleStep(0.1)
self.array_pitch_entry.setRange(0.0000, 10000.0000)
self.lin_grid.addWidget(self.pitch_label, 2, 0)
self.lin_grid.addWidget(self.pitch_entry, 2, 1)
self.array_lin_grid.addWidget(self.slot_array_pitch_label, 2, 0)
self.array_lin_grid.addWidget(self.array_pitch_entry, 2, 1)
# Linear Array angle
self.linear_angle_label = FCLabel('%s:' % _('Angle'))
self.linear_angle_label.setToolTip(
# Linear Slot Array angle
self.slot_array_linear_angle_label = FCLabel('%s:' % _('Angle'))
self.slot_array_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.array_linear_angle_entry = FCDoubleSpinner(policy=False)
self.array_linear_angle_entry.set_precision(self.decimals)
self.array_linear_angle_entry.setSingleStep(1.0)
self.array_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_spinner, 4, 1)
self.array_lin_grid.addWidget(self.slot_array_linear_angle_label, 4, 0)
self.array_lin_grid.addWidget(self.array_linear_angle_entry, 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 #################################################################
# ##################################### Circular SLOT 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.array_grid.addWidget(self.array_circular_frame, 10, 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)
self.array_circ_grid = GLay(v_spacing=5, h_spacing=3)
self.array_circ_grid.setContentsMargins(0, 0, 0, 0)
self.array_circular_frame.setLayout(self.array_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."))
# Slot Circular Array Direction
self.slot_array_direction_label = FCLabel('%s:' % _('Direction'))
self.slot_array_direction_label.setToolTip(_("Direction for circular array.\n"
"Can be CW = clockwise or CCW = counter clockwise."))
self.array_dir_radio = RadioSet([
self.array_direction_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)
self.array_circ_grid.addWidget(self.slot_array_direction_label, 0, 0)
self.array_circ_grid.addWidget(self.array_direction_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."))
# Slot Circular Array Angle
self.slot_array_angle_label = FCLabel('%s:' % _('Angle'))
self.slot_array_angle_label.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.array_angle_entry = FCDoubleSpinner(policy=False)
self.array_angle_entry.set_precision(self.decimals)
self.array_angle_entry.setSingleStep(1)
self.array_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)
self.array_circ_grid.addWidget(self.slot_array_angle_label, 2, 0)
self.array_circ_grid.addWidget(self.array_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.array_circ_grid.addWidget(self.radius_lbl, 4, 0)
self.array_circ_grid.addWidget(self.radius_entry, 4, 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)
# #############################################################################################################
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([
self.array_grid, self.lin_grid, self.dd_grid, self.circ_grid, self.s_grid, self.o_grid
], 0)
dia_grid, pos_grid, slot_grid, self.array_grid, self.array_lin_grid, self.array_circ_grid], 0)
self.layout.addStretch(1)
# Signals
self.slot_direction_radio.activated_custom.connect(self.on_slot_angle_radio)
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)
self.array_axis_radio.activated_custom.connect(self.on_linear_angle_radio)
def confirmation_message(self, accepted, minval, maxval):
if accepted is False:
@@ -503,71 +411,49 @@ class ExcSlotArrayEditorUI:
(_("Edited value is out of range"), minval, maxval), False)
def on_array_type_radio(self, val):
if val == '2D':
if val == 'linear':
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.array_linear_frame.show()
self.app.inform.emit(_("Click to place ..."))
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()
else: # 'circular'
self.array_circular_frame.show()
self.array_linear_frame.hide()
self.app.inform.emit(_("Click on the circular array Center position"))
self.app.inform.emit(_("Click to place ..."))
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.array_linear_angle_entry.show()
self.slot_array_linear_angle_label.show()
else:
self.linear_angle_spinner.hide()
self.linear_angle_label.hide()
self.array_linear_angle_entry.hide()
self.slot_array_linear_angle_label.hide()
def on_placement_radio(self, val):
if val == 's':
self.spacing_frame.show()
self.offset_frame.hide()
def on_slot_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:
self.spacing_frame.hide()
self.offset_frame.show()
self.array_circular_frame.show()
self.array_linear_frame.hide()
self.app.inform.emit(_("Click on the circular array Center position"))
def on_slot_array_linear_angle_radio(self):
val = self.array_axis_radio.get_value()
if val == 'A':
self.array_linear_angle_entry.show()
self.slot_array_linear_angle_label.show()
else:
self.array_linear_angle_entry.hide()
self.slot_array_linear_angle_label.hide()
def on_slot_angle_radio(self):
val = self.slot_direction_radio.get_value()
if val == 'A':
self.slot_angle_entry.setEnabled(True)
self.slot_angle_label.setEnabled(True)
else:
self.slot_angle_entry.setEnabled(False)
self.slot_angle_label.setEnabled(False)