/*************************************************************************** ossimplanet.cpp OssimPlanet plugin for veiwing rasters at the Earth ------------------- begin : Sat Apr 4 11:52:27 MSD 2009 copyright : (C) 2009 by Jack R email : lynx21.12.12@gmail.com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /* $Id: plugin.cpp 9327 2008-09-14 11:18:44Z jef $ */ // // QGIS Specific includes // #include #include #include #include #include #include "ossimplanetplugin.h" #include "ossimplanetgui.h" // // Qt4 Related Includes // #include #include #include static const char * const sIdent = "$Id: plugin.cpp 9327 2008-09-14 11:18:44Z jef $"; static const QString sName = QObject::tr( "OssimPlanet" ); static const QString sDescription = QObject::tr( "OssimPlanet plugin for veiwing rasters at the Earth" ); static const QString sPluginVersion = QObject::tr( "Version 0.1" ); static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI; ////////////////////////////////////////////////////////////////////// // // THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS // ////////////////////////////////////////////////////////////////////// /** * Constructor for the plugin. The plugin is passed a pointer * an interface object that provides access to exposed functions in QGIS. * @param theQGisInterface - Pointer to the QGIS interface object */ OssimPlanetPlugin::OssimPlanetPlugin( QgisInterface * theQgisInterface ): QgisPlugin( sName, sDescription, sPluginVersion, sPluginType ), mQGisIface( theQgisInterface ) { } OssimPlanetPlugin::~OssimPlanetPlugin() { } /* * Initialize the GUI interface for the plugin - this is only called once when the plugin is * added to the plugin registry in the QGIS application. */ void OssimPlanetPlugin::initGui() { // Create the action for tool mQActionPointer = new QAction( QIcon( ":/ossimplanet/ossimplanet.png" ), tr( "OssimPlanet" ), this ); // Set the what's this text mQActionPointer->setWhatsThis( tr( "Veiw layers at the planet" ) ); // Connect the action to the run connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) ); // Add the icon to the toolbar mQGisIface->addToolBarIcon( mQActionPointer ); mQGisIface->addPluginToMenu( tr( "&OssimPlanet" ), mQActionPointer ); mOssimPlanetGui = new OssimPlanetGui(mQGisIface, mQGisIface->mainWindow()); mQGisIface->addTabWidget(mOssimPlanetGui, tr("3D view")); mOssimPlanetGui->uploadImages(); connect(mQGisIface->mapCanvas(), SIGNAL(layersChanged()), mOssimPlanetGui, SLOT(uploadImages())); } //method defined in interface void OssimPlanetPlugin::help() { //implement me! } // Slot called when the menu item is triggered // If you created more menu items / toolbar buttons in initiGui, you should // create a separate handler for each action - this single run() method will // not be enough void OssimPlanetPlugin::run() { QgsMapLayer *activeLayer = mQGisIface->activeLayer(); if (activeLayer) { int idx = QgsMapLayerRegistry::instance()->mapLayers().keys().indexOf(activeLayer->getLayerID()); mOssimPlanetGui->lookAt(idx); } } // Unload the plugin by cleaning up the GUI void OssimPlanetPlugin::unload() { // remove the GUI mQGisIface->removePluginMenu( "&OssimPlanet", mQActionPointer ); mQGisIface->removeToolBarIcon( mQActionPointer ); mQGisIface->removeTabWidget(mQGisIface->tabWidget()->indexOf(mOssimPlanetGui)); delete mQActionPointer; } ////////////////////////////////////////////////////////////////////////// // // // THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT // YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN // MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY // // ////////////////////////////////////////////////////////////////////////// /** * Required extern functions needed for every plugin * These functions can be called prior to creating an instance * of the plugin class */ // Class factory to return a new instance of the plugin class QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer ) { return new OssimPlanetPlugin( theQgisInterfacePointer ); } // Return the name of the plugin - note that we do not user class members as // the class may not yet be insantiated when this method is called. QGISEXTERN QString name() { return sName; } // Return the description QGISEXTERN QString description() { return sDescription; } // Return the type (either UI or MapLayer plugin) QGISEXTERN int type() { return sPluginType; } // Return the version number for the plugin QGISEXTERN QString version() { return sPluginVersion; } // Delete ourself QGISEXTERN void unload( QgisPlugin * thePluginPointer ) { delete thePluginPointer; }