Merge https://bitbucket.org/marius_stanciu/flatcam_mpl/src/master into Port_to_Python3k
This commit is contained in:
@@ -114,10 +114,10 @@ class App(QtCore.QObject):
|
||||
|
||||
plots_updated = QtCore.pyqtSignal()
|
||||
|
||||
# Emitted by new_object() and passes the new object as argument.
|
||||
# on_object_created() adds the object to the collection,
|
||||
# Emitted by new_object() and passes the new object as argument and a plot flag
|
||||
# on_object_created() adds the object to the collection, plot the object if plot flag is True
|
||||
# and emits new_object_available.
|
||||
object_created = QtCore.pyqtSignal(object)
|
||||
object_created = QtCore.pyqtSignal(object, bool)
|
||||
|
||||
# Emitted when a new object has been added to the collection
|
||||
# and is ready to be used.
|
||||
@@ -1023,9 +1023,12 @@ class App(QtCore.QObject):
|
||||
but before it is attached to the application. The function is
|
||||
called with 2 parameters: the new object and the App instance.
|
||||
:type initialize: function
|
||||
:param plot: Whether to plot the object or not
|
||||
:type plot: Bool
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.plot = plot
|
||||
|
||||
App.log.debug("new_object()")
|
||||
|
||||
@@ -1049,6 +1052,10 @@ class App(QtCore.QObject):
|
||||
oname = option[len(kind) + 1:]
|
||||
obj.options[oname] = self.options[option]
|
||||
|
||||
# make sure that the plot option of the new object is reflecting the current status and not the general option
|
||||
# solve issues with the modelview currently used (checkbox on the Project Tab)
|
||||
obj.options['plot'] = self.plot
|
||||
|
||||
# Initialize as per user request
|
||||
# User must take care to implement initialize
|
||||
# in a thread-safe way as is is likely that we
|
||||
@@ -1071,7 +1078,7 @@ class App(QtCore.QObject):
|
||||
|
||||
# Move the object to the main thread and let the app know that it is available.
|
||||
obj.moveToThread(QtGui.QApplication.instance().thread())
|
||||
self.object_created.emit(obj)
|
||||
self.object_created.emit(obj, self.plot)
|
||||
|
||||
return obj
|
||||
|
||||
@@ -1485,12 +1492,14 @@ class App(QtCore.QObject):
|
||||
# Keep this for later
|
||||
try:
|
||||
name = self.collection.get_active().options["name"]
|
||||
isPlotted = self.collection.get_active().options["plot"]
|
||||
except AttributeError:
|
||||
self.log.debug("Nothing selected for deletion")
|
||||
return
|
||||
|
||||
# Remove plot
|
||||
self.plotcanvas.figure.delaxes(self.collection.get_active().axes)
|
||||
# Remove plot only if the object was plotted otherwise delaxes will fail
|
||||
if isPlotted:
|
||||
self.plotcanvas.figure.delaxes(self.collection.get_active().axes)
|
||||
self.plotcanvas.auto_adjust_axes()
|
||||
|
||||
# Clear form
|
||||
@@ -1532,11 +1541,12 @@ class App(QtCore.QObject):
|
||||
def on_row_activated(self, index):
|
||||
self.ui.notebook.setCurrentWidget(self.ui.selected_tab)
|
||||
|
||||
def on_object_created(self, obj):
|
||||
def on_object_created(self, obj, plot):
|
||||
"""
|
||||
Event callback for object creation.
|
||||
|
||||
:param obj: The newly created FlatCAM object.
|
||||
:param plot: If to plot the new object, bool
|
||||
:return: None
|
||||
"""
|
||||
t0 = time.time() # DEBUG
|
||||
@@ -1547,7 +1557,9 @@ class App(QtCore.QObject):
|
||||
|
||||
self.inform.emit("Object (%s) created: %s" % (obj.kind, obj.options['name']))
|
||||
self.new_object_available.emit(obj)
|
||||
obj.plot()
|
||||
if plot:
|
||||
obj.plot()
|
||||
|
||||
self.on_zoom_fit(None)
|
||||
t1 = time.time() # DEBUG
|
||||
self.log.debug("%f seconds adding object and plotting." % (t1 - t0))
|
||||
|
||||
@@ -757,18 +757,29 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
||||
|
||||
# Populate tool list
|
||||
n = len(self.tools)
|
||||
self.ui.tools_table.setColumnCount(2)
|
||||
self.ui.tools_table.setHorizontalHeaderLabels(['#', 'Diameter'])
|
||||
self.ui.tools_table.setColumnCount(3)
|
||||
self.ui.tools_table.setHorizontalHeaderLabels(['#', 'Diameter', 'Count'])
|
||||
self.ui.tools_table.setRowCount(n)
|
||||
self.ui.tools_table.setSortingEnabled(False)
|
||||
|
||||
i = 0
|
||||
for tool in self.tools:
|
||||
|
||||
drill_cnt = 0 # variable to store the nr of drills per tool
|
||||
# Find no of drills for the current tool
|
||||
for drill in self.drills:
|
||||
if drill.get('tool') == tool:
|
||||
drill_cnt += 1
|
||||
|
||||
id = QtGui.QTableWidgetItem(tool)
|
||||
id.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.ui.tools_table.setItem(i, 0, id) # Tool name/id
|
||||
dia = QtGui.QTableWidgetItem(str(self.tools[tool]['C']))
|
||||
dia.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
drill_count = QtGui.QTableWidgetItem('%d' % drill_cnt)
|
||||
drill_count.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
self.ui.tools_table.setItem(i, 1, dia) # Diameter
|
||||
self.ui.tools_table.setItem(i, 2, drill_count) # Number of drills per tool
|
||||
i += 1
|
||||
|
||||
# sort the tool diameter column
|
||||
@@ -778,7 +789,11 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
||||
|
||||
self.ui.tools_table.resizeColumnsToContents()
|
||||
self.ui.tools_table.resizeRowsToContents()
|
||||
self.ui.tools_table.horizontalHeader().setStretchLastSection(True)
|
||||
horizontal_header = self.ui.tools_table.horizontalHeader()
|
||||
horizontal_header.setResizeMode(0, QtGui.QHeaderView.ResizeToContents)
|
||||
horizontal_header.setResizeMode(1, QtGui.QHeaderView.Stretch)
|
||||
horizontal_header.setResizeMode(2, QtGui.QHeaderView.ResizeToContents)
|
||||
# horizontal_header.setStretchLastSection(True)
|
||||
self.ui.tools_table.verticalHeader().hide()
|
||||
self.ui.tools_table.setSortingEnabled(True)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class TclCommandPanelize(TclCommand):
|
||||
"""
|
||||
|
||||
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
|
||||
aliases = ['panelize']
|
||||
aliases = ['panelize', 'pan', 'panel']
|
||||
|
||||
# Dictionary of types from Tcl command, needs to be ordered
|
||||
arg_names = collections.OrderedDict([
|
||||
@@ -128,10 +128,9 @@ class TclCommandPanelize(TclCommand):
|
||||
for col in range(args['columns']):
|
||||
local_outname = outname + ".tmp." + str(col) + "." + str(row)
|
||||
if isinstance(obj, FlatCAMExcellon):
|
||||
self.app.new_object("excellon", local_outname, initialize_local_excellon)
|
||||
self.app.new_object("excellon", local_outname, initialize_local_excellon, plot=False)
|
||||
else:
|
||||
self.app.new_object("geometry", local_outname, initialize_local)
|
||||
|
||||
self.app.new_object("geometry", local_outname, initialize_local, plot=False)
|
||||
currentx += lenghtx
|
||||
currenty += lenghty
|
||||
|
||||
|
||||
Reference in New Issue
Block a user