Ejemplo n.º 1
0
class GEMPlotter:

    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()
                                    ).path() + "/python/plugins/gemplotter"
        # initialize locale
        localePath = ""
        locale = QSettings().value("locale/userLocale")[0:2]

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

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

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

        # Create the dialog (after translation) and keep reference
        self.dlg = GEMPlotterDialog()

    def initGui(self):
        # Create action that will start plugin configuration
        self.action = QAction(
            QIcon(":/plugins/gemplotter/icon.png"),
            u"GEM Plotter", self.iface.mainWindow())
        # connect the action to the run method
        QObject.connect(self.action, SIGNAL("triggered()"), self.run)

        # Add toolbar button and menu item
        self.iface.addToolBarIcon(self.action)
        self.iface.addPluginToMenu(u"&gem-plotter", self.action)

    def unload(self):
        # Remove the plugin menu item and icon
        self.iface.removePluginMenu(u"&gem-plotter", self.action)
        self.iface.removeToolBarIcon(self.action)

    # run method that performs all the real work
    def run(self):
        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        result = self.dlg.exec_()
        # See if OK was pressed
        if result == 1:
            # do something useful (delete the line containing pass and
            # substitute with your code)
            pass
Ejemplo n.º 2
0
class GEMPlotterTestCase(unittest.TestCase):
    def setUp(self):
        self.dialog = GEMPlotterDialog()
        self.dialog.modelfile = FRAGMODEL
        self.dialog._fillCombo()

    def test_taxonomies(self):
        combo = self.dialog.ui.taxonomyCombo
        items = map(combo.itemText, range(combo.count()))
        self.assertEqual(['Taxonomy', 'RC/DMRF-D/LR', 'RC/DMRF-D/HR'], items)
        self.assertTrue(combo.isEnabled())

    def test_plot(self):
        self.dialog.ui.saveButton.setEnabled(False)
        c = self.dialog.ui.taxonomyCombo
        c.currentIndexChanged.connect(self.dialog.plot_ff)
        try:
            c.setCurrentIndex(c.findText('RC/DMRF-D/LR'))
            self.assertTrue(self.dialog.ui.saveButton.isEnabled())
        finally:
            c.currentIndexChanged.disconnect()
Ejemplo n.º 3
0
    def __init__(self, iface):
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()
                                    ).path() + "/python/plugins/gemplotter"
        # initialize locale
        localePath = ""
        locale = QSettings().value("locale/userLocale")[0:2]

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

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

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

        # Create the dialog (after translation) and keep reference
        self.dlg = GEMPlotterDialog()
Ejemplo n.º 4
0
 def setUp(self):
     self.dialog = GEMPlotterDialog()
     self.dialog.modelfile = FRAGMODEL
     self.dialog._fillCombo()