diff --git a/CHANGELOG.md b/CHANGELOG.md index ac6bd974..214c19b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta ================================================= +21.12.2020 + +- made sure that the GCode Editor does not have a misleading Cancel option when closing the tab +- made sure that some other part of the program outputs the log messages to the Tcl Shell if the Verbose Log options is set in Preferences + 20.12.2020 - modified the way the status bar icon is set diff --git a/appEditors/appGCodeEditor.py b/appEditors/appGCodeEditor.py index 8b37bea5..cf8e21d1 100644 --- a/appEditors/appGCodeEditor.py +++ b/appEditors/appGCodeEditor.py @@ -49,7 +49,7 @@ class AppGCodeEditor(QtCore.QObject): self.ui.name_entry.returnPressed.connect(self.on_name_activate) self.ui.update_gcode_button.clicked.connect(self.insert_code_snippet_1) self.ui.update_gcode_sec_button.clicked.connect(self.insert_code_snippet_2) - self.ui.exit_editor_button.clicked.connect(lambda: self.app.editor2object()) + self.ui.exit_editor_button.clicked.connect(lambda: self.app.editor2object(force_cancel=True)) self.app.log.debug("Initialization of the GCode Editor is finished ...") diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 199a507a..9bf630ba 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -61,7 +61,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): feedrate=3.0, feedrate_rapid=3.0, z_cut=-0.002, tooldia=0.0, spindlespeed=None): - log.debug("Creating CNCJob object...") + self.app.log.debug("Creating CNCJob object...") self.decimals = self.app.decimals @@ -956,7 +956,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): except (ObjectDeleted, AttributeError): self.probing_shapes.clear(update=True) except Exception as e: - log.debug("CNCJobObject.plot_probing_geo() --> %s" % str(e)) + self.app.log.debug("CNCJobObject.plot_probing_geo() --> %s" % str(e)) else: self.probing_shapes.clear(update=True) @@ -977,7 +977,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): pts_union = MultiPoint(pts) voronoi_union = voronoi_diagram(geom=pts_union, envelope=env) except Exception as e: - log.debug("CNCJobObject.generate_voronoi_geometry() --> %s" % str(e)) + self.app.log.debug("CNCJobObject.generate_voronoi_geometry() --> %s" % str(e)) for pt_index in range(len(pts)): new_pts[pt_index] = affinity.translate( new_pts[pt_index], random.random() * 1e-09, random.random() * 1e-09) @@ -1419,7 +1419,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): try: self.app.inform_shell.emit('\t\t\t: ' + line.decode('utf-8').strip().upper()) except Exception as e: - log.debug("CNCJobObject.send_grbl_command() --> %s" % str(e)) + self.app.log.debug("CNCJobObject.send_grbl_command() --> %s" % str(e)) if 'ok' in line: result = grbl_out @@ -1442,7 +1442,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): try: self.app.inform_shell.emit(' : ' + line.decode('utf-8').strip().upper()) except Exception as e: - log.debug("CNCJobObject.send_grbl_block() --> %s" % str(e)) + self.app.log.debug("CNCJobObject.send_grbl_block() --> %s" % str(e)) def on_grbl_get_parameter(self, param): if '$' in param: @@ -1607,7 +1607,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): # do nothing here because the Probing GCode for GRBL is obtained differently return else: - log.debug("CNCJobObject.probing_gcode() -> controller not supported") + self.app.log.debug("CNCJobObject.probing_gcode() -> controller not supported") return # ############################################################################################################# @@ -1730,7 +1730,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): try: self.gcode_viewer_tab.load_text(gco, move_to_start=True, clear_text=True) except Exception as e: - log.debug('FlatCAMCNCJob.on_edit_probing_gcode() -->%s' % str(e)) + self.app.log.debug('FlatCAMCNCJob.on_edit_probing_gcode() -->%s' % str(e)) return self.gcode_viewer_tab.t_frame.show() @@ -1794,7 +1794,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): else: return except IOError: - log.error("Failed to open height map file: %s" % filename) + self.app.log.error("Failed to open height map file: %s" % filename) self.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Failed to open height map file"), filename)) return @@ -2049,7 +2049,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): # self.gcode_editor_tab.load_text(self.app.gcode_edited.getvalue(), move_to_start=True, clear_text=True) self.gcode_editor_tab.load_text(self.app.gcode_edited, move_to_start=True, clear_text=True) except Exception as e: - log.debug('FlatCAMCNCJob.on_review_code_click() -->%s' % str(e)) + self.app.log.debug('FlatCAMCNCJob.on_review_code_click() -->%s' % str(e)) return self.gcode_editor_tab.t_frame.show() @@ -2090,7 +2090,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): :return: A string with a GCode header """ - log.debug("FlatCAMCNCJob.gcode_header()") + self.app.log.debug("FlatCAMCNCJob.gcode_header()") time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now()) marlin = False hpgl = False @@ -2113,21 +2113,21 @@ class CNCJobObject(FlatCAMObj, CNCjob): probe_pp = True break except KeyError: - # log.debug("FlatCAMCNCJob.gcode_header() error: --> %s" % str(e)) + # self.app.log.debug("FlatCAMCNCJob.gcode_header() error: --> %s" % str(e)) pass try: if 'marlin' in self.options['ppname_e'].lower() or 'repetier' in self.options['ppname_e'].lower(): marlin = True except KeyError: - # log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e)) + # self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e)) pass try: if "toolchange_probe" in self.options['ppname_e'].lower(): probe_pp = True except KeyError: - # log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e)) + # self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e)) pass if marlin is True: diff --git a/appObjects/FlatCAMExcellon.py b/appObjects/FlatCAMExcellon.py index 54c74a30..eed43b4f 100644 --- a/appObjects/FlatCAMExcellon.py +++ b/appObjects/FlatCAMExcellon.py @@ -119,7 +119,7 @@ class ExcellonObject(FlatCAMObj, Excellon): """ FlatCAMObj.set_ui(self, ui) - log.debug("ExcellonObject.set_ui()") + self.app.log.debug("ExcellonObject.set_ui()") self.units = self.app.defaults['units'].upper() @@ -730,7 +730,7 @@ class ExcellonObject(FlatCAMObj, Excellon): excellon_code += "X{xform}Y{yform}\n".format(xform=exc_x_formatted, yform=exc_y_formatted) except Exception as e: - log.debug(str(e)) + self.app.log.debug('ExcellonObject.export_excellon() drills -> %s' % str(e)) # slots processing try: @@ -830,10 +830,10 @@ class ExcellonObject(FlatCAMObj, Excellon): xstop=stop_slot_x_formatted, ystop=stop_slot_y_formatted ) except Exception as e: - log.debug(str(e)) + self.app.log.debug('ExcellonObject.export_excellon() slots -> %s' % str(e)) if not has_drills and not has_slots: - log.debug("FlatCAMObj.ExcellonObject.export_excellon() --> Excellon Object is empty: no drills, no slots.") + self.app.log.debug("ExcellonObject.export_excellon() --> Excellon Object is empty: no drills, no slots.") return 'fail' return slots_in_file, excellon_code @@ -882,7 +882,7 @@ class ExcellonObject(FlatCAMObj, Excellon): if tools == "all": tools = [i[0] for i in sorted_tools] # List if ordered tool names. - log.debug("Tools 'all' and sorted are: %s" % str(tools)) + self.app.log.debug("Tools 'all' and sorted are: %s" % str(tools)) if len(tools) == 0: self.app.inform.emit('[ERROR_NOTCL] %s' % _("Please select one or more tools from the list and try again.")) @@ -990,7 +990,7 @@ class ExcellonObject(FlatCAMObj, Excellon): if tools == "all": tools = [i[0] for i in sorted_tools] # List if ordered tool names. - log.debug("Tools 'all' and sorted are: %s" % str(tools)) + self.app.log.debug("Tools 'all' and sorted are: %s" % str(tools)) if len(tools) == 0: self.app.inform.emit('[ERROR_NOTCL] %s' % _("Please select one or more tools from the list and try again.")) @@ -1074,7 +1074,7 @@ class ExcellonObject(FlatCAMObj, Excellon): self.generate_milling_slots(use_thread=False, plot=True) def convert_units(self, units): - log.debug("FlatCAMObj.ExcellonObject.convert_units()") + self.app.log.debug("ExcellonObject.convert_units()") Excellon.convert_units(self, units) @@ -1233,7 +1233,7 @@ class ExcellonObject(FlatCAMObj, Excellon): self.shapes.redraw() except (ObjectDeleted, AttributeError) as e: - log.debug("ExcellonObject.plot() -> %s" % str(e)) + self.app.log.debug("ExcellonObject.plot() -> %s" % str(e)) self.shapes.clear(update=True) if multicolored: diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index 59796360..7ee4a24e 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -99,7 +99,7 @@ class GeometryObject(FlatCAMObj, Geometry): tools_diameters = [eval(a) for a in tools_string if a != ''] self.options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0 except Exception as e: - log.debug("FlatCAMObj.GeometryObject.init() --> %s" % str(e)) + self.app.log.debug("FlatCAMObj.GeometryObject.init() --> %s" % str(e)) self.options["startz"] = self.app.defaults["geometry_startz"] @@ -319,7 +319,7 @@ class GeometryObject(FlatCAMObj, Geometry): # self.update_ui() except Exception as e: # when the tools table is empty there will be this error but once the table is populated it will go away - log.debug(str(e)) + self.app.log.debug('GeometryObject.build_ui() -> %s' % str(e)) # disable the Plot column in Tool Table if the geometry is SingleGeo as it is not needed # and can create some problems @@ -423,7 +423,7 @@ class GeometryObject(FlatCAMObj, Geometry): # this one adds the 'name' key and the self.ui.name_entry widget in the self.form_fields dict FlatCAMObj.set_ui(self, ui) - log.debug("GeometryObject.set_ui()") + self.app.log.debug("GeometryObject.set_ui()") assert isinstance(self.ui, GeometryObjectUI), \ "Expected a GeometryObjectUI, got %s" % type(self.ui) @@ -539,8 +539,8 @@ class GeometryObject(FlatCAMObj, Geometry): float(eval(dia)) for dia in temp_tools if dia != '' ] except Exception as e: - log.error("GeometryObject.set_ui() -> At least one tool diameter needed. " - "Verify in Edit -> Preferences -> Geometry General -> Tool dia. %s" % str(e)) + self.app.log.error("GeometryObject.set_ui() -> At least one tool diameter needed. " + "Verify in Edit -> Preferences -> Geometry General -> Tool dia. %s" % str(e)) return self.tooluid += 1 @@ -583,7 +583,7 @@ class GeometryObject(FlatCAMObj, Geometry): # self.old_toolchangeg_state = self.default_data['toolchange'] if not isinstance(self.ui, GeometryObjectUI): - log.debug("Expected a GeometryObjectUI, got %s" % type(self.ui)) + self.app.log.debug("Expected a GeometryObjectUI, got %s" % type(self.ui)) return # ############################################################################################################# @@ -810,7 +810,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.ui.tool_offset_entry.hide() self.ui.tool_offset_lbl.hide() except Exception as e: - log.debug("set_tool_offset_visibility() --> " + str(e)) + self.app.log.debug("set_tool_offset_visibility() --> " + str(e)) return def on_offset_value_edited(self): @@ -1085,7 +1085,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.ui_connect() return except Exception as e: - log.debug("Tool missing. Add a tool in Geo Tool Table. %s" % str(e)) + self.app.log.debug("Tool missing. Add a tool in Geo Tool Table. %s" % str(e)) self.ui_connect() return @@ -1111,7 +1111,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.ui_connect() return except Exception as e: - log.debug("Tool missing. Add a tool in Geo Tool Table. %s" % str(e)) + self.app.log.debug("Tool missing. Add a tool in Geo Tool Table. %s" % str(e)) self.ui_connect() return @@ -1128,7 +1128,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.ui_connect() return except Exception as e: - log.debug("Tool missing in ui_update_v_shape(). Add a tool in Geo Tool Table. %s" % str(e)) + self.app.log.debug("Tool missing in ui_update_v_shape(). Add a tool in Geo Tool Table. %s" % str(e)) return # ######################################################################################################### @@ -1149,12 +1149,12 @@ class GeometryObject(FlatCAMObj, Geometry): if key == 'tool_type' and value == 'V': self.on_update_cutz() except Exception as e: - log.debug("GeometryObject.update_ui() -> %s " % str(e)) + self.app.log.debug("GeometryObject.update_ui() -> %s " % str(e)) self.ui_connect() def on_tool_add(self, clicked_state, dia=None, new_geo=None): - log.debug("GeometryObject.on_add_tool()") + self.app.log.debug("GeometryObject.on_add_tool()") self.ui_disconnect() @@ -1473,7 +1473,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.builduiSig.emit() return except Exception as e: - log.debug("on_tool_copy() --> " + str(e)) + self.app.log.debug("on_tool_copy() --> " + str(e)) # deselect the table # self.ui.geo_tools_table.clearSelection() else: @@ -1490,7 +1490,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.tools[int(max_uid)] = deepcopy(temp_tools[tooluid]) temp_tools.clear() except Exception as e: - log.debug("on_tool_copy() --> " + str(e)) + self.app.log.debug("on_tool_copy() --> " + str(e)) # if there are no more tools in geo tools table then hide the tool offset if not self.tools: @@ -1574,7 +1574,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.builduiSig.emit() return except Exception as e: - log.debug("on_tool_delete() --> " + str(e)) + self.app.log.debug("on_tool_delete() --> " + str(e)) # deselect the table # self.ui.geo_tools_table.clearSelection() else: @@ -1752,7 +1752,7 @@ class GeometryObject(FlatCAMObj, Geometry): try: self.form_fields[form_key].set_value(dict_storage[form_key]) except Exception as e: - log.debug(str(e)) + self.app.log.debug('GeometryObject.update_form() -> %s' % str(e)) # this is done here because those buttons control through OptionalInputSelection if some entry's are Enabled # or not. But due of using the ui_disconnect() status is no longer updated and I had to do it here @@ -1763,7 +1763,7 @@ class GeometryObject(FlatCAMObj, Geometry): def on_apply_param_to_all_clicked(self): if self.ui.geo_tools_table.rowCount() == 0: # there is no tool in tool table so we can't save the GUI elements values to storage - log.debug("GeometryObject.gui_form_to_storage() --> no tool in Tools Table, aborting.") + self.app.log.debug("GeometryObject.gui_form_to_storage() --> no tool in Tools Table, aborting.") return self.ui_disconnect() @@ -1828,7 +1828,7 @@ class GeometryObject(FlatCAMObj, Geometry): if self.ui.geo_tools_table.rowCount() == 0: # there is no tool in tool table so we can't save the GUI elements values to storage - log.debug("GeometryObject.gui_form_to_storage() --> no tool in Tools Table, aborting.") + self.app.log.debug("GeometryObject.gui_form_to_storage() --> no tool in Tools Table, aborting.") return widget_changed = self.sender() @@ -1838,7 +1838,7 @@ class GeometryObject(FlatCAMObj, Geometry): if widget_idx == 1 or widget_idx == 3: self.on_update_cutz() except Exception as e: - log.debug("GeometryObject.gui_form_to_storage() -- wdg index -> %s" % str(e)) + self.app.log.debug("GeometryObject.gui_form_to_storage() -- wdg index -> %s" % str(e)) # the original connect() function of the OptionalInputSelection is no longer working because of the # ui_diconnect() so I use this 'hack' @@ -1969,7 +1969,7 @@ class GeometryObject(FlatCAMObj, Geometry): # points = GeometryObject.get_pts(geo) # msp.add_lwpolyline(points) except Exception as e: - log.debug(str(e)) + self.app.log.debug(str(e)) return dwg @@ -2130,7 +2130,7 @@ class GeometryObject(FlatCAMObj, Geometry): # pass def on_generatecnc_button_click(self): - log.debug("Generating CNCJob from Geometry ...") + self.app.log.debug("Generating CNCJob from Geometry ...") self.app.defaults.report_usage("geometry_on_generatecnc_button") # this reads the values in the UI form to the self.options dictionary @@ -2214,7 +2214,7 @@ class GeometryObject(FlatCAMObj, Geometry): xmax = self.options['xmax'] ymax = self.options['ymax'] except Exception as e: - log.debug("FlatCAMObj.GeometryObject.mtool_gen_cncjob() --> %s\n" % str(e)) + self.app.log.debug("FlatCAMObj.GeometryObject.mtool_gen_cncjob() --> %s\n" % str(e)) msg = '[ERROR] %s' % _("An internal error has occurred. See shell.\n") msg += '%s' % str(e) @@ -2228,7 +2228,7 @@ class GeometryObject(FlatCAMObj, Geometry): # Object initialization function for app.app_obj.new_object() # RUNNING ON SEPARATE THREAD! def job_init_single_geometry(job_obj, app_obj): - log.debug("Creating a CNCJob out of a single-geometry") + self.app.log.debug("Creating a CNCJob out of a single-geometry") assert job_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(job_obj) job_obj.options['xmin'] = xmin @@ -2341,7 +2341,7 @@ class GeometryObject(FlatCAMObj, Geometry): tool_no=tool_cnt, is_first=is_first) if res == 'fail': - log.debug("GeometryObject.mtool_gen_cncjob() --> generate_from_geometry2() failed") + self.app.log.debug("GeometryObject.mtool_gen_cncjob() --> generate_from_geometry2() failed") return 'fail' dia_cnc_dict['gcode'] = res @@ -2377,7 +2377,7 @@ class GeometryObject(FlatCAMObj, Geometry): # Object initialization function for app.app_obj.new_object() # RUNNING ON SEPARATE THREAD! def job_init_multi_geometry(job_obj, app_obj): - log.debug("Creating a CNCJob out of a multi-geometry") + self.app.log.debug("Creating a CNCJob out of a multi-geometry") assert job_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(job_obj) job_obj.options['xmin'] = xmin @@ -2496,7 +2496,7 @@ class GeometryObject(FlatCAMObj, Geometry): is_first=is_first, is_last=is_last, toolchange=True) if res == 'fail': - log.debug("GeometryObject.mtool_gen_cncjob() --> generate_from_geometry2() failed") + self.app.log.debug("GeometryObject.mtool_gen_cncjob() --> generate_from_geometry2() failed") return 'fail' else: dia_cnc_dict['gcode'] = res @@ -2784,7 +2784,7 @@ class GeometryObject(FlatCAMObj, Geometry): except grace: return "fail" except Exception as e: - log.debug("Could not Paint the polygons. %s" % str(e)) + self.app.log.debug("Could not Paint the polygons. %s" % str(e)) mssg = '[ERROR] %s\n%s' % (_("Could not do Paint. Try a different combination of parameters. " "Or a different method of Paint"), str(e)) self.app.inform.emit(mssg) @@ -2810,7 +2810,7 @@ class GeometryObject(FlatCAMObj, Geometry): :return: None :rtype: None """ - log.debug("FlatCAMObj.GeometryObject.scale()") + self.app.log.debug("FlatCAMObj.GeometryObject.scale()") try: xfactor = float(xfactor) @@ -2898,7 +2898,7 @@ class GeometryObject(FlatCAMObj, Geometry): :return: None :rtype: None """ - log.debug("FlatCAMObj.GeometryObject.offset()") + self.app.log.debug("FlatCAMObj.GeometryObject.offset()") try: dx, dy = vect @@ -2963,7 +2963,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.app.inform.emit('[success] %s' % _("Done.")) def convert_units(self, units): - log.debug("FlatCAMObj.GeometryObject.convert_units()") + self.app.log.debug("FlatCAMObj.GeometryObject.convert_units()") self.ui_disconnect() @@ -3231,7 +3231,7 @@ class GeometryObject(FlatCAMObj, Geometry): if not self.app.exc_areas.exclusion_areas_storage: self.app.exc_areas.clear_shapes() except Exception as err: - log.debug('GeometryObject.area_disconnect() -> %s' % str(err)) + self.app.log.debug('GeometryObject.area_disconnect() -> %s' % str(err)) def plot_element(self, element, color=None, visible=None): @@ -3419,7 +3419,7 @@ class GeometryObject(FlatCAMObj, Geometry): try: new_options[option] = deepcopy(geo_obj.options[option]) except Exception as e: - log.warning("Failed to copy option %s. Error: %s" % (str(option), str(e))) + self.app.log.warning("Failed to copy option %s. Error: %s" % (str(option), str(e))) # Expand lists if type(geo_obj) is list: @@ -3434,7 +3434,7 @@ class GeometryObject(FlatCAMObj, Geometry): try: new_solid_geometry += deepcopy(geo_obj.solid_geometry) except Exception as e: - log.debug("GeometryObject.merge() --> %s" % str(e)) + self.app.log.debug("GeometryObject.merge() --> %s" % str(e)) # find the tool_uid maximum value in the geo_final try: diff --git a/appObjects/FlatCAMGerber.py b/appObjects/FlatCAMGerber.py index 2c29219e..441d66b6 100644 --- a/appObjects/FlatCAMGerber.py +++ b/appObjects/FlatCAMGerber.py @@ -741,7 +741,7 @@ class GerberObject(FlatCAMObj, Gerber): try: geom = self.isolation_geometry(offset, geometry=geometry, iso_type=env_iso_type, passes=nr_passes) except Exception as e: - log.debug('GerberObject.isolate().generate_envelope() --> %s' % str(e)) + self.app.log.debug('GerberObject.isolate().generate_envelope() --> %s' % str(e)) return 'fail' if invert: @@ -760,10 +760,10 @@ class GerberObject(FlatCAMObj, Gerber): elif isinstance(geom, LinearRing) and geom is not None: geom = Polygon(geom.coords[::-1]) else: - log.debug("GerberObject.isolate().generate_envelope() Error --> Unexpected Geometry %s" % + self.app.log.debug("GerberObject.isolate().generate_envelope() Error --> Unexpected Geometry %s" % type(geom)) except Exception as e: - log.debug("GerberObject.isolate().generate_envelope() Error --> %s" % str(e)) + self.app.log.debug("GerberObject.isolate().generate_envelope() Error --> %s" % str(e)) return 'fail' return geom @@ -789,7 +789,7 @@ class GerberObject(FlatCAMObj, Gerber): float(eval(dia)) for dia in temp_tools if dia != '' ] except Exception as e: - log.error("GerberObject.follow_geo -> At least one tool diameter needed. -> %s" % str(e)) + self.app.log.error("GerberObject.follow_geo -> At least one tool diameter needed. -> %s" % str(e)) return 'fail' # Propagate options @@ -874,7 +874,7 @@ class GerberObject(FlatCAMObj, Gerber): self.clear_plot_apertures() self.mark_shapes.enabled = False except Exception as e: - log.debug(" GerberObject.on_aperture_visibility_changed() --> %s" % str(e)) + self.app.log.debug(" GerberObject.on_aperture_visibility_changed() --> %s" % str(e)) def convert_units(self, units): """ @@ -890,10 +890,10 @@ class GerberObject(FlatCAMObj, Gerber): # units conversion to get a conversion should be done only once even if we found multiple # units declaration inside a Gerber file (it can happen to find also the obsolete declaration) if self.conversion_done is True: - log.debug("Gerber units conversion cancelled. Already done.") + self.app.log.debug("Gerber units conversion cancelled. Already done.") return - log.debug("FlatCAMObj.GerberObject.convert_units()") + self.app.log.debug("FlatCAMObj.GerberObject.convert_units()") Gerber.convert_units(self, units) @@ -999,7 +999,7 @@ class GerberObject(FlatCAMObj, Gerber): except (ObjectDeleted, AttributeError): self.shapes.clear(update=True) except Exception as e: - log.debug("GerberObject.plot() --> %s" % str(e)) + self.app.log.debug("GerberObject.plot() --> %s" % str(e)) # experimental plot() when the solid_geometry is stored in the self.apertures def plot_aperture(self, only_flashes=False, run_thread=False, **kwargs): @@ -1060,7 +1060,7 @@ class GerberObject(FlatCAMObj, Gerber): except (ObjectDeleted, AttributeError): app_obj.clear_plot_apertures() except Exception as e: - log.debug("GerberObject.plot_aperture() --> %s" % str(e)) + self.app.log.debug("GerberObject.plot_aperture() --> %s" % str(e)) if run_thread: self.app.worker_task.emit({'fcn': job_thread, 'params': [self]}) @@ -1083,7 +1083,7 @@ class GerberObject(FlatCAMObj, Gerber): try: self.mark_shapes.remove(shape_key) except Exception as e: - log.debug("GerberObject.clear_plot_apertures() -> %s" % str(e)) + self.app.log.debug("GerberObject.clear_plot_apertures() -> %s" % str(e)) self.mark_shapes_storage[aperture] = [] self.mark_shapes.redraw() @@ -1177,7 +1177,7 @@ class GerberObject(FlatCAMObj, Gerber): :param factor: factor to be applied onto the Gerber coordinates :return: Gerber_code """ - log.debug("GerberObject.export_gerber() --> Generating the Gerber code from the selected Gerber file") + self.app.log.debug("GerberObject.export_gerber() --> Generating the Gerber code from the selected Gerber file") def tz_format(x, y, fac): x_c = x * fac @@ -1330,7 +1330,7 @@ class GerberObject(FlatCAMObj, Gerber): # gerber_code += "D02*\n" except Exception as e: - log.debug("FlatCAMObj.GerberObject.export_gerber() 'follow' --> %s" % str(e)) + self.app.log.debug("FlatCAMObj.GerberObject.export_gerber() 'follow' --> %s" % str(e)) if 'clear' in geo_elem: geo = geo_elem['clear'] if not geo.is_empty: @@ -1364,7 +1364,7 @@ class GerberObject(FlatCAMObj, Gerber): gerber_code += 'G37*\n' gerber_code += '%LPD*%\n' except Exception as e: - log.debug("FlatCAMObj.GerberObject.export_gerber() '0' aperture --> %s" % str(e)) + self.app.log.debug("FlatCAMObj.GerberObject.export_gerber() '0' aperture --> %s" % str(e)) for apid in self.apertures: if apid == '0': @@ -1415,7 +1415,7 @@ class GerberObject(FlatCAMObj, Gerber): # gerber_code += "D02*\n" except Exception as e: - log.debug("FlatCAMObj.GerberObject.export_gerber() 'follow' --> %s" % str(e)) + self.app.log.debug("FlatCAMObj.GerberObject.export_gerber() 'follow' --> %s" % str(e)) try: if 'clear' in geo_elem: @@ -1519,10 +1519,10 @@ class GerberObject(FlatCAMObj, Gerber): # gerber_code += "D02*\n" gerber_code += '%LPD*%\n' except Exception as e: - log.debug("FlatCAMObj.GerberObject.export_gerber() 'clear' --> %s" % str(e)) + self.app.log.debug("FlatCAMObj.GerberObject.export_gerber() 'clear' --> %s" % str(e)) if not self.apertures: - log.debug("FlatCAMObj.GerberObject.export_gerber() --> Gerber Object is empty: no apertures.") + self.app.log.debug("FlatCAMObj.GerberObject.export_gerber() --> Gerber Object is empty: no apertures.") return 'fail' return gerber_code @@ -1560,7 +1560,7 @@ class GerberObject(FlatCAMObj, Gerber): try: grb_final.options[option] = grb.options[option] except KeyError: - log.warning("Failed to copy option.", option) + self.app.log.warning("Failed to copy option.", option) try: for geos in grb.solid_geometry: diff --git a/appParsers/ParseExcellon.py b/appParsers/ParseExcellon.py index 3c09c5e7..c695c344 100644 --- a/appParsers/ParseExcellon.py +++ b/appParsers/ParseExcellon.py @@ -278,7 +278,7 @@ class Excellon(Geometry): raise grace line_num += 1 - # log.debug("%3d %s" % (line_num, str(eline))) + # self.app.log.debug("%3d %s" % (line_num, str(eline))) self.source_file += eline @@ -288,7 +288,7 @@ class Excellon(Geometry): # Excellon files and Gcode share some extensions therefore if we detect G20 or G21 it's GCODe # and we need to exit from here if self.detect_gcode_re.search(eline): - log.warning("This is GCODE mark: %s" % eline) + self.app.log.warning("This is GCODE mark: %s" % eline) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_('This is GCODE mark'), eline)) return @@ -296,14 +296,14 @@ class Excellon(Geometry): if self.hbegin_re.search(eline): in_header = True headerless = False - log.warning("Found start of the header: %s" % eline) + self.app.log.warning("Found start of the header: %s" % eline) continue # Allegro Header Begin (;HEADER) # if self.allegro_hbegin_re.search(eline): in_header = True allegro_warning = True - log.warning("Found ALLEGRO start of the header: %s" % eline) + self.app.log.warning("Found ALLEGRO start of the header: %s" % eline) continue # Search for Header End # @@ -317,7 +317,7 @@ class Excellon(Geometry): line_units_found = True line_units = match.group(3) self.convert_units({"MILS": "IN", "MM": "MM"}[line_units]) - log.warning("Type of Allegro UNITS found inline in comments: %s" % line_units) + self.app.log.warning("Type of Allegro UNITS found inline in comments: %s" % line_units) if match.group(2): name_tool += 1 @@ -330,13 +330,13 @@ class Excellon(Geometry): 'tooldia': (float(match.group(2)) / 1000) } self.tools[name_tool]['tooldia'] = (float(match.group(2)) / 1000) - log.debug("Tool definition: %d %s" % (name_tool, spec)) + self.app.log.debug("Tool definition: %d %s" % (name_tool, spec)) else: spec = { 'tooldia': float(match.group(2)) } self.tools[name_tool]['tooldia'] = float(match.group(2)) - log.debug("Tool definition: %d %s" % (name_tool, spec)) + self.app.log.debug("Tool definition: %d %s" % (name_tool, spec)) spec['solid_geometry'] = [] continue # search for Altium Excellon Format / Sprint Layout who is included as a comment @@ -347,28 +347,28 @@ class Excellon(Geometry): self.excellon_format_upper_in = match.group(1) self.excellon_format_lower_in = match.group(2) - log.warning("Excellon format preset found in comments: %s:%s" % + self.app.log.warning("Excellon format preset found in comments: %s:%s" % (match.group(1), match.group(2))) continue else: - log.warning("Line ignored, it's a comment: %s" % eline) + self.app.log.warning("Line ignored, it's a comment: %s" % eline) else: if self.hend_re.search(eline): if in_header is False or bool(self.tools) is False: - log.warning("Found end of the header but there is no header: %s" % eline) - log.warning("The only useful data in header are tools, units and format.") - log.warning("Therefore we will create units and format based on defaults.") + self.app.log.warning("Found end of the header but there is no header: %s" % eline) + self.app.log.warning("The only useful data in header are tools, units and format.") + self.app.log.warning("Therefore we will create units and format based on defaults.") headerless = True try: self.convert_units({"INCH": "IN", "METRIC": "MM"}[self.excellon_units]) except Exception as e: - log.warning("Units could not be converted: %s" % str(e)) + self.app.log.warning("Units could not be converted: %s" % str(e)) in_header = False # for Allegro type of Excellons we reset name_tool variable so we can reuse it for toolchange if allegro_warning is True: name_tool = 0 - log.warning("Found end of the header: %s" % eline) + self.app.log.warning("Found end of the header: %s" % eline) ''' In case that the units were not found in the header, we have two choices: @@ -400,14 +400,14 @@ class Excellon(Geometry): self.units = {"1": "MM", "2": "IN"}[match.group(1)] # Modified for issue #80 - log.debug("ALternative M71/M72 units found, before conversion: %s" % self.units) + self.app.log.debug("ALternative M71/M72 units found, before conversion: %s" % self.units) self.convert_units(self.units) - log.debug("ALternative M71/M72 units found, after conversion: %s" % self.units) + self.app.log.debug("ALternative M71/M72 units found, after conversion: %s" % self.units) if self.units == 'MM': - log.warning("Excellon format preset is: %s:%s" % + self.app.log.warning("Excellon format preset is: %s:%s" % (str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm))) else: - log.warning("Excellon format preset is: %s:%s" % + self.app.log.warning("Excellon format preset is: %s:%s" % (str(self.excellon_format_upper_in), str(self.excellon_format_lower_in))) continue @@ -418,7 +418,7 @@ class Excellon(Geometry): match = self.toolsel_re.search(eline) if match: current_tool = int(match.group(1)) - log.debug("Tool change: %s" % current_tool) + self.app.log.debug("Tool change: %s" % current_tool) if bool(headerless): match = self.toolset_hl_re.search(eline) if match: @@ -457,7 +457,7 @@ class Excellon(Geometry): self.tools[name]['tooldia'] = diam self.tools[name]['solid_geometry'] = [] - log.debug("Tool definition out of header: %s %s" % (name, spec)) + self.app.log.debug("Tool definition out of header: %s %s" % (name, spec)) continue @@ -468,7 +468,7 @@ class Excellon(Geometry): if match or match1: name_tool += 1 current_tool = name_tool - log.debug("Tool change for Allegro type of Excellon: %d" % current_tool) + self.app.log.debug("Tool change for Allegro type of Excellon: %d" % current_tool) continue # ## Slots parsing for drilled slots (contain G85) @@ -523,11 +523,11 @@ class Excellon(Geometry): if (slot_start_x is None or slot_start_y is None or slot_stop_x is None or slot_stop_y is None): - log.error("Slots are missing some or all coordinates.") + self.app.log.error("Slots are missing some or all coordinates.") continue # we have a slot - log.debug('Parsed a slot with coordinates: ' + str([slot_start_x, + self.app.log.debug('Parsed a slot with coordinates: ' + str([slot_start_x, slot_start_y, slot_stop_x, slot_stop_y])) @@ -537,7 +537,7 @@ class Excellon(Geometry): slot_dia = float(self.tools[current_tool]['tooldia']) except Exception: pass - log.debug( + self.app.log.debug( 'Milling/Drilling slot with tool %s, diam=%f' % ( current_tool, slot_dia @@ -597,11 +597,11 @@ class Excellon(Geometry): if (slot_start_x is None or slot_start_y is None or slot_stop_x is None or slot_stop_y is None): - log.error("Slots are missing some or all coordinates.") + self.app.log.error("Slots are missing some or all coordinates.") continue # we have a slot - log.debug('Parsed a slot with coordinates: ' + str([slot_start_x, + self.app.log.debug('Parsed a slot with coordinates: ' + str([slot_start_x, slot_start_y, slot_stop_x, slot_stop_y])) @@ -611,7 +611,7 @@ class Excellon(Geometry): slot_dia = float(self.tools[current_tool]['tooldia']) except Exception: pass - log.debug( + self.app.log.debug( 'Milling/Drilling slot with tool %s, diam=%f' % ( current_tool, slot_dia @@ -688,7 +688,7 @@ class Excellon(Geometry): return if x is None or y is None: - log.error("Missing coordinates") + self.app.log.error("Missing coordinates") continue # ## Excellon Routing parse @@ -738,7 +738,7 @@ class Excellon(Geometry): self.tools[current_tool]['drills'].append(Point((x, y))) else: self.tools[current_tool]['drills'] = [Point((x, y))] - # log.debug("{:15} {:8} {:8}".format(eline, x, y)) + # self.app.log.debug("{:15} {:8} {:8}".format(eline, x, y)) continue # ## Coordinates with period: Use literally. # ## @@ -768,7 +768,7 @@ class Excellon(Geometry): repeating_y = 0 if x is None or y is None: - log.error("Missing coordinates") + self.app.log.error("Missing coordinates") continue # ## Excellon Routing parse @@ -839,7 +839,7 @@ class Excellon(Geometry): repeat -= 1 repeating_x = repeating_y = 0 - # log.debug("{:15} {:8} {:8}".format(eline, x, y)) + # self.app.log.debug("{:15} {:8} {:8}".format(eline, x, y)) continue # ### Header #### @@ -856,7 +856,7 @@ class Excellon(Geometry): self.tools[name]['tooldia'] = float(match.group(2)) self.tools[name]['solid_geometry'] = [] - log.debug("Tool definition: %s %s" % (name, spec)) + self.app.log.debug("Tool definition: %s %s" % (name, spec)) continue # ## Units and number format # ## @@ -878,36 +878,36 @@ class Excellon(Geometry): self.excellon_format_lower_in = lower # Modified for issue #80 - log.warning("UNITS found inline - Value before conversion: %s" % self.units) + self.app.log.warning("UNITS found inline - Value before conversion: %s" % self.units) self.convert_units(self.units) - log.warning("UNITS found inline - Value after conversion: %s" % self.units) + self.app.log.warning("UNITS found inline - Value after conversion: %s" % self.units) if self.units == 'MM': - log.warning("Excellon format preset is: %s:%s" % + self.app.log.warning("Excellon format preset is: %s:%s" % (str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm))) else: - log.warning("Excellon format preset is: %s:%s" % + self.app.log.warning("Excellon format preset is: %s:%s" % (str(self.excellon_format_upper_in), str(self.excellon_format_lower_in))) - log.warning("Type of ZEROS found inline, in header: %s" % self.zeros) + self.app.log.warning("Type of ZEROS found inline, in header: %s" % self.zeros) continue # Search for units type again it might be alone on the line if "INCH" in eline: line_units = "IN" # Modified for issue #80 - log.warning("Type of UNITS found inline, in header, before conversion: %s" % line_units) + self.app.log.warning("Type of UNITS found inline, in header, before conversion: %s" % line_units) self.convert_units(line_units) - log.warning("Type of UNITS found inline, in header, after conversion: %s" % self.units) - log.warning("Excellon format preset is: %s:%s" % + self.app.log.warning("Type of UNITS found inline, in header, after conversion: %s" % self.units) + self.app.log.warning("Excellon format preset is: %s:%s" % (str(self.excellon_format_upper_in), str(self.excellon_format_lower_in))) self.excellon_units_found = "IN" continue elif "METRIC" in eline: line_units = "MM" # Modified for issue #80 - log.warning("Type of UNITS found inline, in header, before conversion: %s" % line_units) + self.app.log.warning("Type of UNITS found inline, in header, before conversion: %s" % line_units) self.convert_units(line_units) - log.warning("Type of UNITS found inline, in header, after conversion: %s" % self.units) - log.warning("Excellon format preset is: %s:%s" % + self.app.log.warning("Type of UNITS found inline, in header, after conversion: %s" % self.units) + self.app.log.warning("Excellon format preset is: %s:%s" % (str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm))) self.excellon_units_found = "MM" continue @@ -916,7 +916,7 @@ class Excellon(Geometry): match = re.search(r'[LT]Z', eline) if match: self.zeros = match.group() - log.warning("Type of ZEROS found: %s" % self.zeros) + self.app.log.warning("Type of ZEROS found: %s" % self.zeros) continue # ## Units and number format outside header# ## @@ -938,20 +938,20 @@ class Excellon(Geometry): self.excellon_format_lower_in = lower # Modified for issue #80 - log.warning("Type of UNITS found outside header, inline before conversion: %s" % self.units) + self.app.log.warning("Type of UNITS found outside header, inline before conversion: %s" % self.units) self.convert_units(self.units) - log.warning("Type of UNITS found outside header, inline after conversion: %s" % self.units) + self.app.log.warning("Type of UNITS found outside header, inline after conversion: %s" % self.units) if self.units == 'MM': - log.warning("Excellon format preset is: %s:%s" % + self.app.log.warning("Excellon format preset is: %s:%s" % (str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm))) else: - log.warning("Excellon format preset is: %s:%s" % + self.app.log.warning("Excellon format preset is: %s:%s" % (str(self.excellon_format_upper_in), str(self.excellon_format_lower_in))) - log.warning("Type of ZEROS found outside header, inline: %s" % self.zeros) + self.app.log.warning("Type of ZEROS found outside header, inline: %s" % self.zeros) continue - log.warning("Line ignored: %s" % eline) + self.app.log.warning("Line ignored: %s" % eline) # make sure that since we are in headerless mode, we convert the tools only after the file parsing # is finished since the tools definitions are spread in the Excellon body. We use as units the value @@ -966,9 +966,9 @@ class Excellon(Geometry): if 'slots' not in self.tools[tool]: self.tools[tool]['slots'] = [] - log.info("Zeros: %s, Units %s." % (self.zeros, self.units)) + self.app.log.info("Zeros: %s, Units %s." % (self.zeros, self.units)) except Exception: - log.error("Excellon PARSING FAILED. Line %d: %s" % (line_num, eline)) + self.app.log.error("Excellon PARSING FAILED. Line %d: %s" % (line_num, eline)) msg = '[ERROR_NOTCL] %s' % _("An internal error has occurred. See shell.\n") msg += '{e_code} {tx} {l_nr}: {line}\n'.format( e_code='[ERROR]', @@ -1020,7 +1020,7 @@ class Excellon(Geometry): result = float(number_str) / (10 ** (float(self.excellon_format_lower_mm))) return result except Exception as e: - log.error("Aborted. Operation could not be completed due of %s" % str(e)) + self.app.log.error("Aborted. Operation could not be completed due of %s" % str(e)) return def create_geometry(self): @@ -1043,7 +1043,7 @@ class Excellon(Geometry): :return: None """ - log.debug("appParsers.ParseExcellon.Excellon.create_geometry()") + self.app.log.debug("appParsers.ParseExcellon.Excellon.create_geometry()") self.solid_geometry = [] try: # clear the solid_geometry in self.tools @@ -1081,7 +1081,7 @@ class Excellon(Geometry): self.solid_geometry.append(poly) except Exception as e: - log.debug("appParsers.ParseExcellon.Excellon.create_geometry() -> " + self.app.log.debug("appParsers.ParseExcellon.Excellon.create_geometry() -> " "Excellon geometry creation failed due of ERROR: %s" % str(e)) return "fail" @@ -1093,10 +1093,10 @@ class Excellon(Geometry): :param flatten: No used """ - log.debug("appParsers.ParseExcellon.Excellon.bounds()") + self.app.log.debug("appParsers.ParseExcellon.Excellon.bounds()") if self.solid_geometry is None or not self.tools: - log.debug("appParsers.ParseExcellon.Excellon -> solid_geometry is None") + self.app.log.debug("appParsers.ParseExcellon.Excellon -> solid_geometry is None") return 0, 0, 0, 0 def bounds_rec(obj): @@ -1165,9 +1165,9 @@ class Excellon(Geometry): elif obj_units.upper() == "IN": factor = 1 / 25.4 else: - log.error("Unsupported units: %s" % str(obj_units)) + self.app.log.error("Unsupported units: %s" % str(obj_units)) factor = 1.0 - log.debug("appParsers.ParseExcellon.Excellon.convert_units() --> Factor: %s" % str(factor)) + self.app.log.debug("appParsers.ParseExcellon.Excellon.convert_units() --> Factor: %s" % str(factor)) self.units = obj_units self.scale(factor, factor) @@ -1193,7 +1193,7 @@ class Excellon(Geometry): :return: None :rtype: None """ - log.debug("appParsers.ParseExcellon.Excellon.scale()") + self.app.log.debug("appParsers.ParseExcellon.Excellon.scale()") if yfactor is None: yfactor = xfactor @@ -1267,7 +1267,7 @@ class Excellon(Geometry): :type vect: tuple :return: None """ - log.debug("appParsers.ParseExcellon.Excellon.offset()") + self.app.log.debug("appParsers.ParseExcellon.Excellon.offset()") dx, dy = vect @@ -1336,7 +1336,7 @@ class Excellon(Geometry): :type point: list :return: None """ - log.debug("appParsers.ParseExcellon.Excellon.mirror()") + self.app.log.debug("appParsers.ParseExcellon.Excellon.mirror()") px, py = point xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis] @@ -1411,7 +1411,7 @@ class Excellon(Geometry): See shapely manual for more information: http://toblerity.org/shapely/manual.html#affine-transformations """ - log.debug("appParsers.ParseExcellon.Excellon.skew()") + self.app.log.debug("appParsers.ParseExcellon.Excellon.skew()") if angle_x is None: angle_x = 0.0 @@ -1487,7 +1487,7 @@ class Excellon(Geometry): :param point: tuple of coordinates (x, y) :return: None """ - log.debug("appParsers.ParseExcellon.Excellon.rotate()") + self.app.log.debug("appParsers.ParseExcellon.Excellon.rotate()") if angle == 0: return @@ -1563,7 +1563,7 @@ class Excellon(Geometry): :param join: The type of line joint used by the shapely buffer method: round, square, bevel :return: None """ - log.debug("appParsers.ParseExcellon.Excellon.buffer()") + self.app.log.debug("appParsers.ParseExcellon.Excellon.buffer()") if distance == 0: return diff --git a/appParsers/ParseGerber.py b/appParsers/ParseGerber.py index 3826adc1..ca241788 100644 --- a/appParsers/ParseGerber.py +++ b/appParsers/ParseGerber.py @@ -297,7 +297,7 @@ class Gerber(Geometry): "modifiers": paramList} return apid - log.warning("Aperture not implemented: %s" % str(apertureType)) + self.app.log.warning("Aperture not implemented: %s" % str(apertureType)) return None def parse_file(self, filename, follow=False): @@ -451,7 +451,7 @@ class Gerber(Geometry): match = self.lpol_re.search(gline) if match: new_polarity = match.group(1) - # log.info("Polarity CHANGE, LPC = %s, poly_buff = %s" % (self.is_lpc, poly_buffer)) + # self.app.log.info("Polarity CHANGE, LPC = %s, poly_buff = %s" % (self.is_lpc, poly_buffer)) self.is_lpc = True if new_polarity == 'C' else False try: path_length = len(path) @@ -708,7 +708,7 @@ class Gerber(Geometry): self.apertures[current_aperture]['geometry'].append(deepcopy(geo_dict)) except IndexError: - log.warning("Line %d: %s -> Nothing there to flash!" % (line_num, gline)) + self.app.log.warning("Line %d: %s -> Nothing there to flash!" % (line_num, gline)) continue @@ -1101,14 +1101,14 @@ class Gerber(Geometry): try: geo_s = Polygon(path) except ValueError: - log.warning("Problem %s %s" % (gline, line_num)) + self.app.log.warning("Problem %s %s" % (gline, line_num)) self.app.inform.emit('[ERROR] %s: %s' % (_("Region does not have enough points. " "File will be processed but there are parser errors. " "Line number"), str(line_num))) else: if last_path_aperture is None: - log.warning("No aperture defined for curent path. (%d)" % line_num) + self.app.log.warning("No aperture defined for curent path. (%d)" % line_num) width = self.apertures[last_path_aperture]["size"] # TODO: WARNING this should fail! geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle / 4)) @@ -1300,13 +1300,13 @@ class Gerber(Geometry): j = 0 if quadrant_mode is None: - log.error("Found arc without preceding quadrant specification G74 or G75. (%d)" % line_num) - log.error(gline) + self.app.log.error("Found arc without preceding quadrant specification G74 or G75. (%d)" % line_num) + self.app.log.error(gline) continue if mode is None and current_interpolation_mode not in [2, 3]: - log.error("Found arc without circular interpolation mode defined. (%d)" % line_num) - log.error(gline) + self.app.log.error("Found arc without circular interpolation mode defined. (%d)" % line_num) + self.app.log.error(gline) continue elif mode is not None: current_interpolation_mode = int(mode) @@ -1317,7 +1317,7 @@ class Gerber(Geometry): # Nothing created! Pen Up. if current_operation_code == 2: - log.warning("Arc with D2. (%d)" % line_num) + self.app.log.warning("Arc with D2. (%d)" % line_num) try: path_length = len(path) except TypeError: @@ -1327,7 +1327,7 @@ class Gerber(Geometry): geo_dict = {} if last_path_aperture is None: - log.warning("No aperture defined for curent path. (%d)" % line_num) + self.app.log.warning("No aperture defined for curent path. (%d)" % line_num) # --- BUFFERED --- width = self.apertures[last_path_aperture]["size"] @@ -1409,7 +1409,7 @@ class Gerber(Geometry): ] valid = False - self.app.log.debug("I: %f J: %f" % (i, j)) + self.app.self.app.log.debug("I: %f J: %f" % (i, j)) for center in center_candidates: radius = np.sqrt(i ** 2 + j ** 2) @@ -1527,13 +1527,13 @@ class Gerber(Geometry): try: if buff_length == 0 and sol_geo_length in [0, 1] and self.solid_geometry.area == 0: - log.error("Object is not Gerber file or empty. Aborting Object creation.") + self.app.log.error("Object is not Gerber file or empty. Aborting Object creation.") return 'fail' except TypeError as e: - log.error("Object is not Gerber file or empty. Aborting Object creation. %s" % str(e)) + self.app.log.error("Object is not Gerber file or empty. Aborting Object creation. %s" % str(e)) return 'fail' - log.warning("Joining %d polygons." % buff_length) + self.app.log.warning("Joining %d polygons." % buff_length) self.app.inform.emit('%s: %d.' % (_("Gerber processing. Joining polygons"), buff_length)) if self.use_buffer_for_union: @@ -1543,13 +1543,13 @@ class Gerber(Geometry): if self.app.defaults["gerber_buffering"] == 'full': new_poly = new_poly.buffer(0.00000001) new_poly = new_poly.buffer(-0.00000001) - log.warning("Union(buffer) done.") + self.app.log.warning("Union(buffer) done.") else: self.app.log.debug("Union by union()...") new_poly = unary_union(poly_buffer) new_poly = new_poly.buffer(0, int(self.steps_per_circle / 4)) - log.warning("Union done.") + self.app.log.warning("Union done.") if current_polarity == 'D': self.app.inform.emit('%s' % _("Gerber processing. Applying Gerber polarity.")) @@ -1610,7 +1610,7 @@ class Gerber(Geometry): traceback.print_tb(tb) # print traceback.format_exc() - log.error("Gerber PARSING FAILED. Line %d: %s" % (line_num, gline)) + self.app.log.error("Gerber PARSING FAILED. Line %d: %s" % (line_num, gline)) loc = '%s #%d %s: %s\n' % (_("Gerber Line"), line_num, _("Gerber Line Content"), gline) + repr(err) self.app.inform.emit('[ERROR] %s\n%s:' % @@ -1619,7 +1619,7 @@ class Gerber(Geometry): @staticmethod def create_flash_geometry(location, aperture, steps_per_circle=None): - # log.debug('Flashing @%s, Aperture: %s' % (location, aperture)) + # self.app.log.debug('Flashing @%s, Aperture: %s' % (location, aperture)) if type(location) == list: location = Point(location) diff --git a/app_Main.py b/app_Main.py index d7bad8fe..9d7e3462 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2584,12 +2584,13 @@ class App(QtCore.QObject): self.should_we_save = True - def editor2object(self, cleanup=None): + def editor2object(self, cleanup=None, force_cancel=None): """ Transfers the Geometry or Excellon from it's editor to the current object. - :param cleanup: if True then we closed the app when the editor was open so we close first the editor - :return: None + :param cleanup: if True then we closed the app when the editor was open so we close first the editor + :param force_cancel: if True always add Cancel button + :return: None """ self.defaults.report_usage("editor2object()") @@ -2611,7 +2612,10 @@ class App(QtCore.QObject): bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole) - bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole) + if edited_obj.kind in ["geometry", "gerber", "excellon"] or force_cancel is not None: + bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole) + else: + bt_cancel = None msgbox.setDefaultButton(bt_yes) msgbox.exec()