diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d1c3acd..690bc9b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM Evo beta ================================================= +25.04.2022 + +- deleted the Calibration Plugin (made redundant by changes in other Plugins) +- some strings were updated + 24.04.2022 - some fixes in the Import Image Plugin diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 298bcc24..95fb90e6 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -3142,7 +3142,6 @@ class MainGUI(QtWidgets.QMainWindow): # Extract Drills Tool if key == QtCore.Qt.Key.Key_E: - # self.app.cal_exc_tool.run(toggle=True) self.app.extract_tool.run(toggle=True) return diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index b9814d56..5d554e00 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -685,15 +685,6 @@ class PreferencesUIManager(QtCore.QObject): "tools_fiducials_type": self.ui.plugin2_pref_form.tools2_fiducials_group.fid_type_combo, "tools_fiducials_line_thickness": self.ui.plugin2_pref_form.tools2_fiducials_group.line_thickness_entry, - # Calibration Tool - "tools_cal_calsource": self.ui.plugin2_pref_form.tools2_cal_group.cal_source_radio, - "tools_cal_travelz": self.ui.plugin2_pref_form.tools2_cal_group.travelz_entry, - "tools_cal_verz": self.ui.plugin2_pref_form.tools2_cal_group.verz_entry, - "tools_cal_zeroz": self.ui.plugin2_pref_form.tools2_cal_group.zeroz_cb, - "tools_cal_toolchangez": self.ui.plugin2_pref_form.tools2_cal_group.toolchangez_entry, - "tools_cal_toolchange_xy": self.ui.plugin2_pref_form.tools2_cal_group.toolchange_xy_entry, - "tools_cal_sec_point": self.ui.plugin2_pref_form.tools2_cal_group.second_point_radio, - # Extract Drills Tool "tools_extract_hole_type": self.ui.plugin2_pref_form.tools2_edrills_group.method_radio, "tools_extract_hole_fixed_dia": self.ui.plugin2_pref_form.tools2_edrills_group.dia_entry, diff --git a/appGUI/preferences/tools/Plugins2PreferencesUI.py b/appGUI/preferences/tools/Plugins2PreferencesUI.py index 4a701976..dad3c937 100644 --- a/appGUI/preferences/tools/Plugins2PreferencesUI.py +++ b/appGUI/preferences/tools/Plugins2PreferencesUI.py @@ -3,7 +3,6 @@ from PyQt6 import QtWidgets from appGUI.preferences.tools.Tools2InvertPrefGroupUI import Tools2InvertPrefGroupUI from appGUI.preferences.tools.Tools2PunchGerberPrefGroupUI import Tools2PunchGerberPrefGroupUI from appGUI.preferences.tools.Tools2ExtractPrefGroupUI import Tools2EDrillsPrefGroupUI -from appGUI.preferences.tools.Tools2CalPrefGroupUI import Tools2CalPrefGroupUI from appGUI.preferences.tools.Tools2FiducialsPrefGroupUI import Tools2FiducialsPrefGroupUI from appGUI.preferences.tools.Tools2CThievingPrefGroupUI import Tools2CThievingPrefGroupUI from appGUI.preferences.tools.Tools2QRCodePrefGroupUI import Tools2QRCodePrefGroupUI @@ -20,9 +19,10 @@ fcTranslate.apply_language('strings') if '_' not in builtins.__dict__: _ = gettext.gettext + class Plugins2PreferencesUI(QtWidgets.QWidget): - def __init__(self,app, parent=None): + def __init__(self, app, parent=None): QtWidgets.QWidget.__init__(self, parent=parent) if app.defaults['global_gui_layout'] == 0: self.layout = QtWidgets.QHBoxLayout() @@ -45,9 +45,6 @@ class Plugins2PreferencesUI(QtWidgets.QWidget): self.tools2_fiducials_group = Tools2FiducialsPrefGroupUI(app=app) self.tools2_fiducials_group.setMinimumWidth(250) - self.tools2_cal_group = Tools2CalPrefGroupUI(app=app) - self.tools2_cal_group.setMinimumWidth(250) - self.tools2_edrills_group = Tools2EDrillsPrefGroupUI(app=app) self.tools2_edrills_group.setMinimumWidth(250) @@ -69,7 +66,6 @@ class Plugins2PreferencesUI(QtWidgets.QWidget): self.vlay2.addWidget(self.tools2_cfill_group) self.vlay3 = QtWidgets.QVBoxLayout() - self.vlay3.addWidget(self.tools2_cal_group) self.vlay3.addWidget(self.tools2_edrills_group) self.vlay4 = QtWidgets.QVBoxLayout() diff --git a/appGUI/preferences/tools/Tools2CalPrefGroupUI.py b/appGUI/preferences/tools/Tools2CalPrefGroupUI.py deleted file mode 100644 index 44b2b769..00000000 --- a/appGUI/preferences/tools/Tools2CalPrefGroupUI.py +++ /dev/null @@ -1,151 +0,0 @@ -from PyQt6 import QtWidgets - -from appGUI.GUIElements import RadioSet, FCDoubleSpinner, FCCheckBox, NumericalEvalTupleEntry, FCLabel, \ - GLay, FCFrame -from appGUI.preferences.OptionsGroupUI import OptionsGroupUI - -import gettext -import appTranslation as fcTranslate -import builtins - -fcTranslate.apply_language('strings') -if '_' not in builtins.__dict__: - _ = gettext.gettext - - -class Tools2CalPrefGroupUI(OptionsGroupUI): - def __init__(self, app, parent=None): - - super(Tools2CalPrefGroupUI, self).__init__(self, parent=parent) - - self.setTitle(str(_("Calibration Plugin"))) - self.decimals = app.decimals - self.options = app.options - - # ############################################################################################################# - # Parameters Frame - # ############################################################################################################# - self.param_label = FCLabel('%s' % _("Parameters"), color='blue', bold=True) - self.param_label.setToolTip( - _("Parameters used for this tool.") - ) - - par_frame = FCFrame() - self.layout.addWidget(par_frame) - - param_grid = GLay(v_spacing=5, h_spacing=3) - par_frame.setLayout(param_grid) - - param_grid.addWidget(self.param_label, 0, 0, 1, 2) - - # Calibration source - self.cal_source_lbl = FCLabel("%s:" % _("Source Type")) - self.cal_source_lbl.setToolTip(_("The source of calibration points.\n" - "It can be:\n" - "- Object -> click a hole geo for Excellon or a pad for Gerber\n" - "- Free -> click freely on canvas to acquire the calibration points")) - self.cal_source_radio = RadioSet([{'label': _('Object'), 'value': 'object'}, - {'label': _('Free'), 'value': 'free'}], - compact=True) - - param_grid.addWidget(self.cal_source_lbl, 2, 0) - param_grid.addWidget(self.cal_source_radio, 2, 1, 1, 2) - - separator_line = QtWidgets.QFrame() - separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine) - separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - param_grid.addWidget(separator_line, 4, 0, 1, 2) - - # Travel Z entry - travelz_lbl = FCLabel('%s:' % _("Travel Z")) - travelz_lbl.setToolTip( - _("Height (Z) for travelling between the points.") - ) - - self.travelz_entry = FCDoubleSpinner() - self.travelz_entry.set_range(-10000.0000, 10000.0000) - self.travelz_entry.set_precision(self.decimals) - self.travelz_entry.setSingleStep(0.1) - - param_grid.addWidget(travelz_lbl, 6, 0) - param_grid.addWidget(self.travelz_entry, 6, 1, 1, 2) - - # Verification Z entry - verz_lbl = FCLabel('%s:' % _("Verification Z")) - verz_lbl.setToolTip( - _("Height (Z) for checking the point.") - ) - - self.verz_entry = FCDoubleSpinner() - self.verz_entry.set_range(-10000.0000, 10000.0000) - self.verz_entry.set_precision(self.decimals) - self.verz_entry.setSingleStep(0.1) - - param_grid.addWidget(verz_lbl, 8, 0) - param_grid.addWidget(self.verz_entry, 8, 1, 1, 2) - - # Zero the Z of the verification tool - self.zeroz_cb = FCCheckBox('%s' % _("Zero Z tool")) - self.zeroz_cb.setToolTip( - _("Include a sequence to zero the height (Z)\n" - "of the verification tool.") - ) - - param_grid.addWidget(self.zeroz_cb, 10, 0, 1, 3) - - # Second point choice - second_point_lbl = FCLabel('%s:' % _("Second point")) - second_point_lbl.setToolTip( - _("Second point in the Gcode verification can be:\n" - "- top-left -> the user will align the PCB vertically\n" - "- bottom-right -> the user will align the PCB horizontally") - ) - self.second_point_radio = RadioSet([{'label': _('Top Left'), 'value': 'tl'}, - {'label': _('Bottom Right'), 'value': 'br'}], - orientation='vertical') - - param_grid.addWidget(second_point_lbl, 16, 0) - param_grid.addWidget(self.second_point_radio, 16, 1, 1, 2) - - # ############################################################################################################# - # Tool change Frame - # ############################################################################################################# - tc_lbl = FCLabel('%s' % _("Tool change"), color='brown', bold=True) - self.layout.addWidget(tc_lbl) - - tc_frame = FCFrame() - self.layout.addWidget(tc_frame) - - tc_grid = GLay(v_spacing=5, h_spacing=3) - tc_frame.setLayout(tc_grid) - - # Toolchange X-Y entry - toolchangexy_lbl = FCLabel('%s:' % "X-Y") - toolchangexy_lbl.setToolTip( - _("Toolchange X,Y position.\n" - "If no value is entered then the current\n" - "(x, y) point will be used,") - ) - - self.toolchange_xy_entry = NumericalEvalTupleEntry(border_color='#0069A9') - - tc_grid.addWidget(toolchangexy_lbl, 0, 0) - tc_grid.addWidget(self.toolchange_xy_entry, 0, 1) - - # Toochange Z entry - toolchangez_lbl = FCLabel('%s:' % "Z") - toolchangez_lbl.setToolTip( - _("Height (Z) for mounting the verification probe.") - ) - - self.toolchangez_entry = FCDoubleSpinner() - self.toolchangez_entry.set_range(0.0000, 10000.0000) - self.toolchangez_entry.set_precision(self.decimals) - self.toolchangez_entry.setSingleStep(0.1) - - tc_grid.addWidget(toolchangez_lbl, 2, 0) - tc_grid.addWidget(self.toolchangez_entry, 2, 1) - - GLay.set_common_column_size([param_grid, tc_grid], 0) - - self.layout.addStretch() diff --git a/appMain.py b/appMain.py index c7a3f800..bf90d7c1 100644 --- a/appMain.py +++ b/appMain.py @@ -1253,7 +1253,6 @@ class App(QtCore.QObject): self.pdf_tool = None self.image_tool = None self.pcb_wizard_tool = None - self.cal_exc_tool = None self.qrcode_tool = None self.copper_thieving_tool = None self.fiducial_tool = None @@ -1913,12 +1912,6 @@ class App(QtCore.QObject): self.dblsidedtool = DblSidedTool(self) self.dblsidedtool.install(icon=QtGui.QIcon(self.resource_location + '/doubleside16.png'), separator=False) - self.cal_exc_tool = ToolCalibration(self) - self.cal_exc_tool.install(icon=QtGui.QIcon(self.resource_location + '/calibrate_16.png'), - pos=self.ui.menu_plugins, - before=self.dblsidedtool.menuAction, - separator=False) - self.align_objects_tool = AlignObjects(self) self.align_objects_tool.install(icon=QtGui.QIcon(self.resource_location + '/align16.png'), separator=False) @@ -2063,7 +2056,6 @@ class App(QtCore.QObject): self.pdf_tool, self.image_tool, self.pcb_wizard_tool, - self.cal_exc_tool, self.qrcode_tool, self.copper_thieving_tool, self.fiducial_tool, @@ -2342,7 +2334,6 @@ class App(QtCore.QObject): self.ui.punch_btn.triggered.connect(lambda: self.punch_tool.run(toggle=True)) self.ui.calculators_btn.triggered.connect(lambda: self.calculator_tool.run(toggle=True)) - # self.ui.cal_btn.triggered.connect(lambda: self.cal_exc_tool.run(toggle=True)) # # self.ui.solder_btn.triggered.connect(lambda: self.paste_tool.run(toggle=True)) # self.ui.rules_btn.triggered.connect(lambda: self.rules_tool.run(toggle=True)) @@ -4902,9 +4893,6 @@ class App(QtCore.QObject): # Fiducials Plugin "tools_fiducials_dia", "tools_fiducials_margin", "tools_fiducials_line_thickness", - # Calibration Plugin - "tools_cal_travelz", "tools_cal_verz", "tools_cal_toolchangez", "tools_cal_toolchange_xy", - # Drills Extraction Plugin "tools_extract_hole_fixed_dia", "tools_extract_circular_ring", "tools_extract_oblong_ring", "tools_extract_square_ring", "tools_extract_rectangular_ring", "tools_extract_others_ring", diff --git a/appPlugins/ToolCalibration.py b/appPlugins/ToolCalibration.py deleted file mode 100644 index a897b58d..00000000 --- a/appPlugins/ToolCalibration.py +++ /dev/null @@ -1,1416 +0,0 @@ -# ########################################################## -# FlatCAM: 2D Post-processing for Manufacturing # -# File Author: Marius Adrian Stanciu (c) # -# Date: 3/10/2019 # -# MIT Licence # -# ########################################################## - -from appTool import * -from appEditors.AppTextEditor import AppTextEditor - -fcTranslate.apply_language('strings') -if '_' not in builtins.__dict__: - _ = gettext.gettext - -log = logging.getLogger('base') - - -class ToolCalibration(AppTool): - - def __init__(self, app): - AppTool.__init__(self, app) - - self.app = app - self.canvas = self.app.plotcanvas - - self.decimals = self.app.decimals - - # ############################################################################# - # ######################### Tool GUI ########################################## - # ############################################################################# - self.ui = CalibrationUI(layout=self.layout, app=self.app) - self.pluginName = self.ui.pluginName - self.connect_signals_at_init() - - self.mr = None - self.units = '' - - # here store 4 points to be used for calibration - self.click_points = [[], [], [], []] - - # store the status of the grid - self.grid_status_memory = None - - self.target_obj = None - - # if the mouse events are connected to a local method set this True - self.local_connected = False - - # reference for the tab where to open and view the verification GCode - self.gcode_editor_tab = None - - # calibrated object - self.cal_object = None - - def run(self, toggle=True): - self.app.defaults.report_usage("ToolCalibration()") - - if toggle: - # if the splitter is hidden, display it - if self.app.ui.splitter.sizes()[0] == 0: - self.app.ui.splitter.setSizes([1, 1]) - - # if the Tool Tab is hidden display it, else hide it but only if the objectName is the same - found_idx = None - for idx in range(self.app.ui.notebook.count()): - if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab": - found_idx = idx - break - # show the Tab - if not found_idx: - try: - self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin")) - except RuntimeError: - self.app.ui.plugin_tab = QtWidgets.QWidget() - self.app.ui.plugin_tab.setObjectName("plugin_tab") - self.app.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.app.ui.plugin_tab) - self.app.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2) - - self.app.ui.plugin_scroll_area = VerticalScrollArea() - self.app.ui.plugin_tab_layout.addWidget(self.app.ui.plugin_scroll_area) - self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin")) - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab) - - try: - if self.app.ui.plugin_scroll_area.widget().objectName() == self.pluginName and found_idx: - # if the Tool Tab is not focused, focus on it - if not self.app.ui.notebook.currentWidget() is self.app.ui.plugin_tab: - # focus on Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab) - else: - # else remove the Tool Tab - self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) - self.app.ui.notebook.removeTab(2) - - # if there are no objects loaded in the app then hide the Notebook widget - if not self.app.collection.get_list(): - self.app.ui.splitter.setSizes([0, 1]) - except AttributeError: - pass - else: - if self.app.ui.splitter.sizes()[0] == 0: - self.app.ui.splitter.setSizes([1, 1]) - - AppTool.run(self) - - self.set_tool_ui() - - self.app.ui.notebook.setTabText(2, _("Calibration")) - - def install(self, icon=None, separator=None, **kwargs): - AppTool.install(self, icon, separator, shortcut='Alt+E', **kwargs) - - def connect_signals_at_init(self): - # ## Signals - self.ui.cal_source_radio.activated_custom.connect(self.on_cal_source_radio) - self.ui.obj_type_combo.currentIndexChanged.connect(self.on_obj_type_combo) - self.ui.adj_object_type_combo.currentIndexChanged.connect(self.on_adj_obj_type_combo) - - self.ui.start_button.clicked.connect(self.on_start_collect_points) - - self.ui.gcode_button.clicked.connect(self.generate_verification_gcode) - self.ui.adj_gcode_button.clicked.connect(self.generate_verification_gcode) - - self.ui.generate_factors_button.clicked.connect(self.calculate_factors) - - self.ui.scale_button.clicked.connect(self.on_scale_button) - self.ui.skew_button.clicked.connect(self.on_skew_button) - - self.ui.cal_button.clicked.connect(self.on_cal_button_click) - self.ui.reset_button.clicked.connect(self.set_tool_ui) - - def set_tool_ui(self): - self.units = self.app.app_units.upper() - - self.clear_ui(self.layout) - self.ui = CalibrationUI(layout=self.layout, app=self.app) - self.pluginName = self.ui.pluginName - self.connect_signals_at_init() - - if self.local_connected is True: - self.disconnect_cal_events() - - self.ui.bottom_left_coordx_found.set_value(_("Origin")) - self.ui.bottom_left_coordy_found.set_value(_("Origin")) - - self.reset_calibration_points() - - self.ui.cal_source_radio.set_value(self.app.options['tools_cal_calsource']) - self.ui.travelz_entry.set_value(self.app.options['tools_cal_travelz']) - self.ui.verz_entry.set_value(self.app.options['tools_cal_verz']) - self.ui.zeroz_cb.set_value(self.app.options['tools_cal_zeroz']) - self.ui.toolchangez_entry.set_value(self.app.options['tools_cal_toolchangez']) - self.ui.toolchange_xy_entry.set_value(self.app.options['tools_cal_toolchange_xy']) - - self.ui.second_point_radio.set_value(self.app.options['tools_cal_sec_point']) - - self.ui.scalex_entry.set_value(1.0) - self.ui.scaley_entry.set_value(1.0) - self.ui.skewx_entry.set_value(0.0) - self.ui.skewy_entry.set_value(0.0) - - # default object selection is Excellon = index_1 - self.ui.obj_type_combo.setCurrentIndex(1) - self.on_obj_type_combo() - - self.ui.adj_object_type_combo.setCurrentIndex(0) - self.on_adj_obj_type_combo() - # self.adj_object_combo.setCurrentIndex(0) - - # calibrated object - self.cal_object = None - - self.app.inform.emit('%s...' % _("Tool initialized")) - - def on_obj_type_combo(self): - obj_type = self.ui.obj_type_combo.currentIndex() - self.ui.object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) - # self.object_combo.setCurrentIndex(0) - self.ui.object_combo.obj_type = { - _("Gerber"): "Gerber", _("Excellon"): "Excellon" - }[self.ui.obj_type_combo.get_value()] - - def on_adj_obj_type_combo(self): - obj_type = self.ui.adj_object_type_combo.currentIndex() - self.ui.adj_object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) - # self.adj_object_combo.setCurrentIndex(0) - self.ui.adj_object_combo.obj_type = { - _("Gerber"): "Gerber", _("Excellon"): "Excellon", _("Geometry"): "Geometry" - }[self.ui.adj_object_type_combo.get_value()] - - def on_cal_source_radio(self, val): - if val == 'object': - self.ui.obj_type_label.setDisabled(False) - self.ui.obj_type_combo.setDisabled(False) - self.ui.object_label.setDisabled(False) - self.ui.object_combo.setDisabled(False) - else: - self.ui.obj_type_label.setDisabled(True) - self.ui.obj_type_combo.setDisabled(True) - self.ui.object_label.setDisabled(True) - self.ui.object_combo.setDisabled(True) - - def on_start_collect_points(self): - - if self.ui.cal_source_radio.get_value() == 'object': - selection_index = self.ui.object_combo.currentIndex() - model_index = self.app.collection.index(selection_index, 0, self.ui.object_combo.rootModelIndex()) - try: - self.target_obj = model_index.internalPointer().obj - except AttributeError: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no source FlatCAM object selected...")) - return - - # disengage the grid snapping since it will be hard to find the drills on grid - if self.app.ui.grid_snap_btn.isChecked(): - self.grid_status_memory = True - self.app.ui.grid_snap_btn.trigger() - else: - self.grid_status_memory = False - - self.mr = self.canvas.graph_event_connect('mouse_release', self.on_mouse_click_release) - - if self.app.use_3d_engine: - self.canvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot) - else: - self.canvas.graph_event_disconnect(self.app.mr) - - self.local_connected = True - - self.reset_calibration_points() - - self.app.inform.emit(_("Get First calibration point. Bottom Left...")) - - def on_mouse_click_release(self, event): - if self.app.use_3d_engine: - event_pos = event.pos - right_button = 2 - self.app.event_is_dragging = self.app.event_is_dragging - else: - event_pos = (event.xdata, event.ydata) - right_button = 3 - self.app.event_is_dragging = self.app.ui.popMenu.mouse_is_panning - - pos_canvas = self.canvas.translate_coords(event_pos) - - if event.button == 1: - click_pt = Point([pos_canvas[0], pos_canvas[1]]) - - if self.app.selection_type is not None: - # delete previous selection shape - self.app.delete_selection_shape() - self.app.selection_type = None - else: - if self.ui.cal_source_radio.get_value() == 'object': - if self.target_obj.kind.lower() == 'excellon': - for tool, tool_dict in self.target_obj.tools.items(): - for geo in tool_dict['solid_geometry']: - if click_pt.within(geo): - center_pt = geo.centroid - self.click_points.append( - [ - float('%.*f' % (self.decimals, center_pt.x)), - float('%.*f' % (self.decimals, center_pt.y)) - ] - ) - self.check_points() - else: - for apid, apid_val in self.target_obj.tools.items(): - for geo_el in apid_val['geometry']: - if 'solid' in geo_el: - if click_pt.within(geo_el['solid']): - if isinstance(geo_el['follow'], Point): - center_pt = geo_el['solid'].centroid - self.click_points.append( - [ - float('%.*f' % (self.decimals, center_pt.x)), - float('%.*f' % (self.decimals, center_pt.y)) - ] - ) - self.check_points() - else: - self.click_points.append( - [ - float('%.*f' % (self.decimals, click_pt.x)), - float('%.*f' % (self.decimals, click_pt.y)) - ] - ) - self.check_points() - elif event.button == right_button and self.app.event_is_dragging is False: - if len(self.click_points) != 4: - self.reset_calibration_points() - self.disconnect_cal_events() - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled by user request.")) - - def check_points(self): - if len(self.click_points) == 1: - self.ui.bottom_left_coordx_tgt.set_value(self.click_points[0][0]) - self.ui.bottom_left_coordy_tgt.set_value(self.click_points[0][1]) - self.app.inform.emit(_("Get Second calibration point. Bottom Right (Top Left)...")) - elif len(self.click_points) == 2: - self.ui.bottom_right_coordx_tgt.set_value(self.click_points[1][0]) - self.ui.bottom_right_coordy_tgt.set_value(self.click_points[1][1]) - self.app.inform.emit(_("Get Third calibration point. Top Left (Bottom Right)...")) - elif len(self.click_points) == 3: - self.ui.top_left_coordx_tgt.set_value(self.click_points[2][0]) - self.ui.top_left_coordy_tgt.set_value(self.click_points[2][1]) - self.app.inform.emit(_("Get Forth calibration point. Top Right...")) - elif len(self.click_points) == 4: - self.ui.top_right_coordx_tgt.set_value(self.click_points[3][0]) - self.ui.top_right_coordy_tgt.set_value(self.click_points[3][1]) - self.app.inform.emit('[success] %s' % _("Done.")) - self.disconnect_cal_events() - - def reset_calibration_points(self): - self.click_points = [] - - self.ui.bottom_left_coordx_tgt.set_value('') - self.ui.bottom_left_coordy_tgt.set_value('') - - self.ui.bottom_right_coordx_tgt.set_value('') - self.ui.bottom_right_coordy_tgt.set_value('') - - self.ui.top_left_coordx_tgt.set_value('') - self.ui.top_left_coordy_tgt.set_value('') - - self.ui.top_right_coordx_tgt.set_value('') - self.ui.top_right_coordy_tgt.set_value('') - - self.ui.bottom_right_coordx_found.set_value('') - self.ui.bottom_right_coordy_found.set_value('') - - self.ui.top_left_coordx_found.set_value('') - self.ui.top_left_coordy_found.set_value('') - - def gcode_header(self): - self.app.log.debug("ToolCalibration.gcode_header()") - time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now()) - - gcode = '(G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s)\n' % \ - (str(self.app.version), str(self.app.version_date)) + '\n' - - gcode += '(Name: ' + _('Verification GCode for FlatCAM Calibration Tool') + ')\n' - - gcode += '(Units: ' + self.units.upper() + ')\n\n' - gcode += '(Created on ' + time_str + ')\n\n' - gcode += 'G20\n' if self.units.upper() == 'IN' else 'G21\n' - gcode += 'G90\n' - gcode += 'G17\n' - gcode += 'G94\n\n' - return gcode - - def close_tab(self): - for idx in range(self.app.ui.plot_tab_area.count()): - if self.app.ui.plot_tab_area.tabText(idx) == _("Gcode Viewer"): - wdg = self.app.ui.plot_tab_area.widget(idx) - wdg.deleteLater() - self.app.ui.plot_tab_area.removeTab(idx) - - def generate_verification_gcode(self): - sec_point = self.ui.second_point_radio.get_value() - - travel_z = '%.*f' % (self.decimals, self.ui.travelz_entry.get_value()) - toolchange_z = '%.*f' % (self.decimals, self.ui.toolchangez_entry.get_value()) - toolchange_xy_temp = self.ui.toolchange_xy_entry.get_value().split(",") - toolchange_xy = [float(eval(a)) for a in toolchange_xy_temp if a != ''] - - verification_z = '%.*f' % (self.decimals, self.ui.verz_entry.get_value()) - - if len(self.click_points) != 4: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Four points are needed for GCode generation.")) - return 'fail' - - gcode = self.gcode_header() - if self.ui.zeroz_cb.get_value(): - gcode += 'M5\n' - gcode += 'G00 Z%s\n' % toolchange_z - if toolchange_xy: - gcode += 'G00 X%s Y%s\n' % (toolchange_xy[0], toolchange_xy[1]) - gcode += 'M0\n' - gcode += 'G01 Z0\n' - gcode += 'M0\n' - gcode += 'G00 Z%s\n' % toolchange_z - gcode += 'M0\n' - - # first point: bottom - left -> ORIGIN set - gcode += 'G00 Z%s\n' % travel_z - gcode += 'G00 X%s Y%s\n' % (self.click_points[0][0], self.click_points[0][1]) - gcode += 'G01 Z%s\n' % verification_z - gcode += 'M0\n' - - if sec_point == 'tl': - # second point: top - left -> align the PCB to this point - gcode += 'G00 Z%s\n' % travel_z - gcode += 'G00 X%s Y%s\n' % (self.click_points[2][0], self.click_points[2][1]) - gcode += 'G01 Z%s\n' % verification_z - gcode += 'M0\n' - - # third point: bottom - right -> check for scale on X axis or for skew on Y axis - gcode += 'G00 Z%s\n' % travel_z - gcode += 'G00 X%s Y%s\n' % (self.click_points[1][0], self.click_points[1][1]) - gcode += 'G01 Z%s\n' % verification_z - gcode += 'M0\n' - - # forth point: top - right -> verification point - gcode += 'G00 Z%s\n' % travel_z - gcode += 'G00 X%s Y%s\n' % (self.click_points[3][0], self.click_points[3][1]) - gcode += 'G01 Z%s\n' % verification_z - gcode += 'M0\n' - else: - # second point: bottom - right -> align the PCB to this point - gcode += 'G00 Z%s\n' % travel_z - gcode += 'G00 X%s Y%s\n' % (self.click_points[1][0], self.click_points[1][1]) - gcode += 'G01 Z%s\n' % verification_z - gcode += 'M0\n' - - # third point: top - left -> check for scale on Y axis or for skew on X axis - gcode += 'G00 Z%s\n' % travel_z - gcode += 'G00 X%s Y%s\n' % (self.click_points[2][0], self.click_points[2][1]) - gcode += 'G01 Z%s\n' % verification_z - gcode += 'M0\n' - - # forth point: top - right -> verification point - gcode += 'G00 Z%s\n' % travel_z - gcode += 'G00 X%s Y%s\n' % (self.click_points[3][0], self.click_points[3][1]) - gcode += 'G01 Z%s\n' % verification_z - gcode += 'M0\n' - - # return to (toolchange_xy[0], toolchange_xy[1], toolchange_z) point for toolchange event - gcode += 'G00 Z%s\n' % travel_z - gcode += 'G00 X0 Y0\n' - gcode += 'G00 Z%s\n' % toolchange_z - if toolchange_xy: - gcode += 'G00 X%s Y%s\n' % (toolchange_xy[0], toolchange_xy[1]) - - gcode += 'M2' - - self.gcode_editor_tab = AppTextEditor(app=self.app, plain_text=True) - - # add the tab if it was closed - self.app.ui.plot_tab_area.addTab(self.gcode_editor_tab, '%s' % _("Gcode Viewer")) - self.gcode_editor_tab.setObjectName('gcode_viewer_tab') - - # delete the absolute and relative position and messages in the infobar - self.app.ui.position_label.setText("") - self.app.ui.rel_position_label.setText("") - - self.gcode_editor_tab.code_editor.completer_enable = False - self.gcode_editor_tab.buttonRun.hide() - - # Switch plot_area to CNCJob tab - self.app.ui.plot_tab_area.setCurrentWidget(self.gcode_editor_tab) - - self.gcode_editor_tab.t_frame.hide() - # then append the text from GCode to the text editor - try: - self.gcode_editor_tab.load_text(gcode, move_to_start=True, clear_text=True) - except Exception as e: - self.app.inform.emit('[ERROR] %s %s' % ('ERROR -->', str(e))) - return - - self.gcode_editor_tab.t_frame.show() - self.app.proc_container.view.set_idle() - - self.app.inform.emit('[success] %s...' % _('Loaded Machine Code into Code Editor')) - - _filter_ = "G-Code Files (*.nc);;All Files (*.*)" - self.gcode_editor_tab.buttonSave.clicked.disconnect() - self.gcode_editor_tab.buttonSave.clicked.connect( - lambda: self.gcode_editor_tab.handleSaveGCode(name='fc_ver_gcode', filt=_filter_, callback=self.close_tab)) - - def calculate_factors(self): - origin_x = self.click_points[0][0] - origin_y = self.click_points[0][1] - - top_left_x = self.click_points[2][0] - top_left_y = self.click_points[2][1] - - bot_right_x = self.click_points[1][0] - bot_right_y = self.click_points[1][1] - - try: - top_left_dx = float(self.ui.top_left_coordx_found.get_value()) - except TypeError: - top_left_dx = top_left_x - - try: - top_left_dy = float(self.ui.top_left_coordy_found.get_value()) - except TypeError: - top_left_dy = top_left_y - - try: - bot_right_dx = float(self.ui.bottom_right_coordx_found.get_value()) - except TypeError: - bot_right_dx = bot_right_x - - try: - bot_right_dy = float(self.ui.bottom_right_coordy_found.get_value()) - except TypeError: - bot_right_dy = bot_right_y - - # ------------------------------------------------------------------------------- # - # --------------------------- FACTORS CALCULUS ---------------------------------- # - # ------------------------------------------------------------------------------- # - if bot_right_dx != float('%.*f' % (self.decimals, bot_right_x)): - # we have scale on X - scale_x = (bot_right_dx / (bot_right_x - origin_x)) + 1 - self.ui.scalex_entry.set_value(scale_x) - - if top_left_dy != float('%.*f' % (self.decimals, top_left_y)): - # we have scale on Y - scale_y = (top_left_dy / (top_left_y - origin_y)) + 1 - self.ui.scaley_entry.set_value(scale_y) - - if top_left_dx != float('%.*f' % (self.decimals, top_left_x)): - # we have skew on X - dx = top_left_dx - dy = top_left_y - origin_y - skew_angle_x = math.degrees(math.atan(dx / dy)) - self.ui.skewx_entry.set_value(skew_angle_x) - - if bot_right_dy != float('%.*f' % (self.decimals, bot_right_y)): - # we have skew on Y - dx = bot_right_x - origin_x - dy = bot_right_dy + origin_y - skew_angle_y = math.degrees(math.atan(dy / dx)) - self.ui.skewy_entry.set_value(skew_angle_y) - - @property - def target_values_in_table(self): - self.click_points[0][0] = self.ui.bottom_left_coordx_tgt.get_value() - self.click_points[0][1] = self.ui.bottom_left_coordy_tgt.get_value() - - self.click_points[1][0] = self.ui.bottom_right_coordx_tgt.get_value() - self.click_points[1][1] = self.ui.bottom_right_coordy_tgt.get_value() - - self.click_points[2][0] = self.ui.top_left_coordx_tgt.get_value() - self.click_points[2][1] = self.ui.top_left_coordy_tgt.get_value() - - self.click_points[3][0] = self.ui.top_right_coordx_tgt.get_value() - self.click_points[3][1] = self.ui.top_right_coordy_tgt.get_value() - - return self.click_points - - @target_values_in_table.setter - def target_values_in_table(self, param): - bl_pt, br_pt, tl_pt, tr_pt = param - - self.click_points[0] = [bl_pt[0], bl_pt[1]] - self.click_points[1] = [br_pt[0], br_pt[1]] - self.click_points[2] = [tl_pt[0], tl_pt[1]] - self.click_points[3] = [tr_pt[0], tr_pt[1]] - - self.ui.bottom_left_coordx_tgt.set_value(float('%.*f' % (self.decimals, bl_pt[0]))) - self.ui.bottom_left_coordy_tgt.set_value(float('%.*f' % (self.decimals, bl_pt[1]))) - - self.ui.bottom_right_coordx_tgt.set_value(float('%.*f' % (self.decimals, br_pt[0]))) - self.ui.bottom_right_coordy_tgt.set_value(float('%.*f' % (self.decimals, br_pt[1]))) - - self.ui.top_left_coordx_tgt.set_value(float('%.*f' % (self.decimals, tl_pt[0]))) - self.ui.top_left_coordy_tgt.set_value(float('%.*f' % (self.decimals, tl_pt[1]))) - - self.ui.top_right_coordx_tgt.set_value(float('%.*f' % (self.decimals, tr_pt[0]))) - self.ui.top_right_coordy_tgt.set_value(float('%.*f' % (self.decimals, tr_pt[1]))) - - def on_scale_button(self): - scalex_fact = self.ui.scalex_entry.get_value() - scaley_fact = self.ui.scaley_entry.get_value() - bl, br, tl, tr = self.target_values_in_table - - bl_geo = Point(bl[0], bl[1]) - br_geo = Point(br[0], br[1]) - tl_geo = Point(tl[0], tl[1]) - tr_geo = Point(tr[0], tr[1]) - - bl_scaled = scale(bl_geo, xfact=scalex_fact, yfact=scaley_fact, origin=(bl[0], bl[1])) - br_scaled = scale(br_geo, xfact=scalex_fact, yfact=scaley_fact, origin=(bl[0], bl[1])) - tl_scaled = scale(tl_geo, xfact=scalex_fact, yfact=scaley_fact, origin=(bl[0], bl[1])) - tr_scaled = scale(tr_geo, xfact=scalex_fact, yfact=scaley_fact, origin=(bl[0], bl[1])) - - scaled_values = [ - [bl_scaled.x, bl_scaled.y], - [br_scaled.x, br_scaled.y], - [tl_scaled.x, tl_scaled.y], - [tr_scaled.x, tr_scaled.y] - ] - self.target_values_in_table = scaled_values - - def on_skew_button(self): - skewx_angle = self.ui.skewx_entry.get_value() - skewy_angle = self.ui.skewy_entry.get_value() - bl, br, tl, tr = self.target_values_in_table - - bl_geo = Point(bl[0], bl[1]) - br_geo = Point(br[0], br[1]) - tl_geo = Point(tl[0], tl[1]) - tr_geo = Point(tr[0], tr[1]) - - bl_skewed = skew(bl_geo, xs=skewx_angle, ys=skewy_angle, origin=(bl[0], bl[1])) - br_skewed = skew(br_geo, xs=skewx_angle, ys=skewy_angle, origin=(bl[0], bl[1])) - tl_skewed = skew(tl_geo, xs=skewx_angle, ys=skewy_angle, origin=(bl[0], bl[1])) - tr_skewed = skew(tr_geo, xs=skewx_angle, ys=skewy_angle, origin=(bl[0], bl[1])) - - skewed_values = [ - [bl_skewed.x, bl_skewed.y], - [br_skewed.x, br_skewed.y], - [tl_skewed.x, tl_skewed.y], - [tr_skewed.x, tr_skewed.y] - ] - self.target_values_in_table = skewed_values - - def on_cal_button_click(self): - # get the FlatCAM object to calibrate - selection_index = self.ui.adj_object_combo.currentIndex() - model_index = self.app.collection.index(selection_index, 0, self.ui.adj_object_combo.rootModelIndex()) - - try: - self.cal_object = model_index.internalPointer().obj - except Exception as e: - self.app.log.error("ToolCalibration.on_cal_button_click() --> %s" % str(e)) - self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) - return - - obj_name = self.cal_object.obj_options["name"] + "_calibrated" - - self.app.worker_task.emit({'fcn': self.new_calibrated_object, 'params': [obj_name]}) - - def new_calibrated_object(self, obj_name): - - try: - origin_x = self.click_points[0][0] - origin_y = self.click_points[0][1] - except IndexError as e: - self.app.log.debug("ToolCalibration.new_calibrated_object() --> %s" % str(e)) - return 'fail' - - scalex = self.ui.scalex_entry.get_value() - scaley = self.ui.scaley_entry.get_value() - - skewx = self.ui.skewx_entry.get_value() - skewy = self.ui.skewy_entry.get_value() - - # create a new object adjusted (calibrated) - def initialize_geometry(obj_init, app): - obj_init.solid_geometry = deepcopy(obj.solid_geometry) - try: - obj_init.follow_geometry = deepcopy(obj.follow_geometry) - except AttributeError: - pass - - try: - obj_init.tools = deepcopy(obj.tools) - except AttributeError: - pass - - try: - if obj.tools: - obj_init.tools = deepcopy(obj.tools) - except Exception as ee: - app.log.error("ToolCalibration.new_calibrated_object.initialize_geometry() --> %s" % str(ee)) - - obj_init.scale(xfactor=scalex, yfactor=scaley, point=(origin_x, origin_y)) - obj_init.skew(angle_x=skewx, angle_y=skewy, point=(origin_x, origin_y)) - - try: - obj_init.source_file = deepcopy(obj.source_file) - except (AttributeError, TypeError): - pass - - def initialize_gerber(obj_init, app_obj): - obj_init.solid_geometry = deepcopy(obj.solid_geometry) - try: - obj_init.follow_geometry = deepcopy(obj.follow_geometry) - except AttributeError: - pass - - try: - obj_init.tools = deepcopy(obj.tools) - except AttributeError: - pass - - try: - if obj.tools: - obj_init.tools = deepcopy(obj.tools) - except Exception as err: - self.app.log.error("ToolCalibration.new_calibrated_object.initialize_gerber() --> %s" % str(err)) - - obj_init.scale(xfactor=scalex, yfactor=scaley, point=(origin_x, origin_y)) - obj_init.skew(angle_x=skewx, angle_y=skewy, point=(origin_x, origin_y)) - - try: - obj_init.source_file = app_obj.f_handlers.export_gerber(obj_name=obj_name, filename=None, - local_use=obj_init, use_thread=False) - except (AttributeError, TypeError): - pass - - def initialize_excellon(obj_init, app_obj): - obj_init.tools = deepcopy(obj.tools) - - obj_init.scale(xfactor=scalex, yfactor=scaley, point=(origin_x, origin_y)) - obj_init.skew(angle_x=skewx, angle_y=skewy, point=(origin_x, origin_y)) - - obj_init.create_geometry() - - obj_init.source_file = app_obj.f_handlers.export_excellon(obj_name=obj_name, local_use=obj, filename=None, - use_thread=False) - - obj = self.cal_object - obj_name = obj_name - - if obj is None: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) - self.app.log.debug("ToolCalibration.new_calibrated_object() --> No object to calibrate") - return 'fail' - - try: - if obj.kind.lower() == 'excellon': - self.app.app_obj.new_object("excellon", str(obj_name), initialize_excellon) - elif obj.kind.lower() == 'gerber': - self.app.app_obj.new_object("gerber", str(obj_name), initialize_gerber) - elif obj.kind.lower() == 'geometry': - self.app.app_obj.new_object("geometry", str(obj_name), initialize_geometry) - except Exception as e: - self.app.log.error("ToolCalibration.new_calibrated_object() --> %s" % str(e)) - return "Operation failed: %s" % str(e) - - def disconnect_cal_events(self): - # restore the Grid snapping if it was active before - if self.grid_status_memory is True: - self.app.ui.grid_snap_btn.trigger() - - self.app.mr = self.canvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot) - - if self.app.use_3d_engine: - self.canvas.graph_event_disconnect('mouse_release', self.on_mouse_click_release) - else: - self.canvas.graph_event_disconnect(self.mr) - - self.local_connected = False - - def reset_fields(self): - self.ui.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) - self.ui.adj_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) - - -class CalibrationUI: - - pluginName = _("Calibration") - - def __init__(self, layout, app): - self.app = app - self.decimals = self.app.decimals - self.layout = layout - - # ## Title - title_label = FCLabel("%s" % self.pluginName) - title_label.setStyleSheet(""" - QLabel - { - font-size: 16px; - font-weight: bold; - } - """) - self.layout.addWidget(title_label) - - # ## Grid Layout - grid_lay = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 1, 0]) - self.layout.addLayout(grid_lay) - - self.gcode_title_label = FCLabel('%s:' % _('Parameters'), bold=True) - self.gcode_title_label.setToolTip( - _("Parameters used when creating the GCode in this tool.") - ) - grid_lay.addWidget(self.gcode_title_label, 0, 0, 1, 3) - - # Travel Z entry - travelz_lbl = FCLabel('%s:' % _("Travel Z")) - travelz_lbl.setToolTip( - _("Height (Z) for travelling between the points.") - ) - - self.travelz_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.travelz_entry.set_range(-10000.0000, 10000.0000) - self.travelz_entry.set_precision(self.decimals) - self.travelz_entry.setSingleStep(0.1) - - grid_lay.addWidget(travelz_lbl, 1, 0) - grid_lay.addWidget(self.travelz_entry, 1, 1, 1, 2) - - # Verification Z entry - verz_lbl = FCLabel('%s:' % _("Verification Z")) - verz_lbl.setToolTip( - _("Height (Z) for checking the point.") - ) - - self.verz_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.verz_entry.set_range(-10000.0000, 10000.0000) - self.verz_entry.set_precision(self.decimals) - self.verz_entry.setSingleStep(0.1) - - grid_lay.addWidget(verz_lbl, 2, 0) - grid_lay.addWidget(self.verz_entry, 2, 1, 1, 2) - - # Zero the Z of the verification tool - self.zeroz_cb = FCCheckBox('%s' % _("Zero Z tool")) - self.zeroz_cb.setToolTip( - _("Include a sequence to zero the height (Z)\n" - "of the verification tool.") - ) - - grid_lay.addWidget(self.zeroz_cb, 3, 0, 1, 3) - - # Toolchange Z entry - toolchangez_lbl = FCLabel('%s:' % _("Toolchange Z")) - toolchangez_lbl.setToolTip( - _("Height (Z) for mounting the verification probe.") - ) - - self.toolchangez_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.toolchangez_entry.set_range(0.0000, 10000.0000) - self.toolchangez_entry.set_precision(self.decimals) - self.toolchangez_entry.setSingleStep(0.1) - - grid_lay.addWidget(toolchangez_lbl, 4, 0) - grid_lay.addWidget(self.toolchangez_entry, 4, 1, 1, 2) - - # Toolchange X-Y entry - toolchangexy_lbl = FCLabel('%s:' % _('Toolchange X-Y')) - toolchangexy_lbl.setToolTip( - _("Toolchange X,Y position.\n" - "If no value is entered then the current\n" - "(x, y) point will be used,") - ) - - self.toolchange_xy_entry = FCEntry() - - grid_lay.addWidget(toolchangexy_lbl, 5, 0) - grid_lay.addWidget(self.toolchange_xy_entry, 5, 1, 1, 2) - - self.z_ois = OptionalInputSection( - self.zeroz_cb, - [ - toolchangez_lbl, - self.toolchangez_entry, - toolchangexy_lbl, - self.toolchange_xy_entry - ] - ) - - separator_line1 = QtWidgets.QFrame() - separator_line1.setFrameShape(QtWidgets.QFrame.Shape.HLine) - separator_line1.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - grid_lay.addWidget(separator_line1, 6, 0, 1, 3) - - # Second point choice - second_point_lbl = FCLabel('%s:' % _("Second point")) - second_point_lbl.setToolTip( - _("Second point in the Gcode verification can be:\n" - "- top-left -> the user will align the PCB vertically\n" - "- bottom-right -> the user will align the PCB horizontally") - ) - self.second_point_radio = RadioSet([{'label': _('Top Left'), 'value': 'tl'}, - {'label': _('Bottom Right'), 'value': 'br'}], - orientation='vertical') - - grid_lay.addWidget(second_point_lbl, 7, 0) - grid_lay.addWidget(self.second_point_radio, 7, 1, 1, 2) - - separator_line1 = QtWidgets.QFrame() - separator_line1.setFrameShape(QtWidgets.QFrame.Shape.HLine) - separator_line1.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - grid_lay.addWidget(separator_line1, 8, 0, 1, 3) - - grid_lay.addWidget(FCLabel(''), 9, 0, 1, 3) - - step_1 = FCLabel('%s' % _("STEP 1: Acquire Calibration Points"), bold=True) - step_1.setToolTip( - _("Pick four points by clicking on canvas.\n" - "Those four points should be in the four\n" - "(as much as possible) corners of the object.") - ) - grid_lay.addWidget(step_1, 10, 0, 1, 3) - - self.cal_source_lbl = FCLabel('%s:' % _("Source Type"), bold=True) - self.cal_source_lbl.setToolTip(_("The source of calibration points.\n" - "It can be:\n" - "- Object -> click a hole geo for Excellon or a pad for Gerber\n" - "- Free -> click freely on canvas to acquire the calibration points")) - self.cal_source_radio = RadioSet([{'label': _('Object'), 'value': 'object'}, - {'label': _('Free'), 'value': 'free'}], - compact=True) - - grid_lay.addWidget(self.cal_source_lbl, 11, 0) - grid_lay.addWidget(self.cal_source_radio, 11, 1, 1, 2) - - self.obj_type_label = FCLabel("%s:" % _("Object Type")) - - self.obj_type_combo = FCComboBox() - self.obj_type_combo.addItem(_("Gerber")) - self.obj_type_combo.addItem(_("Excellon")) - - self.obj_type_combo.setItemIcon(0, QtGui.QIcon(self.app.resource_location + "/flatcam_icon16.png")) - self.obj_type_combo.setItemIcon(1, QtGui.QIcon(self.app.resource_location + "/drill16.png")) - - grid_lay.addWidget(self.obj_type_label, 12, 0) - grid_lay.addWidget(self.obj_type_combo, 12, 1, 1, 2) - - self.object_combo = FCComboBox() - self.object_combo.setModel(self.app.collection) - self.object_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex())) - self.object_combo.is_last = True - - self.object_label = FCLabel("%s:" % _("Source object selection")) - self.object_label.setToolTip( - _("FlatCAM Object to be used as a source for reference points.") - ) - - grid_lay.addWidget(self.object_label, 13, 0, 1, 3) - grid_lay.addWidget(self.object_combo, 14, 0, 1, 3) - - self.points_table_label = FCLabel('%s' % _('Calibration Points'), bold=True) - self.points_table_label.setToolTip( - _("Contain the expected calibration points and the\n" - "ones measured.") - ) - grid_lay.addWidget(self.points_table_label, 15, 0, 1, 3) - - self.points_table = FCTable() - self.points_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) - # self.points_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents) - grid_lay.addWidget(self.points_table, 16, 0, 1, 3) - - self.points_table.setColumnCount(4) - self.points_table.setHorizontalHeaderLabels( - [ - '#', - _("Name"), - _("Target"), - _("Found Delta") - ] - ) - self.points_table.setRowCount(8) - row = 0 - - # BOTTOM LEFT - id_item_1 = QtWidgets.QTableWidgetItem('%d' % 1) - flags = QtCore.Qt.ItemFlag.ItemIsEnabled - id_item_1.setFlags(flags) - self.points_table.setItem(row, 0, id_item_1) # Tool name/id - - self.bottom_left_coordx_lbl = FCLabel('%s' % _('Bot Left X')) - self.points_table.setCellWidget(row, 1, self.bottom_left_coordx_lbl) - self.bottom_left_coordx_tgt = EvalEntry() - self.points_table.setCellWidget(row, 2, self.bottom_left_coordx_tgt) - self.bottom_left_coordx_tgt.setReadOnly(True) - self.bottom_left_coordx_found = EvalEntry() - self.points_table.setCellWidget(row, 3, self.bottom_left_coordx_found) - row += 1 - - self.bottom_left_coordy_lbl = FCLabel('%s' % _('Bot Left Y')) - self.points_table.setCellWidget(row, 1, self.bottom_left_coordy_lbl) - self.bottom_left_coordy_tgt = EvalEntry() - self.points_table.setCellWidget(row, 2, self.bottom_left_coordy_tgt) - self.bottom_left_coordy_tgt.setReadOnly(True) - self.bottom_left_coordy_found = EvalEntry() - self.points_table.setCellWidget(row, 3, self.bottom_left_coordy_found) - - self.bottom_left_coordx_found.setDisabled(True) - self.bottom_left_coordy_found.setDisabled(True) - row += 1 - - # BOTTOM RIGHT - id_item_2 = QtWidgets.QTableWidgetItem('%d' % 2) - flags = QtCore.Qt.ItemFlag.ItemIsEnabled - id_item_2.setFlags(flags) - self.points_table.setItem(row, 0, id_item_2) # Tool name/id - - self.bottom_right_coordx_lbl = FCLabel('%s' % _('Bot Right X')) - self.points_table.setCellWidget(row, 1, self.bottom_right_coordx_lbl) - self.bottom_right_coordx_tgt = EvalEntry() - self.points_table.setCellWidget(row, 2, self.bottom_right_coordx_tgt) - self.bottom_right_coordx_tgt.setReadOnly(True) - self.bottom_right_coordx_found = EvalEntry() - self.points_table.setCellWidget(row, 3, self.bottom_right_coordx_found) - - row += 1 - - self.bottom_right_coordy_lbl = FCLabel('%s' % _('Bot Right Y')) - self.points_table.setCellWidget(row, 1, self.bottom_right_coordy_lbl) - self.bottom_right_coordy_tgt = EvalEntry() - self.points_table.setCellWidget(row, 2, self.bottom_right_coordy_tgt) - self.bottom_right_coordy_tgt.setReadOnly(True) - self.bottom_right_coordy_found = EvalEntry() - self.points_table.setCellWidget(row, 3, self.bottom_right_coordy_found) - row += 1 - - # TOP LEFT - id_item_3 = QtWidgets.QTableWidgetItem('%d' % 3) - flags = QtCore.Qt.ItemFlag.ItemIsEnabled - id_item_3.setFlags(flags) - self.points_table.setItem(row, 0, id_item_3) # Tool name/id - - self.top_left_coordx_lbl = FCLabel('%s' % _('Top Left X')) - self.points_table.setCellWidget(row, 1, self.top_left_coordx_lbl) - self.top_left_coordx_tgt = EvalEntry() - self.points_table.setCellWidget(row, 2, self.top_left_coordx_tgt) - self.top_left_coordx_tgt.setReadOnly(True) - self.top_left_coordx_found = EvalEntry() - self.points_table.setCellWidget(row, 3, self.top_left_coordx_found) - row += 1 - - self.top_left_coordy_lbl = FCLabel('%s' % _('Top Left Y')) - self.points_table.setCellWidget(row, 1, self.top_left_coordy_lbl) - self.top_left_coordy_tgt = EvalEntry() - self.points_table.setCellWidget(row, 2, self.top_left_coordy_tgt) - self.top_left_coordy_tgt.setReadOnly(True) - self.top_left_coordy_found = EvalEntry() - self.points_table.setCellWidget(row, 3, self.top_left_coordy_found) - row += 1 - - # TOP RIGHT - id_item_4 = QtWidgets.QTableWidgetItem('%d' % 4) - flags = QtCore.Qt.ItemFlag.ItemIsEnabled - id_item_4.setFlags(flags) - self.points_table.setItem(row, 0, id_item_4) # Tool name/id - - self.top_right_coordx_lbl = FCLabel('%s' % _('Top Right X')) - self.points_table.setCellWidget(row, 1, self.top_right_coordx_lbl) - self.top_right_coordx_tgt = EvalEntry() - self.points_table.setCellWidget(row, 2, self.top_right_coordx_tgt) - self.top_right_coordx_tgt.setReadOnly(True) - self.top_right_coordx_found = EvalEntry() - self.top_right_coordx_found.setDisabled(True) - self.points_table.setCellWidget(row, 3, self.top_right_coordx_found) - row += 1 - - self.top_right_coordy_lbl = FCLabel('%s' % _('Top Right Y')) - self.points_table.setCellWidget(row, 1, self.top_right_coordy_lbl) - self.top_right_coordy_tgt = EvalEntry() - self.points_table.setCellWidget(row, 2, self.top_right_coordy_tgt) - self.top_right_coordy_tgt.setReadOnly(True) - self.top_right_coordy_found = EvalEntry() - self.top_right_coordy_found.setDisabled(True) - self.points_table.setCellWidget(row, 3, self.top_right_coordy_found) - - vertical_header = self.points_table.verticalHeader() - vertical_header.hide() - self.points_table.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff) - - horizontal_header = self.points_table.horizontalHeader() - horizontal_header.setMinimumSectionSize(10) - horizontal_header.setDefaultSectionSize(70) - - self.points_table.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents) - # for x in range(4): - # self.points_table.resizeColumnToContents(x) - self.points_table.resizeColumnsToContents() - self.points_table.resizeRowsToContents() - - horizontal_header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeMode.Fixed) - horizontal_header.resizeSection(0, 20) - horizontal_header.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeMode.Fixed) - horizontal_header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeMode.Stretch) - horizontal_header.setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeMode.Stretch) - - self.points_table.setMinimumHeight(self.points_table.getHeight() + 2) - self.points_table.setMaximumHeight(self.points_table.getHeight() + 3) - - # ## Get Points Button - self.start_button = QtWidgets.QPushButton(_("Get Points")) - self.start_button.setToolTip( - _("Pick four points by clicking on canvas if the source choice\n" - "is 'free' or inside the object geometry if the source is 'object'.\n" - "Those four points should be in the four squares of\n" - "the object.") - ) - self.start_button.setStyleSheet(""" - QPushButton - { - font-weight: bold; - } - """) - grid_lay.addWidget(self.start_button, 17, 0, 1, 3) - - separator_line = QtWidgets.QFrame() - separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine) - separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - grid_lay.addWidget(separator_line, 18, 0, 1, 3) - - grid_lay.addWidget(FCLabel(''), 19, 0) - - # STEP 2 # - step_2 = FCLabel('%s' % _("STEP 2: Verification GCode"), bold=True) - step_2.setToolTip( - _("Generate GCode file to locate and align the PCB by using\n" - "the four points acquired above.\n" - "The points sequence is:\n" - "- first point -> set the origin\n" - "- second point -> alignment point. Can be: top-left or bottom-right.\n" - "- third point -> check point. Can be: top-left or bottom-right.\n" - "- forth point -> final verification point. Just for evaluation.") - ) - grid_lay.addWidget(step_2, 20, 0, 1, 3) - - # ## GCode Button - self.gcode_button = QtWidgets.QPushButton(_("Generate GCode")) - self.gcode_button.setToolTip( - _("Generate GCode file to locate and align the PCB by using\n" - "the four points acquired above.\n" - "The points sequence is:\n" - "- first point -> set the origin\n" - "- second point -> alignment point. Can be: top-left or bottom-right.\n" - "- third point -> check point. Can be: top-left or bottom-right.\n" - "- forth point -> final verification point. Just for evaluation.") - ) - self.gcode_button.setStyleSheet(""" - QPushButton - { - font-weight: bold; - } - """) - grid_lay.addWidget(self.gcode_button, 21, 0, 1, 3) - - separator_line1 = QtWidgets.QFrame() - separator_line1.setFrameShape(QtWidgets.QFrame.Shape.HLine) - separator_line1.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - grid_lay.addWidget(separator_line1, 22, 0, 1, 3) - - grid_lay.addWidget(FCLabel(''), 23, 0, 1, 3) - - # STEP 3 # - step_3 = FCLabel('%s' % _("STEP 3: Adjustments"), bold=True) - step_3.setToolTip( - _("Calculate Scale and Skew factors based on the differences (delta)\n" - "found when checking the PCB pattern. The differences must be filled\n" - "in the fields Found (Delta).") - ) - grid_lay.addWidget(step_3, 24, 0, 1, 3) - - # ## Factors Button - self.generate_factors_button = QtWidgets.QPushButton(_("Calculate Factors")) - self.generate_factors_button.setToolTip( - _("Calculate Scale and Skew factors based on the differences (delta)\n" - "found when checking the PCB pattern. The differences must be filled\n" - "in the fields Found (Delta).") - ) - self.generate_factors_button.setStyleSheet(""" - QPushButton - { - font-weight: bold; - } - """) - grid_lay.addWidget(self.generate_factors_button, 25, 0, 1, 3) - - separator_line1 = QtWidgets.QFrame() - separator_line1.setFrameShape(QtWidgets.QFrame.Shape.HLine) - separator_line1.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - grid_lay.addWidget(separator_line1, 26, 0, 1, 3) - - grid_lay.addWidget(FCLabel(''), 27, 0, 1, 3) - - # STEP 4 # - step_4 = FCLabel('%s' % _("STEP 4: Adjusted GCode"), bold=True) - step_4.setToolTip( - _("Generate verification GCode file adjusted with\n" - "the factors above.") - ) - grid_lay.addWidget(step_4, 28, 0, 1, 3) - - self.scalex_label = FCLabel(_("Scale Factor X:")) - self.scalex_label.setToolTip( - _("Factor for Scale action over X axis.") - ) - self.scalex_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.scalex_entry.set_range(0, 10000.0000) - self.scalex_entry.set_precision(self.decimals) - self.scalex_entry.setSingleStep(0.1) - - grid_lay.addWidget(self.scalex_label, 29, 0) - grid_lay.addWidget(self.scalex_entry, 29, 1, 1, 2) - - self.scaley_label = FCLabel(_("Scale Factor Y:")) - self.scaley_label.setToolTip( - _("Factor for Scale action over Y axis.") - ) - self.scaley_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.scaley_entry.set_range(0, 10000.0000) - self.scaley_entry.set_precision(self.decimals) - self.scaley_entry.setSingleStep(0.1) - - grid_lay.addWidget(self.scaley_label, 30, 0) - grid_lay.addWidget(self.scaley_entry, 30, 1, 1, 2) - - self.scale_button = QtWidgets.QPushButton(_("Apply Scale Factors")) - self.scale_button.setToolTip( - _("Apply Scale factors on the calibration points.") - ) - self.scale_button.setStyleSheet(""" - QPushButton - { - font-weight: bold; - } - """) - grid_lay.addWidget(self.scale_button, 31, 0, 1, 3) - - self.skewx_label = FCLabel(_("Skew Angle X:")) - self.skewx_label.setToolTip( - _("Angle, in degrees.\n" - "Float number between -360 and 359.") - ) - self.skewx_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.skewx_entry.set_range(-360, 360) - self.skewx_entry.set_precision(self.decimals) - self.skewx_entry.setSingleStep(0.1) - - grid_lay.addWidget(self.skewx_label, 32, 0) - grid_lay.addWidget(self.skewx_entry, 32, 1, 1, 2) - - self.skewy_label = FCLabel(_("Skew Angle Y:")) - self.skewy_label.setToolTip( - _("Angle, in degrees.\n" - "Float number between -360 and 359.") - ) - self.skewy_entry = FCDoubleSpinner(callback=self.confirmation_message) - self.skewy_entry.set_range(-360, 360) - self.skewy_entry.set_precision(self.decimals) - self.skewy_entry.setSingleStep(0.1) - - grid_lay.addWidget(self.skewy_label, 33, 0) - grid_lay.addWidget(self.skewy_entry, 33, 1, 1, 2) - - self.skew_button = QtWidgets.QPushButton(_("Apply Skew Factors")) - self.skew_button.setToolTip( - _("Apply Skew factors on the calibration points.") - ) - self.skew_button.setStyleSheet(""" - QPushButton - { - font-weight: bold; - } - """) - grid_lay.addWidget(self.skew_button, 34, 0, 1, 3) - - # final_factors_lbl = FCLabel('%s' % _("Final Factors"), bold=True) - # final_factors_lbl.setToolTip( - # _("Generate verification GCode file adjusted with\n" - # "the factors above.") - # ) - # grid_lay.addWidget(final_factors_lbl, 27, 0, 1, 3) - # - # self.fin_scalex_label = FCLabel(_("Scale Factor X:")) - # self.fin_scalex_label.setToolTip( - # _("Final factor for Scale action over X axis.") - # ) - # self.fin_scalex_entry = FCDoubleSpinner(callback=self.confirmation_message) - # self.fin_scalex_entry.set_range(0, 10000.0000) - # self.fin_scalex_entry.set_precision(self.decimals) - # self.fin_scalex_entry.setSingleStep(0.1) - # - # grid_lay.addWidget(self.fin_scalex_label, 28, 0) - # grid_lay.addWidget(self.fin_scalex_entry, 28, 1, 1, 2) - # - # self.fin_scaley_label = FCLabel(_("Scale Factor Y:")) - # self.fin_scaley_label.setToolTip( - # _("Final factor for Scale action over Y axis.") - # ) - # self.fin_scaley_entry = FCDoubleSpinner(callback=self.confirmation_message) - # self.fin_scaley_entry.set_range(0, 10000.0000) - # self.fin_scaley_entry.set_precision(self.decimals) - # self.fin_scaley_entry.setSingleStep(0.1) - # - # grid_lay.addWidget(self.fin_scaley_label, 29, 0) - # grid_lay.addWidget(self.fin_scaley_entry, 29, 1, 1, 2) - # - # self.fin_skewx_label = FCLabel(_("Skew Angle X:")) - # self.fin_skewx_label.setToolTip( - # _("Final value for angle for Skew action, in degrees.\n" - # "Float number between -360 and 359.") - # ) - # self.fin_skewx_entry = FCDoubleSpinner(callback=self.confirmation_message) - # self.fin_skewx_entry.set_range(-360, 360) - # self.fin_skewx_entry.set_precision(self.decimals) - # self.fin_skewx_entry.setSingleStep(0.1) - # - # grid_lay.addWidget(self.fin_skewx_label, 30, 0) - # grid_lay.addWidget(self.fin_skewx_entry, 30, 1, 1, 2) - # - # self.fin_skewy_label = FCLabel(_("Skew Angle Y:")) - # self.fin_skewy_label.setToolTip( - # _("Final value for angle for Skew action, in degrees.\n" - # "Float number between -360 and 359.") - # ) - # self.fin_skewy_entry = FCDoubleSpinner(callback=self.confirmation_message) - # self.fin_skewy_entry.set_range(-360, 360) - # self.fin_skewy_entry.set_precision(self.decimals) - # self.fin_skewy_entry.setSingleStep(0.1) - # - # grid_lay.addWidget(self.fin_skewy_label, 31, 0) - # grid_lay.addWidget(self.fin_skewy_entry, 31, 1, 1, 2) - - # ## Adjusted GCode Button - - self.adj_gcode_button = QtWidgets.QPushButton(_("Generate Adjusted GCode")) - self.adj_gcode_button.setToolTip( - _("Generate verification GCode file adjusted with\n" - "the factors set above.\n" - "The GCode parameters can be readjusted\n" - "before clicking this button.") - ) - self.adj_gcode_button.setStyleSheet(""" - QPushButton - { - font-weight: bold; - } - """) - grid_lay.addWidget(self.adj_gcode_button, 42, 0, 1, 3) - - separator_line1 = QtWidgets.QFrame() - separator_line1.setFrameShape(QtWidgets.QFrame.Shape.HLine) - separator_line1.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - grid_lay.addWidget(separator_line1, 43, 0, 1, 3) - - grid_lay.addWidget(FCLabel(''), 44, 0, 1, 3) - - # STEP 5 # - step_5 = FCLabel('%s' % _("STEP 5: Calibrate FlatCAM Objects"), bold=True) - step_5.setToolTip( - _("Adjust the FlatCAM objects\n" - "with the factors determined and verified above.") - ) - grid_lay.addWidget(step_5, 45, 0, 1, 3) - - self.adj_object_type_combo = FCComboBox() - self.adj_object_type_combo.addItems([_("Gerber"), _("Excellon"), _("Geometry")]) - - self.adj_object_type_combo.setItemIcon(0, QtGui.QIcon(self.app.resource_location + "/flatcam_icon16.png")) - self.adj_object_type_combo.setItemIcon(1, QtGui.QIcon(self.app.resource_location + "/drill16.png")) - self.adj_object_type_combo.setItemIcon(2, QtGui.QIcon(self.app.resource_location + "/geometry16.png")) - - self.adj_object_type_label = FCLabel("%s:" % _("Adjusted object type")) - self.adj_object_type_label.setToolTip(_("Type of the Application Object to be adjusted.")) - - grid_lay.addWidget(self.adj_object_type_label, 46, 0, 1, 3) - grid_lay.addWidget(self.adj_object_type_combo, 47, 0, 1, 3) - - self.adj_object_combo = FCComboBox() - self.adj_object_combo.setModel(self.app.collection) - self.adj_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) - self.adj_object_combo.is_last = True - self.adj_object_combo.obj_type = { - _("Gerber"): "Gerber", _("Excellon"): "Excellon", _("Geometry"): "Geometry" - }[self.adj_object_type_combo.get_value()] - - self.adj_object_label = FCLabel("%s:" % _("Adjusted object selection")) - self.adj_object_label.setToolTip( - _("The Application Object to be adjusted.") - ) - - grid_lay.addWidget(self.adj_object_label, 48, 0, 1, 3) - grid_lay.addWidget(self.adj_object_combo, 49, 0, 1, 3) - - # ## Adjust Objects Button - self.cal_button = QtWidgets.QPushButton(_("Calibrate")) - self.cal_button.setToolTip( - _("Adjust (scale and/or skew) the objects\n" - "with the factors determined above.") - ) - self.cal_button.setStyleSheet(""" - QPushButton - { - font-weight: bold; - } - """) - grid_lay.addWidget(self.cal_button, 50, 0, 1, 3) - - separator_line2 = QtWidgets.QFrame() - separator_line2.setFrameShape(QtWidgets.QFrame.Shape.HLine) - separator_line2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - grid_lay.addWidget(separator_line2, 51, 0, 1, 3) - - grid_lay.addWidget(FCLabel(''), 52, 0, 1, 3) - - self.layout.addStretch() - - # ## Reset Tool - self.reset_button = QtWidgets.QPushButton(_("Reset Tool")) - self.reset_button.setIcon(QtGui.QIcon(self.app.resource_location + '/reset32.png')) - self.reset_button.setToolTip( - _("Will reset the tool parameters.") - ) - self.reset_button.setStyleSheet(""" - QPushButton - { - font-weight: bold; - } - """) - self.layout.addWidget(self.reset_button) - # #################################### FINSIHED GUI ########################### - # ############################################################################# - - def confirmation_message(self, accepted, minval, maxval): - if accepted is False: - self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%.*f, %.*f]' % (_("Edited value is out of range"), - self.decimals, - minval, - self.decimals, - maxval), False) - else: - self.app.inform[str, bool].emit('[success] %s' % _("Edited value is within limits."), False) - - def confirmation_message_int(self, accepted, minval, maxval): - if accepted is False: - self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%d, %d]' % - (_("Edited value is out of range"), minval, maxval), False) - else: - self.app.inform[str, bool].emit('[success] %s' % _("Edited value is within limits."), False) diff --git a/appPlugins/ToolIsolation.py b/appPlugins/ToolIsolation.py index acdc7e0e..a7699059 100644 --- a/appPlugins/ToolIsolation.py +++ b/appPlugins/ToolIsolation.py @@ -1577,7 +1577,7 @@ class ToolIsolation(AppTool, Gerber): except Exception as e: self.app.log.error(str(e)) - self.app.inform.emit('[success] %s' % _("Tool(s) deleted from Tool Table.")) + self.app.inform.emit('[success] %s' % _("Tools deleted from Tool Table.")) self.build_ui() def on_generate_buffer(self): diff --git a/appPlugins/ToolNCC.py b/appPlugins/ToolNCC.py index 66f44520..5b44b417 100644 --- a/appPlugins/ToolNCC.py +++ b/appPlugins/ToolNCC.py @@ -1189,7 +1189,7 @@ class NonCopperClear(AppTool, Gerber): # if new tool diameter already in the Tool List then abort if truncated_tooldia in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) self.blockSignals(False) return @@ -1268,7 +1268,7 @@ class NonCopperClear(AppTool, Gerber): # if new tool diameter found in Tools Database already in the Tool List then abort if updated_tooldia is not None and updated_tooldia in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) self.blockSignals(False) return @@ -1326,7 +1326,7 @@ class NonCopperClear(AppTool, Gerber): truncated_tooldia = self.app.dec_format(tool_dia, self.decimals) if truncated_tooldia in tool_dias: if muted is None: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) # self.ui.tools_table.itemChanged.connect(self.on_tool_edit) self.blockSignals(False) return @@ -1479,7 +1479,7 @@ class NonCopperClear(AppTool, Gerber): except Exception as e: self.app.log.error(str(e)) - self.app.inform.emit('[success] %s' % _("Tool(s) deleted from Tool Table.")) + self.app.inform.emit('[success] %s' % _("Tools deleted from Tool Table.")) self.blockSignals(False) self.build_ui() @@ -3962,7 +3962,7 @@ class NonCopperClear(AppTool, Gerber): truncated_tooldia = self.app.dec_format(tooldia, self.decimals) if truncated_tooldia in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) self.ui_connect() return 'fail' diff --git a/appPlugins/ToolPaint.py b/appPlugins/ToolPaint.py index 03690b15..caf3acbd 100644 --- a/appPlugins/ToolPaint.py +++ b/appPlugins/ToolPaint.py @@ -834,7 +834,7 @@ class ToolPaint(AppTool, Gerber): # if new tool diameter already in the Tool List then abort if truncated_tooldia in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) self.blockSignals(False) return @@ -920,7 +920,7 @@ class ToolPaint(AppTool, Gerber): # if new tool diameter found in Tools Database already in the Tool List then abort if updated_tooldia is not None and updated_tooldia in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) self.blockSignals(False) return @@ -980,7 +980,7 @@ class ToolPaint(AppTool, Gerber): truncated_tooldia = self.app.dec_format(tool_dia, self.decimals) if truncated_tooldia in tool_dias: if muted is None: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) self.blockSignals(False) return @@ -1099,7 +1099,7 @@ class ToolPaint(AppTool, Gerber): except Exception as e: self.app.log.error(str(e)) - self.app.inform.emit('[success] %s' % _("Tool(s) deleted from Tool Table.")) + self.app.inform.emit('[success] %s' % _("Tools deleted from Tool Table.")) self.blockSignals(False) self.build_ui() @@ -2845,7 +2845,7 @@ class ToolPaint(AppTool, Gerber): tool_dias.append(float('%.*f' % (self.decimals, (v[tool_v])))) if float('%.*f' % (self.decimals, tooldia)) in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) self.ui_connect() return 'fail' diff --git a/appPlugins/ToolSolderPaste.py b/appPlugins/ToolSolderPaste.py index 533d18f8..044c2a2b 100644 --- a/appPlugins/ToolSolderPaste.py +++ b/appPlugins/ToolSolderPaste.py @@ -545,8 +545,7 @@ class SolderPaste(AppTool): try: tool_dia = float(self.ui.addtool_entry.get_value().replace(',', '.')) except ValueError: - self.app.inform.emit('[ERROR_NOTCL] %s' % - _("Wrong value format entered, use a number.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number.")) return if tool_dia is None: self.build_ui() @@ -580,12 +579,12 @@ class SolderPaste(AppTool): # if float('%.*f' % (self.decimals, tool_dia)) in tool_dias: if self.app.dec_format(tool_dia, self.decimals) in tool_dias: if muted is None: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Cancelled."), _("Tool already in Tool Table."))) self.ui.tools_table.itemChanged.connect(self.on_tool_edit) return else: if muted is None: - self.app.inform.emit('[success] %s' % _("New Nozzle tool added to Tool Table.")) + self.app.inform.emit('[success] %s' % _("New tool added to Tool Table.")) self.tooltable_tools.update({ int(self.tooluid): { 'tooldia': float('%.*f' % (self.decimals, tool_dia)), @@ -618,8 +617,7 @@ class SolderPaste(AppTool): try: new_tool_dia = float(self.ui.tools_table.item(row, 1).text().replace(',', '.')) except ValueError: - self.app.inform.emit('[ERROR_NOTCL] %s' % - _("Wrong value format entered, use a number.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number.")) return tooluid = int(self.ui.tools_table.item(row, 2).text()) @@ -627,7 +625,7 @@ class SolderPaste(AppTool): # identify the tool that was edited and get it's tooluid if new_tool_dia not in tool_dias: self.tooltable_tools[tooluid]['tooldia'] = new_tool_dia - self.app.inform.emit('[success] %s' % _("Nozzle tool from Tool Table was edited.")) + self.app.inform.emit('[success] %s' % _("Tool from Tool Table was edited.")) self.build_ui() return else: @@ -639,8 +637,7 @@ class SolderPaste(AppTool): break restore_dia_item = self.ui.tools_table.item(row, 1) restore_dia_item.setText(str(old_tool_dia)) - self.app.inform.emit('[WARNING_NOTCL] %s' % - _("Cancelled. New diameter value is already in the Tool Table.")) + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Already in the Tool Table.")) self.build_ui() def on_tool_delete(self, rows_to_delete=None, all_tools=None): @@ -744,7 +741,7 @@ class SolderPaste(AppTool): """ name = self.ui.obj_combo.currentText() if name == '': - self.app.inform.emit('[WARNING_NOTCL] %s' % _("No SolderPaste mask Gerber object loaded.")) + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Selected object cannot be used.")) return obj = self.app.collection.get_by_name(name) @@ -775,7 +772,7 @@ class SolderPaste(AppTool): sorted_tools.sort(reverse=True) if not sorted_tools: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("No Nozzle tools in the tool table.")) + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Tools table is empty.")) return 'fail' def flatten(geometry=None, reset=True, pathonly=False): @@ -968,9 +965,7 @@ class SolderPaste(AppTool): return if obj.special_group != 'solder_paste_tool': - self.app.inform.emit('[WARNING_NOTCL] %s' % - _("This Geometry can't be processed. " - "NOT a solder_paste_tool geometry.")) + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Selected object cannot be used.")) return a = 0 @@ -978,7 +973,7 @@ class SolderPaste(AppTool): if obj.tools[tooluid_key]['solid_geometry'] is None: a += 1 if a == len(obj.tools): - self.app.inform.emit('[ERROR_NOTCL] %s...' % _('Cancelled. Empty file, it has no geometry')) + self.app.inform.emit('[ERROR_NOTCL] %s...' % _('Cancelled.')) return # use the name of the first tool selected in self.geo_tools_table which has the diameter passed as tool_dia @@ -1049,7 +1044,7 @@ class SolderPaste(AppTool): res = new_obj.generate_gcode_from_solderpaste_geo(is_first=is_first, **tooluid_value) if res == 'fail': - app_obj.log.debug("GeometryObject.mtool_gen_cncjob() --> generate_from_geometry2() failed") + app_obj.log.debug("SolderPaste.on_create_gcode() --> generate_gcode_from_solderpaste_geo() failed") return 'fail' else: tool_cnc_dict['gcode'] = res @@ -1079,7 +1074,7 @@ class SolderPaste(AppTool): def job_thread(app_obj): with self.app.proc_container.new('%s...' % _("Working")): if app_obj.app_obj.new_object("cncjob", name, job_init) != 'fail': - app_obj.inform.emit('[success] %s: %s' % (_("ToolSolderPaste CNCjob created"), name)) + app_obj.inform.emit('[success] %s: %s' % (_("CNCjob created"), name)) # Create a promise with the name self.app.collection.promise(name) # Send to worker @@ -1095,6 +1090,20 @@ class SolderPaste(AppTool): """ time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now()) + name = self.ui.cnc_obj_combo.currentText() + obj = self.app.collection.get_by_name(name) + + if not obj: + return + + try: + if obj.special_group != 'solder_paste_tool': + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Selected object cannot be used.")) + return + except AttributeError: + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Selected object cannot be used.")) + return + self.text_editor_tab = AppTextEditor(app=self.app, plain_text=True) # add the tab if it was closed @@ -1104,21 +1113,6 @@ class SolderPaste(AppTool): # Switch plot_area to CNCJob tab self.app.ui.plot_tab_area.setCurrentWidget(self.text_editor_tab) - name = self.ui.cnc_obj_combo.currentText() - obj = self.app.collection.get_by_name(name) - - try: - if obj.special_group != 'solder_paste_tool': - self.app.inform.emit('[WARNING_NOTCL] %s' % - _("This CNCJob object can't be processed. " - "NOT a solder_paste_tool CNCJob object.")) - return - except AttributeError: - self.app.inform.emit('[WARNING_NOTCL] %s' % - _("This CNCJob object can't be processed. " - "NOT a solder_paste_tool CNCJob object.")) - return - gcode = '(G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s)\n' % \ (str(self.app.version), str(self.app.version_date)) + '\n' @@ -1152,7 +1146,7 @@ class SolderPaste(AppTool): self.text_editor_tab.load_text(gcode, move_to_start=True) except Exception as e: self.app.log.error('ToolSolderPaste.on_view_gcode() -->%s' % str(e)) - self.app.inform.emit('[ERROR] %s --> %s' % ('ToolSolderPaste.on_view_gcode()', str(e))) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("Failed.")) return def on_save_gcode(self): @@ -1166,9 +1160,7 @@ class SolderPaste(AppTool): obj = self.app.collection.get_by_name(name) if obj.special_group != 'solder_paste_tool': - self.app.inform.emit('[WARNING_NOTCL] %s' % - _("This CNCJob object can't be processed. " - "NOT a solder_paste_tool CNCJob object.")) + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Selected object cannot be used.")) return _filter_ = "G-Code Files (*.nc);;G-Code Files (*.txt);;G-Code Files (*.tap);;G-Code Files (*.cnc);;" \ @@ -1211,8 +1203,7 @@ class SolderPaste(AppTool): for line in lines: f.write(line) except FileNotFoundError: - self.app.inform.emit('[WARNING_NOTCL] %s' % - _("No such file or directory")) + self.app.inform.emit('[WARNING_NOTCL] %s' % _("No such file or directory")) return except PermissionError: self.app.inform.emit('[WARNING] %s' % @@ -1223,7 +1214,7 @@ class SolderPaste(AppTool): if self.app.options["global_open_style"] is False: self.app.file_opened.emit("gcode", filename) self.app.file_saved.emit("gcode", filename) - self.app.inform.emit('[success] %s: %s' % (_("Solder paste dispenser GCode file saved to"), filename)) + self.app.inform.emit('[success] %s: %s' % (_("Saved to"), filename)) def reset_fields(self): self.ui.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) diff --git a/appPlugins/__init__.py b/appPlugins/__init__.py index a2cb50d0..c03a79cc 100644 --- a/appPlugins/__init__.py +++ b/appPlugins/__init__.py @@ -1,5 +1,4 @@ from appPlugins.ToolCalculators import ToolCalculator -from appPlugins.ToolCalibration import ToolCalibration from appPlugins.ToolDblSided import DblSidedTool from appPlugins.ToolExtract import ToolExtract diff --git a/defaults.py b/defaults.py index 61af3fec..7e58fd47 100644 --- a/defaults.py +++ b/defaults.py @@ -757,15 +757,6 @@ class AppDefaults: "tools_fiducials_line_thickness": 0.25, "tools_fiducials_big_cursor": True, - # Calibration Tool - "tools_cal_calsource": 'object', - "tools_cal_travelz": 2.0, - "tools_cal_verz": 0.1, - "tools_cal_zeroz": False, - "tools_cal_toolchangez": 15, - "tools_cal_toolchange_xy": '', - "tools_cal_sec_point": 'tl', - # Drills Extraction Tool "tools_extract_hole_type": 'fixed', "tools_extract_hole_fixed_dia": 0.5,