Przeglądaj źródła

- more changes in strings throughout the app
- made some minor changes in the GUI of the FlatCAM Tools
- in Tools Database made sure that each new tool added has a unique name
- in AppTool made some methods to be class methods

Marius Stanciu 5 lat temu
rodzic
commit
57a969afdd

+ 24 - 7
AppDatabase.py

@@ -119,7 +119,7 @@ class ToolsDB(QtWidgets.QWidget):
         )
         self.buttons_box.addWidget(import_db_btn)
 
-        self.add_tool_from_db = FCButton(_("Add Tool from Tools DB"))
+        self.add_tool_from_db = FCButton(_("Transfer Tool"))
         self.add_tool_from_db.setToolTip(
             _("Add a new tool in the Tools Table of the\n"
               "active Geometry object after selecting a tool\n"
@@ -1792,12 +1792,19 @@ class ToolsDB2(QtWidgets.QWidget):
         )
         self.buttons_box.addWidget(self.save_db_btn)
 
-        self.add_tool_from_db = FCButton(_("Add Tool from Tools DB"))
+        self.add_tool_from_db = FCButton(_("Transfer Tool"))
         self.add_tool_from_db.setToolTip(
-            _("Add a new tool in the Tools Table of the\n"
-              "active Geometry object after selecting a tool\n"
+            _("Insert a new tool in the Tools Table of the\n"
+              "object/application tool after selecting a tool\n"
               "in the Tools Database.")
         )
+        self.add_tool_from_db.setStyleSheet("""
+                                            QPushButton
+                                            {
+                                                font-weight: bold;
+                                                color: green;
+                                            }
+                                            """)
         self.add_tool_from_db.hide()
 
         self.cancel_tool_from_db = FCButton(_("Cancel"))
@@ -1807,7 +1814,7 @@ class ToolsDB2(QtWidgets.QWidget):
         tree_layout.addLayout(hlay)
         hlay.addWidget(self.add_tool_from_db)
         hlay.addWidget(self.cancel_tool_from_db)
-        hlay.addStretch()
+        # hlay.addStretch()
 
         # ##############################################################################
         # ##############################################################################
@@ -2015,7 +2022,7 @@ class ToolsDB2(QtWidgets.QWidget):
         self.blockSignals(False)
 
     def setup_db_ui(self):
-        filename = self.app.data_path + '/geo_tools_db.FlatDB'
+        filename = self.app.data_path + '\geo_tools_db.FlatDB'
 
         # load the database tools from the file
         try:
@@ -2145,8 +2152,18 @@ class ToolsDB2(QtWidgets.QWidget):
             "tools_iso_isotype":        self.app.defaults["tools_iso_isotype"],
         })
 
+        temp = []
+        for k, v in self.db_tool_dict.items():
+            if "new_tool_" in v['name']:
+                temp.append(float(v['name'].rpartition('_')[2]))
+
+        if temp:
+            new_name = "new_tool_%d" % int(max(temp) + 1)
+        else:
+            new_name = "new_tool_1"
+
         dict_elem = {}
-        dict_elem['name'] = 'new_tool'
+        dict_elem['name'] = new_name
         if type(self.app.defaults["geometry_cnctooldia"]) == float:
             dict_elem['tooldia'] = self.app.defaults["geometry_cnctooldia"]
         else:

+ 1 - 1
AppGUI/MainGUI.py

@@ -1124,7 +1124,7 @@ class MainGUI(QtWidgets.QMainWindow):
         # #######################################################################
         # ####################### TCL Shell DOCK ################################
         # #######################################################################
-        self.shell_dock = FCDock("FlatCAM TCL Shell", close_callback=self.toggle_shell_ui)
+        self.shell_dock = FCDock("TCL Shell", close_callback=self.toggle_shell_ui)
         self.shell_dock.setObjectName('Shell_DockWidget')
         self.shell_dock.setAllowedAreas(QtCore.Qt.AllDockWidgetAreas)
         self.shell_dock.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable |

+ 24 - 19
AppTool.py

@@ -101,7 +101,8 @@ class AppTool(QtWidgets.QWidget):
 
         self.show()
 
-    def draw_tool_selection_shape(self, old_coords, coords, **kwargs):
+    @classmethod
+    def draw_tool_selection_shape(cls, old_coords, coords, **kwargs):
         """
 
         :param old_coords: old coordinates
@@ -113,17 +114,17 @@ class AppTool(QtWidgets.QWidget):
         if 'shapes_storage' in kwargs:
             s_storage = kwargs['shapes_storage']
         else:
-            s_storage = self.app.tool_shapes
+            s_storage = cls.app.tool_shapes
 
         if 'color' in kwargs:
             color = kwargs['color']
         else:
-            color = self.app.defaults['global_sel_line']
+            color = cls.app.defaults['global_sel_line']
 
         if 'face_color' in kwargs:
             face_color = kwargs['face_color']
         else:
-            face_color = self.app.defaults['global_sel_fill']
+            face_color = cls.app.defaults['global_sel_fill']
 
         if 'face_alpha' in kwargs:
             face_alpha = kwargs['face_alpha']
@@ -145,10 +146,11 @@ class AppTool(QtWidgets.QWidget):
         color_t = face_color[:-2] + str(hex(int(face_alpha * 255)))[2:]
 
         s_storage.add(sel_rect, color=color, face_color=color_t, update=True, layer=0, tolerance=None)
-        if self.app.is_legacy is True:
+        if cls.app.is_legacy is True:
             s_storage.redraw()
 
-    def draw_selection_shape_polygon(self, points, **kwargs):
+    @classmethod
+    def draw_selection_shape_polygon(cls, points, **kwargs):
         """
 
         :param points: a list of points from which to create a Polygon
@@ -159,17 +161,17 @@ class AppTool(QtWidgets.QWidget):
         if 'shapes_storage' in kwargs:
             s_storage = kwargs['shapes_storage']
         else:
-            s_storage = self.app.tool_shapes
+            s_storage = cls.app.tool_shapes
 
         if 'color' in kwargs:
             color = kwargs['color']
         else:
-            color = self.app.defaults['global_sel_line']
+            color = cls.app.defaults['global_sel_line']
 
         if 'face_color' in kwargs:
             face_color = kwargs['face_color']
         else:
-            face_color = self.app.defaults['global_sel_fill']
+            face_color = cls.app.defaults['global_sel_fill']
 
         if 'face_alpha' in kwargs:
             face_alpha = kwargs['face_alpha']
@@ -187,10 +189,11 @@ class AppTool(QtWidgets.QWidget):
         color_t = face_color[:-2] + str(hex(int(face_alpha * 255)))[2:]
 
         s_storage.add(sel_rect, color=color, face_color=color_t, update=True, layer=0, tolerance=None)
-        if self.app.is_legacy is True:
+        if cls.app.is_legacy is True:
             s_storage.redraw()
 
-    def delete_tool_selection_shape(self, **kwargs):
+    @classmethod
+    def delete_tool_selection_shape(cls, **kwargs):
         """
 
         :param kwargs:
@@ -200,12 +203,13 @@ class AppTool(QtWidgets.QWidget):
         if 'shapes_storage' in kwargs:
             s_storage = kwargs['shapes_storage']
         else:
-            s_storage = self.app.tool_shapes
+            s_storage = cls.app.tool_shapes
 
         s_storage.clear()
         s_storage.redraw()
 
-    def draw_moving_selection_shape_poly(self, points, data, **kwargs):
+    @classmethod
+    def draw_moving_selection_shape_poly(cls, points, data, **kwargs):
         """
 
         :param points:
@@ -217,17 +221,17 @@ class AppTool(QtWidgets.QWidget):
         if 'shapes_storage' in kwargs:
             s_storage = kwargs['shapes_storage']
         else:
-            s_storage = self.app.move_tool.sel_shapes
+            s_storage = cls.app.move_tool.sel_shapes
 
         if 'color' in kwargs:
             color = kwargs['color']
         else:
-            color = self.app.defaults['global_sel_line']
+            color = cls.app.defaults['global_sel_line']
 
         if 'face_color' in kwargs:
             face_color = kwargs['face_color']
         else:
-            face_color = self.app.defaults['global_sel_fill']
+            face_color = cls.app.defaults['global_sel_fill']
 
         if 'face_alpha' in kwargs:
             face_alpha = kwargs['face_alpha']
@@ -257,10 +261,11 @@ class AppTool(QtWidgets.QWidget):
         elif not geo.is_valid:
             s_storage.add(geo, color="red", face_color=color_t_error, update=True, layer=0, tolerance=None)
 
-        if self.app.is_legacy is True:
+        if cls.app.is_legacy is True:
             s_storage.redraw()
 
-    def delete_moving_selection_shape(self, **kwargs):
+    @classmethod
+    def delete_moving_selection_shape(cls, **kwargs):
         """
 
         :param kwargs:
@@ -270,7 +275,7 @@ class AppTool(QtWidgets.QWidget):
         if 'shapes_storage' in kwargs:
             s_storage = kwargs['shapes_storage']
         else:
-            s_storage = self.app.move_tool.sel_shapes
+            s_storage = cls.app.move_tool.sel_shapes
 
         s_storage.clear()
         s_storage.redraw()

+ 1 - 1
AppTools/ToolCalibration.py

@@ -64,7 +64,7 @@ class ToolCalibration(AppTool):
         grid_lay.setColumnStretch(1, 1)
         grid_lay.setColumnStretch(2, 0)
 
-        self.gcode_title_label = QtWidgets.QLabel('<b>%s</b>' % _('GCode Parameters'))
+        self.gcode_title_label = QtWidgets.QLabel('<b>%s:</b>' % _('Parameters'))
         self.gcode_title_label.setToolTip(
             _("Parameters used when creating the GCode in this tool.")
         )

+ 6 - 2
AppTools/ToolCopperThieving.py

@@ -77,8 +77,12 @@ class ToolCopperThieving(AppTool):
         )
 
         i_grid_lay.addWidget(self.grbobj_label, 0, 0)
-        i_grid_lay.addWidget(self.grb_object_combo, 0, 1, 1, 2)
-        i_grid_lay.addWidget(QtWidgets.QLabel(''), 1, 0)
+        i_grid_lay.addWidget(self.grb_object_combo, 1, 0, 1, 2)
+
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        i_grid_lay.addWidget(separator_line, 2, 0, 1, 2)
 
         # ## Grid Layout
         grid_lay = QtWidgets.QGridLayout()

+ 8 - 2
AppTools/ToolEtchCompensation.py

@@ -78,7 +78,10 @@ class ToolEtchCompensation(AppTool):
         grid0.addWidget(self.gerber_label, 1, 0, 1, 2)
         grid0.addWidget(self.gerber_combo, 2, 0, 1, 2)
 
-        grid0.addWidget(QtWidgets.QLabel(""), 3, 0, 1, 2)
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        grid0.addWidget(separator_line, 3, 0, 1, 2)
 
         self.util_label = QtWidgets.QLabel("<b>%s:</b>" % _("Utilities"))
         self.util_label.setToolTip('%s.' % _("Conversion utilities"))
@@ -127,7 +130,10 @@ class ToolEtchCompensation(AppTool):
         hlay_2.addWidget(self.mils_to_um_entry)
         grid0.addLayout(hlay_2, 8, 0, 1, 2)
 
-        grid0.addWidget(QtWidgets.QLabel(""), 9, 0, 1, 2)
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        grid0.addWidget(separator_line, 9, 0, 1, 2)
 
         self.param_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
         self.param_label.setToolTip('%s.' % _("Parameters for this tool"))

+ 7 - 4
AppTools/ToolFiducials.py

@@ -63,9 +63,6 @@ class ToolFiducials(AppTool):
         self.points_table = FCTable()
         self.points_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
 
-        self.layout.addWidget(self.points_table)
-        self.layout.addWidget(QtWidgets.QLabel(''))
-
         self.points_table.setColumnCount(3)
         self.points_table.setHorizontalHeaderLabels(
             [
@@ -76,7 +73,6 @@ class ToolFiducials(AppTool):
         )
         self.points_table.setRowCount(3)
         row = 0
-
         flags = QtCore.Qt.ItemIsEnabled
 
         # BOTTOM LEFT
@@ -140,6 +136,13 @@ class ToolFiducials(AppTool):
         for row in range(self.points_table.rowCount()):
             self.points_table.cellWidget(row, 2).setFrame(False)
 
+        self.layout.addWidget(self.points_table)
+
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        self.layout.addWidget(separator_line)
+
         # ## Grid Layout
         grid_lay = QtWidgets.QGridLayout()
         self.layout.addLayout(grid_lay)

+ 4 - 1
AppTools/ToolInvertGerber.py

@@ -77,7 +77,10 @@ class ToolInvertGerber(AppTool):
         grid0.addWidget(self.gerber_label, 1, 0, 1, 2)
         grid0.addWidget(self.gerber_combo, 2, 0, 1, 2)
 
-        grid0.addWidget(QtWidgets.QLabel(""), 3, 0, 1, 2)
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        grid0.addWidget(separator_line, 3, 0, 1, 2)
 
         self.param_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
         self.param_label.setToolTip('%s.' % _("Parameters for this tool"))

+ 7 - 1
AppTools/ToolOptimal.py

@@ -72,7 +72,13 @@ class ToolOptimal(AppTool):
         self.gerber_object_label.setToolTip(
             "Gerber object for which to find the minimum distance between copper features."
         )
-        form_lay.addRow(self.gerber_object_label, self.gerber_object_combo)
+        form_lay.addRow(self.gerber_object_label)
+        form_lay.addRow(self.gerber_object_combo)
+
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        form_lay.addRow(separator_line)
 
         # Precision = nr of decimals
         self.precision_label = QtWidgets.QLabel('%s:' % _("Precision"))

+ 25 - 16
AppTools/ToolQRCode.py

@@ -75,14 +75,35 @@ class QRCode(AppTool):
         self.grb_object_combo.is_last = True
         self.grb_object_combo.obj_type = "Gerber"
 
-        self.grbobj_label = QtWidgets.QLabel("<b>%s:</b>" % _("Object"))
+        self.grbobj_label = QtWidgets.QLabel("<b>%s:</b>" % _("GERBER"))
         self.grbobj_label.setToolTip(
             _("Gerber Object to which the QRCode will be added.")
         )
 
         i_grid_lay.addWidget(self.grbobj_label, 0, 0)
-        i_grid_lay.addWidget(self.grb_object_combo, 0, 1, 1, 2)
-        i_grid_lay.addWidget(QtWidgets.QLabel(''), 1, 0)
+        i_grid_lay.addWidget(self.grb_object_combo, 1, 0, 1, 2)
+
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        i_grid_lay.addWidget(separator_line, 2, 0, 1, 2)
+
+        # Text box
+        self.text_label = QtWidgets.QLabel('<b>%s</b>:' % _("QRCode Data"))
+        self.text_label.setToolTip(
+            _("QRCode Data. Alphanumeric text to be encoded in the QRCode.")
+        )
+        self.text_data = FCTextArea()
+        self.text_data.setPlaceholderText(
+            _("Add here the text to be included in the QRCode...")
+        )
+        i_grid_lay.addWidget(self.text_label, 5, 0)
+        i_grid_lay.addWidget(self.text_data, 6, 0, 1, 2)
+
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        i_grid_lay.addWidget(separator_line, 7, 0, 1, 2)
 
         # ## Grid Layout
         grid_lay = QtWidgets.QGridLayout()
@@ -90,7 +111,7 @@ class QRCode(AppTool):
         grid_lay.setColumnStretch(0, 0)
         grid_lay.setColumnStretch(1, 1)
 
-        self.qrcode_label = QtWidgets.QLabel('<b>%s</b>' % _('QRCode Parameters'))
+        self.qrcode_label = QtWidgets.QLabel('<b>%s</b>' % _('Parameters'))
         self.qrcode_label.setToolTip(
             _("The parameters used to shape the QRCode.")
         )
@@ -158,18 +179,6 @@ class QRCode(AppTool):
         grid_lay.addWidget(self.border_size_label, 4, 0)
         grid_lay.addWidget(self.border_size_entry, 4, 1)
 
-        # Text box
-        self.text_label = QtWidgets.QLabel('%s:' % _("QRCode Data"))
-        self.text_label.setToolTip(
-            _("QRCode Data. Alphanumeric text to be encoded in the QRCode.")
-        )
-        self.text_data = FCTextArea()
-        self.text_data.setPlaceholderText(
-            _("Add here the text to be included in the QRCode...")
-        )
-        grid_lay.addWidget(self.text_label, 5, 0)
-        grid_lay.addWidget(self.text_data, 6, 0, 1, 2)
-
         # POLARITY CHOICE #
         self.pol_label = QtWidgets.QLabel('%s:' % _("Polarity"))
         self.pol_label.setToolTip(

+ 25 - 17
AppTools/ToolSolderPaste.py

@@ -64,11 +64,16 @@ class SolderPaste(AppTool):
         self.obj_combo.is_last = True
         self.obj_combo.obj_type = "Gerber"
 
-        self.object_label = QtWidgets.QLabel("Gerber:   ")
-        self.object_label.setToolTip(
-            _("Gerber Solder paste object.                        ")
+        self.object_label = QtWidgets.QLabel('<b>%s</b>:'% _("GERBER"))
+        self.object_label.setToolTip(_("Gerber Solder paste object.")
         )
-        obj_form_layout.addRow(self.object_label, self.obj_combo)
+        obj_form_layout.addRow(self.object_label)
+        obj_form_layout.addRow(self.obj_combo)
+
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        obj_form_layout.addRow(separator_line)
 
         # ### Tools ## ##
         self.tools_table_label = QtWidgets.QLabel('<b>%s</b>' % _('Tools Table'))
@@ -131,22 +136,13 @@ class SolderPaste(AppTool):
              "by first selecting a row(s) in the Tool Table.")
         )
 
-        self.soldergeo_btn = QtWidgets.QPushButton(_("Generate Geo"))
-        self.soldergeo_btn.setToolTip(
-            _("Generate solder paste dispensing geometry.")
-        )
-        self.soldergeo_btn.setStyleSheet("""
-                        QPushButton
-                        {
-                            font-weight: bold;
-                        }
-                        """)
-
         grid0.addWidget(self.addtool_btn, 0, 0)
-        # grid2.addWidget(self.copytool_btn, 0, 1)
         grid0.addWidget(self.deltool_btn, 0, 2)
 
-        self.layout.addSpacing(10)
+        separator_line = QtWidgets.QFrame()
+        separator_line.setFrameShape(QtWidgets.QFrame.HLine)
+        separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
+        grid0.addWidget(separator_line, 1, 0, 1, 3)
 
         # ## Buttons
         grid0_1 = QtWidgets.QGridLayout()
@@ -373,6 +369,18 @@ class SolderPaste(AppTool):
             _("Second step is to create a solder paste dispensing\n"
               "geometry out of an Solder Paste Mask Gerber file.")
         )
+
+        self.soldergeo_btn = QtWidgets.QPushButton(_("Generate Geo"))
+        self.soldergeo_btn.setToolTip(
+            _("Generate solder paste dispensing geometry.")
+        )
+        self.soldergeo_btn.setStyleSheet("""
+                                        QPushButton
+                                        {
+                                            font-weight: bold;
+                                        }
+                                        """)
+
         grid2.addWidget(step2_lbl, 0, 0)
         grid2.addWidget(self.soldergeo_btn, 0, 2)
 

+ 1 - 1
App_Main.py

@@ -6832,7 +6832,7 @@ class App(QtCore.QObject):
 
         data = None
         if self.is_legacy is False:
-            image = _screenshot(alpha=None)
+            image = _screenshot(alpha=False)
             data = np.asarray(image)
             if not data.ndim == 3 and data.shape[-1] in (3, 4):
                 self.inform.emit('[[WARNING_NOTCL]] %s' % _('Data must be a 3D array with last dimension 3 or 4'))

+ 4 - 0
CHANGELOG.md

@@ -13,6 +13,10 @@ CHANGELOG for FlatCAM beta
 - changed some strings
 - fixed the warning that old preferences found even for new installation
 - in Paint Tool fixed the message to select a polygon when using the Selection: Single Polygon being overwritten by the "Grid disabled" message
+- more changes in strings throughout the app
+- made some minor changes in the GUI of the FlatCAM Tools
+- in Tools Database made sure that each new tool added has a unique name
+- in AppTool made some methods to be class methods
 
 31.05.2020
 

+ 0 - 3
Common.py

@@ -212,9 +212,6 @@ class ExclusionAreas(QtCore.QObject):
 
         self.shape_type_button = shape_button
 
-        # TODO use the self.app.defaults when made general (not in Geo object Pref UI)
-        # self.shape_type_button.set_value('square')
-
         self.over_z_button = overz_button
         self.strategy_button = strategy_radio
         self.cnc_button = cnc_button