- made all TclCommands not to be plotted automatically

- made sure that all TclCommands are not threaded
This commit is contained in:
Marius Stanciu 2019-09-16 01:39:11 +03:00 committed by Marius
parent 2f553c9005
commit 8cba74647f
25 changed files with 100 additions and 65 deletions

View File

@ -5948,15 +5948,14 @@ class App(QtCore.QObject):
except tk.TclError as e:
log.debug("App.handleRunCode() --> %s" % str(e))
old_line = old_line + tcl_command_line + '\n'
except Exception as e:
log.debug("App.handleRunCode() --> %s" % str(e))
if old_line != '':
# it means that the script finished with an error
result = self.tcl.eval("set errorInfo")
self.log.error("Exec command Exception: %s" % (result + '\n'))
self.shell.append_error('ERROR: ' + result + '\n')
else:
# success! plot all objects
self.plot_all()
self.shell.close_proccessing()
@ -8310,6 +8309,10 @@ class App(QtCore.QObject):
self.ui.buttonOpen.clicked.connect(lambda: self.handleOpen(filt=flt))
self.ui.buttonSave.clicked.connect(lambda: self.handleSaveGCode(filt=flt))
self.ui.buttonRun.show()
try:
self.ui.buttonRun.clicked.disconnect(self.handleRunCode)
except TypeError:
pass
self.ui.buttonRun.clicked.connect(self.handleRunCode)
self.handleTextChanged()

View File

@ -924,7 +924,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
return "Operation failed: %s" % str(e)
def isolate(self, iso_type=None, dia=None, passes=None, overlap=None, outname=None, combine=None,
milling_type=None, follow=None):
milling_type=None, follow=None, plot=True):
"""
Creates an isolation routing geometry object in the project.
@ -1164,7 +1164,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
geo_obj.solid_geometry = area_subtraction(geo_obj.solid_geometry)
# TODO: Do something if this is None. Offer changing name?
self.app.new_object("geometry", iso_name, iso_init)
self.app.new_object("geometry", iso_name, iso_init, plot=plot)
else:
for i in range(passes):
@ -1239,7 +1239,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
geo_obj.solid_geometry = area_subtraction(geo_obj.solid_geometry)
# TODO: Do something if this is None. Offer changing name?
self.app.new_object("geometry", iso_name, iso_init)
self.app.new_object("geometry", iso_name, iso_init, plot=plot)
def on_plot_cb_click(self, *args):
if self.muted_ui:
@ -2604,7 +2604,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
return has_slots, excellon_code
def generate_milling_drills(self, tools=None, outname=None, tooldia=None, use_thread=False):
def generate_milling_drills(self, tools=None, outname=None, tooldia=None, plot=False, use_thread=False):
"""
Note: This method is a good template for generic operations as
it takes it's options from parameters or otherwise from the
@ -2683,7 +2683,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
Point(hole['point']).buffer(buffer_value).exterior)
if use_thread:
def geo_thread(app_obj):
app_obj.new_object("geometry", outname, geo_init)
app_obj.new_object("geometry", outname, geo_init, plot=plot)
app_obj.progress.emit(100)
# Create a promise with the new name
@ -2692,11 +2692,11 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
# Send to worker
self.app.worker_task.emit({'fcn': geo_thread, 'params': [self.app]})
else:
self.app.new_object("geometry", outname, geo_init)
self.app.new_object("geometry", outname, geo_init, plot=plot)
return True, ""
def generate_milling_slots(self, tools=None, outname=None, tooldia=None, use_thread=False):
def generate_milling_slots(self, tools=None, outname=None, tooldia=None, plot=True, use_thread=False):
"""
Note: This method is a good template for generic operations as
it takes it's options from parameters or otherwise from the
@ -2790,7 +2790,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
if use_thread:
def geo_thread(app_obj):
app_obj.new_object("geometry", outname + '_slot', geo_init)
app_obj.new_object("geometry", outname + '_slot', geo_init, plot=plot)
app_obj.progress.emit(100)
# Create a promise with the new name
@ -2799,7 +2799,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
# Send to worker
self.app.worker_task.emit({'fcn': geo_thread, 'params': [self.app]})
else:
self.app.new_object("geometry", outname + '_slot', geo_init)
self.app.new_object("geometry", outname + '_slot', geo_init, plot=plot)
return True, ""
@ -4527,7 +4527,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Failed. No tool selected in the tool table ..."))
def mtool_gen_cncjob(self, outname=None, tools_dict=None, tools_in_use=None, segx=None, segy=None, use_thread=True):
def mtool_gen_cncjob(self, outname=None, tools_dict=None, tools_in_use=None, segx=None, segy=None,
plot=True, use_thread=True):
"""
Creates a multi-tool CNCJob out of this Geometry object.
The actual work is done by the target FlatCAMCNCjob object's
@ -4884,7 +4885,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
def job_thread(app_obj):
if self.solid_geometry:
with self.app.proc_container.new(_("Generating CNC Code")):
if app_obj.new_object("cncjob", outname, job_init_single_geometry) != 'fail':
if app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot) != 'fail':
app_obj.inform.emit('[success] %s: %s' %
(_("CNCjob created")), outname)
app_obj.progress.emit(100)
@ -4901,9 +4902,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
else:
if self.solid_geometry:
self.app.new_object("cncjob", outname, job_init_single_geometry)
self.app.new_object("cncjob", outname, job_init_single_geometry, plot=plot)
else:
self.app.new_object("cncjob", outname, job_init_multi_geometry)
self.app.new_object("cncjob", outname, job_init_multi_geometry, plot=plot)
def generatecncjob(
self, outname=None,
@ -4916,7 +4917,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
extracut=None, startz=None, endz=None,
ppname_g=None,
segx=None, segy=None,
use_thread=True):
use_thread=True,
plot=True):
"""
Only used for TCL Command.
Creates a CNCJob out of this Geometry object. The actual
@ -5043,7 +5045,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
# To be run in separate thread
def job_thread(app_obj):
with self.app.proc_container.new(_("Generating CNC Code")):
app_obj.new_object("cncjob", outname, job_init)
app_obj.new_object("cncjob", outname, job_init, plot=plot)
app_obj.inform.emit('[success] %s: %s' %
(_("CNCjob created")), outname)
app_obj.progress.emit(100)
@ -5053,7 +5055,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
# Send to worker
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
else:
self.app.new_object("cncjob", outname, job_init)
self.app.new_object("cncjob", outname, job_init, plot=plot)
# def on_plot_cb_click(self, *args): # TODO: args not needed
# if self.muted_ui:

View File

@ -23,7 +23,9 @@ CAD program, and create G-Code for Isolation routing.
- added possibility to see the GCode when right clicking on the Project tab on a CNCJob object and then clicking View Source
- added a new TclCommand named PlotObjects which will plot a list of FlatCAM objects
- made that after opening an object in FlatCAM it is not automatically plotted. If the user wants to plot it can use the TclCommands PlotAll or PlotObjects
- modified the TclCommands that open files to not plot the opened files automatically
- modified the TclCommands so that open files do not plot the opened files automatically
- made all TclCommands not to be plotted automatically
- made sure that all TclCommands are not threaded
14.09.2019

View File

@ -1292,6 +1292,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
method=None,
rest=None,
tools_storage=None,
plot=True,
run_threaded=True):
"""
Clear the excess copper from the entire object.
@ -2189,9 +2190,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
def job_thread(app_obj):
try:
if rest_machining_choice is True:
app_obj.new_object("geometry", name, gen_clear_area_rest)
app_obj.new_object("geometry", name, gen_clear_area_rest, plot=plot)
else:
app_obj.new_object("geometry", name, gen_clear_area)
app_obj.new_object("geometry", name, gen_clear_area, plot=plot)
except FlatCAMApp.GracefulException:
proc.done()
return

View File

@ -1168,7 +1168,9 @@ class ToolPaint(FlatCAMTool, Gerber):
outname=None,
connect=None,
contour=None,
tools_storage=None):
tools_storage=None,
plot=True,
run_threaded=True):
"""
Paints a polygon selected by clicking on its interior or by having a point coordinates given
@ -1432,7 +1434,7 @@ class ToolPaint(FlatCAMTool, Gerber):
def job_thread(app_obj):
try:
app_obj.new_object("geometry", name, gen_paintarea)
app_obj.new_object("geometry", name, gen_paintarea, plot=plot)
except FlatCAMApp.GracefulException:
proc.done()
return
@ -1451,8 +1453,11 @@ class ToolPaint(FlatCAMTool, Gerber):
# Promise object with the new name
self.app.collection.promise(name)
# Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
if run_threaded:
# Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
else:
job_thread(app_obj=self.app)
def paint_poly_all(self, obj,
tooldia=None,
@ -1463,7 +1468,9 @@ class ToolPaint(FlatCAMTool, Gerber):
outname=None,
connect=None,
contour=None,
tools_storage=None):
tools_storage=None,
plot=True,
run_threaded=True):
"""
Paints all polygons in this object.
@ -1901,9 +1908,9 @@ class ToolPaint(FlatCAMTool, Gerber):
def job_thread(app_obj):
try:
if self.rest_cb.isChecked():
app_obj.new_object("geometry", name, gen_paintarea_rest_machining)
app_obj.new_object("geometry", name, gen_paintarea_rest_machining, plot=plot)
else:
app_obj.new_object("geometry", name, gen_paintarea)
app_obj.new_object("geometry", name, gen_paintarea, plot=plot)
except FlatCAMApp.GracefulException:
proc.done()
return
@ -1920,8 +1927,11 @@ class ToolPaint(FlatCAMTool, Gerber):
# Promise object with the new name
self.app.collection.promise(name)
# Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
if run_threaded:
# Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
else:
job_thread(app_obj=self.app)
def paint_poly_area(self, obj, sel_obj,
tooldia=None,
@ -1932,7 +1942,9 @@ class ToolPaint(FlatCAMTool, Gerber):
outname=None,
connect=None,
contour=None,
tools_storage=None):
tools_storage=None,
plot=True,
run_threaded=True):
"""
Paints all polygons in this object that are within the sel_obj object
@ -2366,9 +2378,9 @@ class ToolPaint(FlatCAMTool, Gerber):
def job_thread(app_obj):
try:
if self.rest_cb.isChecked():
app_obj.new_object("geometry", name, gen_paintarea_rest_machining)
app_obj.new_object("geometry", name, gen_paintarea_rest_machining, plot=plot)
else:
app_obj.new_object("geometry", name, gen_paintarea)
app_obj.new_object("geometry", name, gen_paintarea, plot=plot)
except FlatCAMApp.GracefulException:
proc.done()
return
@ -2385,8 +2397,11 @@ class ToolPaint(FlatCAMTool, Gerber):
# Promise object with the new name
self.app.collection.promise(name)
# Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
if run_threaded:
# Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
else:
job_thread(app_obj=self.app)
def paint_poly_ref(self, obj, sel_obj,
tooldia=None,
@ -2397,7 +2412,9 @@ class ToolPaint(FlatCAMTool, Gerber):
outname=None,
connect=None,
contour=None,
tools_storage=None):
tools_storage=None,
plot=True,
run_threaded=True):
"""
Paints all polygons in this object that are within the sel_obj object
@ -2441,7 +2458,9 @@ class ToolPaint(FlatCAMTool, Gerber):
outname=outname,
connect=connect,
contour=contour,
tools_storage=tools_storage)
tools_storage=tools_storage,
plot=plot,
run_threaded=run_threaded)
@staticmethod
def paint_bounds(geometry):

View File

@ -178,7 +178,7 @@ class TclCommandAlignDrill(TclCommandSignaled):
obj.app.new_object("excellon",
name + "_aligndrill",
alligndrill_init_me)
alligndrill_init_me, plot=False)
except Exception as e:
return "Operation failed: %s" % str(e)
@ -194,8 +194,8 @@ class TclCommandAlignDrill(TclCommandSignaled):
try:
px = dist
py = dist
obj.app.new_object("excellon", name + "_alligndrill", alligndrill_init_me)
obj.app.new_object("excellon", name + "_alligndrill", alligndrill_init_me, plot=False)
except Exception as e:
return "Operation failed: %s" % str(e)
return 'Ok'
return 'Ok. Align Drills Excelon object created'

View File

@ -102,4 +102,4 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
init_obj.create_geometry()
# Create the new object
self.app.new_object("excellon", args['outname'], aligndrillgrid_init_me)
self.app.new_object("excellon", args['outname'], aligndrillgrid_init_me, plot=False)

View File

@ -90,6 +90,6 @@ class TclCommandBbox(TclCommand):
bounding_box = bounding_box.envelope
geo_obj.solid_geometry = bounding_box
self.app.new_object("geometry", args['outname'], geo_init)
self.app.new_object("geometry", args['outname'], geo_init, plot=False)
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@ -143,7 +143,7 @@ class TclCommandCncjob(TclCommandSignaled):
obj.options['multidepth'] = False
if not obj.multigeo:
obj.generatecncjob(use_thread=False, **args)
obj.generatecncjob(use_thread=False, plot=False, **args)
else:
# Update the local_tools_dict values with the args value
local_tools_dict = deepcopy(obj.tools)
@ -171,5 +171,6 @@ class TclCommandCncjob(TclCommandSignaled):
outname=args['outname'],
tools_dict=local_tools_dict,
tools_in_use=[],
use_thread=False)
use_thread=False,
plot=False)
# self.raise_tcl_error('The object is a multi-geo geometry which is not supported in cncjob Tcl Command')

View File

@ -226,6 +226,7 @@ class TclCommandCopperClear(TclCommand):
contour=contour,
rest=rest,
tools_storage=ncc_tools,
plot=False,
run_threaded=False)
return
@ -259,6 +260,7 @@ class TclCommandCopperClear(TclCommand):
contour=contour,
rest=rest,
tools_storage=ncc_tools,
plot=False,
run_threaded=False)
return
else:

View File

@ -123,7 +123,7 @@ class TclCommandCutout(TclCommand):
geo_obj.solid_geometry = cascaded_union([LineString(segment) for segment in cuts])
try:
self.app.new_object("geometry", name + "_cutout", geo_init_me)
self.app.new_object("geometry", name + "_cutout", geo_init_me, plot=False)
self.app.inform.emit("[success] Rectangular-form Cutout operation finished.")
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@ -181,4 +181,4 @@ class TclCommandDrillcncjob(TclCommandSignaled):
job_obj.gcode_parse()
job_obj.create_geometry()
self.app.new_object("cncjob", args['outname'], job_init)
self.app.new_object("cncjob", args['outname'], job_init, plot=False)

View File

@ -61,4 +61,4 @@ class TclCommandExteriors(TclCommandSignaled):
geo_obj.solid_geometry = obj_exteriors
obj_exteriors = obj.get_exteriors()
self.app.new_object('geometry', outname, geo_init)
self.app.new_object('geometry', outname, geo_init, plot=False)

View File

@ -279,7 +279,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
app_obj.inform.emit("[success] Any-form Cutout operation finished.")
outname = cutout_obj.options["name"] + "_cutout"
self.app.new_object('geometry', outname, geo_init)
self.app.new_object('geometry', outname, geo_init, plot=False)
# cutout_obj.plot()
# self.app.inform.emit("[success] Any-form Cutout operation finished.")
@ -338,7 +338,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
app_obj.inform.emit("[success] Any-form Cutout operation finished.")
outname = cutout_obj.options["name"] + "_cutout"
self.app.new_object('geometry', outname, geo_init)
self.app.new_object('geometry', outname, geo_init, plot=False)
cutout_obj = self.app.collection.get_by_name(outname)
else:

View File

@ -71,7 +71,7 @@ class TclCommandImportSvg(TclCommandSignaled):
with self.app.proc_container.new("Import SVG"):
# Object creation
self.app.new_object(obj_type, outname, obj_init)
self.app.new_object(obj_type, outname, obj_init, plot=False)
# Register recent file
self.app.file_opened.emit("svg", filename)

View File

@ -85,4 +85,4 @@ class TclCommandIsolate(TclCommandSignaled):
self.raise_tcl_error('Expected FlatCAMGerber, got %s %s.' % (name, type(obj)))
del args['name']
obj.isolate(**args)
obj.isolate(plot=False, **args)

View File

@ -61,4 +61,4 @@ class TclCommandJoinExcellon(TclCommand):
FlatCAMExcellon.merge(objs, obj_)
if objs is not None:
self.app.new_object("excellon", outname, initialize)
self.app.new_object("excellon", outname, initialize, plot=False)

View File

@ -61,4 +61,4 @@ class TclCommandJoinGeometry(TclCommand):
FlatCAMGeometry.merge(objs, obj_)
if objs is not None:
self.app.new_object("geometry", outname, initialize)
self.app.new_object("geometry", outname, initialize, plot=False)

View File

@ -128,7 +128,7 @@ class TclCommandMillDrills(TclCommandSignaled):
del args['name']
# This runs in the background... Is blocking handled?
success, msg = obj.generate_milling_drills(**args)
success, msg = obj.generate_milling_drills(plot=False, **args)
except Exception as e:
success = None
msg = None

View File

@ -127,7 +127,7 @@ class TclCommandMillSlots(TclCommandSignaled):
del args['name']
# This runs in the background... Is blocking handled?
success, msg = obj.generate_milling_slots(**args)
success, msg = obj.generate_milling_slots(plot=False, **args)
except Exception as e:
success = None

View File

@ -103,6 +103,5 @@ class TclCommandMirror(TclCommandSignaled):
try:
obj.mirror(axis, [dist, dist])
obj.plot()
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@ -46,4 +46,4 @@ class TclCommandNewGeometry(TclCommandSignaled):
name = args['name']
self.app.new_object('geometry', str(name), lambda x, y: None)
self.app.new_object('geometry', str(name), lambda x, y: None, plot=False)

View File

@ -89,7 +89,7 @@ class TclCommandNregions(TclCommand):
non_copper = bounding_box.difference(geo)
geo_obj.solid_geometry = non_copper
self.app.new_object("geometry", args['outname'], geo_init)
self.app.new_object("geometry", args['outname'], geo_init, plot=False)
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@ -201,7 +201,9 @@ class TclCommandPaint(TclCommand):
outname=outname,
connect=connect,
contour=contour,
tools_storage=paint_tools)
tools_storage=paint_tools,
plot=False,
run_threaded=False)
return
# Paint single polygon in the painted object
@ -222,7 +224,9 @@ class TclCommandPaint(TclCommand):
outname=outname,
connect=connect,
contour=contour,
tools_storage=paint_tools)
tools_storage=paint_tools,
plot=False,
run_threaded=False)
return
# Paint all polygons found within the box object from the the painted object
@ -250,7 +254,9 @@ class TclCommandPaint(TclCommand):
outname=outname,
connect=connect,
contour=contour,
tools_storage=paint_tools)
tools_storage=paint_tools,
plot=False,
run_threaded=False)
return
else:

View File

@ -90,7 +90,7 @@ class TclCommandPanelize(TclCommand):
if 'threaded' in args:
threaded = args['threaded']
else:
threaded = 1
threaded = 0
if 'spacing_columns' in args:
spacing_columns = args['spacing_columns']
@ -265,10 +265,10 @@ class TclCommandPanelize(TclCommand):
if isinstance(obj, FlatCAMExcellon):
self.app.progress.emit(50)
self.app.new_object("excellon", outname, job_init_excellon, plot=True, autoselected=True)
self.app.new_object("excellon", outname, job_init_excellon, plot=False, autoselected=True)
else:
self.app.progress.emit(50)
self.app.new_object("geometry", outname, job_init_geometry, plot=True, autoselected=True)
self.app.new_object("geometry", outname, job_init_geometry, plot=False, autoselected=True)
if threaded == 1:
proc = self.app.proc_container.new("Generating panel ... Please wait.")