Exemplo n.º 1
0
    def saveSetupFile(self, setupObject):
        setupFilePath = setupObject.setupPath

        if os.path.isfile(setupFilePath):
            limboSetupObject = copy.deepcopy(setupObject)
            limboSetupObject.decimalPlaces = int(self.precComboBox.currentText())
            limboSetupObject.marxanPath = self.marxanLineEdit.text()
            limboSetupObject.inputPath = self.inputLineEdit.text()
            limboSetupObject.outputPath = self.outputLineEdit.text()
            limboSetupObject.puPath = self.puLineEdit.text()
            limboSetupObject.targetPath = self.targLineEdit.text()

            cluz_setup.checkStatusObjectValues(limboSetupObject)
            if limboSetupObject.setupStatus == "values_checked":
                cluz_setup.createAndCheckCLUZFiles(limboSetupObject)
                setupObject = copy.deepcopy(limboSetupObject)

            if setupObject.setupStatus == "files_checked":
                cluz_setup.updateClzSetupFile(setupObject)
                setupPathLabelText = "Setup file location: " + str(setupFilePath)
                self.setupPathLabel.setText(setupPathLabelText)
                cluz_setup.checkAddPlanningUnit(setupObject)

        elif setupFilePath == "blank":
            qgis.utils.iface.messageBar().pushMessage("No CLUZ setup file name", "The CLUZ setup file name has not been set. Please use the Save As... option instead.", QgsMessageBar.WARNING)
        else:
            qgis.utils.iface.messageBar().pushMessage("CLUZ setup file name error", "The current CLUZ setup file path is incorrect.", QgsMessageBar.WARNING)
Exemplo n.º 2
0
    def loadSetupFile(self, setupObject):
        setupPathLabelText = QFileDialog.getOpenFileName(self, 'Select CLUZ setup file', '*.clz')
        if setupPathLabelText != "":

            cluz_setup.updateSetupObjectFromSetupFile(setupObject, setupPathLabelText)
            cluz_setup.checkStatusObjectValues(setupObject)
            if setupObject.setupStatus == "values_checked":
                cluz_setup.createAndCheckCLUZFiles(setupObject)

            if setupObject.setupStatus == "files_checked":
                setupObject.setupAction = "blank"
                setupPathLabelText = os.path.abspath(setupPathLabelText)
                setupPathLabelText = "Setup file location: " + str(setupPathLabelText)
                self.setupPathLabel.setText(setupPathLabelText)

                self.marxanLineEdit.setText(os.path.abspath(setupObject.marxanPath))
                self.inputLineEdit.setText(os.path.abspath(setupObject.inputPath))
                self.outputLineEdit.setText(setupObject.outputPath)
                self.puLineEdit.setText(setupObject.puPath)
                self.targLineEdit.setText(setupObject.targetPath)

                numberList = [0, 1, 2, 3, 4, 5]
                precValue = setupObject.decimalPlaces
                if precValue > 5:
                    qgis.utils.iface.messageBar().pushMessage("Decimal precision value problem", "The number of decimal places specified in the CLUZ setup file cannot be more than 5. The specified value has been changed to 5.", QgsMessageBar.WARNING)
                    precValue = 5
                indexValue = numberList.index(precValue)
                self.precComboBox.setCurrentIndex(indexValue)

                cluz_setup.checkAddPlanningUnit(setupObject)
Exemplo n.º 3
0
    def saveAsSetupFile(self, setupObject):
        newSetupFilePath = QFileDialog.getSaveFileName(self, 'Save new CLUZ setup file', '*.clz')
        if newSetupFilePath != "":
            setupObject.decimalPlaces = int(self.precComboBox.currentText())
            setupObject.marxanPath = self.marxanLineEdit.text()
            setupObject.inputPath = self.inputLineEdit.text()
            setupObject.outputPath = self.outputLineEdit.text()
            setupObject.puPath = self.puLineEdit.text()
            setupObject.targetPath = self.targLineEdit.text()

            setupObject.setupPath = newSetupFilePath

            cluz_setup.checkStatusObjectValues(setupObject)
            if setupObject.setupStatus == "values_checked":
                cluz_setup.createAndCheckCLUZFiles(setupObject)
            if setupObject.setupStatus == "files_checked":
                cluz_setup.updateClzSetupFile(setupObject)
                setupPathLabelText = "Setup file location: " + str(newSetupFilePath)
                self.setupPathLabel.setText(setupPathLabelText)
                cluz_setup.checkAddPlanningUnit(setupObject)

        else:
            qgis.utils.iface.messageBar().pushMessage("CLUZ setup file name error", "The current CLUZ setup file path is incorrect.", QgsMessageBar.WARNING)