Esempio n. 1
0
    def configure(self):
        wizard = ProjectWizard(self._plugin.iface.mainWindow())

        ok = wizard.exec_()

        if ok:

            if wizard.newProject():
                if Project.exists():
                    Project.write()
                Project.clear()
                projectFolderPath = os.path.join(wizard.projectFolder(), 'project')
                if not QDir(projectFolderPath).mkpath('.'):
                    return False
                projectFilePath = os.path.join(projectFolderPath, wizard.projectFilename() + '.qgs')
                Project.setFileName(projectFilePath)

            Settings.setProjectCode(wizard.project().projectCode())
            Settings.setProjectName(wizard.project().projectName())
            Settings.setSiteCode(wizard.project().siteCode())
            if not Project.title():
                Project.setTitle(wizard.project().projectCode() + ' - ' + wizard.project().projectName())

            self._initialised = Project.write()
            if self._initialised:

                # We always want the site collection
                self._addCollection('site')
                self.collection('site').loadCollection()
                # Add the Site Location if entered
                location = wizard.projectLocation()
                if not location.isEmpty():
                    siteCode = wizard.project().siteCode() if wizard.project().siteCode() else wizard.project().projectCode()
                    item = Item(siteCode, 'site', siteCode)
                    source = Source('other', item)
                    audit = Audit(Settings.userFullName(), utils.timestamp())
                    itemFeature = ItemFeature(item, 'loc', None, source, 'New Project Wizard', audit)
                    layer = self.collection('site').layer('points')
                    feature = QgsFeature(layer.pendingFields(), 0)
                    feature.setGeometry(QgsGeometry(location))
                    attributes = itemFeature.toFeature(feature)
                    layers.addFeatures([feature], layer)

                # Temp load of other collection, later do on demand
                self._addCollection('plan')
                self.collection('plan').loadCollection()
                self._addCollection('section')
                self.collection('section').loadCollection()
                self._addCollection('grid')
                self.collection('grid').loadCollection()

                # self._configureDrawing('context')
                # self._configureDrawing('plan')
                # self._configureDrawing('section')

                Settings.setProjectConfigured()

        return ok
Esempio n. 2
0
 def _setDrawing(self, pmd):
     self.metadata.setSiteCode(pmd.siteCode)
     self.metadata.setClassCode(pmd.sourceClass)
     if pmd.sourceId > 0:
         self.metadata.setItemId(pmd.sourceId)
         self.metadata.setSourceId(pmd.sourceId)
     self.metadata.setSourceCode('drawing')
     self.metadata.setSourceClass(pmd.sourceClass)
     self.metadata.setSourceFile(pmd.filename)
     self.metadata.setEditor(Settings.userFullName())
Esempio n. 3
0
    def _mergeBuffers(self, collection):
        # Check the layers are writable
        name = collection.settings.collectionGroupName
        if not collection.isWritable():
            self._plugin.showCriticalMessage(
                name + ' layers are not writable! Please correct the permissions and log out.', 0)
            return

        # Check the buffers contain valid data
        errors = self._preMergeBufferCheck(collection.buffer('points'))
        errors.extend(self._preMergeBufferCheck(collection.buffer('lines')))
        errors.extend(self._preMergeBufferCheck(collection.buffer('polygons')))
        if len(errors) > 0:
            dialog = ItemFeatureErrorDialog()
            dialog.loadErrors(errors)
            dialog.exec_()
            if not dialog.ignoreErrors():
                return

        # Update the audit attributes
        timestamp = utils.timestamp()
        user = Settings.userFullName()
        self._preMergeBufferUpdate(collection.buffer('points'), timestamp, user)
        self._preMergeBufferUpdate(collection.buffer('lines'), timestamp, user)
        self._preMergeBufferUpdate(collection.buffer('polygons'), timestamp, user)

        # Finally actually merge the data
        if collection.mergeBuffers('Merge data', timestamp):
            self._plugin.showInfoMessage(name + ' data successfully merged.')
            # TODO pass current Item...
            self._logItemAction(Item(), 'Merge Buffers', timestamp)
            # TODO Signal out layers merged for schematic dock to catch
            # if self._editSchematic:
            #     self._editSchematic = False
            #     self._dock.activateSchematicCheck()
            #     self._findContext()
        else:
            self._plugin.showCriticalMessage(
                name + ' data merge failed! Some data has not been saved, please check your data.', 5)
Esempio n. 4
0
 def load(self):
     self.setProjectsFolder(Settings.projectsFolder())
     self.setUserFullName(Settings.userFullName())
     self.setUserInitials(Settings.userInitials())
     self.setUserOrganisation(Settings.userOrganisation())
 def load(self):
     self.setProjectsFolder(Settings.projectsFolder())
     self.setUserFullName(Settings.userFullName())
     self.setUserInitials(Settings.userInitials())
     self.setUserOrganisation(Settings.userOrganisation())