Beispiel #1
0
class LoadCommand(Command):
	""" Load the objects from a file. """
	def __init__(self, mainWindow):
		Command.__init__(self)
		self.mainWindow = mainWindow
		self.prototypeManager = PrototypeManager()
		
	def execute(self, filename):
		doc = QtXml.QDomDocument( "Geometric Constraints" )
		file = QtCore.QFile(filename)

		if not file.open(QtCore.QIODevice.ReadOnly):
			raise StandardError, "File could not be opened"
			return
		
		""" Skip the first line, because we need the root of the objects not the document. """
		file.readLine()
		
		if not doc.setContent(file, False):
			file.close()
			raise StandardError, "Could not initialize the file"
			return
		file.close()
		
		root = doc.documentElement()

		if root.tagName() != "Objects":
			raise StandardError, "Invalid document"
			return

		self.prototypeManager.load(root)
		self.mainWindow.viewportManager.updateViewports()
Beispiel #2
0
class LoadCommand(Command):
    """ Load the objects from a file. """
    def __init__(self, mainWindow):
        Command.__init__(self)
        self.mainWindow = mainWindow
        self.prototypeManager = PrototypeManager()

    def execute(self, filename):
        doc = QtXml.QDomDocument("Geometric Constraints")
        file = QtCore.QFile(filename)

        if not file.open(QtCore.QIODevice.ReadOnly):
            raise StandardError, "File could not be opened"
            return
        """ Skip the first line, because we need the root of the objects not the document. """
        file.readLine()

        if not doc.setContent(file, False):
            file.close()
            raise StandardError, "Could not initialize the file"
            return
        file.close()

        root = doc.documentElement()

        if root.tagName() != "Objects":
            raise StandardError, "Invalid document"
            return

        self.prototypeManager.load(root)
        self.mainWindow.viewportManager.updateViewports()