Kaynağa Gözat

- selected rows in the Tools Tables will stay colored in blue after loosing focus instead of the default gray
- in NCC Tool the Tool name in the Parameters section will be the Tool ID in the Tool Table
- added an exception catch in case the plotcanvas init failed for the OpenGL graphic engine and warn user about what happened

Marius Stanciu 6 yıl önce
ebeveyn
işleme
856f568f9e
4 değiştirilmiş dosya ile 64 ekleme ve 25 silme
  1. 47 10
      FlatCAMApp.py
  2. 3 0
      README.md
  3. 5 0
      flatcamGUI/GUIElements.py
  4. 9 15
      flatcamTools/ToolNonCopperClear.py

+ 47 - 10
FlatCAMApp.py

@@ -1631,7 +1631,7 @@ class App(QtCore.QObject):
         self.toggle_units_ignore = False
 
         # #############################################################################
-        # ########################## LOAD POSTPROCESSORS ##############################
+        # ########################## LOAD PREPROCESSORS ###############################
         # #############################################################################
 
         # a dictionary that have as keys the name of the preprocessor files and the value is the class from
@@ -2464,7 +2464,10 @@ class App(QtCore.QObject):
         self.fiducial_tool = None
 
         # always install tools only after the shell is initialized because the self.inform.emit() depends on shell
-        self.install_tools()
+        try:
+            self.install_tools()
+        except AttributeError:
+            pass
 
         # ##################################################################################
         # ########################### SETUP RECENT ITEMS ###################################
@@ -2628,7 +2631,10 @@ class App(QtCore.QObject):
         # Storage for shapes, storage that can be used by FlatCAm tools for utility geometry
         # VisPy visuals
         if self.is_legacy is False:
-            self.tool_shapes = ShapeCollection(parent=self.plotcanvas.view.scene, layers=1)
+            try:
+                self.tool_shapes = ShapeCollection(parent=self.plotcanvas.view.scene, layers=1)
+            except AttributeError:
+                self.tool_shapes = None
         else:
             from flatcamGUI.PlotCanvasLegacy import ShapeCollectionLegacy
             self.tool_shapes = ShapeCollectionLegacy(obj=self, app=self, name="tool")
@@ -2639,9 +2645,20 @@ class App(QtCore.QObject):
 
         # watch out for the position of the editors instantiation ... if it is done before a save of the default values
         # at the first launch of the App , the editors will not be functional.
-        self.geo_editor = FlatCAMGeoEditor(self, disabled=True)
-        self.exc_editor = FlatCAMExcEditor(self)
-        self.grb_editor = FlatCAMGrbEditor(self)
+        try:
+            self.geo_editor = FlatCAMGeoEditor(self, disabled=True)
+        except AttributeError:
+            pass
+
+        try:
+            self.exc_editor = FlatCAMExcEditor(self)
+        except AttributeError:
+            pass
+
+        try:
+            self.grb_editor = FlatCAMGrbEditor(self)
+        except AttributeError:
+            pass
         self.log.debug("Finished adding FlatCAM Editor's.")
 
         self.set_ui_title(name=_("New Project - Not saved"))
@@ -3136,7 +3153,11 @@ class App(QtCore.QObject):
         self.ui.menutoolshell.triggered.connect(self.on_toggle_shell)
 
         # third install all of them
-        self.install_tools()
+        try:
+            self.install_tools()
+        except AttributeError:
+            pass
+
         self.log.debug("Tools are initialized.")
 
     # def parse_system_fonts(self):
@@ -11607,6 +11628,11 @@ class App(QtCore.QObject):
 
         }
 
+        try:
+            image_opener = self.image_tool.import_image
+        except AttributeError:
+            image_opener = None
+
         openers = {
             'gerber': lambda fname: self.worker_task.emit({'fcn': self.open_gerber, 'params': [fname]}),
             'excellon': lambda fname: self.worker_task.emit({'fcn': self.open_excellon, 'params': [fname]}),
@@ -11617,7 +11643,7 @@ class App(QtCore.QObject):
             'project': self.open_project,
             'svg': self.import_svg,
             'dxf': self.import_dxf,
-            'image': self.image_tool.import_image,
+            'image': image_opener,
             'pdf': lambda fname: self.worker_task.emit({'fcn': self.pdf_tool.open_pdf, 'params': [fname]})
         }
 
@@ -11946,7 +11972,7 @@ class App(QtCore.QObject):
 
     def on_plotcanvas_setup(self, container=None):
         """
-        This is doing the setup for the plot area (VisPy canvas)
+        This is doing the setup for the plot area (canvas)
 
         :param container: widget where to install the canvas
         :return: None
@@ -11957,7 +11983,18 @@ class App(QtCore.QObject):
             plot_container = self.ui.right_layout
 
         if self.is_legacy is False:
-            self.plotcanvas = PlotCanvas(plot_container, self)
+            try:
+                self.plotcanvas = PlotCanvas(plot_container, self)
+            except Exception as er:
+                msg_txt = traceback.format_exc()
+                log.debug("App.on_plotcanvas_setup() failed -> %s" % str(er))
+                log.debug("OpenGL canvas initialization failed with the following error.\n" + msg_txt)
+                msg = '[ERROR_NOTCL] %s' % _("An internal error has occurred. See shell.\n")
+                msg += _("OpenGL canvas initialization failed. HW or HW configuration not supported."
+                         "Change the graphic engine to Legacy(2D) in Edit -> Preferences -> General tab.\n\n")
+                msg += msg_txt
+                self.inform.emit(msg)
+                return 'fail'
         else:
             self.plotcanvas = PlotCanvasLegacy(plot_container, self)
 

+ 3 - 0
README.md

@@ -12,6 +12,9 @@ CAD program, and create G-Code for Isolation routing.
 8.01.2019
 
 - working in NCC Tool
+- selected rows in the Tools Tables will stay colored in blue after loosing focus instead of the default gray
+- in NCC Tool the Tool name in the Parameters section will be the Tool ID in the Tool Table
+- added an exception catch in case the plotcanvas init failed for the OpenGL graphic engine and warn user about what happened
 
 7.01.2019
 

+ 5 - 0
flatcamGUI/GUIElements.py

@@ -2006,6 +2006,11 @@ class FCTable(QtWidgets.QTableWidget):
     def __init__(self, drag_drop=False, protected_rows=None, parent=None):
         super(FCTable, self).__init__(parent)
 
+        palette = QtGui.QPalette()
+        palette.setColor(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight,
+                         palette.color(QtGui.QPalette.Active, QtGui.QPalette.Highlight))
+        self.setPalette(palette)
+
         if drag_drop:
             self.setDragEnabled(True)
             self.setAcceptDrops(True)

+ 9 - 15
flatcamTools/ToolNonCopperClear.py

@@ -6,6 +6,7 @@
 # ##########################################################
 
 from PyQt5 import QtWidgets, QtCore, QtGui
+
 from FlatCAMTool import FlatCAMTool
 from flatcamGUI.GUIElements import FCCheckBox, FCDoubleSpinner, RadioSet, FCTable, FCInputDialog, FCButton
 from flatcamParsers.ParseGerber import Gerber
@@ -697,7 +698,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
 
         # update the QLabel that shows for which Tool we have the parameters in the UI form
         self.tool_data_label.setText(
-            "<b>%s: <font color='#0000FF'>%s %d</font></b>" % (_('Parameters for'), _("Tool"), tooluid)
+            "<b>%s: <font color='#0000FF'>%s %d</font></b>" % (_('Parameters for'), _("Tool"), (current_row + 1))
         )
 
         try:
@@ -765,8 +766,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
         type_item = self.tools_table.cellWidget(row, 2).currentText()
         operation_type_item = self.ui.geo_tools_table.cellWidget(row, 4).currentText()
 
-        offset_item = self.ncc_choice_offset_cb.get_value()
-        offset_value_item = float(self.ncc_offset_spinner.get_value())
+        nccoffset_item = self.ncc_choice_offset_cb.get_value()
+        nccoffset_value_item = float(self.ncc_offset_spinner.get_value())
 
         # this new dict will hold the actual useful data, another dict that is the value of key 'data'
         temp_tools = {}
@@ -775,16 +776,6 @@ class NonCopperClear(FlatCAMTool, Gerber):
 
         for tooluid_key, tooluid_value in self.ncc_tools.items():
             for key, value in tooluid_value.items():
-                if key == 'tooldia':
-                    temp_dia[key] = tooldia_item
-                # update the 'offset', 'type' and 'tool_type' sections
-                if key == 'offset':
-                    temp_dia[key] = offset_item
-                if key == 'type':
-                    temp_dia[key] = type_item
-                if key == 'offset_value':
-                    temp_dia[key] = offset_value_item
-
                 if key == 'data':
                     # update the 'data' section
                     for data_key in tooluid_value[key].keys():
@@ -798,8 +789,10 @@ class NonCopperClear(FlatCAMTool, Gerber):
                     temp_dia[key] = deepcopy(temp_data)
                     temp_data.clear()
 
-                if key == 'solid_geometry':
+                elif key == 'solid_geometry':
                     temp_dia[key] = deepcopy(self.tools[tooluid_key]['solid_geometry'])
+                else:
+                    temp_dia[key] = deepcopy(value)
 
                 temp_tools[tooluid_key] = deepcopy(temp_dia)
 
@@ -1382,7 +1375,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
                     tooluid_del = int(self.tools_table.item(row, 3).text())
                     deleted_tools_list.append(tooluid_del)
             except TypeError:
-                deleted_tools_list.append(rows_to_delete)
+                tooluid_del = int(self.tools_table.item(rows_to_delete, 3).text())
+                deleted_tools_list.append(tooluid_del)
 
             for t in deleted_tools_list:
                 self.ncc_tools.pop(t, None)