Merged in Beta_8.994 (pull request #327)

Beta 8.994 - improvements
This commit is contained in:
Marius Stanciu 2020-10-30 02:11:04 +00:00
commit c7f82937c9
5 changed files with 155 additions and 26 deletions

View File

@ -25,6 +25,10 @@ CHANGELOG for FlatCAM beta
- fixed the Search and Add feature in Geometry Object UI
- fixed issue with preamble not being inserted when used alone
- modified the way that the start GCode is stored such that now the bug in GCode Editor that did not allowed selection of the first tool is now solved
- in Punch Gerber Tool added a column in the apertures table that allow marking of the selected aperture so the user can see what apertures are selected
- improvements in the Punch Gerber Tool aperture markings
- improved the Geometry Object functionality in regards of Tools DB, deleting a tool and adding a tool
- when using the 'T' shortcut key with Properties Tab in focus and populated with the properties of a Geometry Object made the popped up spinner to have the value autoselected
28.10.2020

View File

@ -1015,7 +1015,7 @@ class GeometryObject(FlatCAMObj, Geometry):
self.ui_connect()
def on_tool_add(self, dia=None, new_geo=None):
def on_tool_add(self, clicked_state, dia=None, new_geo=None):
log.debug("GeometryObject.on_add_tool()")
self.ui_disconnect()
@ -1023,6 +1023,7 @@ class GeometryObject(FlatCAMObj, Geometry):
filename = self.app.tools_database_path()
tool_dia = dia if dia is not None else self.ui.addtool_entry.get_value()
# construct a list of all 'tooluid' in the self.iso_tools
tool_uid_list = [int(tooluid_key) for tooluid_key in self.tools]
@ -1147,6 +1148,10 @@ class GeometryObject(FlatCAMObj, Geometry):
# update the UI form
self.update_ui()
# if there is at least one tool left in the Tools Table, enable the parameters GUI
if self.ui.geo_tools_table.rowCount() != 0:
self.ui.geo_param_frame.setDisabled(False)
self.app.inform.emit('[success] %s' % _("New tool added to Tool Table from Tools Database."))
def on_tool_default_add(self, dia=None, new_geo=None, muted=None):
@ -1397,7 +1402,11 @@ class GeometryObject(FlatCAMObj, Geometry):
self.ui_connect()
self.builduiSig.emit()
def on_tool_delete(self, all_tools=None):
def on_tool_delete(self, clicked_signal, all_tools=None):
"""
It's important to keep the not clicked_signal parameter otherwise the signal will go to the all_tools
parameter and I might get all the tool deleted
"""
self.ui_disconnect()
if all_tools is None:

View File

@ -961,11 +961,12 @@ class GerberObject(FlatCAMObj, Gerber):
log.debug("GerberObject.plot() --> %s" % str(e))
# experimental plot() when the solid_geometry is stored in the self.apertures
def plot_aperture(self, run_thread=False, **kwargs):
def plot_aperture(self, only_flashes=False, run_thread=False, **kwargs):
"""
:param run_thread: if True run the aperture plot as a thread in a worker
:param kwargs: color and face_color
:param only_flashes: plot only flashed
:param run_thread: if True run the aperture plot as a thread in a worker
:param kwargs: color and face_color
:return:
"""
@ -994,35 +995,36 @@ class GerberObject(FlatCAMObj, Gerber):
else:
visibility = kwargs['visible']
with self.app.proc_container.new(_("Plotting Apertures")):
def job_thread(app_obj):
def job_thread(app_obj):
with self.app.proc_container.new(_("Plotting Apertures")):
try:
if aperture_to_plot_mark in self.apertures:
for elem in self.apertures[aperture_to_plot_mark]['geometry']:
for elem in app_obj.apertures[aperture_to_plot_mark]['geometry']:
if 'solid' in elem:
if only_flashes and not isinstance(elem['follow'], Point):
continue
geo = elem['solid']
try:
for el in geo:
shape_key = self.add_mark_shape(shape=el, color=color, face_color=color,
visible=visibility)
self.mark_shapes_storage[aperture_to_plot_mark].append(shape_key)
shape_key = app_obj.add_mark_shape(shape=el, color=color, face_color=color,
visible=visibility)
app_obj.mark_shapes_storage[aperture_to_plot_mark].append(shape_key)
except TypeError:
shape_key = self.add_mark_shape(shape=geo, color=color, face_color=color,
visible=visibility)
self.mark_shapes_storage[aperture_to_plot_mark].append(shape_key)
shape_key = app_obj.add_mark_shape(shape=geo, color=color, face_color=color,
visible=visibility)
app_obj.mark_shapes_storage[aperture_to_plot_mark].append(shape_key)
self.mark_shapes.redraw()
app_obj.mark_shapes.redraw()
except (ObjectDeleted, AttributeError):
self.clear_plot_apertures()
app_obj.clear_plot_apertures()
except Exception as e:
log.debug("GerberObject.plot_aperture() --> %s" % str(e))
if run_thread:
self.app.worker_task.emit({'fcn': job_thread, 'params': [self]})
else:
job_thread(self)
if run_thread:
self.app.worker_task.emit({'fcn': job_thread, 'params': [self]})
else:
job_thread(self)
def clear_plot_apertures(self, aperture='all'):
"""

View File

@ -35,6 +35,9 @@ class ToolPunchGerber(AppTool):
self.decimals = self.app.decimals
self.units = self.app.defaults['units']
# store here the old object name
self.old_name = ''
# #############################################################################
# ######################### Tool GUI ##########################################
# #############################################################################
@ -81,6 +84,32 @@ class ToolPunchGerber(AppTool):
self.ui.rectangular_cb.stateChanged.connect(self.build_tool_ui)
self.ui.other_cb.stateChanged.connect(self.build_tool_ui)
self.ui.gerber_object_combo.currentIndexChanged.connect(self.on_object_combo_changed)
def on_object_combo_changed(self):
# get the Gerber file who is the source of the punched Gerber
selection_index = self.ui.gerber_object_combo.currentIndex()
model_index = self.app.collection.index(selection_index, 0, self.ui.gerber_object_combo.rootModelIndex())
try:
grb_obj = model_index.internalPointer().obj
except Exception:
return
if self.old_name != '':
old_obj = self.app.collection.get_by_name(self.old_name)
old_obj.clear_plot_apertures()
old_obj.mark_shapes.enabled = False
# enable mark shapes
grb_obj.mark_shapes.enabled = True
# create storage for shapes
for ap_code in grb_obj.apertures:
grb_obj.mark_shapes_storage[ap_code] = []
self.old_name = grb_obj.options['name']
def run(self, toggle=True):
self.app.defaults.report_usage("ToolPunchGerber()")
@ -138,8 +167,10 @@ class ToolPunchGerber(AppTool):
self.ui.factor_entry.set_value(float(self.app.defaults["tools_punch_hole_prop_factor"]))
def build_tool_ui(self):
self.ui_disconnect()
# reset table
self.ui.apertures_table.clear()
# self.ui.apertures_table.clear() # this deletes the headers/tooltips too ... not nice!
self.ui.apertures_table.setRowCount(0)
# get the Gerber file who is the source of the punched Gerber
@ -199,12 +230,15 @@ class ToolPunchGerber(AppTool):
else:
continue
# Aperture CODE
ap_code_item = QtWidgets.QTableWidgetItem(ap_code)
ap_code_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
# Aperture TYPE
ap_type_item = QtWidgets.QTableWidgetItem(str(ap_type))
ap_type_item.setFlags(QtCore.Qt.ItemIsEnabled)
# Aperture SIZE
try:
if obj.apertures[ap_code]['size'] is not None:
size_val = self.app.dec_format(float(obj.apertures[ap_code]['size']), self.decimals)
@ -215,10 +249,19 @@ class ToolPunchGerber(AppTool):
ap_size_item = QtWidgets.QTableWidgetItem('')
ap_size_item.setFlags(QtCore.Qt.ItemIsEnabled)
# Aperture MARK Item
mark_item = FCCheckBox()
mark_item.setLayoutDirection(QtCore.Qt.RightToLeft)
# Empty PLOT ITEM
empty_plot_item = QtWidgets.QTableWidgetItem('')
empty_plot_item.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
empty_plot_item.setFlags(QtCore.Qt.ItemIsEnabled)
self.ui.apertures_table.setItem(row, 0, ap_code_item) # Aperture Code
self.ui.apertures_table.setItem(row, 1, ap_type_item) # Aperture Type
self.ui.apertures_table.setItem(row, 2, ap_size_item) # Aperture Dimensions
self.ui.apertures_table.setItem(row, 3, empty_plot_item)
self.ui.apertures_table.setCellWidget(row, 3, mark_item)
# increment row
row += 1
@ -236,12 +279,17 @@ class ToolPunchGerber(AppTool):
horizontal_header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
horizontal_header.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
horizontal_header.setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
horizontal_header.setSectionResizeMode(3, QtWidgets.QHeaderView.Fixed)
horizontal_header.resizeSection(3, 17)
self.ui.apertures_table.setColumnWidth(3, 17)
self.ui.apertures_table.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.ui.apertures_table.setSortingEnabled(False)
# self.ui.apertures_table.setMinimumHeight(self.ui.apertures_table.getHeight())
# self.ui.apertures_table.setMaximumHeight(self.ui.apertures_table.getHeight())
self.ui_connect()
def on_select_all(self, state):
self.ui_disconnect()
if state:
@ -256,6 +304,18 @@ class ToolPunchGerber(AppTool):
self.ui.square_cb.setChecked(False)
self.ui.rectangular_cb.setChecked(False)
self.ui.other_cb.setChecked(False)
# get the Gerber file who is the source of the punched Gerber
selection_index = self.ui.gerber_object_combo.currentIndex()
model_index = self.app.collection.index(selection_index, 0, self.ui.gerber_object_combo.rootModelIndex())
try:
grb_obj = model_index.internalPointer().obj
except Exception:
return
grb_obj.clear_plot_apertures()
self.ui_connect()
def on_method(self, val):
@ -286,12 +346,27 @@ class ToolPunchGerber(AppTool):
def ui_connect(self):
self.ui.select_all_cb.stateChanged.connect(self.on_select_all)
# Mark Checkboxes
for row in range(self.ui.apertures_table.rowCount()):
try:
self.ui.apertures_table.cellWidget(row, 3).clicked.disconnect()
except (TypeError, AttributeError):
pass
self.ui.apertures_table.cellWidget(row, 3).clicked.connect(self.on_mark_cb_click_table)
def ui_disconnect(self):
try:
self.ui.select_all_cb.stateChanged.disconnect()
except (AttributeError, TypeError):
pass
# Mark Checkboxes
for row in range(self.ui.apertures_table.rowCount()):
try:
self.ui.apertures_table.cellWidget(row, 3).clicked.disconnect()
except (TypeError, AttributeError):
pass
def on_generate_object(self):
# get the Gerber file who is the source of the punched Gerber
@ -852,6 +927,42 @@ class ToolPunchGerber(AppTool):
self.app.app_obj.new_object('gerber', outname, init_func)
def on_mark_cb_click_table(self):
"""
Will mark aperture geometries on canvas or delete the markings depending on the checkbox state
:return:
"""
try:
cw = self.sender()
cw_index = self.ui.apertures_table.indexAt(cw.pos())
cw_row = cw_index.row()
except AttributeError:
cw_row = 0
except TypeError:
return
try:
aperture = self.ui.apertures_table.item(cw_row, 0).text()
except AttributeError:
return
# get the Gerber file who is the source of the punched Gerber
selection_index = self.ui.gerber_object_combo.currentIndex()
model_index = self.app.collection.index(selection_index, 0, self.ui.gerber_object_combo.rootModelIndex())
try:
grb_obj = model_index.internalPointer().obj
except Exception:
return
if self.ui.apertures_table.cellWidget(cw_row, 3).isChecked():
# self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True)
grb_obj.plot_aperture(color=self.app.defaults['global_sel_draw_color'] + 'AA',
marked_aperture=aperture, visible=True, run_thread=True)
else:
grb_obj.clear_plot_apertures(aperture=aperture)
def reset_fields(self):
self.ui.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.ui.exc_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex()))
@ -971,8 +1082,8 @@ class PunchUI:
self.apertures_table = FCTable()
pad_all_grid.addWidget(self.apertures_table, 0, 1)
self.apertures_table.setColumnCount(3)
self.apertures_table.setHorizontalHeaderLabels([_('Code'), _('Type'), _('Size')])
self.apertures_table.setColumnCount(4)
self.apertures_table.setHorizontalHeaderLabels([_('Code'), _('Type'), _('Size'), 'M'])
self.apertures_table.setSortingEnabled(False)
self.apertures_table.setRowCount(0)
self.apertures_table.resizeColumnsToContents()
@ -984,6 +1095,8 @@ class PunchUI:
_("Type of aperture: circular, rectangle, macros etc"))
self.apertures_table.horizontalHeaderItem(2).setToolTip(
_("Aperture Size:"))
self.apertures_table.horizontalHeaderItem(3).setToolTip(
_("Mark the aperture instances on canvas."))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred)
self.apertures_table.setSizePolicy(sizePolicy)

View File

@ -4436,6 +4436,7 @@ class App(QtCore.QObject):
text='%s:' % _('Enter a Tool Diameter'),
min=0.0000, max=100.0000, decimals=self.decimals, step=0.1)
tool_add_popup.setWindowIcon(QtGui.QIcon(self.resource_location + '/letter_t_32.png'))
tool_add_popup.wdg.selectAll()
val, ok = tool_add_popup.get_value()
if ok:
@ -4443,7 +4444,7 @@ class App(QtCore.QObject):
self.inform.emit('[WARNING_NOTCL] %s' %
_("Please enter a tool diameter with non-zero value, in Float format."))
return
self.collection.get_active().on_tool_add(dia=float(val))
self.collection.get_active().on_tool_add(clicked_state=False, dia=float(val))
else:
self.inform.emit('[WARNING_NOTCL] %s...' % _("Adding Tool cancelled"))
else: