Ejemplo n.º 1
0
class ImportCommand(Command):
    """ Import the objects from a file into the scene. """
    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")

        # 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")
        file.close()

        root = doc.documentElement()

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

        self.prototypeManager.importScene(root)
        self.mainWindow.viewportManager.updateViewports()
Ejemplo n.º 2
0
class ClearSceneCommand(Command):
    """ Clear the whole scene of all the objects. """
    def __init__(self, mainWindow):
        Command.__init__(self)
        self.mainWindow = mainWindow
        self.prototypeManager = PrototypeManager()

    def execute(self):
        self.prototypeManager.removeAllObjects()
        self.mainWindow.viewportManager.resetScene()
        self.mainWindow.viewportManager.updateViewports()
        self.mainWindow.saveFileName = ""
Ejemplo n.º 3
0
 def generateRandom(self):
     # # first do as if File->New was selected
     self.new()
     # # then show randomProblemDialog
     # ui = Ui_randomProblemDialog()
     # dialog = QtDialog()
     # # create random problem
     (numpoints, ratio, size, rounding) = (10, 0.0, 100.0, 0.0)
     problem = random_triangular_problem_3D(numpoints, size, rounding,
                                            ratio)
     prototypeManager = PrototypeManager()
     prototypeManager.setProblem(problem)
     self.viewportManager.updateViewports()
Ejemplo n.º 4
0
 def execute(self, tool):
     """ Update a tool to a new tool
     
     Parameters:
         tool = new tool which the user has selected
     """
     if self.viewportManager.displayViewport == DisplayViewport.ALL:
         for viewport in self.viewportManager.viewportList:
             viewport.glViewport.currentTool = tool
             for action in viewport.editGroup.actions():
                 action.setChecked(False)
     else:
         self.viewportManager.viewport.glViewport.currentTool = tool
         for action in self.viewportManager.viewport.editGroup.actions():
             action.setChecked(False)
     PrototypeManager().deselectObject()
     self.viewportManager.updateViewports()
Ejemplo n.º 5
0
 def createTriggers(self):
     # # menu actions
     self.actionNew.triggered.connect(self.new)
     self.actionQuit.triggered.connect(self.close)
     self.actionSave.triggered.connect(self.save)
     self.actionSave_As.triggered.connect(self.saveAs)
     self.actionImport.triggered.connect(self.importFile)
     self.actionOpen.triggered.connect(self.load)
     #
     self.actionCompositionView.triggered.connect(self.showCompositionView)
     self.actionSolutionView.triggered.connect(self.showSolutionView)
     self.actionPreferences.triggered.connect(self.showPreferencesDlg)
     #
     self.actionSelect.changed.connect(self.selectTriggered)
     self.actionPlacePoint.changed.connect(self.placePointTriggered)
     self.actionMove.changed.connect(self.moveTriggered)
     self.actionConnect.changed.connect(self.connectTriggered)
     self.actionDistanceConstraint.changed.connect(
         self.distanceConstraintTriggered)
     self.actionMinMaxView.triggered.connect(
         self.viewportManager.minmaxView)
     #
     self.actionSolve.triggered.connect(PrototypeManager().solve)
     self.actionSolve.triggered.connect(
         self.compositionView.createDecomposition)
     self.actionSolve.triggered.connect(self.solutionView.createSolution)
     self.actionSolve.triggered.connect(self.viewportManager.updateSolution)
     self.actionSolve.triggered.connect(
         self.viewportManager.updateDecomposition)
     self.actionSolve.triggered.connect(
         self.viewportManager.updateViewports)
     self.actionSolve.triggered.connect(self.updateConstraintInfo)
     #
     self.actionClusters.triggered.connect(self.showClusters)
     self.actionDistance.changed.connect(self.placeDistanceTriggered)
     self.actionAngleConstraint.changed.connect(
         self.placeAngleConstraintTriggered)
     self.actionFixedConstraint.changed.connect(
         self.placeFixedConstraintTriggered)
Ejemplo n.º 6
0
class SaveCommand(Command):
    """ Save the file for all the objects in the scene. """
    def __init__(self, mainWindow):
        Command.__init__(self)
        self.mainWindow = mainWindow
        self.prototypeManager = PrototypeManager()

    def execute(self, filename):
        doc = QtXml.QDomDocument("Geometric Constraints")
        root = doc.createElement("Objects")
        doc.appendChild(root)

        for prtObject in self.prototypeManager.prtObjects:
            if not prtObject.ghost:
                root.appendChild(prtObject.save(doc))
        root.appendChild(self.prototypeManager.save(doc))

        file = QtCore.QFile(filename)
        if file.open(QtCore.QIODevice.WriteOnly):
            ts = QtCore.QTextStream(file)
            ts << doc.toString()
            file.close()
Ejemplo n.º 7
0
 def showClusters(self):
     prtManager = PrototypeManager()
     prtManager.showClusters()
     self.viewportManager.updateViewports()
Ejemplo n.º 8
0
 def updateConstraintInfo(self):
     self.infoPanel.reset()
     updateTaskbarCommand = UpdateTextInTaskbarCommand(
         PrototypeManager(), self)
     updateTaskbarCommand.execute()
Ejemplo n.º 9
0
 def createSolutionView(self):
     self.solutionView = SolutionView(self, self.viewportManager,
                                      ViewportType.SOLUTION,
                                      PrototypeManager())
Ejemplo n.º 10
0
 def createDecompositionView(self):
     self.compositionView = CompositionView(None, self.viewportManager,
                                            ViewportType.DECOMPOSITION,
                                            PrototypeManager())
Ejemplo n.º 11
0
 def __init__(self, mainWindow):
     Command.__init__(self)
     self.mainWindow = mainWindow
     self.prototypeManager = PrototypeManager()