|
|
@@ -30,8 +30,6 @@ log = logging.getLogger('base')
|
|
|
|
|
|
class ToolOptimal(AppTool):
|
|
|
|
|
|
- toolName = _("Optimal Tool")
|
|
|
-
|
|
|
update_text = QtCore.pyqtSignal(list)
|
|
|
update_sec_distances = QtCore.pyqtSignal(dict)
|
|
|
|
|
|
@@ -41,222 +39,11 @@ class ToolOptimal(AppTool):
|
|
|
self.units = self.app.defaults['units'].upper()
|
|
|
self.decimals = self.app.decimals
|
|
|
|
|
|
- # ############################################################################
|
|
|
- # ############################ GUI creation ##################################
|
|
|
- # ## Title
|
|
|
- title_label = QtWidgets.QLabel("%s" % self.toolName)
|
|
|
- title_label.setStyleSheet(
|
|
|
- """
|
|
|
- QLabel
|
|
|
- {
|
|
|
- font-size: 16px;
|
|
|
- font-weight: bold;
|
|
|
- }
|
|
|
- """)
|
|
|
- self.layout.addWidget(title_label)
|
|
|
-
|
|
|
- # ## Form Layout
|
|
|
- form_lay = QtWidgets.QFormLayout()
|
|
|
- self.layout.addLayout(form_lay)
|
|
|
-
|
|
|
- form_lay.addRow(QtWidgets.QLabel(""))
|
|
|
-
|
|
|
- # ## Gerber Object to mirror
|
|
|
- self.gerber_object_combo = FCComboBox()
|
|
|
- self.gerber_object_combo.setModel(self.app.collection)
|
|
|
- self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
- self.gerber_object_combo.is_last = True
|
|
|
- self.gerber_object_combo.obj_type = "Gerber"
|
|
|
-
|
|
|
- self.gerber_object_label = QtWidgets.QLabel("<b>%s:</b>" % _("GERBER"))
|
|
|
- self.gerber_object_label.setToolTip(
|
|
|
- "Gerber object for which to find the minimum distance between copper features."
|
|
|
- )
|
|
|
- form_lay.addRow(self.gerber_object_label)
|
|
|
- form_lay.addRow(self.gerber_object_combo)
|
|
|
-
|
|
|
- separator_line = QtWidgets.QFrame()
|
|
|
- separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
|
|
- separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
|
|
- form_lay.addRow(separator_line)
|
|
|
-
|
|
|
- # Precision = nr of decimals
|
|
|
- self.precision_label = QtWidgets.QLabel('%s:' % _("Precision"))
|
|
|
- self.precision_label.setToolTip(_("Number of decimals kept for found distances."))
|
|
|
-
|
|
|
- self.precision_spinner = FCSpinner(callback=self.confirmation_message_int)
|
|
|
- self.precision_spinner.set_range(2, 10)
|
|
|
- self.precision_spinner.setWrapping(True)
|
|
|
- form_lay.addRow(self.precision_label, self.precision_spinner)
|
|
|
-
|
|
|
- # Results Title
|
|
|
- self.title_res_label = QtWidgets.QLabel('<b>%s:</b>' % _("Minimum distance"))
|
|
|
- self.title_res_label.setToolTip(_("Display minimum distance between copper features."))
|
|
|
- form_lay.addRow(self.title_res_label)
|
|
|
-
|
|
|
- # Result value
|
|
|
- self.result_label = QtWidgets.QLabel('%s:' % _("Determined"))
|
|
|
- self.result_entry = FCEntry()
|
|
|
- self.result_entry.setReadOnly(True)
|
|
|
-
|
|
|
- self.units_lbl = QtWidgets.QLabel(self.units.lower())
|
|
|
- self.units_lbl.setDisabled(True)
|
|
|
-
|
|
|
- hlay = QtWidgets.QHBoxLayout()
|
|
|
- hlay.addWidget(self.result_entry)
|
|
|
- hlay.addWidget(self.units_lbl)
|
|
|
-
|
|
|
- form_lay.addRow(self.result_label, hlay)
|
|
|
-
|
|
|
- # Frequency of minimum encounter
|
|
|
- self.freq_label = QtWidgets.QLabel('%s:' % _("Occurring"))
|
|
|
- self.freq_label.setToolTip(_("How many times this minimum is found."))
|
|
|
- self.freq_entry = FCEntry()
|
|
|
- self.freq_entry.setReadOnly(True)
|
|
|
- form_lay.addRow(self.freq_label, self.freq_entry)
|
|
|
-
|
|
|
- # Control if to display the locations of where the minimum was found
|
|
|
- self.locations_cb = FCCheckBox(_("Minimum points coordinates"))
|
|
|
- self.locations_cb.setToolTip(_("Coordinates for points where minimum distance was found."))
|
|
|
- form_lay.addRow(self.locations_cb)
|
|
|
-
|
|
|
- # Locations where minimum was found
|
|
|
- self.locations_textb = FCTextArea(parent=self)
|
|
|
- self.locations_textb.setPlaceholderText(
|
|
|
- _("Coordinates for points where minimum distance was found.")
|
|
|
- )
|
|
|
- self.locations_textb.setReadOnly(True)
|
|
|
- stylesheet = """
|
|
|
- QTextEdit { selection-background-color:blue;
|
|
|
- selection-color:white;
|
|
|
- }
|
|
|
- """
|
|
|
-
|
|
|
- self.locations_textb.setStyleSheet(stylesheet)
|
|
|
- form_lay.addRow(self.locations_textb)
|
|
|
-
|
|
|
- # Jump button
|
|
|
- self.locate_button = QtWidgets.QPushButton(_("Jump to selected position"))
|
|
|
- self.locate_button.setToolTip(
|
|
|
- _("Select a position in the Locations text box and then\n"
|
|
|
- "click this button.")
|
|
|
- )
|
|
|
- self.locate_button.setMinimumWidth(60)
|
|
|
- self.locate_button.setDisabled(True)
|
|
|
- form_lay.addRow(self.locate_button)
|
|
|
-
|
|
|
- # Other distances in Gerber
|
|
|
- self.title_second_res_label = QtWidgets.QLabel('<b>%s:</b>' % _("Other distances"))
|
|
|
- self.title_second_res_label.setToolTip(_("Will display other distances in the Gerber file ordered from\n"
|
|
|
- "the minimum to the maximum, not including the absolute minimum."))
|
|
|
- form_lay.addRow(self.title_second_res_label)
|
|
|
-
|
|
|
- # Control if to display the locations of where the minimum was found
|
|
|
- self.sec_locations_cb = FCCheckBox(_("Other distances points coordinates"))
|
|
|
- self.sec_locations_cb.setToolTip(_("Other distances and the coordinates for points\n"
|
|
|
- "where the distance was found."))
|
|
|
- form_lay.addRow(self.sec_locations_cb)
|
|
|
-
|
|
|
- # this way I can hide/show the frame
|
|
|
- self.sec_locations_frame = QtWidgets.QFrame()
|
|
|
- self.sec_locations_frame.setContentsMargins(0, 0, 0, 0)
|
|
|
- self.layout.addWidget(self.sec_locations_frame)
|
|
|
- self.distances_box = QtWidgets.QVBoxLayout()
|
|
|
- self.distances_box.setContentsMargins(0, 0, 0, 0)
|
|
|
- self.sec_locations_frame.setLayout(self.distances_box)
|
|
|
-
|
|
|
- # Other Distances label
|
|
|
- self.distances_label = QtWidgets.QLabel('%s' % _("Gerber distances"))
|
|
|
- self.distances_label.setToolTip(_("Other distances and the coordinates for points\n"
|
|
|
- "where the distance was found."))
|
|
|
- self.distances_box.addWidget(self.distances_label)
|
|
|
-
|
|
|
- # Other distances
|
|
|
- self.distances_textb = FCTextArea(parent=self)
|
|
|
- self.distances_textb.setPlaceholderText(
|
|
|
- _("Other distances and the coordinates for points\n"
|
|
|
- "where the distance was found.")
|
|
|
- )
|
|
|
- self.distances_textb.setReadOnly(True)
|
|
|
- stylesheet = """
|
|
|
- QTextEdit { selection-background-color:blue;
|
|
|
- selection-color:white;
|
|
|
- }
|
|
|
- """
|
|
|
-
|
|
|
- self.distances_textb.setStyleSheet(stylesheet)
|
|
|
- self.distances_box.addWidget(self.distances_textb)
|
|
|
-
|
|
|
- self.distances_box.addWidget(QtWidgets.QLabel(''))
|
|
|
-
|
|
|
- # Other Locations label
|
|
|
- self.locations_label = QtWidgets.QLabel('%s' % _("Points coordinates"))
|
|
|
- self.locations_label.setToolTip(_("Other distances and the coordinates for points\n"
|
|
|
- "where the distance was found."))
|
|
|
- self.distances_box.addWidget(self.locations_label)
|
|
|
-
|
|
|
- # Locations where minimum was found
|
|
|
- self.locations_sec_textb = FCTextArea(parent=self)
|
|
|
- self.locations_sec_textb.setPlaceholderText(
|
|
|
- _("Other distances and the coordinates for points\n"
|
|
|
- "where the distance was found.")
|
|
|
- )
|
|
|
- self.locations_sec_textb.setReadOnly(True)
|
|
|
- stylesheet = """
|
|
|
- QTextEdit { selection-background-color:blue;
|
|
|
- selection-color:white;
|
|
|
- }
|
|
|
- """
|
|
|
-
|
|
|
- self.locations_sec_textb.setStyleSheet(stylesheet)
|
|
|
- self.distances_box.addWidget(self.locations_sec_textb)
|
|
|
-
|
|
|
- # Jump button
|
|
|
- self.locate_sec_button = QtWidgets.QPushButton(_("Jump to selected position"))
|
|
|
- self.locate_sec_button.setToolTip(
|
|
|
- _("Select a position in the Locations text box and then\n"
|
|
|
- "click this button.")
|
|
|
- )
|
|
|
- self.locate_sec_button.setMinimumWidth(60)
|
|
|
- self.locate_sec_button.setDisabled(True)
|
|
|
- self.distances_box.addWidget(self.locate_sec_button)
|
|
|
-
|
|
|
- # GO button
|
|
|
- self.calculate_button = QtWidgets.QPushButton(_("Find Minimum"))
|
|
|
- self.calculate_button.setToolTip(
|
|
|
- _("Calculate the minimum distance between copper features,\n"
|
|
|
- "this will allow the determination of the right tool to\n"
|
|
|
- "use for isolation or copper clearing.")
|
|
|
- )
|
|
|
- self.calculate_button.setStyleSheet("""
|
|
|
- QPushButton
|
|
|
- {
|
|
|
- font-weight: bold;
|
|
|
- }
|
|
|
- """)
|
|
|
- self.calculate_button.setMinimumWidth(60)
|
|
|
- self.layout.addWidget(self.calculate_button)
|
|
|
-
|
|
|
- self.layout.addStretch()
|
|
|
-
|
|
|
- # ## Reset Tool
|
|
|
- self.reset_button = QtWidgets.QPushButton(_("Reset Tool"))
|
|
|
- self.reset_button.setIcon(QtGui.QIcon(self.app.resource_location + '/reset32.png'))
|
|
|
- self.reset_button.setToolTip(
|
|
|
- _("Will reset the tool parameters.")
|
|
|
- )
|
|
|
- self.reset_button.setStyleSheet("""
|
|
|
- QPushButton
|
|
|
- {
|
|
|
- font-weight: bold;
|
|
|
- }
|
|
|
- """)
|
|
|
- self.layout.addWidget(self.reset_button)
|
|
|
-
|
|
|
- self.loc_ois = OptionalHideInputSection(self.locations_cb, [self.locations_textb, self.locate_button])
|
|
|
- self.sec_loc_ois = OptionalHideInputSection(self.sec_locations_cb, [self.sec_locations_frame])
|
|
|
- # ################## Finished GUI creation ###################################
|
|
|
- # ############################################################################
|
|
|
+ # #############################################################################
|
|
|
+ # ######################### Tool GUI ##########################################
|
|
|
+ # #############################################################################
|
|
|
+ self.ui = OptimalUI(layout=self.layout, app=self.app)
|
|
|
+ self.toolName = self.ui.toolName
|
|
|
|
|
|
# this is the line selected in the textbox with the locations of the minimum
|
|
|
self.selected_text = ''
|
|
|
@@ -271,17 +58,17 @@ class ToolOptimal(AppTool):
|
|
|
# ############################################################################
|
|
|
# ############################ Signals #######################################
|
|
|
# ############################################################################
|
|
|
- self.calculate_button.clicked.connect(self.find_minimum_distance)
|
|
|
- self.locate_button.clicked.connect(self.on_locate_position)
|
|
|
- self.update_text.connect(self.on_update_text)
|
|
|
- self.locations_textb.cursorPositionChanged.connect(self.on_textbox_clicked)
|
|
|
+ self.ui.calculate_button.clicked.connect(self.find_minimum_distance)
|
|
|
+ self.ui.locate_button.clicked.connect(self.on_locate_position)
|
|
|
+ self.ui.update_text.connect(self.on_update_text)
|
|
|
+ self.ui.locations_textb.cursorPositionChanged.connect(self.on_textbox_clicked)
|
|
|
|
|
|
- self.locate_sec_button.clicked.connect(self.on_locate_sec_position)
|
|
|
- self.update_sec_distances.connect(self.on_update_sec_distances_txt)
|
|
|
- self.distances_textb.cursorPositionChanged.connect(self.on_distances_textb_clicked)
|
|
|
- self.locations_sec_textb.cursorPositionChanged.connect(self.on_locations_sec_clicked)
|
|
|
+ self.ui.locate_sec_button.clicked.connect(self.on_locate_sec_position)
|
|
|
+ self.ui.update_sec_distances.connect(self.on_update_sec_distances_txt)
|
|
|
+ self.ui.distances_textb.cursorPositionChanged.connect(self.on_distances_textb_clicked)
|
|
|
+ self.ui.locations_sec_textb.cursorPositionChanged.connect(self.on_locations_sec_clicked)
|
|
|
|
|
|
- self.reset_button.clicked.connect(self.set_tool_ui)
|
|
|
+ self.ui.reset_button.clicked.connect(self.set_tool_ui)
|
|
|
|
|
|
def install(self, icon=None, separator=None, **kwargs):
|
|
|
AppTool.install(self, icon, separator, shortcut='Alt+O', **kwargs)
|
|
|
@@ -314,13 +101,13 @@ class ToolOptimal(AppTool):
|
|
|
self.app.ui.notebook.setTabText(2, _("Optimal Tool"))
|
|
|
|
|
|
def set_tool_ui(self):
|
|
|
- self.result_entry.set_value(0.0)
|
|
|
- self.freq_entry.set_value('0')
|
|
|
+ self.ui.result_entry.set_value(0.0)
|
|
|
+ self.ui.freq_entry.set_value('0')
|
|
|
|
|
|
- self.precision_spinner.set_value(int(self.app.defaults["tools_opt_precision"]))
|
|
|
- self.locations_textb.clear()
|
|
|
+ self.ui.precision_spinner.set_value(int(self.app.defaults["tools_opt_precision"]))
|
|
|
+ self.ui.locations_textb.clear()
|
|
|
# new cursor - select all document
|
|
|
- cursor = self.locations_textb.textCursor()
|
|
|
+ cursor = self.ui.locations_textb.textCursor()
|
|
|
cursor.select(QtGui.QTextCursor.Document)
|
|
|
|
|
|
# clear previous selection highlight
|
|
|
@@ -328,20 +115,20 @@ class ToolOptimal(AppTool):
|
|
|
tmp.clearBackground()
|
|
|
cursor.setBlockFormat(tmp)
|
|
|
|
|
|
- self.locations_textb.setVisible(False)
|
|
|
- self.locate_button.setVisible(False)
|
|
|
+ self.ui.locations_textb.setVisible(False)
|
|
|
+ self.ui.locate_button.setVisible(False)
|
|
|
|
|
|
- self.result_entry.set_value(0.0)
|
|
|
- self.freq_entry.set_value('0')
|
|
|
+ self.ui.result_entry.set_value(0.0)
|
|
|
+ self.ui.freq_entry.set_value('0')
|
|
|
self.reset_fields()
|
|
|
|
|
|
def find_minimum_distance(self):
|
|
|
self.units = self.app.defaults['units'].upper()
|
|
|
- self.decimals = int(self.precision_spinner.get_value())
|
|
|
+ self.decimals = int(self.ui.precision_spinner.get_value())
|
|
|
|
|
|
- selection_index = self.gerber_object_combo.currentIndex()
|
|
|
+ selection_index = self.ui.gerber_object_combo.currentIndex()
|
|
|
|
|
|
- model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
|
|
|
+ model_index = self.app.collection.index(selection_index, 0, self.ui.gerber_object_combo.rootModelIndex())
|
|
|
try:
|
|
|
fcobj = model_index.internalPointer().obj
|
|
|
except Exception as e:
|
|
|
@@ -426,17 +213,16 @@ class ToolOptimal(AppTool):
|
|
|
old_disp_number = disp_number
|
|
|
idx += 1
|
|
|
|
|
|
- app_obj.inform.emit(
|
|
|
- _("Optimal Tool. Finding the minimum distance."))
|
|
|
+ app_obj.inform.emit(_("Optimal Tool. Finding the minimum distance."))
|
|
|
|
|
|
min_list = list(self.min_dict.keys())
|
|
|
min_dist = min(min_list)
|
|
|
min_dist_string = '%.*f' % (self.decimals, float(min_dist))
|
|
|
- self.result_entry.set_value(min_dist_string)
|
|
|
+ self.ui.result_entry.set_value(min_dist_string)
|
|
|
|
|
|
freq = len(self.min_dict[min_dist])
|
|
|
freq = '%d' % int(freq)
|
|
|
- self.freq_entry.set_value(freq)
|
|
|
+ self.ui.freq_entry.set_value(freq)
|
|
|
|
|
|
min_locations = self.min_dict.pop(min_dist)
|
|
|
|
|
|
@@ -484,12 +270,12 @@ class ToolOptimal(AppTool):
|
|
|
for loc in data:
|
|
|
if loc:
|
|
|
txt += '%s, %s\n' % (str(loc[0]), str(loc[1]))
|
|
|
- self.locations_textb.setPlainText(txt)
|
|
|
- self.locate_button.setDisabled(False)
|
|
|
+ self.ui.locations_textb.setPlainText(txt)
|
|
|
+ self.ui.locate_button.setDisabled(False)
|
|
|
|
|
|
def on_textbox_clicked(self):
|
|
|
# new cursor - select all document
|
|
|
- cursor = self.locations_textb.textCursor()
|
|
|
+ cursor = self.ui.locations_textb.textCursor()
|
|
|
cursor.select(QtGui.QTextCursor.Document)
|
|
|
|
|
|
# clear previous selection highlight
|
|
|
@@ -498,7 +284,7 @@ class ToolOptimal(AppTool):
|
|
|
cursor.setBlockFormat(tmp)
|
|
|
|
|
|
# new cursor - select the current line
|
|
|
- cursor = self.locations_textb.textCursor()
|
|
|
+ cursor = self.ui.locations_textb.textCursor()
|
|
|
cursor.select(QtGui.QTextCursor.LineUnderCursor)
|
|
|
|
|
|
# highlight the current selected line
|
|
|
@@ -513,12 +299,12 @@ class ToolOptimal(AppTool):
|
|
|
txt = ''
|
|
|
for loc in distance_list:
|
|
|
txt += '%s\n' % str(loc)
|
|
|
- self.distances_textb.setPlainText(txt)
|
|
|
- self.locate_sec_button.setDisabled(False)
|
|
|
+ self.ui.distances_textb.setPlainText(txt)
|
|
|
+ self.ui.locate_sec_button.setDisabled(False)
|
|
|
|
|
|
def on_distances_textb_clicked(self):
|
|
|
# new cursor - select all document
|
|
|
- cursor = self.distances_textb.textCursor()
|
|
|
+ cursor = self.ui.distances_textb.textCursor()
|
|
|
cursor.select(QtGui.QTextCursor.Document)
|
|
|
|
|
|
# clear previous selection highlight
|
|
|
@@ -527,7 +313,7 @@ class ToolOptimal(AppTool):
|
|
|
cursor.setBlockFormat(tmp)
|
|
|
|
|
|
# new cursor - select the current line
|
|
|
- cursor = self.distances_textb.textCursor()
|
|
|
+ cursor = self.ui.distances_textb.textCursor()
|
|
|
cursor.select(QtGui.QTextCursor.LineUnderCursor)
|
|
|
|
|
|
# highlight the current selected line
|
|
|
@@ -545,11 +331,11 @@ class ToolOptimal(AppTool):
|
|
|
for loc in distance_list:
|
|
|
if loc:
|
|
|
txt += '%s, %s\n' % (str(loc[0]), str(loc[1]))
|
|
|
- self.locations_sec_textb.setPlainText(txt)
|
|
|
+ self.ui.locations_sec_textb.setPlainText(txt)
|
|
|
|
|
|
def on_locations_sec_clicked(self):
|
|
|
# new cursor - select all document
|
|
|
- cursor = self.locations_sec_textb.textCursor()
|
|
|
+ cursor = self.ui.locations_sec_textb.textCursor()
|
|
|
cursor.select(QtGui.QTextCursor.Document)
|
|
|
|
|
|
# clear previous selection highlight
|
|
|
@@ -558,7 +344,7 @@ class ToolOptimal(AppTool):
|
|
|
cursor.setBlockFormat(tmp)
|
|
|
|
|
|
# new cursor - select the current line
|
|
|
- cursor = self.locations_sec_textb.textCursor()
|
|
|
+ cursor = self.ui.locations_sec_textb.textCursor()
|
|
|
cursor.select(QtGui.QTextCursor.LineUnderCursor)
|
|
|
|
|
|
# highlight the current selected line
|
|
|
@@ -593,5 +379,247 @@ class ToolOptimal(AppTool):
|
|
|
return
|
|
|
|
|
|
def reset_fields(self):
|
|
|
+ self.ui.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
+ self.ui.gerber_object_combo.setCurrentIndex(0)
|
|
|
+
|
|
|
+
|
|
|
+class OptimalUI:
|
|
|
+
|
|
|
+ toolName = _("Optimal Tool")
|
|
|
+
|
|
|
+ def __init__(self, layout, app):
|
|
|
+ self.app = app
|
|
|
+ self.decimals = self.app.decimals
|
|
|
+ self.layout = layout
|
|
|
+ self.units = self.app.defaults['units'].upper()
|
|
|
+
|
|
|
+ # ## Title
|
|
|
+ title_label = QtWidgets.QLabel("%s" % self.toolName)
|
|
|
+ title_label.setStyleSheet("""
|
|
|
+ QLabel
|
|
|
+ {
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ """)
|
|
|
+ self.layout.addWidget(title_label)
|
|
|
+ self.layout.addWidget(QtWidgets.QLabel(""))
|
|
|
+
|
|
|
+ # ## Form Layout
|
|
|
+ form_lay = QtWidgets.QFormLayout()
|
|
|
+ self.layout.addLayout(form_lay)
|
|
|
+
|
|
|
+ # ## Gerber Object to mirror
|
|
|
+ self.gerber_object_combo = FCComboBox()
|
|
|
+ self.gerber_object_combo.setModel(self.app.collection)
|
|
|
self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
- self.gerber_object_combo.setCurrentIndex(0)
|
|
|
+ self.gerber_object_combo.is_last = True
|
|
|
+ self.gerber_object_combo.obj_type = "Gerber"
|
|
|
+
|
|
|
+ self.gerber_object_label = QtWidgets.QLabel("<b>%s:</b>" % _("GERBER"))
|
|
|
+ self.gerber_object_label.setToolTip(
|
|
|
+ "Gerber object for which to find the minimum distance between copper features."
|
|
|
+ )
|
|
|
+ form_lay.addRow(self.gerber_object_label)
|
|
|
+ form_lay.addRow(self.gerber_object_combo)
|
|
|
+
|
|
|
+ separator_line = QtWidgets.QFrame()
|
|
|
+ separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
|
|
+ separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
|
|
+ form_lay.addRow(separator_line)
|
|
|
+
|
|
|
+ # Precision = nr of decimals
|
|
|
+ self.precision_label = QtWidgets.QLabel('%s:' % _("Precision"))
|
|
|
+ self.precision_label.setToolTip(_("Number of decimals kept for found distances."))
|
|
|
+
|
|
|
+ self.precision_spinner = FCSpinner(callback=self.confirmation_message_int)
|
|
|
+ self.precision_spinner.set_range(2, 10)
|
|
|
+ self.precision_spinner.setWrapping(True)
|
|
|
+ form_lay.addRow(self.precision_label, self.precision_spinner)
|
|
|
+
|
|
|
+ # Results Title
|
|
|
+ self.title_res_label = QtWidgets.QLabel('<b>%s:</b>' % _("Minimum distance"))
|
|
|
+ self.title_res_label.setToolTip(_("Display minimum distance between copper features."))
|
|
|
+ form_lay.addRow(self.title_res_label)
|
|
|
+
|
|
|
+ # Result value
|
|
|
+ self.result_label = QtWidgets.QLabel('%s:' % _("Determined"))
|
|
|
+ self.result_entry = FCEntry()
|
|
|
+ self.result_entry.setReadOnly(True)
|
|
|
+
|
|
|
+ self.units_lbl = QtWidgets.QLabel(self.units.lower())
|
|
|
+ self.units_lbl.setDisabled(True)
|
|
|
+
|
|
|
+ hlay = QtWidgets.QHBoxLayout()
|
|
|
+ hlay.addWidget(self.result_entry)
|
|
|
+ hlay.addWidget(self.units_lbl)
|
|
|
+
|
|
|
+ form_lay.addRow(self.result_label, hlay)
|
|
|
+
|
|
|
+ # Frequency of minimum encounter
|
|
|
+ self.freq_label = QtWidgets.QLabel('%s:' % _("Occurring"))
|
|
|
+ self.freq_label.setToolTip(_("How many times this minimum is found."))
|
|
|
+ self.freq_entry = FCEntry()
|
|
|
+ self.freq_entry.setReadOnly(True)
|
|
|
+ form_lay.addRow(self.freq_label, self.freq_entry)
|
|
|
+
|
|
|
+ # Control if to display the locations of where the minimum was found
|
|
|
+ self.locations_cb = FCCheckBox(_("Minimum points coordinates"))
|
|
|
+ self.locations_cb.setToolTip(_("Coordinates for points where minimum distance was found."))
|
|
|
+ form_lay.addRow(self.locations_cb)
|
|
|
+
|
|
|
+ # Locations where minimum was found
|
|
|
+ self.locations_textb = FCTextArea(parent=self)
|
|
|
+ self.locations_textb.setPlaceholderText(
|
|
|
+ _("Coordinates for points where minimum distance was found.")
|
|
|
+ )
|
|
|
+ self.locations_textb.setReadOnly(True)
|
|
|
+ stylesheet = """
|
|
|
+ QTextEdit { selection-background-color:blue;
|
|
|
+ selection-color:white;
|
|
|
+ }
|
|
|
+ """
|
|
|
+
|
|
|
+ self.locations_textb.setStyleSheet(stylesheet)
|
|
|
+ form_lay.addRow(self.locations_textb)
|
|
|
+
|
|
|
+ # Jump button
|
|
|
+ self.locate_button = QtWidgets.QPushButton(_("Jump to selected position"))
|
|
|
+ self.locate_button.setToolTip(
|
|
|
+ _("Select a position in the Locations text box and then\n"
|
|
|
+ "click this button.")
|
|
|
+ )
|
|
|
+ self.locate_button.setMinimumWidth(60)
|
|
|
+ self.locate_button.setDisabled(True)
|
|
|
+ form_lay.addRow(self.locate_button)
|
|
|
+
|
|
|
+ # Other distances in Gerber
|
|
|
+ self.title_second_res_label = QtWidgets.QLabel('<b>%s:</b>' % _("Other distances"))
|
|
|
+ self.title_second_res_label.setToolTip(_("Will display other distances in the Gerber file ordered from\n"
|
|
|
+ "the minimum to the maximum, not including the absolute minimum."))
|
|
|
+ form_lay.addRow(self.title_second_res_label)
|
|
|
+
|
|
|
+ # Control if to display the locations of where the minimum was found
|
|
|
+ self.sec_locations_cb = FCCheckBox(_("Other distances points coordinates"))
|
|
|
+ self.sec_locations_cb.setToolTip(_("Other distances and the coordinates for points\n"
|
|
|
+ "where the distance was found."))
|
|
|
+ form_lay.addRow(self.sec_locations_cb)
|
|
|
+
|
|
|
+ # this way I can hide/show the frame
|
|
|
+ self.sec_locations_frame = QtWidgets.QFrame()
|
|
|
+ self.sec_locations_frame.setContentsMargins(0, 0, 0, 0)
|
|
|
+ self.layout.addWidget(self.sec_locations_frame)
|
|
|
+ self.distances_box = QtWidgets.QVBoxLayout()
|
|
|
+ self.distances_box.setContentsMargins(0, 0, 0, 0)
|
|
|
+ self.sec_locations_frame.setLayout(self.distances_box)
|
|
|
+
|
|
|
+ # Other Distances label
|
|
|
+ self.distances_label = QtWidgets.QLabel('%s' % _("Gerber distances"))
|
|
|
+ self.distances_label.setToolTip(_("Other distances and the coordinates for points\n"
|
|
|
+ "where the distance was found."))
|
|
|
+ self.distances_box.addWidget(self.distances_label)
|
|
|
+
|
|
|
+ # Other distances
|
|
|
+ self.distances_textb = FCTextArea(parent=self)
|
|
|
+ self.distances_textb.setPlaceholderText(
|
|
|
+ _("Other distances and the coordinates for points\n"
|
|
|
+ "where the distance was found.")
|
|
|
+ )
|
|
|
+ self.distances_textb.setReadOnly(True)
|
|
|
+ stylesheet = """
|
|
|
+ QTextEdit { selection-background-color:blue;
|
|
|
+ selection-color:white;
|
|
|
+ }
|
|
|
+ """
|
|
|
+
|
|
|
+ self.distances_textb.setStyleSheet(stylesheet)
|
|
|
+ self.distances_box.addWidget(self.distances_textb)
|
|
|
+
|
|
|
+ self.distances_box.addWidget(QtWidgets.QLabel(''))
|
|
|
+
|
|
|
+ # Other Locations label
|
|
|
+ self.locations_label = QtWidgets.QLabel('%s' % _("Points coordinates"))
|
|
|
+ self.locations_label.setToolTip(_("Other distances and the coordinates for points\n"
|
|
|
+ "where the distance was found."))
|
|
|
+ self.distances_box.addWidget(self.locations_label)
|
|
|
+
|
|
|
+ # Locations where minimum was found
|
|
|
+ self.locations_sec_textb = FCTextArea(parent=self)
|
|
|
+ self.locations_sec_textb.setPlaceholderText(
|
|
|
+ _("Other distances and the coordinates for points\n"
|
|
|
+ "where the distance was found.")
|
|
|
+ )
|
|
|
+ self.locations_sec_textb.setReadOnly(True)
|
|
|
+ stylesheet = """
|
|
|
+ QTextEdit { selection-background-color:blue;
|
|
|
+ selection-color:white;
|
|
|
+ }
|
|
|
+ """
|
|
|
+
|
|
|
+ self.locations_sec_textb.setStyleSheet(stylesheet)
|
|
|
+ self.distances_box.addWidget(self.locations_sec_textb)
|
|
|
+
|
|
|
+ # Jump button
|
|
|
+ self.locate_sec_button = QtWidgets.QPushButton(_("Jump to selected position"))
|
|
|
+ self.locate_sec_button.setToolTip(
|
|
|
+ _("Select a position in the Locations text box and then\n"
|
|
|
+ "click this button.")
|
|
|
+ )
|
|
|
+ self.locate_sec_button.setMinimumWidth(60)
|
|
|
+ self.locate_sec_button.setDisabled(True)
|
|
|
+ self.distances_box.addWidget(self.locate_sec_button)
|
|
|
+
|
|
|
+ # GO button
|
|
|
+ self.calculate_button = QtWidgets.QPushButton(_("Find Minimum"))
|
|
|
+ self.calculate_button.setToolTip(
|
|
|
+ _("Calculate the minimum distance between copper features,\n"
|
|
|
+ "this will allow the determination of the right tool to\n"
|
|
|
+ "use for isolation or copper clearing.")
|
|
|
+ )
|
|
|
+ self.calculate_button.setStyleSheet("""
|
|
|
+ QPushButton
|
|
|
+ {
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ """)
|
|
|
+ self.calculate_button.setMinimumWidth(60)
|
|
|
+ self.layout.addWidget(self.calculate_button)
|
|
|
+
|
|
|
+ self.layout.addStretch()
|
|
|
+
|
|
|
+ # ## Reset Tool
|
|
|
+ self.reset_button = QtWidgets.QPushButton(_("Reset Tool"))
|
|
|
+ self.reset_button.setIcon(QtGui.QIcon(self.app.resource_location + '/reset32.png'))
|
|
|
+ self.reset_button.setToolTip(
|
|
|
+ _("Will reset the tool parameters.")
|
|
|
+ )
|
|
|
+ self.reset_button.setStyleSheet("""
|
|
|
+ QPushButton
|
|
|
+ {
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ """)
|
|
|
+ self.layout.addWidget(self.reset_button)
|
|
|
+
|
|
|
+ self.loc_ois = OptionalHideInputSection(self.locations_cb, [self.locations_textb, self.locate_button])
|
|
|
+ self.sec_loc_ois = OptionalHideInputSection(self.sec_locations_cb, [self.sec_locations_frame])
|
|
|
+
|
|
|
+ # #################################### FINSIHED GUI ###########################
|
|
|
+ # #############################################################################
|
|
|
+
|
|
|
+ def confirmation_message(self, accepted, minval, maxval):
|
|
|
+ if accepted is False:
|
|
|
+ self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%.*f, %.*f]' % (_("Edited value is out of range"),
|
|
|
+ self.decimals,
|
|
|
+ minval,
|
|
|
+ self.decimals,
|
|
|
+ maxval), False)
|
|
|
+ else:
|
|
|
+ self.app.inform[str, bool].emit('[success] %s' % _("Edited value is within limits."), False)
|
|
|
+
|
|
|
+ def confirmation_message_int(self, accepted, minval, maxval):
|
|
|
+ if accepted is False:
|
|
|
+ self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%d, %d]' %
|
|
|
+ (_("Edited value is out of range"), minval, maxval), False)
|
|
|
+ else:
|
|
|
+ self.app.inform[str, bool].emit('[success] %s' % _("Edited value is within limits."), False)
|