Skip to content

Commit

Permalink
Unload globe viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Oct 19, 2012
1 parent be2eadf commit a3097b4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
27 changes: 23 additions & 4 deletions src/plugins/globe/globe_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,25 @@ void GlobePlugin::initGui()
// Create the action for tool
mQActionPointer = new QAction( QIcon( ":/globe/globe.png" ), tr( "Launch Globe" ), this );
mQActionSettingsPointer = new QAction( QIcon( ":/globe/globe.png" ), tr( "Globe Settings" ), this );
QAction* actionUnload = new QAction( tr( "Unload Globe" ), this );

// Set the what's this text
mQActionPointer->setWhatsThis( tr( "Overlay data on a 3D globe" ) );
mQActionSettingsPointer->setWhatsThis( tr( "Settings for 3D globe" ) );
// Connect the action to the run
actionUnload->setWhatsThis( tr( "Unload globe" ) );

// Connect actions
connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) );
// Connect to the setting slot
connect( mQActionSettingsPointer, SIGNAL( triggered() ), this, SLOT( settings() ) );
connect( actionUnload, SIGNAL( triggered() ), this, SLOT( reset() ) );

// Add the icon to the toolbar
mQGisIface->addToolBarIcon( mQActionPointer );

//Add menu
mQGisIface->addPluginToMenu( tr( "&Globe" ), mQActionPointer );
mQGisIface->addPluginToMenu( tr( "&Globe" ), mQActionSettingsPointer );
mQGisIface->addPluginToMenu( tr( "&Globe" ), actionUnload );

connect( mQGisIface->mapCanvas() , SIGNAL( extentsChanged() ),
this, SLOT( extentsChanged() ) );
Expand Down Expand Up @@ -340,7 +347,6 @@ void GlobePlugin::setupMap()
GDALOptions driverOptions;
driverOptions.url() = QDir::cleanPath( QgsApplication::pkgDataPath() + "/globe/world.tif" ).toStdString();
ImageLayerOptions layerOptions( "world", driverOptions );
layerOptions.cacheEnabled() = false;
map->addImageLayer( new osgEarth::ImageLayer( layerOptions ) );
*/
TMSOptions imagery;
Expand Down Expand Up @@ -669,7 +675,7 @@ void GlobePlugin::setupControls()
#if ENABLE_SYNC_BUTTON
extraControls->setPosition( 5, 231 );
#else
extraControls->setPosition( 3, 231 );
extraControls->setPosition( 35, 231 );
#endif
extraControls->setPadding( 6 );

Expand Down Expand Up @@ -828,8 +834,21 @@ void GlobePlugin::elevationLayersChanged()
}
}

void GlobePlugin::reset()
{
if (mViewerWidget) {
delete mViewerWidget;
mViewerWidget = 0;
}
if (mOsgViewer) {
delete mOsgViewer;
mOsgViewer = 0;
}
}

void GlobePlugin::unload()
{
reset();
// remove the GUI
mQGisIface->removePluginMenu( "&Globe", mQActionPointer );
mQGisIface->removeToolBarIcon( mQActionPointer );
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/globe/globe_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class GlobePlugin : public QObject, public QgisPlugin
void run();
//! Show the settings dialog box
void settings();
//! Reset globe
void reset();
//! unload the plugin
void unload();
//! show the help document
Expand Down Expand Up @@ -87,7 +89,6 @@ class GlobePlugin : public QObject, public QgisPlugin
//! get elevation of user right click
double getSelectedElevation();


//! Place an OSG model on the globe
void placeNode( osg::Node* node, double lat, double lon, double alt = 0.0 );

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/globe/globe_plugin_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ void QgsGlobePluginDialog::resetElevationDatasources()

void QgsGlobePluginDialog::readElevationDatasources()
{
//showMessageBox("reading");
// clear the widget
elevationDatasourcesWidget->clearContents();
elevationDatasourcesWidget->setRowCount( 0 );
Expand All @@ -276,7 +275,7 @@ void QgsGlobePluginDialog::readElevationDatasources()
QgsProject::instance()->readEntry( "Globe-Plugin", "/elevationDatasources/L" + iNum + "/type" ) );
QTableWidgetItem *uri = new QTableWidgetItem(
QgsProject::instance()->readEntry( "Globe-Plugin", "/elevationDatasources/L" + iNum + "/uri" ) );
bool cache = QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/elevationDatasources/L" + iNum + "/cache" );
//bool cache = QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/elevationDatasources/L" + iNum + "/cache" );

elevationDatasourcesWidget->setRowCount( 1 + i );
elevationDatasourcesWidget->setItem( i, 0, type );
Expand Down

0 comments on commit a3097b4

Please sign in to comment.