def run(self):

        is_open = QSettings().value("vogisprofiltoolmain/isopen", False)
        #Python treats almost everything as True````
        #is_open = bool(is_open)
        QgsMessageLog.logMessage(u'isopen: {0}'.format(is_open), 'VoGis')
        #!!!string comparison
        if is_open == 'true':
            QgsMessageLog.logMessage(u'Dialog already opened', 'VoGis')
            return

        try:
            import shapely
        except ImportError:
            QMessageBox.warning(
                self.iface.mainWindow(), "VoGIS-Profiltool",
                'Library "shapely" not found. Please install!')
            return
        except:
            QMessageBox.warning(
                self.iface.mainWindow(), "VoGIS-Profiltool",
                'There seems to be a problem with your shapely/geos install.\nSee:\nhttp://comments.gmane.org/gmane.linux.debian.devel.bugs.general/1111838!'
            )
            return

        self.settings = Settings(self.__getMapData())
        #QMessageBox.warning(self.iface.mainWindow(), "VoGIS-Profiltool", "lines:" + str(self.settings.mapData.lines.count()) + " rasters:" + str(self.settings.mapData.rasters.count()))

        #checken ob raster und oder lines vorhanden sind
        #if self.settings.mapData.lines.count() < 1:
        #    QMessageBox.warning(self.iface.mainWindow(), "VoGIS-Profiltool", "Keine Linienebene vorhanden")
        #    return 2
        if self.settings.mapData.rasters.count() < 1:
            retVal = QMessageBox.warning(
                self.iface.mainWindow(), "VoGIS-Profiltool",
                QApplication.translate(
                    'code',
                    'Keine Rasterebene vorhanden oder sichtbar! Nur hektometrieren?',
                    None, QApplication.UnicodeUTF8),
                QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
            if retVal == QMessageBox.No:
                return 2
            else:
                self.settings.onlyHektoMode = True
                self.settings.createHekto = True

        try:
            QSettings().setValue("vogisprofiltoolmain/isopen", True)
            # Create the dialog (after translation) and keep reference
            self.dlg = VoGISProfilToolMainDialog(self.iface, self.settings)
            # show the dialog
            self.dlg.show()
            # Run the dialog event loop
            #result = self.dlg.exec_()
            self.dlg.exec_()
        finally:
            QSettings().setValue("vogisprofiltoolmain/isopen", False)
Example #2
0
    def run(self):

        try:
            import shapely
        except ImportError:
            QMessageBox.warning(
                self.iface.mainWindow(), "VoGIS-Profiltool",
                'Library "shapely" not found. Please install!')
            return
        except:
            QMessageBox.warning(
                self.iface.mainWindow(), "VoGIS-Profiltool",
                'There seems to be a problem with your shapely/geos install.\nSee:\nhttp://comments.gmane.org/gmane.linux.debian.devel.bugs.general/1111838!'
            )
            return

        self.settings = Settings(self.__getMapData())
        #QMessageBox.warning(self.iface.mainWindow(), "VoGIS-Profiltool", "lines:" + str(self.settings.mapData.lines.count()) + " rasters:" + str(self.settings.mapData.rasters.count()))

        #checken ob raster und oder lines vorhanden sind
        #if self.settings.mapData.lines.count() < 1:
        #    QMessageBox.warning(self.iface.mainWindow(), "VoGIS-Profiltool", "Keine Linienebene vorhanden")
        #    return 2
        if self.settings.mapData.rasters.count() < 1:
            retVal = QMessageBox.warning(
                self.iface.mainWindow(), "VoGIS-Profiltool",
                QApplication.translate(
                    'code',
                    'Keine Rasterebene vorhanden oder sichtbar! Nur hektometrieren?',
                    None, QApplication.UnicodeUTF8),
                QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
            if retVal == QMessageBox.No:
                return 2
            else:
                self.settings.onlyHektoMode = True
                self.settings.createHekto = True

        # Create the dialog (after translation) and keep reference
        self.dlg = VoGISProfilToolMainDialog(self.iface, self.settings)
        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        #result = self.dlg.exec_()
        self.dlg.exec_()