Jelajahi Sumber

- added a new parameter in the Tool Film which control the thickness of the stroke width in the resulting SVG. It's a scale parameter.
- whatever was the visibility of the corresponding toolbar when we enter in the Editor, it will be set after exit from the Editor (either Geometry Editor or Excellon Editor).
- added ability to be detached for the tabs in the Notebook section (Project, Selected and Tool)
- added ability for all detachable tabs to be restored to the same position from where they were detached.
- restored the way the tools autoloaded the objects in the comboboxes

Marius Stanciu 7 tahun lalu
induk
melakukan
713b584841

+ 8 - 4
FlatCAMApp.py

@@ -426,7 +426,7 @@ class App(QtCore.QObject):
 
             "tools_film_type": self.tools_defaults_form.tools_film_group.film_type_radio,
             "tools_film_boundary": self.tools_defaults_form.tools_film_group.film_boundary_entry,
-            "tools_film_adjust": self.tools_defaults_form.tools_film_group.film_adjust_entry,
+            "tools_film_scale": self.tools_defaults_form.tools_film_group.film_scale_entry,
 
             "tools_panelize_spacing_columns": self.tools_defaults_form.tools_panelize_group.pspacing_columns,
             "tools_panelize_spacing_rows": self.tools_defaults_form.tools_panelize_group.pspacing_rows,
@@ -607,7 +607,7 @@ class App(QtCore.QObject):
 
             "tools_film_type": 'neg',
             "tools_film_boundary": 1,
-            "tools_film_adjust": 0,
+            "tools_film_scale": 0,
 
             "tools_panelize_spacing_columns": 0,
             "tools_panelize_spacing_rows": 0,
@@ -749,7 +749,7 @@ class App(QtCore.QObject):
 
             "tools_film_type": self.tools_options_form.tools_film_group.film_type_radio,
             "tools_film_boundary": self.tools_options_form.tools_film_group.film_boundary_entry,
-            "tools_film_adjust": self.tools_options_form.tools_film_group.film_adjust_entry,
+            "tools_film_scale": self.tools_options_form.tools_film_group.film_scale_entry,
 
             "tools_panelize_spacing_columns": self.tools_options_form.tools_panelize_group.pspacing_columns,
             "tools_panelize_spacing_rows": self.tools_options_form.tools_panelize_group.pspacing_rows,
@@ -867,7 +867,7 @@ class App(QtCore.QObject):
 
             "tools_film_type": 'neg',
             "tools_film_boundary": 1,
-            "tools_film_adjust": 0,
+            "tools_film_scale": 0,
 
             "tools_panelize_spacing_columns": 0,
             "tools_panelize_spacing_rows": 0,
@@ -1564,11 +1564,15 @@ class App(QtCore.QObject):
                 self.inform.emit("[WARNING_NOTCL]Editing a MultiGeo Geometry is not possible for the moment.")
                 return
 
+            # store the Geometry Editor Toolbar visibility before entering in the Editor
+            self.geo_editor.toolbar_old_state = True if self.ui.geo_edit_toolbar.isVisible() else False
             self.geo_editor.edit_fcgeometry(edited_object)
             # set call source to the Editor we go into
             self.call_source = 'geo_editor'
 
         elif isinstance(edited_object, FlatCAMExcellon):
+            # store the Excellon Editor Toolbar visibility before entering in the Editor
+            self.exc_editor.toolbar_old_state = True if self.ui.exc_edit_toolbar.isVisible() else False
             self.exc_editor.edit_fcexcellon(edited_object)
 
             # set call source to the Editor we go into

+ 21 - 6
FlatCAMEditor.py

@@ -1970,6 +1970,9 @@ class FlatCAMGeoEditor(QtCore.QObject):
         self.move_timer = QtCore.QTimer()
         self.move_timer.setSingleShot(True)
 
+        # this var will store the state of the toolbar before starting the editor
+        self.toolbar_old_state = False
+
         self.key = None  # Currently pressed key
         self.geo_key_modifiers = None
         self.x = None  # Current mouse cursor pos
@@ -2083,24 +2086,29 @@ class FlatCAMGeoEditor(QtCore.QObject):
         if settings.contains("theme"):
             theme = settings.value('theme', type=str)
             if theme == 'standard':
-                self.app.ui.geo_edit_toolbar.setVisible(False)
+                # self.app.ui.geo_edit_toolbar.setVisible(False)
 
                 self.app.ui.snap_max_dist_entry.setEnabled(False)
                 self.app.ui.corner_snap_btn.setEnabled(False)
                 self.app.ui.snap_magnet.setVisible(False)
                 self.app.ui.corner_snap_btn.setVisible(False)
             elif theme == 'compact':
-                self.app.ui.snap_max_dist_entry.setEnabled(False)
+                # self.app.ui.geo_edit_toolbar.setVisible(True)
 
+                self.app.ui.snap_max_dist_entry.setEnabled(False)
                 self.app.ui.corner_snap_btn.setEnabled(False)
         else:
-            self.app.ui.geo_edit_toolbar.setVisible(False)
+            # self.app.ui.geo_edit_toolbar.setVisible(False)
 
             self.app.ui.snap_magnet.setVisible(False)
             self.app.ui.corner_snap_btn.setVisible(False)
             self.app.ui.snap_max_dist_entry.setEnabled(False)
             self.app.ui.corner_snap_btn.setEnabled(False)
 
+        # set the Editor Toolbar visibility to what was before entering in the Editor
+        self.app.ui.geo_edit_toolbar.setVisible(False) if self.toolbar_old_state is False \
+            else self.app.ui.geo_edit_toolbar.setVisible(True)
+
         # Disable visuals
         self.shapes.enabled = False
         self.tool_shape.enabled = False
@@ -3695,6 +3703,9 @@ class FlatCAMExcEditor(QtCore.QObject):
         # this will flag if the Editor "tools" are launched from key shortcuts (True) or from menu toolbar (False)
         self.launched_from_shortcuts = False
 
+        # this var will store the state of the toolbar before starting the editor
+        self.toolbar_old_state = False
+
         self.app.ui.delete_drill_btn.triggered.connect(self.on_delete_btn)
         self.name_entry.returnPressed.connect(self.on_name_activate)
         self.addtool_btn.clicked.connect(self.on_tool_add)
@@ -4216,27 +4227,31 @@ class FlatCAMExcEditor(QtCore.QObject):
         if settings.contains("theme"):
             theme = settings.value('theme', type=str)
             if theme == 'standard':
-                self.app.ui.exc_edit_toolbar.setVisible(False)
+                # self.app.ui.exc_edit_toolbar.setVisible(False)
 
                 self.app.ui.snap_max_dist_entry.setEnabled(False)
                 self.app.ui.corner_snap_btn.setEnabled(False)
                 self.app.ui.snap_magnet.setVisible(False)
                 self.app.ui.corner_snap_btn.setVisible(False)
             elif theme == 'compact':
-                self.app.ui.exc_edit_toolbar.setVisible(True)
+                # self.app.ui.exc_edit_toolbar.setVisible(True)
 
                 self.app.ui.snap_max_dist_entry.setEnabled(False)
                 self.app.ui.corner_snap_btn.setEnabled(False)
                 self.app.ui.snap_magnet.setVisible(True)
                 self.app.ui.corner_snap_btn.setVisible(True)
         else:
-            self.app.ui.exc_edit_toolbar.setVisible(False)
+            # self.app.ui.exc_edit_toolbar.setVisible(False)
 
             self.app.ui.snap_max_dist_entry.setEnabled(False)
             self.app.ui.corner_snap_btn.setEnabled(False)
             self.app.ui.snap_magnet.setVisible(False)
             self.app.ui.corner_snap_btn.setVisible(False)
 
+        # set the Editor Toolbar visibility to what was before entering in the Editor
+        self.app.ui.exc_edit_toolbar.setVisible(False) if self.toolbar_old_state is False \
+            else self.app.ui.exc_edit_toolbar.setVisible(True)
+
         # Disable visuals
         self.shapes.enabled = False
         self.tool_shape.enabled = False

+ 21 - 15
FlatCAMGUI.py

@@ -394,7 +394,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.splitter = QtWidgets.QSplitter()
         self.setCentralWidget(self.splitter)
 
-        self.notebook = QtWidgets.QTabWidget()
+        # self.notebook = QtWidgets.QTabWidget()
+        self.notebook = FCDetachableTab(protect=True)
+        self.notebook.setTabsClosable(False)
+        self.notebook.useOldIndex(True)
+
         self.splitter.addWidget(self.notebook)
 
         self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
@@ -585,7 +589,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.right_lay.setContentsMargins(0, 0, 0, 0)
         self.right_widget.setLayout(self.right_lay)
         # self.plot_tab_area = FCTab()
-        self.plot_tab_area = FCDetachableTab()
+        self.plot_tab_area = FCDetachableTab(protect=False, protect_by_name=['Plot Area'])
+        self.plot_tab_area.useOldIndex(True)
 
         self.right_lay.addWidget(self.plot_tab_area)
         self.plot_tab_area.setTabsClosable(True)
@@ -2840,7 +2845,7 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
         self.setTitle(str("NCC Tool Options"))
 
         ## Clear non-copper regions
-        self.clearcopper_label = QtWidgets.QLabel("<b>Clear non-copper:</b>")
+        self.clearcopper_label = QtWidgets.QLabel("<b>Parameters:</b>")
         self.clearcopper_label.setToolTip(
             "Create a Geometry object with\n"
             "toolpaths to cut all non-copper regions."
@@ -2941,7 +2946,7 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI):
         self.setTitle(str("Cutout Tool Options"))
 
         ## Board cuttout
-        self.board_cutout_label = QtWidgets.QLabel("<b>Board cutout:</b>")
+        self.board_cutout_label = QtWidgets.QLabel("<b>Parameters:</b>")
         self.board_cutout_label.setToolTip(
             "Create toolpaths to cut around\n"
             "the PCB and separate it from\n"
@@ -3024,7 +3029,7 @@ class Tools2sidedPrefGroupUI(OptionsGroupUI):
         self.setTitle(str("2Sided Tool Options"))
 
         ## Board cuttout
-        self.dblsided_label = QtWidgets.QLabel("<b>Double Sided:</b>")
+        self.dblsided_label = QtWidgets.QLabel("<b>Parameters:</b>")
         self.dblsided_label.setToolTip(
             "A tool to help in creating a double sided\n"
             "PCB using alignment holes."
@@ -3083,7 +3088,7 @@ class ToolsPaintPrefGroupUI(OptionsGroupUI):
         # ------------------------------
         ## Paint area
         # ------------------------------
-        self.paint_label = QtWidgets.QLabel('<b>Paint Area:</b>')
+        self.paint_label = QtWidgets.QLabel('<b>Parameters:</b>')
         self.paint_label.setToolTip(
             "Creates tool paths to cover the\n"
             "whole area of a polygon (remove\n"
@@ -3186,7 +3191,7 @@ class ToolsFilmPrefGroupUI(OptionsGroupUI):
         self.setTitle(str("Film Tool Options"))
 
         ## Board cuttout
-        self.film_label = QtWidgets.QLabel("<b>Film parameters:</b>")
+        self.film_label = QtWidgets.QLabel("<b>Parameters:</b>")
         self.film_label.setToolTip(
             "Create a PCB film from a Gerber or Geometry\n"
             "FlatCAM object.\n"
@@ -3225,14 +3230,15 @@ class ToolsFilmPrefGroupUI(OptionsGroupUI):
         grid0.addWidget(self.film_boundary_label, 1, 0)
         grid0.addWidget(self.film_boundary_entry, 1, 1)
 
-        self.film_adjust_entry = FCEntry()
-        self.film_adjust_label = QtWidgets.QLabel("Adjust:")
-        self.film_adjust_label.setToolTip(
-            "Adjust the line thickness of each feature in the SVG file.\n"
-            "In pixels."
+        self.film_scale_entry = FCEntry()
+        self.film_scale_label = QtWidgets.QLabel("Scale Stroke:")
+        self.film_scale_label.setToolTip(
+            "Scale the line stroke thickness of each feature in the SVG file.\n"
+            "It means that the line that envelope each SVG feature will be thicker or thinner,\n"
+            "therefore the fine features may be more affected by this parameter."
         )
-        grid0.addWidget(self.film_adjust_label, 2, 0)
-        grid0.addWidget(self.film_adjust_entry, 2, 1)
+        grid0.addWidget(self.film_scale_label, 2, 0)
+        grid0.addWidget(self.film_scale_entry, 2, 1)
 
         self.layout.addStretch()
 
@@ -3245,7 +3251,7 @@ class ToolsPanelizePrefGroupUI(OptionsGroupUI):
         self.setTitle(str("Panelize Tool Options"))
 
         ## Board cuttout
-        self.panelize_label = QtWidgets.QLabel("<b>Board cutout:</b>")
+        self.panelize_label = QtWidgets.QLabel("<b>Parameters:</b>")
         self.panelize_label.setToolTip(
             "Create an object that contains an array of (x, y) elements,\n"
             "each element is a copy of the source object spaced\n"

+ 36 - 11
GUIElements.py

@@ -554,7 +554,7 @@ class FCTab(QtWidgets.QTabWidget):
 
 class FCDetachableTab(QtWidgets.QTabWidget):
     # From here: https://stackoverflow.com/questions/47267195/in-pyqt4-is-it-possible-to-detach-tabs-from-a-qtabwidget
-    def __init__(self, parent=None):
+    def __init__(self, protect=None, protect_by_name=None, parent=None):
 
         super().__init__()
 
@@ -569,12 +569,26 @@ class FCDetachableTab(QtWidgets.QTabWidget):
         # does not have a parent
         self.detachedTabs = {}
 
+        # a way to make sure that tabs can't be closed after they attach to the parent tab
+        self.protect_tab = True if protect is not None and protect is True else False
+
+        self.protect_by_name = protect_by_name if isinstance(protect_by_name, list) else None
+
         # Close all detached tabs if the application is closed explicitly
         QtWidgets.qApp.aboutToQuit.connect(self.closeDetachedTabs) # @UndefinedVariable
 
+        # used by the property self.useOldIndex(param)
+        self.use_old_index = None
+        self.old_index = None
+
         self.setTabsClosable(True)
         self.tabCloseRequested.connect(self.closeTab)
 
+    def useOldIndex(self, param):
+        if param:
+            self.use_old_index = True
+        else:
+            self.use_old_index = False
 
     def deleteTab(self, currentIndex):
         widget = self.widget(currentIndex)
@@ -610,7 +624,6 @@ class FCDetachableTab(QtWidgets.QTabWidget):
         self.insertTab(toIndex, widget, icon, text)
         self.setCurrentIndex(toIndex)
 
-
     ##
     #  Detach the tab by removing it's contents and placing them in
     #  a DetachedTab window
@@ -620,6 +633,8 @@ class FCDetachableTab(QtWidgets.QTabWidget):
     @pyqtSlot(int, QtCore.QPoint)
     def detachTab(self, index, point):
 
+        self.old_index = index
+
         # Get the tab content
         name = self.tabText(index)
         icon = self.tabIcon(index)
@@ -663,6 +678,9 @@ class FCDetachableTab(QtWidgets.QTabWidget):
         # Remove the reference
         del self.detachedTabs[name]
 
+        # helps in restoring the tab to the same index that it was before was detached
+        insert_index = self.old_index if self.use_old_index is True else insertAt
+
         # Create an image from the given icon (for comparison)
         if not icon.isNull():
             try:
@@ -686,21 +704,30 @@ class FCDetachableTab(QtWidgets.QTabWidget):
         # Determine if the given image and the main window icon are the same.
         # If they are, then do not add the icon to the tab
         if tabIconImage == windowIconImage:
-            if insertAt == None:
+            if insert_index is None:
                 index = self.addTab(contentWidget, name)
             else:
-                index = self.insertTab(insertAt, contentWidget, name)
+                index = self.insertTab(insert_index, contentWidget, name)
         else:
-            if insertAt == None:
+            if insert_index is None:
                 index = self.addTab(contentWidget, icon, name)
             else:
-                index = self.insertTab(insertAt, contentWidget, icon, name)
+                index = self.insertTab(insert_index, contentWidget, icon, name)
 
+        # on reattaching the tab if protect is true then the closure button is not added
+        if self.protect_tab is True:
+            self.protectTab(index)
 
-        # Make this tab the current tab
-        if index > -1:
-            self.setCurrentIndex(index)
+        # on reattaching the tab disable the closure button for the tabs with the name in the self.protect_by_name list
+        if self.protect_by_name is not None:
+            for tab_name in self.protect_by_name:
+                for index in range(self.count()):
+                    if str(tab_name) == str(self.tabText(index)):
+                        self.protectTab(index)
 
+        # Make this tab the current tab
+            if index > -1:
+                self.setCurrentIndex(insert_index) if self.use_old_index else self.setCurrentIndex(index)
 
     ##
     #  Remove the tab with the given name, even if it is detached
@@ -986,8 +1013,6 @@ class FCDetachableTab(QtWidgets.QTabWidget):
             self.dragDropedPos = event.pos()
             QtWidgets.QTabBar.dropEvent(self, event)
 
-
-
         #  Determine if the detached tab drop event occurred on an existing tab,
         #  then send the event to the DetachableTabWidget
         def detachedTabDrop(self, name, dropPos):

+ 5 - 1
README.md

@@ -9,11 +9,15 @@ CAD program, and create G-Code for Isolation routing.
 
 =================================================
 
-24.02.2019
+4.02.2019
 
 - modified the Toolchange_Probe_general postprocessor file to remove any Z moves before the actual toolchange event
 - created a prototype postprocessor file for usage with tool probing in MACH3
 - added the default values for Tool Film and Tool Panelize to the Edit -> Preferences
+- added a new parameter in the Tool Film which control the thickness of the stroke width in the resulting SVG. It's a scale parameter.
+- whatever was the visibility of the corresponding toolbar when we enter in the Editor, it will be set after exit from the Editor (either Geometry Editor or Excellon Editor).
+- added ability to be detached for the tabs in the Notebook section (Project, Selected and Tool)
+- added ability for all detachable tabs to be restored to the same position from where they were detached.
 
 3.3.2019
 

+ 2 - 1
flatcamTools/ToolCutOut.py

@@ -48,6 +48,8 @@ class ToolCutOut(FlatCAMTool):
         self.obj_combo = QtWidgets.QComboBox()
         self.obj_combo.setModel(self.app.collection)
         self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
+        self.obj_combo.setCurrentIndex(1)
+
         self.object_label = QtWidgets.QLabel("Object:")
         self.object_label.setToolTip(
             "Object to be cutout.                        "
@@ -201,7 +203,6 @@ class ToolCutOut(FlatCAMTool):
 
     def set_tool_ui(self):
         self.reset_fields()
-        self.obj_combo.setCurrentIndex(1)
 
         self.dia.set_value(float(self.app.defaults["tools_cutouttooldia"]))
         self.margin.set_value(float(self.app.defaults["tools_cutoutmargin"]))

+ 2 - 3
flatcamTools/ToolDblSided.py

@@ -29,6 +29,7 @@ class DblSidedTool(FlatCAMTool):
         self.gerber_object_combo = QtWidgets.QComboBox()
         self.gerber_object_combo.setModel(self.app.collection)
         self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
+        self.gerber_object_combo.setCurrentIndex(1)
 
         self.botlay_label = QtWidgets.QLabel("<b>GERBER:</b>")
         self.botlay_label.setToolTip(
@@ -52,6 +53,7 @@ class DblSidedTool(FlatCAMTool):
         self.exc_object_combo = QtWidgets.QComboBox()
         self.exc_object_combo.setModel(self.app.collection)
         self.exc_object_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex()))
+        self.exc_object_combo.setCurrentIndex(1)
 
         self.excobj_label = QtWidgets.QLabel("<b>EXCELLON:</b>")
         self.excobj_label.setToolTip(
@@ -262,9 +264,6 @@ class DblSidedTool(FlatCAMTool):
     def set_tool_ui(self):
         self.reset_fields()
 
-        self.gerber_object_combo.setCurrentIndex(1)
-        self.exc_object_combo.setCurrentIndex(1)
-
         self.point_entry.set_value("")
         self.alignment_holes.set_value("")
 

+ 26 - 4
flatcamTools/ToolFilm.py

@@ -43,6 +43,8 @@ class Film(FlatCAMTool):
         self.tf_object_combo = QtWidgets.QComboBox()
         self.tf_object_combo.setModel(self.app.collection)
         self.tf_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
+        self.tf_object_combo.setCurrentIndex(1)
+
         self.tf_object_label = QtWidgets.QLabel("Film Object:")
         self.tf_object_label.setToolTip(
             "Object for which to create the film."
@@ -74,6 +76,7 @@ class Film(FlatCAMTool):
         self.tf_box_combo = QtWidgets.QComboBox()
         self.tf_box_combo.setModel(self.app.collection)
         self.tf_box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
+        self.tf_box_combo.setCurrentIndex(1)
 
         self.tf_box_combo_label = QtWidgets.QLabel("Box Object:")
         self.tf_box_combo_label.setToolTip(
@@ -113,6 +116,15 @@ class Film(FlatCAMTool):
         )
         tf_form_layout.addRow(self.boundary_label, self.boundary_entry)
 
+        self.film_scale_entry = FCEntry()
+        self.film_scale_label = QtWidgets.QLabel("Scale Stroke:")
+        self.film_scale_label.setToolTip(
+            "Scale the line stroke thickness of each feature in the SVG file.\n"
+            "It means that the line that envelope each SVG feature will be thicker or thinner,\n"
+            "therefore the fine features may be more affected by this parameter."
+        )
+        tf_form_layout.addRow(self.film_scale_label, self.film_scale_entry)
+
         # Buttons
         hlay = QtWidgets.QHBoxLayout()
         self.layout.addLayout(hlay)
@@ -157,19 +169,22 @@ class Film(FlatCAMTool):
     def set_tool_ui(self):
         self.reset_fields()
 
-        self.tf_object_combo.setCurrentIndex(1)
-        self.tf_box_combo.setCurrentIndex(1)
         f_type = self.app.defaults["tools_film_type"] if self.app.defaults["tools_film_type"] else 'neg'
         self.film_type.set_value(str(f_type))
+
         b_entry = self.app.defaults[ "tools_film_boundary"] if self.app.defaults[ "tools_film_boundary"] else 0.0
         self.boundary_entry.set_value(float(b_entry))
 
+        scale_stroke_width = self.app.defaults["tools_film_scale"] if self.app.defaults["tools_film_scale"] else 0.0
+        self.film_scale_entry.set_value(int(scale_stroke_width))
+
     def on_film_creation(self):
         try:
             name = self.tf_object_combo.currentText()
         except:
             self.app.inform.emit("[ERROR_NOTCL] No FlatCAM object selected. Load an object for Film and retry.")
             return
+
         try:
             boxname = self.tf_box_combo.currentText()
         except:
@@ -187,6 +202,13 @@ class Film(FlatCAMTool):
                                      "use a number.")
                 return
 
+        try:
+            scale_stroke_width = int(self.film_scale_entry.get_value())
+        except ValueError:
+            self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, "
+                                 "use a number.")
+            return
+
         if border is None:
             border = 0
 
@@ -207,7 +229,7 @@ class Film(FlatCAMTool):
                 self.app.inform.emit("[WARNING_NOTCL]Export SVG positive cancelled.")
                 return
             else:
-                self.app.export_svg_black(name, boxname, filename)
+                self.app.export_svg_black(name, boxname, filename, scale_factor=scale_stroke_width)
         else:
             try:
                 filename, _ = QtWidgets.QFileDialog.getSaveFileName(
@@ -223,7 +245,7 @@ class Film(FlatCAMTool):
                 self.app.inform.emit("[WARNING_NOTCL]Export SVG negative cancelled.")
                 return
             else:
-                self.app.export_svg_negative(name, boxname, filename, border)
+                self.app.export_svg_negative(name, boxname, filename, border, scale_factor=scale_stroke_width)
 
     def reset_fields(self):
         self.tf_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))

+ 2 - 2
flatcamTools/ToolNonCopperClear.py

@@ -34,6 +34,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
         self.object_combo = QtWidgets.QComboBox()
         self.object_combo.setModel(self.app.collection)
         self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
+        self.object_combo.setCurrentIndex(1)
+
         self.object_label = QtWidgets.QLabel("Gerber:")
         self.object_label.setToolTip(
             "Gerber object to be cleared of excess copper.                        "
@@ -246,8 +248,6 @@ class NonCopperClear(FlatCAMTool, Gerber):
     def set_tool_ui(self):
         self.tools_frame.show()
 
-        self.object_combo.setCurrentIndex(1)
-
         self.ncc_overlap_entry.set_value(self.app.defaults["tools_nccoverlap"])
         self.ncc_margin_entry.set_value(self.app.defaults["tools_nccmargin"])
         self.ncc_method_radio.set_value(self.app.defaults["tools_nccmethod"])

+ 2 - 1
flatcamTools/ToolPaint.py

@@ -32,6 +32,8 @@ class ToolPaint(FlatCAMTool, Gerber):
         self.object_combo = QtWidgets.QComboBox()
         self.object_combo.setModel(self.app.collection)
         self.object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
+        self.object_combo.setCurrentIndex(1)
+
         self.object_label = QtWidgets.QLabel("Geometry:")
         self.object_label.setToolTip(
             "Geometry object to be painted.                        "
@@ -323,7 +325,6 @@ class ToolPaint(FlatCAMTool, Gerber):
     def set_tool_ui(self):
         self.tools_frame.show()
         self.reset_fields()
-        self.object_combo.setCurrentIndex(1)
 
         ## Init the GUI interface
         self.paintmargin_entry.set_value(self.default_data["paintmargin"])

+ 4 - 2
flatcamTools/ToolPanelize.py

@@ -43,6 +43,8 @@ class Panelize(FlatCAMTool):
         self.object_combo = QtWidgets.QComboBox()
         self.object_combo.setModel(self.app.collection)
         self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
+        self.object_combo.setCurrentIndex(1)
+
         self.object_label = QtWidgets.QLabel("Object:")
         self.object_label.setToolTip(
             "Object to be panelized. This means that it will\n"
@@ -74,6 +76,8 @@ class Panelize(FlatCAMTool):
         self.box_combo = QtWidgets.QComboBox()
         self.box_combo.setModel(self.app.collection)
         self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
+        self.box_combo.setCurrentIndex(1)
+
         self.box_combo_label = QtWidgets.QLabel("Box Object:")
         self.box_combo_label.setToolTip(
             "The actual object that is used a container for the\n "
@@ -187,8 +191,6 @@ class Panelize(FlatCAMTool):
 
     def set_tool_ui(self):
         self.reset_fields()
-        self.object_combo.setCurrentIndex(1)
-        self.box_combo.setCurrentIndex(1)
 
         sp_c = self.app.defaults["tools_panelize_spacing_columns"] if \
             self.app.defaults["tools_panelize_spacing_columns"] else 0.0