コード例 #1
0
ファイル: qgridder.py プロジェクト: cmkolb/Qgridder
    def __init__(self, iface):
        """
	Description
	-----------
	Initialize Qgridder plugin
	"""
        # Save reference to the QGIS interface
        self.iface = iface

        # load settings
        self.settings = QgridderSettings()

        # Create the dialogs and keep reference
        self.dlg_new = QGridderDialogNew(self.iface, self.settings)
        self.dlg_refinement = QGridderDialogRefinement(self.iface,
                                                       self.settings)
        self.dlg_check3D = QGridderDialogCheck3D(self.iface, self.settings)
        self.dlg_plot = QGridderDialogPlot(self.iface, self.settings)
        self.dlg_export = QGridderDialogExport(self.iface, self.settings)
        self.dlg_settings = QGridderDialogSettings(self.iface, self.settings)
        self.dlg_preproc = QGridderDialogPreProc(self.iface, self.settings)
        # Initialize menu
        self.qgridder_menu = None
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path(
        ) + "/python/plugins/Qgridder"
        # initialize locale
        localePath = ""
        locale = QSettings().value("locale/userLocale")[0:2]

        if QFileInfo(self.plugin_dir).exists():
            localePath = self.plugin_dir + "/i18n/Qgridder_" + locale + ".qm"

        if QFileInfo(localePath).exists():
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
コード例 #2
0
ファイル: qgridder.py プロジェクト: jeffnorville/Qgridder
    def __init__(self, iface):
	"""
	Description
	-----------
	Initialize Qgridder plugin
	"""
        # Save reference to the QGIS interface
        self.iface = iface

	# load settings
	self.settings = QgridderSettings()

        # Create the dialogs and keep reference
        self.dlg_new = QGridderDialogNew(self.iface, self.settings)
        self.dlg_refinement = QGridderDialogRefinement(self.iface,  self.settings)
        self.dlg_check3D = QGridderDialogCheck3D(self.iface,  self.settings)
        self.dlg_plot = QGridderDialogPlot(self.iface,  self.settings)
        self.dlg_export = QGridderDialogExport(self.iface,  self.settings)
        self.dlg_settings = QGridderDialogSettings(self.iface,  self.settings)
        self.dlg_preproc = QGridderDialogPreProc(self.iface,  self.settings)
	# Initialize menu
	self.qgridder_menu = None
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/Qgridder"
        # initialize locale
        localePath = ""
        locale = QSettings().value("locale/userLocale")[0:2]
       
        if QFileInfo(self.plugin_dir).exists():
            localePath = self.plugin_dir + "/i18n/Qgridder_" + locale + ".qm"

        if QFileInfo(localePath).exists():
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
コード例 #3
0
ファイル: qgridder.py プロジェクト: jeffnorville/Qgridder
class QGridder:
    """
    Description
    -----------
    Qgridder plugin class 
    """


    def __init__(self, iface):
	"""
	Description
	-----------
	Initialize Qgridder plugin
	"""
        # Save reference to the QGIS interface
        self.iface = iface

	# load settings
	self.settings = QgridderSettings()

        # Create the dialogs and keep reference
        self.dlg_new = QGridderDialogNew(self.iface, self.settings)
        self.dlg_refinement = QGridderDialogRefinement(self.iface,  self.settings)
        self.dlg_check3D = QGridderDialogCheck3D(self.iface,  self.settings)
        self.dlg_plot = QGridderDialogPlot(self.iface,  self.settings)
        self.dlg_export = QGridderDialogExport(self.iface,  self.settings)
        self.dlg_settings = QGridderDialogSettings(self.iface,  self.settings)
        self.dlg_preproc = QGridderDialogPreProc(self.iface,  self.settings)
	# Initialize menu
	self.qgridder_menu = None
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/Qgridder"
        # initialize locale
        localePath = ""
        locale = QSettings().value("locale/userLocale")[0:2]
       
        if QFileInfo(self.plugin_dir).exists():
            localePath = self.plugin_dir + "/i18n/Qgridder_" + locale + ".qm"

        if QFileInfo(localePath).exists():
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)
   
    def initGui(self):
	"""
	Description
	-----------
	Initialize plugin Gui :  dialogs, icons and menu
	"""
	#Create actions that will set up plugin
        self.action_new = QAction(QIcon(":/plugins/Qgridder/icon_new.png"), \
            "New grid", self.iface.mainWindow())
	self.action_refinement = QAction(QIcon(":/plugins/Qgridder/icon_refinement.png"), \
            "Refine grid", self.iface.mainWindow())
	self.action_check3D = QAction(QIcon(":/plugins/Qgridder/icon_check3D.png"), \
            "3D grid", self.iface.mainWindow())
	self.action_plot = QAction(QIcon(":/plugins/Qgridder/icon_plot.png"), \
            "Plot chart", self.iface.mainWindow())
	self.action_export = QAction(QIcon(":/plugins/Qgridder/icon_export.png"), \
            "Export", self.iface.mainWindow())
	self.action_settings = QAction(QIcon(":/plugins/Qgridder/icon_settings.png"), \
            "Settings", self.iface.mainWindow())
	self.action_preproc = QAction(QIcon(":/plugins/Qgridder/icon_pproc.png"), \
            "Settings", self.iface.mainWindow())

        # connect the action to the run method
        QObject.connect(self.action_new, SIGNAL("activated()"), self.run_new)
        QObject.connect(self.action_refinement, SIGNAL("activated()"), self.run_refinement)
        QObject.connect(self.action_check3D, SIGNAL("activated()"), self.run_check3D)
        QObject.connect(self.action_plot, SIGNAL("activated()"), self.run_plot)
        QObject.connect(self.action_export, SIGNAL("activated()"), self.run_export)
        QObject.connect(self.action_settings, SIGNAL("activated()"), self.run_settings)
        QObject.connect(self.action_preproc, SIGNAL("activated()"), self.run_preproc)
	

        # Add toolbar buttons 
        self.iface.addToolBarIcon(self.action_new)
        self.iface.addToolBarIcon(self.action_refinement)
        self.iface.addToolBarIcon(self.action_check3D)
        self.iface.addToolBarIcon(self.action_plot)
        self.iface.addToolBarIcon(self.action_export)
        self.iface.addToolBarIcon(self.action_settings)
        self.iface.addToolBarIcon(self.action_preproc)
	

	# Add menu items
        self.iface.addPluginToMenu("Qgridder", self.action_new)
        self.iface.addPluginToMenu("Qgridder", self.action_refinement)
        self.iface.addPluginToMenu("Qgridder", self.action_check3D)
        self.iface.addPluginToMenu("Qgridder", self.action_plot)
        self.iface.addPluginToMenu("Qgridder", self.action_export)
        self.iface.addPluginToMenu("Qgridder", self.action_settings)
        self.iface.addPluginToMenu("Qgridder", self.action_preproc)
	

    def unload(self):
	"""
	Description
	-----------
	Remove the plugin menu item and icon
	"""
	self.iface.removeToolBarIcon(self.action_new)
        self.iface.removeToolBarIcon(self.action_refinement)
        self.iface.removeToolBarIcon(self.action_check3D)
        self.iface.removeToolBarIcon(self.action_plot)
        self.iface.removeToolBarIcon(self.action_export)
        self.iface.removeToolBarIcon(self.action_settings)
        self.iface.removeToolBarIcon(self.action_preproc)

	self.iface.removePluginMenu("Qgridder", self.action_new)
        self.iface.removePluginMenu("Qgridder", self.action_refinement)
        self.iface.removePluginMenu("Qgridder", self.action_check3D)
        self.iface.removePluginMenu("Qgridder", self.action_plot)
        self.iface.removePluginMenu("Qgridder", self.action_export)
        self.iface.removePluginMenu("Qgridder", self.action_settings)
        self.iface.removePluginMenu("Qgridder", self.action_preproc)



    def run_new(self):
	"""
	Description
	-----------
	Launch grid creation dialog
	"""
	# update settings
	self.settings.load_settings( QgsProject.instance() )
	# Populate layer list
	self.dlg_new.populate_layer_list(self.dlg_new.listSourceLayer)
	# Get update extents from map canvas
	self.dlg_new.update_from_canvas()
	# show the dialog
	self.dlg_new.show()
	# Run the dialog event loop
	result = self.dlg_new.exec_()

    def run_refinement(self):
	"""
	Description
	-----------
	Launch grid refinement dialog
	"""
	# update settings
	self.settings.load_settings( QgsProject.instance() )
	# Populate layer list
	self.dlg_refinement.populate_layer_list(self.dlg_refinement.listGridLayer)

	# show the dialog
	self.dlg_refinement.show()
	# Run the dialog event loop
	result = self.dlg_refinement.exec_()

    def run_check3D(self):
	"""
	Description
	-----------
	Launch pseudo 3D grid topology check dialog
	"""
	# update settings
	self.settings.load_settings( QgsProject.instance() )
	# Populate layer list
	self.dlg_check3D.populate_layer_list(self.dlg_check3D.listReferenceGrid)
	self.dlg_check3D.populate_layer_list(self.dlg_check3D.listExistingLayer)

	# show the dialog
	self.dlg_check3D.show()
	# Run the dialog event loop
	result = self.dlg_check3D.exec_()

    def run_plot(self):
	"""
	Description
	-----------
	Launch plot chart dialog 
	"""
	# update settings
	self.settings.load_settings( QgsProject.instance() )
	# show the dialog
	self.dlg_plot.show()
	# plot data
	self.dlg_plot.run_plot()
	# Run the dialog event loop
	result = self.dlg_plot.exec_()

    def run_preproc(self):
	"""
	Description
	-----------
	Launch pre-processing dialog
	"""
	# update settings
	self.settings.load_settings( QgsProject.instance() )
	# update layer list
	self.dlg_preproc.populate_layer_list(self.dlg_preproc.listGridLayer)
	# show the dialog
	self.dlg_preproc.show()
	# Run the dialog event loop
	result = self.dlg_preproc.exec_()

    def run_export(self):
	"""
	Description
	-----------
	Launch grid creation dialog
	"""
	# update settings
	self.settings.load_settings( QgsProject.instance() )
	# Populate layer list
	self.dlg_export.populate_layer_list(self.dlg_export.listGridLayer)

	# show the dialog
	self.dlg_export.show()
	# Run the dialog event loop
	result = self.dlg_export.exec_()

    def run_settings(self):
	"""
	Description
	-----------
	Launch grid creation dialog
	"""
	# update settings
	self.settings.load_settings( QgsProject.instance() )

	# refresh dialog with current settings
	self.dlg_settings.load_settings_to_dialog()

	# show the dialog
	self.dlg_settings.show()
	# Run the dialog event loop
	result = self.dlg_settings.exec_()
コード例 #4
0
ファイル: qgridder.py プロジェクト: cmkolb/Qgridder
class QGridder:
    """
    Description
    -----------
    Qgridder plugin class 
    """
    def __init__(self, iface):
        """
	Description
	-----------
	Initialize Qgridder plugin
	"""
        # Save reference to the QGIS interface
        self.iface = iface

        # load settings
        self.settings = QgridderSettings()

        # Create the dialogs and keep reference
        self.dlg_new = QGridderDialogNew(self.iface, self.settings)
        self.dlg_refinement = QGridderDialogRefinement(self.iface,
                                                       self.settings)
        self.dlg_check3D = QGridderDialogCheck3D(self.iface, self.settings)
        self.dlg_plot = QGridderDialogPlot(self.iface, self.settings)
        self.dlg_export = QGridderDialogExport(self.iface, self.settings)
        self.dlg_settings = QGridderDialogSettings(self.iface, self.settings)
        self.dlg_preproc = QGridderDialogPreProc(self.iface, self.settings)
        # Initialize menu
        self.qgridder_menu = None
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path(
        ) + "/python/plugins/Qgridder"
        # initialize locale
        localePath = ""
        locale = QSettings().value("locale/userLocale")[0:2]

        if QFileInfo(self.plugin_dir).exists():
            localePath = self.plugin_dir + "/i18n/Qgridder_" + locale + ".qm"

        if QFileInfo(localePath).exists():
            self.translator = QTranslator()
            self.translator.load(localePath)

            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

    def initGui(self):
        """
	Description
	-----------
	Initialize plugin Gui :  dialogs, icons and menu
	"""
        #Create actions that will set up plugin
        self.action_new = QAction(QIcon(":/plugins/Qgridder/icon_new.png"), \
            "New grid", self.iface.mainWindow())
        self.action_refinement = QAction(QIcon(":/plugins/Qgridder/icon_refinement.png"), \
                   "Refine grid", self.iface.mainWindow())
        self.action_check3D = QAction(QIcon(":/plugins/Qgridder/icon_check3D.png"), \
                   "3D grid", self.iface.mainWindow())
        self.action_plot = QAction(QIcon(":/plugins/Qgridder/icon_plot.png"), \
                   "Plot chart", self.iface.mainWindow())
        self.action_export = QAction(QIcon(":/plugins/Qgridder/icon_export.png"), \
                   "Export", self.iface.mainWindow())
        self.action_settings = QAction(QIcon(":/plugins/Qgridder/icon_settings.png"), \
                   "Settings", self.iface.mainWindow())
        self.action_preproc = QAction(QIcon(":/plugins/Qgridder/icon_pproc.png"), \
                   "Settings", self.iface.mainWindow())

        # connect the action to the run method
        QObject.connect(self.action_new, SIGNAL("activated()"), self.run_new)
        QObject.connect(self.action_refinement, SIGNAL("activated()"),
                        self.run_refinement)
        QObject.connect(self.action_check3D, SIGNAL("activated()"),
                        self.run_check3D)
        QObject.connect(self.action_plot, SIGNAL("activated()"), self.run_plot)
        QObject.connect(self.action_export, SIGNAL("activated()"),
                        self.run_export)
        QObject.connect(self.action_settings, SIGNAL("activated()"),
                        self.run_settings)
        QObject.connect(self.action_preproc, SIGNAL("activated()"),
                        self.run_preproc)

        # Add toolbar buttons
        self.iface.addToolBarIcon(self.action_new)
        self.iface.addToolBarIcon(self.action_refinement)
        self.iface.addToolBarIcon(self.action_check3D)
        self.iface.addToolBarIcon(self.action_plot)
        self.iface.addToolBarIcon(self.action_export)
        self.iface.addToolBarIcon(self.action_settings)
        self.iface.addToolBarIcon(self.action_preproc)

        # Add menu items
        self.iface.addPluginToMenu("Qgridder", self.action_new)
        self.iface.addPluginToMenu("Qgridder", self.action_refinement)
        self.iface.addPluginToMenu("Qgridder", self.action_check3D)
        self.iface.addPluginToMenu("Qgridder", self.action_plot)
        self.iface.addPluginToMenu("Qgridder", self.action_export)
        self.iface.addPluginToMenu("Qgridder", self.action_settings)
        self.iface.addPluginToMenu("Qgridder", self.action_preproc)

    def unload(self):
        """
	Description
	-----------
	Remove the plugin menu item and icon
	"""
        self.iface.removeToolBarIcon(self.action_new)
        self.iface.removeToolBarIcon(self.action_refinement)
        self.iface.removeToolBarIcon(self.action_check3D)
        self.iface.removeToolBarIcon(self.action_plot)
        self.iface.removeToolBarIcon(self.action_export)
        self.iface.removeToolBarIcon(self.action_settings)
        self.iface.removeToolBarIcon(self.action_preproc)

        self.iface.removePluginMenu("Qgridder", self.action_new)
        self.iface.removePluginMenu("Qgridder", self.action_refinement)
        self.iface.removePluginMenu("Qgridder", self.action_check3D)
        self.iface.removePluginMenu("Qgridder", self.action_plot)
        self.iface.removePluginMenu("Qgridder", self.action_export)
        self.iface.removePluginMenu("Qgridder", self.action_settings)
        self.iface.removePluginMenu("Qgridder", self.action_preproc)

    def run_new(self):
        """
	Description
	-----------
	Launch grid creation dialog
	"""
        # update settings
        self.settings.load_settings(QgsProject.instance())
        # Populate layer list
        self.dlg_new.populate_layer_list(self.dlg_new.listSourceLayer)
        # Get update extents from map canvas
        self.dlg_new.update_from_canvas()
        # show the dialog
        self.dlg_new.show()
        # Run the dialog event loop
        result = self.dlg_new.exec_()

    def run_refinement(self):
        """
	Description
	-----------
	Launch grid refinement dialog
	"""
        # update settings
        self.settings.load_settings(QgsProject.instance())
        # Populate layer list
        self.dlg_refinement.populate_layer_list(
            self.dlg_refinement.listGridLayer)

        # show the dialog
        self.dlg_refinement.show()
        # Run the dialog event loop
        result = self.dlg_refinement.exec_()

    def run_check3D(self):
        """
	Description
	-----------
	Launch pseudo 3D grid topology check dialog
	"""
        # update settings
        self.settings.load_settings(QgsProject.instance())
        # Populate layer list
        self.dlg_check3D.populate_layer_list(
            self.dlg_check3D.listReferenceGrid)
        self.dlg_check3D.populate_layer_list(
            self.dlg_check3D.listExistingLayer)

        # show the dialog
        self.dlg_check3D.show()
        # Run the dialog event loop
        result = self.dlg_check3D.exec_()

    def run_plot(self):
        """
	Description
	-----------
	Launch plot chart dialog 
	"""
        # update settings
        self.settings.load_settings(QgsProject.instance())
        # show the dialog
        self.dlg_plot.show()
        # plot data
        self.dlg_plot.run_plot()
        # Run the dialog event loop
        result = self.dlg_plot.exec_()

    def run_preproc(self):
        """
	Description
	-----------
	Launch pre-processing dialog
	"""
        # update settings
        self.settings.load_settings(QgsProject.instance())
        # update layer list
        self.dlg_preproc.populate_layer_list(self.dlg_preproc.listGridLayer)
        # show the dialog
        self.dlg_preproc.show()
        # Run the dialog event loop
        result = self.dlg_preproc.exec_()

    def run_export(self):
        """
	Description
	-----------
	Launch grid creation dialog
	"""
        # update settings
        self.settings.load_settings(QgsProject.instance())
        # Populate layer list
        self.dlg_export.populate_layer_list(self.dlg_export.listGridLayer)

        # show the dialog
        self.dlg_export.show()
        # Run the dialog event loop
        result = self.dlg_export.exec_()

    def run_settings(self):
        """
	Description
	-----------
	Launch grid creation dialog
	"""
        # update settings
        self.settings.load_settings(QgsProject.instance())

        # refresh dialog with current settings
        self.dlg_settings.load_settings_to_dialog()

        # show the dialog
        self.dlg_settings.show()
        # Run the dialog event loop
        result = self.dlg_settings.exec_()