- remade GUI in Tool Cutout, Tool Align Objects, Tool Panelize

This commit is contained in:
Marius Stanciu 2020-01-30 05:14:05 +02:00 committed by Marius
parent e7c25e9b8a
commit 123ae16b20
4 changed files with 127 additions and 116 deletions

View File

@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
=================================================
30.01.2020
- remade GUI in Tool Cutout, Tool Align Objects, Tool Panelize
29.01.2020
- changes in how the Editor exit is handled

View File

@ -50,32 +50,31 @@ class AlignObjects(FlatCAMTool):
""")
self.layout.addWidget(title_label)
self.layout.addWidget(QtWidgets.QLabel(''))
# Form Layout
grid0 = QtWidgets.QGridLayout()
grid0.setColumnStretch(0, 0)
grid0.setColumnStretch(1, 1)
self.layout.addLayout(grid0)
self.aligned_label = QtWidgets.QLabel('<b>%s</b>' % _("Selection of the WORKING object"))
self.aligned_label = QtWidgets.QLabel('<b>%s:</b>' % _("MOVING object"))
grid0.addWidget(self.aligned_label, 0, 0, 1, 2)
# Type of object to be aligned
self.type_obj_combo = FCComboBox()
self.type_obj_combo.addItem("Gerber")
self.type_obj_combo.addItem("Excellon")
self.type_obj_combo.setItemIcon(0, QtGui.QIcon(self.app.resource_location + "/flatcam_icon16.png"))
self.type_obj_combo.setItemIcon(1, QtGui.QIcon(self.app.resource_location + "/drill16.png"))
self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type"))
self.type_obj_combo_label.setToolTip(
self.aligned_label.setToolTip(
_("Specify the type of object to be aligned.\n"
"It can be of type: Gerber or Excellon.\n"
"The selection here decide the type of objects that will be\n"
"in the Object combobox.")
)
grid0.addWidget(self.type_obj_combo_label, 2, 0)
grid0.addWidget(self.type_obj_combo, 2, 1)
# Type of object to be aligned
self.type_obj_radio = RadioSet([
{"label": _("Gerber"), "value": "grb"},
{"label": _("Excellon"), "value": "exc"},
], orientation='vertical', stretch=False)
grid0.addWidget(self.type_obj_radio, 3, 0, 1, 2)
# Object to be aligned
self.object_combo = FCComboBox()
@ -83,42 +82,35 @@ class AlignObjects(FlatCAMTool):
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.object_combo.setCurrentIndex(1)
self.object_label = QtWidgets.QLabel('%s:' % _("Object"))
self.object_label.setToolTip(
self.object_combo.setToolTip(
_("Object to be aligned.")
)
grid0.addWidget(self.object_label, 3, 0)
grid0.addWidget(self.object_combo, 3, 1)
grid0.addWidget(self.object_combo, 4, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 4, 0, 1, 2)
grid0.addWidget(separator_line, 5, 0, 1, 2)
self.aligned_label = QtWidgets.QLabel('<b>%s</b>' % _("Selection of the TARGET object"))
grid0.addWidget(QtWidgets.QLabel(''), 6, 0, 1, 2)
self.aligned_label = QtWidgets.QLabel('<b>%s:</b>' % _("TARGET object"))
self.aligned_label.setToolTip(
_("Object to which the other objects will be aligned to (moved to).")
)
grid0.addWidget(self.aligned_label, 6, 0, 1, 2)
# Type of object to be aligned to = aligner
self.type_aligner_obj_combo = FCComboBox()
self.type_aligner_obj_combo.addItem("Gerber")
self.type_aligner_obj_combo.addItem("Excellon")
self.type_aligner_obj_combo.setItemIcon(0, QtGui.QIcon(self.app.resource_location + "/flatcam_icon16.png"))
self.type_aligner_obj_combo.setItemIcon(1, QtGui.QIcon(self.app.resource_location + "/drill16.png"))
self.type_aligner_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type"))
self.type_aligner_obj_combo_label.setToolTip(
_("Specify the type of object to be aligned to.\n"
"It can be of type: Gerber or Excellon.\n"
"The selection here decide the type of objects that will be\n"
"in the Object combobox.")
)
grid0.addWidget(self.type_aligner_obj_combo_label, 7, 0)
grid0.addWidget(self.type_aligner_obj_combo, 7, 1)
grid0.addWidget(self.aligned_label, 7, 0, 1, 2)
# Type of object to be aligned to = aligner
self.type_aligner_obj_radio = RadioSet([
{"label": _("Gerber"), "value": "grb"},
{"label": _("Excellon"), "value": "exc"},
], orientation='vertical', stretch=False)
grid0.addWidget(self.type_aligner_obj_radio, 8, 0, 1, 2)
# Object to be aligned to = aligner
self.aligner_object_combo = FCComboBox()
@ -126,18 +118,18 @@ class AlignObjects(FlatCAMTool):
self.aligner_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.aligner_object_combo.setCurrentIndex(1)
self.aligner_object_label = QtWidgets.QLabel('%s:' % _("Object"))
self.aligner_object_label.setToolTip(
self.aligner_object_combo.setToolTip(
_("Object to be aligned to. Aligner.")
)
grid0.addWidget(self.aligner_object_label, 8, 0)
grid0.addWidget(self.aligner_object_combo, 8, 1)
grid0.addWidget(self.aligner_object_combo, 9, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 9, 0, 1, 2)
grid0.addWidget(separator_line, 10, 0, 1, 2)
grid0.addWidget(QtWidgets.QLabel(''), 11, 0, 1, 2)
# Alignment Type
self.a_type_lbl = QtWidgets.QLabel('<b>%s:</b>' % _("Alignment Type"))
@ -151,17 +143,17 @@ class AlignObjects(FlatCAMTool):
{'label': _('Single Point'), 'value': 'sp'},
{'label': _('Dual Point'), 'value': 'dp'}
],
orientation='horizontal',
orientation='vertical',
stretch=False
)
grid0.addWidget(self.a_type_lbl, 10, 0, 1, 2)
grid0.addWidget(self.a_type_radio, 11, 0, 1, 2)
grid0.addWidget(self.a_type_lbl, 12, 0, 1, 2)
grid0.addWidget(self.a_type_radio, 13, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 12, 0, 1, 2)
grid0.addWidget(separator_line, 14, 0, 1, 2)
# Buttons
self.align_object_button = QtWidgets.QPushButton(_("Align Object"))
@ -195,8 +187,8 @@ class AlignObjects(FlatCAMTool):
# Signals
self.align_object_button.clicked.connect(self.on_align)
self.type_obj_combo.currentIndexChanged.connect(self.on_type_obj_index_changed)
self.type_aligner_obj_combo.currentIndexChanged.connect(self.on_type_aligner_index_changed)
self.type_obj_radio.activated_custom.connect(self.on_type_obj_changed)
self.type_aligner_obj_radio.activated_custom.connect(self.on_type_aligner_changed)
self.reset_button.clicked.connect(self.set_tool_ui)
self.mr = None
@ -268,17 +260,19 @@ class AlignObjects(FlatCAMTool):
self.aligned_old_line_color = None
self.a_type_radio.set_value(self.app.defaults["tools_align_objects_align_type"])
self.type_obj_radio.set_value('grb')
self.type_aligner_obj_radio.set_value('grb')
if self.local_connected is True:
self.disconnect_cal_events()
def on_type_obj_index_changed(self):
obj_type = self.type_obj_combo.currentIndex()
def on_type_obj_changed(self, val):
obj_type = {'grb': 0, 'exc': 1}[val]
self.object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
self.object_combo.setCurrentIndex(0)
def on_type_aligner_index_changed(self):
obj_type = self.type_aligner_obj_combo.currentIndex()
def on_type_aligner_changed(self, val):
obj_type = {'grb': 0, 'exc': 1}[val]
self.aligner_object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
self.aligner_object_combo.setCurrentIndex(0)

View File

@ -7,7 +7,7 @@
from PyQt5 import QtWidgets, QtGui, QtCore
from FlatCAMTool import FlatCAMTool
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, RadioSet, FCComboBox, OptionalInputSection
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, RadioSet, FCComboBox, OptionalInputSection, FCButton
from FlatCAMObj import FlatCAMGerber
from shapely.geometry import box, MultiPolygon, Polygon, LineString, LinearRing
@ -59,46 +59,18 @@ class CutOut(FlatCAMTool):
""")
self.layout.addWidget(title_label)
self.layout.addWidget(QtWidgets.QLabel(''))
# Form Layout
grid0 = QtWidgets.QGridLayout()
grid0.setColumnStretch(0, 0)
grid0.setColumnStretch(1, 1)
self.layout.addLayout(grid0)
# Type of object to be cutout
self.type_obj_combo = QtWidgets.QComboBox()
self.type_obj_combo.addItem("Gerber")
self.type_obj_combo.addItem("Excellon")
self.type_obj_combo.addItem("Geometry")
# we get rid of item1 ("Excellon") as it is not suitable for creating film
self.type_obj_combo.view().setRowHidden(1, True)
self.type_obj_combo.setItemIcon(0, QtGui.QIcon(self.app.resource_location + "/flatcam_icon16.png"))
# self.type_obj_combo.setItemIcon(1, QtGui.QIcon(self.app.resource_location + "/drill16.png"))
self.type_obj_combo.setItemIcon(2, QtGui.QIcon(self.app.resource_location + "/geometry16.png"))
self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type"))
self.type_obj_combo_label.setToolTip(
_("Specify the type of object to be cutout.\n"
"It can be of type: Gerber or Geometry.\n"
"What is selected here will dictate the kind\n"
"of objects that will populate the 'Object' combobox.")
)
self.type_obj_combo_label.setMinimumWidth(60)
grid0.addWidget(self.type_obj_combo_label, 0, 0)
grid0.addWidget(self.type_obj_combo, 0, 1)
self.object_label = QtWidgets.QLabel('<b>%s:</b>' % _("Object to be cutout"))
self.object_label = QtWidgets.QLabel('<b>%s:</b>' % _("Source Object"))
self.object_label.setToolTip('%s.' % _("Object to be cutout"))
# Object to be cutout
self.obj_combo = QtWidgets.QComboBox()
self.obj_combo.setModel(self.app.collection)
self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.obj_combo.setCurrentIndex(1)
grid0.addWidget(self.object_label, 1, 0, 1, 2)
grid0.addWidget(self.obj_combo, 2, 0, 1, 2)
grid0.addWidget(self.object_label, 0, 0, 1, 2)
# Object kind
self.kindlabel = QtWidgets.QLabel('%s:' % _('Object kind'))
@ -112,8 +84,43 @@ class CutOut(FlatCAMTool):
{"label": _("Single"), "value": "single"},
{"label": _("Panel"), "value": "panel"},
])
grid0.addWidget(self.kindlabel, 3, 0)
grid0.addWidget(self.obj_kind_combo, 3, 1)
grid0.addWidget(self.kindlabel, 1, 0)
grid0.addWidget(self.obj_kind_combo, 1, 1)
# Type of object to be cutout
self.type_obj_radio = RadioSet([
{"label": _("Gerber"), "value": "grb"},
{"label": _("Geometry"), "value": "geo"},
])
self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type"))
self.type_obj_combo_label.setToolTip(
_("Specify the type of object to be cutout.\n"
"It can be of type: Gerber or Geometry.\n"
"What is selected here will dictate the kind\n"
"of objects that will populate the 'Object' combobox.")
)
grid0.addWidget(self.type_obj_combo_label, 2, 0)
grid0.addWidget(self.type_obj_radio, 2, 1)
# Object to be cutout
self.obj_combo = QtWidgets.QComboBox()
self.obj_combo.setModel(self.app.collection)
self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.obj_combo.setCurrentIndex(1)
grid0.addWidget(self.obj_combo, 3, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 4, 0, 1, 2)
grid0.addWidget(QtWidgets.QLabel(''), 5, 0, 1, 2)
self.param_label = QtWidgets.QLabel('<b>%s:</b>' % _("Tool Parameters"))
grid0.addWidget(self.param_label, 6, 0, 1, 2)
# Tool Diameter
self.dia = FCDoubleSpinner()
@ -125,8 +132,8 @@ class CutOut(FlatCAMTool):
_("Diameter of the tool used to cutout\n"
"the PCB shape out of the surrounding material.")
)
grid0.addWidget(self.dia_label, 4, 0)
grid0.addWidget(self.dia, 4, 1)
grid0.addWidget(self.dia_label, 8, 0)
grid0.addWidget(self.dia, 8, 1)
# Cut Z
cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
@ -146,8 +153,8 @@ class CutOut(FlatCAMTool):
self.cutz_entry.setSingleStep(0.1)
grid0.addWidget(cutzlabel, 5, 0)
grid0.addWidget(self.cutz_entry, 5, 1)
grid0.addWidget(cutzlabel, 9, 0)
grid0.addWidget(self.cutz_entry, 9, 1)
# Multi-pass
self.mpass_cb = FCCheckBox('%s:' % _("Multi-Depth"))
@ -172,8 +179,8 @@ class CutOut(FlatCAMTool):
)
self.ois_mpass_geo = OptionalInputSection(self.mpass_cb, [self.maxdepth_entry])
grid0.addWidget(self.mpass_cb, 6, 0)
grid0.addWidget(self.maxdepth_entry, 6, 1)
grid0.addWidget(self.mpass_cb, 10, 0)
grid0.addWidget(self.maxdepth_entry, 10, 1)
# Margin
self.margin = FCDoubleSpinner()
@ -187,8 +194,8 @@ class CutOut(FlatCAMTool):
"will make the cutout of the PCB further from\n"
"the actual PCB border")
)
grid0.addWidget(self.margin_label, 7, 0)
grid0.addWidget(self.margin, 7, 1)
grid0.addWidget(self.margin_label, 11, 0)
grid0.addWidget(self.margin, 11, 1)
# Gapsize
self.gapsize = FCDoubleSpinner()
@ -201,8 +208,8 @@ class CutOut(FlatCAMTool):
"the surrounding material (the one \n"
"from which the PCB is cutout).")
)
grid0.addWidget(self.gapsize_label, 8, 0)
grid0.addWidget(self.gapsize, 8, 1)
grid0.addWidget(self.gapsize_label, 13, 0)
grid0.addWidget(self.gapsize, 13, 1)
# How gaps wil be rendered:
# lr - left + right
@ -219,12 +226,14 @@ class CutOut(FlatCAMTool):
_("Create a convex shape surrounding the entire PCB.\n"
"Used only if the source object type is Gerber.")
)
grid0.addWidget(self.convex_box, 9, 0, 1, 2)
grid0.addWidget(self.convex_box, 15, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 10, 0, 1, 2)
grid0.addWidget(separator_line, 16, 0, 1, 2)
grid0.addWidget(QtWidgets.QLabel(''), 17, 0, 1, 2)
# Title2
title_param_label = QtWidgets.QLabel("<font size=4><b>%s</b></font>" % _('A. Automatic Bridge Gaps'))
@ -398,13 +407,13 @@ class CutOut(FlatCAMTool):
self.ff_cutout_object_btn.clicked.connect(self.on_freeform_cutout)
self.rect_cutout_object_btn.clicked.connect(self.on_rectangular_cutout)
self.type_obj_combo.currentIndexChanged.connect(self.on_type_obj_index_changed)
self.type_obj_radio.activated_custom.connect(self.on_type_obj_changed)
self.man_geo_creation_btn.clicked.connect(self.on_manual_geo)
self.man_gaps_creation_btn.clicked.connect(self.on_manual_gap_click)
self.reset_button.clicked.connect(self.set_tool_ui)
def on_type_obj_index_changed(self, index):
obj_type = self.type_obj_combo.currentIndex()
def on_type_obj_changed(self, val):
obj_type = {'grb': 0, 'geo': 2}[val]
self.obj_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
self.obj_combo.setCurrentIndex(0)
@ -451,6 +460,7 @@ class CutOut(FlatCAMTool):
self.gapsize.set_value(float(self.app.defaults["tools_cutoutgapsize"]))
self.gaps.set_value(self.app.defaults["tools_gaps_ff"])
self.convex_box.set_value(self.app.defaults['tools_cutout_convexshape'])
self.type_obj_radio.set_value('grb')
def on_freeform_cutout(self):

View File

@ -49,6 +49,18 @@ class Panelize(FlatCAMTool):
""")
self.layout.addWidget(title_label)
self.layout.addWidget(QtWidgets.QLabel(''))
self.object_label = QtWidgets.QLabel('<b>%s:</b>' % _("Source Object"))
self.object_label.setToolTip(
_("Specify the type of object to be panelized\n"
"It can be of type: Gerber, Excellon or Geometry.\n"
"The selection here decide the type of objects that will be\n"
"in the Object combobox.")
)
self.layout.addWidget(self.object_label)
# Form Layout
form_layout_0 = QtWidgets.QFormLayout()
self.layout.addLayout(form_layout_0)
@ -63,14 +75,9 @@ class Panelize(FlatCAMTool):
self.type_obj_combo.setItemIcon(1, QtGui.QIcon(self.app.resource_location + "/drill16.png"))
self.type_obj_combo.setItemIcon(2, QtGui.QIcon(self.app.resource_location + "/geometry16.png"))
self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type"))
self.type_obj_combo_label.setToolTip(
_("Specify the type of object to be panelized\n"
"It can be of type: Gerber, Excellon or Geometry.\n"
"The selection here decide the type of objects that will be\n"
"in the Object combobox.")
)
form_layout_0.addRow(self.type_obj_combo_label, self.type_obj_combo)
self.type_object_label = QtWidgets.QLabel('%s:' % _("Object Type"))
form_layout_0.addRow(self.type_object_label, self.type_obj_combo)
# Object to be panelized
self.object_combo = QtWidgets.QComboBox()
@ -78,12 +85,11 @@ class Panelize(FlatCAMTool):
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.object_combo.setCurrentIndex(1)
self.object_label = QtWidgets.QLabel('%s:' % _("Object"))
self.object_label.setToolTip(
self.object_combo.setToolTip(
_("Object to be panelized. This means that it will\n"
"be duplicated in an array of rows and columns.")
)
form_layout_0.addRow(self.object_label, self.object_combo)
form_layout_0.addRow(self.object_combo)
form_layout_0.addRow(QtWidgets.QLabel(""))
# Form Layout
@ -133,12 +139,11 @@ class Panelize(FlatCAMTool):
self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.box_combo.setCurrentIndex(1)
self.box_combo_label = QtWidgets.QLabel('%s:' % _("Box Object"))
self.box_combo_label.setToolTip(
self.box_combo.setToolTip(
_("The actual object that is used a container for the\n "
"selected object that is to be panelized.")
)
form_layout.addRow(self.box_combo_label, self.box_combo)
form_layout.addRow(self.box_combo)
form_layout.addRow(QtWidgets.QLabel(""))
panel_data_label = QtWidgets.QLabel("<b>%s:</b>" % _("Panel Data"))
@ -382,12 +387,10 @@ class Panelize(FlatCAMTool):
self.type_box_combo.setDisabled(False)
self.type_box_combo_label.setDisabled(False)
self.box_combo.setDisabled(False)
self.box_combo_label.setDisabled(False)
else:
self.type_box_combo.setDisabled(True)
self.type_box_combo_label.setDisabled(True)
self.box_combo.setDisabled(True)
self.box_combo_label.setDisabled(True)
def on_panelize(self):
name = self.object_combo.currentText()