Skip to content
Permalink
Browse files

[globe] Add Anti-Aliasing option (Enabled by default)

  • Loading branch information
m-kuhn committed Nov 4, 2013
1 parent c59cd92 commit eb6ca1e0986d2529fa61d2a92913d1382e34191b
@@ -234,6 +234,8 @@ void GlobePlugin::run()
{
if ( mViewerWidget == 0 )
{
QSettings settings;

#ifdef QGISDEBUG
if ( !getenv( "OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel( osg::DEBUG_INFO );
#endif
@@ -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 ),
@@ -50,6 +50,7 @@ class QAction;
class QToolBar;
class QgisInterface;

namespace osgEarth { namespace QtGui { class ViewerWidget; } }

class GlobePlugin : public QObject, public QgisPlugin
{
@@ -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
@@ -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() );
}
@@ -126,6 +127,7 @@ void QgsGlobePluginDialog::on_buttonBox_accepted()
saveStereoConfig();

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

@@ -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 )
@@ -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();
@@ -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">
@@ -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>

0 comments on commit eb6ca1e

Please sign in to comment.
You can’t perform that action at this time.