Skip to content

Commit

Permalink
[globe] Add Anti-Aliasing option (Enabled by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 4, 2013
1 parent c59cd92 commit eb6ca1e
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/plugins/globe/globe_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ void GlobePlugin::run()
{
if ( mViewerWidget == 0 )
{
QSettings settings;

#ifdef QGISDEBUG
if ( !getenv( "OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel( osg::DEBUG_INFO );
#endif
Expand Down Expand Up @@ -309,6 +311,21 @@ void GlobePlugin::run()
mViewerWidget->setGeometry( 100, 100, 1024, 800 );
mViewerWidget->show();

if ( settings.value( "/Plugin-Globe/anti-aliasing", true ).toBool() )
{
QGLFormat glf = QGLFormat::defaultFormat();
glf.setSampleBuffers( true );
bool aaLevelIsInt;
int aaLevel;
QString aaLevelStr = settings.value( "/Plugin-Globe/anti-aliasing-level", "" ).toString();
aaLevel = aaLevelStr.toInt( &aaLevelIsInt );
if ( aaLevelIsInt )
{
glf.setSamples( aaLevel );
}
mViewerWidget->setFormat( glf );
}

// Set a home viewpoint
manip->setHomeViewpoint(
osgEarth::Util::Viewpoint( osg::Vec3d( -90, 0, 0 ), 0.0, -90.0, 4e7 ),
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 @@ -50,6 +50,7 @@ class QAction;
class QToolBar;
class QgisInterface;

namespace osgEarth { namespace QtGui { class ViewerWidget; } }

class GlobePlugin : public QObject, public QgisPlugin
{
Expand Down Expand Up @@ -129,7 +130,7 @@ class GlobePlugin : public QObject, public QgisPlugin
//! OSG Viewer
osgViewer::Viewer* mOsgViewer;
//! QT viewer widget
QWidget* mViewerWidget;
osgEarth::QtGui::ViewerWidget* mViewerWidget;
//! Settings Dialog
QgsGlobePluginDialog *mSettingsDialog;
//! OSG root node
Expand Down
15 changes: 15 additions & 0 deletions src/plugins/globe/globe_plugin_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
loadStereoConfig(); //values from settings, default values from OSG
setStereoConfig(); //overwrite with values from QSettings
updateStereoDialog(); //update the dialog gui
loadVideoSettings();

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

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

Expand Down Expand Up @@ -522,6 +524,19 @@ void QgsGlobePluginDialog::setStereoMode()
}
}

void QgsGlobePluginDialog::loadVideoSettings()
{
mAntiAliasingGroupBox->setChecked( settings.value( "/Plugin-Globe/anti-aliasing", true ).toBool() );
mAANumSamples->setValidator( new QIntValidator( mAANumSamples ) );
mAANumSamples->setText( settings.value( "/Plugin-Globe/anti-aliasing-level", "" ).toString() );
}

void QgsGlobePluginDialog::saveVideoSettings()
{
settings.setValue( "/Plugin-Globe/anti-aliasing", mAntiAliasingGroupBox->isChecked() );
settings.setValue( "/Plugin-Globe/anti-aliasing-level", mAANumSamples->text() );
}

void QgsGlobePluginDialog::setStereoConfig()
{
if ( mViewer )
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/globe/globe_plugin_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class QgsGlobePluginDialog: public QDialog, private Ui::QgsGlobePluginDialogGuiB
void saveStereoConfig();
//! Handle stereoMode
void setStereoMode();
void loadVideoSettings();
void saveVideoSettings();

private slots:
void on_buttonBox_accepted();
Expand Down
51 changes: 50 additions & 1 deletion src/plugins/globe/globe_plugin_dialog_guibase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="elevation">
<attribute name="title">
Expand Down Expand Up @@ -296,6 +296,55 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="video">
<attribute name="title">
<string>Video</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QGroupBox" name="mAntiAliasingGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Anti Aliasing</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Samples</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mAANumSamples">
<property name="placeholderText">
<string>[Leave empty for maximum]</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;i&gt;Changing video settings requires a restart of the globe plugin&lt;/i&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="model">
<attribute name="title">
<string>Model</string>
Expand Down

0 comments on commit eb6ca1e

Please sign in to comment.