- fixed the PDF Tool when importing as Gerber objects

- moved all the parsing out of the PDF Tool to a new file ParsePDF in the flatcamParsers folder
- trying to fix the pixmap load crash when running a FlatCAMScript
This commit is contained in:
Marius Stanciu 2020-05-18 05:46:57 +03:00 committed by Marius
parent 4cfecfa70a
commit 1085d26b7b
8 changed files with 1138 additions and 1090 deletions

View File

@ -7,6 +7,12 @@ CHANGELOG for FlatCAM beta
=================================================
18.05.2020
- fixed the PDF Tool when importing as Gerber objects
- moved all the parsing out of the PDF Tool to a new file ParsePDF in the flatcamParsers folder
- trying to fix the pixmap load crash when running a FlatCAMScript
17.05.2020
- added new FlatCAM Tool: Corner Markers Tool which will add line markers in the selected corners of the bounding box of the targeted Gerber object

View File

@ -9810,16 +9810,18 @@ class App(QtCore.QObject):
App.log.debug(" **************** Finished PROJECT loading... **************** ")
def plot_all(self, fit_view=True, use_thread=True):
def plot_all(self, fit_view=True, muted=False, use_thread=True):
"""
Re-generates all plots from all objects.
:param fit_view: if True will plot the objects and will adjust the zoom to fit all plotted objects into view
:param muted: if True don't print messages
:param use_thread: if True will use threading for plotting the objects
:return: None
"""
self.log.debug("Plot_all()")
self.inform.emit('[success] %s...' % _("Redrawing all objects"))
if muted is not True:
self.inform.emit('[success] %s...' % _("Redrawing all objects"))
for plot_obj in self.collection.get_list():
def worker_task(obj):

View File

@ -4300,6 +4300,8 @@ class FlatCAMInfoBar(QtWidgets.QWidget):
self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
self.icon.setPixmap(self.pmap)
self.lock_pmaps = False
layout = QtWidgets.QHBoxLayout()
layout.setContentsMargins(5, 0, 5, 0)
self.setLayout(layout)
@ -4311,7 +4313,6 @@ class FlatCAMInfoBar(QtWidgets.QWidget):
self.text.setToolTip(_("Hello!"))
layout.addWidget(self.text)
layout.addStretch()
def set_text_(self, text, color=None):
@ -4323,17 +4324,18 @@ class FlatCAMInfoBar(QtWidgets.QWidget):
def set_status(self, text, level="info"):
level = str(level)
self.pmap.fill()
if level == "ERROR" or level == "ERROR_NOTCL":
self.pmap = QtGui.QPixmap(self.app.resource_location + '/redlight12.png')
elif level.lower() == "success":
self.pmap = QtGui.QPixmap(self.app.resource_location + '/greenlight12.png')
elif level == "WARNING" or level == "WARNING_NOTCL":
self.pmap = QtGui.QPixmap(self.app.resource_location + '/yellowlight12.png')
elif level.lower() == "selected":
self.pmap = QtGui.QPixmap(self.app.resource_location + '/bluelight12.png')
else:
self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
if self.lock_pmaps is not True:
self.pmap.fill()
if level == "ERROR" or level == "ERROR_NOTCL":
self.pmap = QtGui.QPixmap(self.app.resource_location + '/redlight12.png')
elif level.lower() == "success":
self.pmap = QtGui.QPixmap(self.app.resource_location + '/greenlight12.png')
elif level == "WARNING" or level == "WARNING_NOTCL":
self.pmap = QtGui.QPixmap(self.app.resource_location + '/yellowlight12.png')
elif level.lower() == "selected":
self.pmap = QtGui.QPixmap(self.app.resource_location + '/bluelight12.png')
else:
self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
try:
self.set_text_(text)

View File

@ -183,7 +183,13 @@ class ScriptObject(FlatCAMObj):
if self.app.ui.shell_dock.isHidden():
self.app.ui.shell_dock.show()
self.script_code = deepcopy(self.script_editor_tab.code_editor.toPlainText())
self.app.shell.open_processing() # Disables input box.
# make sure that the pixmaps are not updated when running this as they will crash
# TODO find why the pixmaps load crash when run from this object (perhaps another thread?)
self.app.ui.fcinfo.lock_pmaps = True
self.script_code = self.script_editor_tab.code_editor.toPlainText()
old_line = ''
for tcl_command_line in self.script_code.splitlines():
@ -202,8 +208,6 @@ class ScriptObject(FlatCAMObj):
# execute the actual Tcl command
try:
self.app.shell.open_processing() # Disables input box.
result = self.app.shell.tcl.eval(str(new_command))
if result != 'None':
self.app.shell.append_output(result + '\n')
@ -220,6 +224,7 @@ class ScriptObject(FlatCAMObj):
log.error("Exec command Exception: %s\n" % result)
self.app.shell.append_error('ERROR: %s\n '% result)
self.app.ui.fcinfo.lock_pmaps = False
self.app.shell.close_processing()
def on_autocomplete_changed(self, state):

1080
flatcamParsers/ParsePDF.py Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -98,6 +98,6 @@ class TclCommandSetOrigin(TclCommand):
loc = [0, 0]
self.app.on_set_zero_click(event=None, location=loc, noplot=True, use_thread=False)
self.app.inform.emit('[success] Tcl %s: %s' %
(_('Origin set by offsetting all loaded objects with '),
'{0:.4f}, {0:.4f}'.format(loc[0], loc[1])))
msg = '[success] Tcl %s: %s' % (_('Origin set by offsetting all loaded objects with '),
'{0:.4f}, {0:.4f}'.format(loc[0], loc[1]))
self.app.shell_message(msg, success=True, show=False)

View File

@ -75,19 +75,22 @@ class TclCommandSetPath(TclCommand):
if path_isdir is False:
path_isfile = os.path.isfile(path)
if path_isfile:
self.app.inform.emit('[ERROR] %s: %s, %s' % (
msg = '[ERROR] %s: %s, %s' % (
"The provided path",
str(path),
"is a path to file and not a directory as expected."))
"is a path to file and not a directory as expected.")
self.app.shell_message(msg, success=True, show=False)
return "Failed. The Tcl command set_path was used but it was not a directory."
else:
self.app.inform.emit('[ERROR] %s: %s, %s' % (
msg = '[ERROR] %s: %s, %s' % (
"The provided path",
str(path),
"do not exist. Check for typos."))
"do not exist. Check for typos.")
self.app.shell_message(msg, success=True, show=False)
return "Failed. The Tcl command set_path was used but it does not exist."
cd_command = 'cd %s' % path
self.app.shell.exec_command(cd_command, no_echo=False)
self.app.defaults["global_tcl_path"] = str(path)
self.app.inform.emit('[success] %s: %s' % ("Relative path set to", str(path)))
msg = '[success] %s: %s' % ("Relative path set to", str(path))
self.app.shell_message(msg, success=True, show=False)