78 changes: 74 additions & 4 deletions src/plugins/globe/globe_plugin_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,24 @@
#include <osg/DisplaySettings>

//constructor
QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
QgsGlobePluginDialog::QgsGlobePluginDialog(QWidget* parent, GlobePlugin* globe, Qt::WFlags fl )
: QDialog( parent, fl )
, mViewer( 0 )
, mGlobe( globe )
{
setupUi( this );

mBaseLayerComboBox->addItem( "Readymap: NASA BlueMarble Imagery", "http://readymap.org/readymap/tiles/1.0.0/1/" );
mBaseLayerComboBox->addItem( "Readymap: NASA BlueMarble with land removed, only ocean", "http://readymap.org/readymap/tiles/1.0.0/2/" );
mBaseLayerComboBox->addItem( "Readymap: High resolution insets from various locations around the world Austin, TX; Kandahar, Afghanistan; Bagram, Afghanistan; Boston, MA; Washington, DC", "http://readymap.org/readymap/tiles/1.0.0/3/" );
mBaseLayerComboBox->addItem( "Readymap: Global Land Cover Facility 15m Landsat", "http://readymap.org/readymap/tiles/1.0.0/6/" );
mBaseLayerComboBox->addItem( "Readymap: NASA BlueMarble + Landsat + Ocean Masking Layer", "http://readymap.org/readymap/tiles/1.0.0/7/" );
mBaseLayerComboBox->addItem( "[Custom]" );

loadStereoConfig(); //values from settings, default values from OSG
setStereoConfig(); //overwrite with values from QSettings
updateStereoDialog(); //update the dialog gui
loadVideoSettings();
loadMapSettings();

elevationPath->setText( QDir::homePath() );
}
Expand Down Expand Up @@ -128,6 +137,7 @@ void QgsGlobePluginDialog::on_buttonBox_accepted()

saveElevationDatasources();
saveVideoSettings();
saveMapSettings();
accept();
}

Expand Down Expand Up @@ -212,6 +222,20 @@ void QgsGlobePluginDialog::on_elevationDown_clicked()
moveRow( elevationDatasourcesWidget, false );
}

void QgsGlobePluginDialog::on_mBaseLayerComboBox_currentIndexChanged( int index )
{
QVariant url = mBaseLayerComboBox->itemData( index );
if ( url.isValid() )
{
mBaseLayerURL->setEnabled( false );
mBaseLayerURL->setText( url.toString() );
}
else
{
mBaseLayerURL->setEnabled( true );
}
}

void QgsGlobePluginDialog::moveRow( QTableWidget* widget, bool up )
{
//moves QTableWidget row up or down
Expand Down Expand Up @@ -537,11 +561,57 @@ void QgsGlobePluginDialog::saveVideoSettings()
settings.setValue( "/Plugin-Globe/anti-aliasing-level", mAANumSamples->text() );
}

void QgsGlobePluginDialog::loadMapSettings()
{
mBaseLayerGroupBox->setChecked( settings.value( "/Plugin-Globe/baseLayerEnabled", true ).toBool() );
QString mapUrl = settings.value( "/Plugin-Globe/baseLayerURL", "http://readymap.org/readymap/tiles/1.0.0/7/" ).toString();
int urlIndex = mBaseLayerComboBox->findData( mapUrl );

if ( urlIndex != -1 )
{
mBaseLayerComboBox->setCurrentIndex( urlIndex );
}
else
{
mBaseLayerComboBox->setCurrentIndex( mBaseLayerComboBox->findData( QVariant() ) );
}

mBaseLayerURL->setText( mapUrl );

mSkyGroupBox->setChecked( settings.value( "/Plugin-Globe/skyEnabled", false ).toBool() );
mSkyAutoAmbient->setChecked( settings.value( "/Plugin-Globe/skyAutoAmbient", false ).toBool() );
mSkyDateTime->setDateTime( settings.value( "/Plugin-Globe/skyDateTime", QDateTime() ).toDateTime() );
}

void QgsGlobePluginDialog::saveMapSettings()
{
settings.setValue( "/Plugin-Globe/baseLayerEnabled", mBaseLayerGroupBox->isChecked() );
settings.setValue( "/Plugin-Globe/baseLayerURL", mBaseLayerURL->text() );

// Let globe update the current view
if ( mBaseLayerGroupBox->isChecked() )
{
mGlobe->setBaseMap( mBaseLayerURL->text() );
}
else
{
mGlobe->setBaseMap( QString::null );
}

settings.setValue( "/Plugin-Globe/skyEnabled", mSkyGroupBox->isChecked() );
settings.setValue( "/Plugin-Globe/skyAutoAmbient", mSkyAutoAmbient->isChecked() );
settings.setValue( "/Plugin-Globe/skyDateTime", mSkyDateTime->dateTime() );

// Adjust sky of a running globe viewer
mGlobe->setSkyParameters( mSkyGroupBox->isChecked(), mSkyDateTime->dateTime(), mSkyAutoAmbient->isChecked() );
}

void QgsGlobePluginDialog::setStereoConfig()
{
if ( mViewer )
osgViewer::Viewer* viewer = mGlobe->osgViewer();
if ( viewer )
{
mViewer->getDatabasePager()->clear();
viewer->getDatabasePager()->clear();
//SETTING THE VALUES IN THE OEGearth instance
setStereoMode();
osg::DisplaySettings::instance()->setScreenDistance( screenDistance->value() );
Expand Down
18 changes: 13 additions & 5 deletions src/plugins/globe/globe_plugin_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,22 @@
#include <qgsproject.h>
#include <qgsvectorlayer.h>

class GlobePlugin;

class QgsGlobePluginDialog: public QDialog, private Ui::QgsGlobePluginDialogGuiBase
{
Q_OBJECT

public:
QgsGlobePluginDialog( QWidget * parent = 0, Qt::WFlags fl = 0 );
QgsGlobePluginDialog( QWidget * parent, GlobePlugin* globe, Qt::WFlags fl = 0 );
~QgsGlobePluginDialog();
void setViewer( osgViewer::Viewer* viewer ) { mViewer = viewer; }
void resetElevationDatasources();
void readElevationDatasources();
QTableWidget *elevationDatasources() { return elevationDatasourcesWidget; }
void updatePointLayers();
QgsVectorLayer* modelLayer();
QString modelPath() { return modelPathLineEdit->text(); }
private:
osgViewer::Viewer* mViewer;
QSettings settings;

private:
QString openRasterFile();
void updateStereoDialog();
Expand All @@ -61,6 +60,8 @@ class QgsGlobePluginDialog: public QDialog, private Ui::QgsGlobePluginDialogGuiB
void setStereoMode();
void loadVideoSettings();
void saveVideoSettings();
void loadMapSettings();
void saveMapSettings();

private slots:
void on_buttonBox_accepted();
Expand Down Expand Up @@ -89,8 +90,15 @@ class QgsGlobePluginDialog: public QDialog, private Ui::QgsGlobePluginDialogGuiB
void on_elevationUp_clicked();
void on_elevationDown_clicked();

//MAP
void on_mBaseLayerComboBox_currentIndexChanged( int index );

signals:
void elevationDatasourcesChanged();

private:
GlobePlugin* mGlobe;
QSettings settings;
};

#endif // QGIS_GLOBE_PLUGIN_DIALOG_H
79 changes: 77 additions & 2 deletions src/plugins/globe/globe_plugin_dialog_guibase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>593</width>
<width>1407</width>
<height>534</height>
</rect>
</property>
Expand All @@ -36,8 +36,83 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Map</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="mBaseLayerGroupBox">
<property name="title">
<string>Base Layer</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="mBaseLayerComboBox"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mBaseLayerURL"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="mSkyGroupBox">
<property name="title">
<string>Sky</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Date / Time (UTC)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDateTimeEdit" name="mSkyDateTime">
<property name="displayFormat">
<string>dd.MM.yyyy HH:mm</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="mSkyAutoAmbient">
<property name="text">
<string>Auto ambient</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="elevation">
<attribute name="title">
<string>Elevation</string>
Expand Down
10 changes: 4 additions & 6 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,13 +1019,13 @@ void QgsWmsProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, in
Q_UNUSED( bandNo );
QgsDebugMsg( "Entered" );
// TODO: optimize to avoid writing to QImage
QImage* image = draw( viewExtent, pixelWidth, pixelHeight );

if ( ! image ) // should not happen
QImage *image = draw( viewExtent, pixelWidth, pixelHeight );
if ( !image ) // should not happen
{
QgsMessageLog::logMessage( tr( "image is NULL" ), tr( "WMS" ) );
return;
}

QgsDebugMsg( QString( "image height = %1 bytesPerLine = %2" ).arg( image->height() ) . arg( image->bytesPerLine() ) ) ;
size_t myExpectedSize = pixelWidth * pixelHeight * 4;
size_t myImageSize = image->height() * image->bytesPerLine();
Expand Down Expand Up @@ -4785,9 +4785,7 @@ void QgsWmsProvider::getLegendGraphicReplyFinished()
}
else
{
mErrorFormat = "text/plain";
mError = tr( "Download of GetLegendGraphic failed: %1" ).arg( mGetLegendGraphicReply->errorString() );
QgsMessageLog::logMessage( mError, tr( "WMS" ) );
QgsMessageLog::logMessage( tr( "Download of GetLegendGraphic failed: %1" ).arg( mGetLegendGraphicReply->errorString() ), tr( "WMS" ) );
mHttpGetLegendGraphicResponse.clear();
}

Expand Down