Просмотр исходного кода

- I've finally run the tests with OK result (56 tests in 102.937 sec)
- I had to play with module imports as they created a lot of error in
the tests although in reality the program worked OK.
- I've fixed some mistakes in TcL commands (they were testing isinstance
against the like of Geometry instead of FlatCAMGeometry)
- I've had to add some fixes in ObjectCollections.py (error on
create_index() method but Marco already fixed this in the checkbox
in project tab pull request and knew about this.
- Although at some point the tests run fine, I've made some checkings
on my own over the Tcl commands and discovered errors which I fixed as
mentioned above.
- conclusion is that tests are just a must and do not cover everything
(like saving projects which at some point by juggling with imports I
braked and tests were 100% OK)

Marius Stanciu 7 лет назад
Родитель
Сommit
3b9767cc6f
47 измененных файлов с 63 добавлено и 105 удалено
  1. 9 7
      FlatCAMApp.py
  2. 1 1
      FlatCAMObj.py
  3. 7 8
      ObjectCollection.py
  4. 1 0
      tclCommands/TclCommand.py
  5. 1 2
      tclCommands/TclCommandAddCircle.py
  6. 1 2
      tclCommands/TclCommandAddPolygon.py
  7. 1 2
      tclCommands/TclCommandAddPolyline.py
  8. 1 2
      tclCommands/TclCommandAddRectangle.py
  9. 1 2
      tclCommands/TclCommandAlignDrill.py
  10. 1 2
      tclCommands/TclCommandAlignDrillGrid.py
  11. 1 2
      tclCommands/TclCommandCncjob.py
  12. 1 2
      tclCommands/TclCommandCutout.py
  13. 1 2
      tclCommands/TclCommandDelete.py
  14. 1 2
      tclCommands/TclCommandDrillcncjob.py
  15. 1 2
      tclCommands/TclCommandExportGcode.py
  16. 1 2
      tclCommands/TclCommandExportSVG.py
  17. 2 3
      tclCommands/TclCommandExteriors.py
  18. 1 2
      tclCommands/TclCommandGeoCutout.py
  19. 1 2
      tclCommands/TclCommandGeoUnion.py
  20. 1 2
      tclCommands/TclCommandGetNames.py
  21. 1 2
      tclCommands/TclCommandGetSys.py
  22. 1 2
      tclCommands/TclCommandImportSvg.py
  23. 1 2
      tclCommands/TclCommandInteriors.py
  24. 1 2
      tclCommands/TclCommandIsolate.py
  25. 1 2
      tclCommands/TclCommandJoinExcellon.py
  26. 1 2
      tclCommands/TclCommandJoinGeometry.py
  27. 1 2
      tclCommands/TclCommandMillHoles.py
  28. 1 2
      tclCommands/TclCommandMirror.py
  29. 1 2
      tclCommands/TclCommandNew.py
  30. 1 2
      tclCommands/TclCommandNewGeometry.py
  31. 1 2
      tclCommands/TclCommandOffset.py
  32. 1 2
      tclCommands/TclCommandOpenExcellon.py
  33. 1 2
      tclCommands/TclCommandOpenGCode.py
  34. 2 3
      tclCommands/TclCommandOpenGerber.py
  35. 1 2
      tclCommands/TclCommandOpenProject.py
  36. 1 2
      tclCommands/TclCommandOptions.py
  37. 1 2
      tclCommands/TclCommandPaint.py
  38. 1 3
      tclCommands/TclCommandPanelize.py
  39. 1 2
      tclCommands/TclCommandPlot.py
  40. 1 2
      tclCommands/TclCommandSaveProject.py
  41. 1 2
      tclCommands/TclCommandScale.py
  42. 1 2
      tclCommands/TclCommandSetActive.py
  43. 1 2
      tclCommands/TclCommandSetSys.py
  44. 1 2
      tclCommands/TclCommandSubtractPoly.py
  45. 1 2
      tclCommands/TclCommandSubtractRectangle.py
  46. 1 2
      tclCommands/TclCommandVersion.py
  47. 1 2
      tclCommands/TclCommandWriteGCode.py

+ 9 - 7
FlatCAMApp.py

@@ -17,7 +17,7 @@ import re
 import webbrowser
 import os
 import tkinter
-from PyQt4 import QtCore
+from PyQt4 import Qt, QtCore, QtGui
 import time  # Just used for debugging. Double check before removing.
 from xml.dom.minidom import parseString as parse_xml_string
 from contextlib import contextmanager
@@ -27,10 +27,10 @@ from contextlib import contextmanager
 ########################################
 import FlatCAMVersion
 from FlatCAMWorker import Worker
-from ObjectCollection import *
-from FlatCAMObj import *
-from PlotCanvas import *
-from FlatCAMGUI import *
+import ObjectCollection
+from FlatCAMObj import FlatCAMCNCjob, FlatCAMExcellon, FlatCAMGerber, FlatCAMGeometry, FlatCAMObj
+from PlotCanvas import PlotCanvas
+from FlatCAMGUI import FlatCAMGUI, GlobalOptionsUI, FlatCAMActivityView, FlatCAMInfoBar
 from FlatCAMCommon import LoudDict
 from FlatCAMShell import FCShell
 from FlatCAMDraw import FlatCAMDraw
@@ -39,6 +39,8 @@ from MeasurementTool import Measurement
 from DblSidedTool import DblSidedTool
 import tclCommands
 
+from camlib import *
+
 
 ########################################
 ##                App                 ##
@@ -471,7 +473,7 @@ class App(QtCore.QObject):
         #self.options_write_form()
         self.on_options_combo_change(0)  # Will show the initial form
 
-        self.collection = ObjectCollection()
+        self.collection = ObjectCollection.ObjectCollection()
         self.ui.project_tab_layout.addWidget(self.collection.view)
         #### End of Data ####
 
@@ -1065,7 +1067,7 @@ class App(QtCore.QObject):
             t3 = time.time()
             self.log.debug("%f seconds converting units." % (t3 - t2))
 
-        FlatCAMApp.App.log.debug("Moving new object back to main thread.")
+        self.log.debug("Moving new object back to main thread.")
 
         # Move the object to the main thread and let the app know that it is available.
         obj.moveToThread(QtGui.QApplication.instance().thread())

+ 1 - 1
FlatCAMObj.py

@@ -221,7 +221,7 @@ class FlatCAMObj(QtCore.QObject):
         try:
             self.form_fields[option].set_value(self.options[option])
         except KeyError:
-            self.app.log.warn("Tried to set an option or field that does not exist: %s" % option)
+            self.app.log.warning("Tried to set an option or field that does not exist: %s" % option)
 
     def read_form_item(self, option):
         """

+ 7 - 8
ObjectCollection.py

@@ -6,7 +6,6 @@
 # MIT Licence                                              #
 ############################################################
 
-#from PyQt4.QtCore import QModelIndex
 from FlatCAMObj import *
 import inspect  # TODO: Remove
 import FlatCAMApp
@@ -162,13 +161,13 @@ class ObjectCollection():
         self.object_list.append(obj)
 
         # Create the model item to insert into the QListView
-        icon = QtGui.QIcon(self.icons[obj.kind])#self.icons["gerber"])
-        item = QtGui.QStandardItem(icon, name)
+        icon = QtGui.QIcon(self.icons[obj.kind])    #self.icons["gerber"])
+        item = QtGui.QStandardItem(icon, str(name))
         item.setCheckable(True)
-        if obj.options["plot"] == True:
-            item.setCheckState(2)#Qt.Checked)
+        if obj.options["plot"] is True:
+            item.setCheckState(2)   #Qt.Checked)
         else:
-            item.setCheckState(0) #Qt.Unchecked)
+            item.setCheckState(0)   #Qt.Unchecked)
 
         self.model.appendRow(item)
 
@@ -289,7 +288,7 @@ class ObjectCollection():
         :param name: Name of the FlatCAM Object
         :return: None
         """
-        iobj = self.createIndex(self.get_names().index(name), 0)  # Column 0
+        iobj = self.model.createIndex(self.get_names().index(name), 0)  # Column 0
         self.view.selectionModel().select(iobj, QtGui.QItemSelectionModel.Select)
 
     def set_inactive(self, name):
@@ -300,7 +299,7 @@ class ObjectCollection():
         :param name: Name of the FlatCAM Object
         :return: None
         """
-        iobj = self.createIndex(self.get_names().index(name), 0)  # Column 0
+        iobj = self.model.createIndex(self.get_names().index(name), 0)  # Column 0
         self.view.selectionModel().select(iobj, QtGui.QItemSelectionModel.Deselect)
 
     def set_all_inactive(self):

+ 1 - 0
tclCommands/TclCommand.py

@@ -5,6 +5,7 @@ import abc
 import collections
 from PyQt4 import QtCore
 from contextlib import contextmanager
+from FlatCAMObj import FlatCAMGerber, FlatCAMExcellon, FlatCAMGeometry, FlatCAMCNCjob, FlatCAMObj
 
 
 class TclCommand(object):

+ 1 - 2
tclCommands/TclCommandAddCircle.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandAddCircle(TclCommand):

+ 1 - 2
tclCommands/TclCommandAddPolygon.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandAddPolygon(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandAddPolyline.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandAddPolyline(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandAddRectangle.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandAddRectangle(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandAlignDrill.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandAlignDrill(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandAlignDrillGrid.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandAlignDrillGrid(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandCncjob.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandCncjob(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandCutout.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandCutout(TclCommand):

+ 1 - 2
tclCommands/TclCommandDelete.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandDelete(TclCommand):

+ 1 - 2
tclCommands/TclCommandDrillcncjob.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandDrillcncjob(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandExportGcode.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandExportGcode(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandExportSVG.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandExportSVG(TclCommand):

+ 2 - 3
tclCommands/TclCommandExteriors.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandExteriors(TclCommandSignaled):
@@ -54,7 +53,7 @@ class TclCommandExteriors(TclCommandSignaled):
         if obj is None:
             self.raise_tcl_error("Object not found: %s" % name)
 
-        if not isinstance(obj, Geometry):
+        if not isinstance(obj, FlatCAMGeometry):
             self.raise_tcl_error('Expected Geometry, got %s %s.' % (name, type(obj)))
 
         def geo_init(geo_obj, app_obj):

+ 1 - 2
tclCommands/TclCommandGeoCutout.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandGeoCutout(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandGeoUnion.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandGeoUnion(TclCommand):

+ 1 - 2
tclCommands/TclCommandGetNames.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandGetNames(TclCommand):

+ 1 - 2
tclCommands/TclCommandGetSys.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandGetSys(TclCommand):

+ 1 - 2
tclCommands/TclCommandImportSvg.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandImportSvg(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandInteriors.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandInteriors(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandIsolate.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandIsolate(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandJoinExcellon.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandJoinExcellon(TclCommand):

+ 1 - 2
tclCommands/TclCommandJoinGeometry.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandJoinGeometry(TclCommand):

+ 1 - 2
tclCommands/TclCommandMillHoles.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandMillHoles(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandMirror.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandMirror(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandNew.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandNew(TclCommand):

+ 1 - 2
tclCommands/TclCommandNewGeometry.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandNewGeometry(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandOffset.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandOffset(TclCommand):

+ 1 - 2
tclCommands/TclCommandOpenExcellon.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandOpenExcellon(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandOpenGCode.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandOpenGCode(TclCommandSignaled):

+ 2 - 3
tclCommands/TclCommandOpenGerber.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandOpenGerber(TclCommandSignaled):
@@ -48,7 +47,7 @@ class TclCommandOpenGerber(TclCommandSignaled):
         # How the object should be initialized
         def obj_init(gerber_obj, app_obj):
 
-            if not isinstance(gerber_obj, Geometry):
+            if not isinstance(gerber_obj, FlatCAMGerber):
                 self.raise_tcl_error('Expected FlatCAMGerber, got %s %s.' % (outname, type(gerber_obj)))
 
             # Opening the file happens here

+ 1 - 2
tclCommands/TclCommandOpenProject.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandOpenProject(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandOptions.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandOptions(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandPaint.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandPaint(TclCommandSignaled):

+ 1 - 3
tclCommands/TclCommandPanelize.py

@@ -1,7 +1,5 @@
-from ObjectCollection import *
 from copy import copy,deepcopy
-
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandPanelize(TclCommand):

+ 1 - 2
tclCommands/TclCommandPlot.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandPlot(TclCommand):

+ 1 - 2
tclCommands/TclCommandSaveProject.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandSaveProject(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandScale.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandScale(TclCommand):

+ 1 - 2
tclCommands/TclCommandSetActive.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandSetActive(TclCommand):

+ 1 - 2
tclCommands/TclCommandSetSys.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandSetSys(TclCommand):

+ 1 - 2
tclCommands/TclCommandSubtractPoly.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandSubtractPoly(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandSubtractRectangle.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandSubtractRectangle(TclCommandSignaled):

+ 1 - 2
tclCommands/TclCommandVersion.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommand
+from tclCommands.TclCommand import *
 
 
 class TclCommandVersion(TclCommand):

+ 1 - 2
tclCommands/TclCommandWriteGCode.py

@@ -1,5 +1,4 @@
-from ObjectCollection import *
-from tclCommands.TclCommand import TclCommandSignaled
+from tclCommands.TclCommand import *
 
 
 class TclCommandWriteGCode(TclCommandSignaled):