Преглед изворни кода

- updated the Excellon plot function so it can plot the Excellon's from old projects
- removed the message boxes that popup on Excellon Export errors and replaced them with status bar messages

Marius Stanciu пре 7 година
родитељ
комит
679b33fa72
3 измењених фајлова са 29 додато и 36 уклоњено
  1. 4 15
      FlatCAMApp.py
  2. 23 21
      FlatCAMObj.py
  3. 2 0
      README.md

+ 4 - 15
FlatCAMApp.py

@@ -4978,23 +4978,12 @@ class App(QtCore.QObject):
 
         obj = self.collection.get_active()
         if obj is None:
-            self.inform.emit("[WARNING_NOTCL] No object selected.")
-            msg = "Please Select an Excellon object to export"
-            msgbox = QtWidgets.QMessageBox()
-            msgbox.setInformativeText(msg)
-            msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
-            msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
-            msgbox.exec_()
+            self.inform.emit("[WARNING_NOTCL] No object selected. Please Select an Excellon object to export.")
             return
 
         # Check for more compatible types and add as required
         if not isinstance(obj, FlatCAMExcellon):
-            msg = "[WARNING_NOTCL] Only Excellon objects can be used."
-            msgbox = QtWidgets.QMessageBox()
-            msgbox.setInformativeText(msg)
-            msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
-            msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
-            msgbox.exec_()
+            self.inform.emit("[ERROR_NOTCL] Failed. Only Excellon objects can be saved as Excellon files...")
             return
 
         name = self.collection.get_active().options["name"]
@@ -6105,7 +6094,7 @@ class App(QtCore.QObject):
             App.log.debug(obj['kind'] + ":  " + obj['options']['name'])
             self.new_object(obj['kind'], obj['options']['name'], obj_init, active=False, fit=False, plot=True)
 
-        # self.plot_all()
+        self.plot_all()
         self.inform.emit("[success] Project loaded from: " + filename)
 
         self.should_we_save = False
@@ -6807,7 +6796,7 @@ The normal flow when working in FlatCAM is the following:</span></p>
             json.dump(d, f, default=to_dict, indent=2, sort_keys=True)
             f.close()
 
-        # verification of the saved project
+            # verification of the saved project
             # Open and parse
             try:
                 saved_f = open(filename, 'r')

+ 23 - 21
FlatCAMObj.py

@@ -2226,29 +2226,31 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
                             self.add_shape(shape=ints, color='green', visible=self.options['plot'])
 
             self.shapes.redraw()
-        except (ObjectDeleted, AttributeError):
+            return
+        except (ObjectDeleted, AttributeError, KeyError):
             self.shapes.clear(update=True)
 
-        # try:
-        #     _ = iter(self.solid_geometry)
-        # except TypeError:
-        #     self.solid_geometry = [self.solid_geometry]
-        #
-        # try:
-        #     # Plot excellon (All polygons?)
-        #     if self.options["solid"]:
-        #         for geo in self.solid_geometry:
-        #             self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF', visible=self.options['plot'],
-        #                            layer=2)
-        #     else:
-        #         for geo in self.solid_geometry:
-        #             self.add_shape(shape=geo.exterior, color='red', visible=self.options['plot'])
-        #             for ints in geo.interiors:
-        #                 self.add_shape(shape=ints, color='green', visible=self.options['plot'])
-        #
-        #     self.shapes.redraw()
-        # except (ObjectDeleted, AttributeError):
-        #     self.shapes.clear(update=True)
+        # this stays for compatibility reasons, in case we try to open old projects
+        try:
+            _ = iter(self.solid_geometry)
+        except TypeError:
+            self.solid_geometry = [self.solid_geometry]
+
+        try:
+            # Plot excellon (All polygons?)
+            if self.options["solid"]:
+                for geo in self.solid_geometry:
+                    self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF', visible=self.options['plot'],
+                                   layer=2)
+            else:
+                for geo in self.solid_geometry:
+                    self.add_shape(shape=geo.exterior, color='red', visible=self.options['plot'])
+                    for ints in geo.interiors:
+                        self.add_shape(shape=ints, color='green', visible=self.options['plot'])
+
+            self.shapes.redraw()
+        except (ObjectDeleted, AttributeError):
+            self.shapes.clear(update=True)
 
         # try:
         #     # Plot excellon (All polygons?)

+ 2 - 0
README.md

@@ -17,6 +17,8 @@ CAD program, and create G-Code for Isolation routing.
 - remade the Excellon export function to work with parameters entered in Edit -> Preferences -> Excellon Export
 - added a new entry in the Project Context Menu named 'Save'. It will actually work for Geometry and it will do Export DXF and for Excellon and it will do Export Excellon
 - reworked the offer to save a project so it is done only if there are objects in the project but those objects are new and/or are modified since last project load (if an old project was loaded.)
+- updated the Excellon plot function so it can plot the Excellon's from old projects
+- removed the message boxes that popup on Excellon Export errors and replaced them with status bar messages
 
 14.02.2019