Skip to content

Commit eb6ca1e

Browse files
committedNov 4, 2013
[globe] Add Anti-Aliasing option (Enabled by default)
1 parent c59cd92 commit eb6ca1e

File tree

5 files changed

+86
-2
lines changed

5 files changed

+86
-2
lines changed
 

‎src/plugins/globe/globe_plugin.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ void GlobePlugin::run()
234234
{
235235
if ( mViewerWidget == 0 )
236236
{
237+
QSettings settings;
238+
237239
#ifdef QGISDEBUG
238240
if ( !getenv( "OSGNOTIFYLEVEL" ) ) osgEarth::setNotifyLevel( osg::DEBUG_INFO );
239241
#endif
@@ -309,6 +311,21 @@ void GlobePlugin::run()
309311
mViewerWidget->setGeometry( 100, 100, 1024, 800 );
310312
mViewerWidget->show();
311313

314+
if ( settings.value( "/Plugin-Globe/anti-aliasing", true ).toBool() )
315+
{
316+
QGLFormat glf = QGLFormat::defaultFormat();
317+
glf.setSampleBuffers( true );
318+
bool aaLevelIsInt;
319+
int aaLevel;
320+
QString aaLevelStr = settings.value( "/Plugin-Globe/anti-aliasing-level", "" ).toString();
321+
aaLevel = aaLevelStr.toInt( &aaLevelIsInt );
322+
if ( aaLevelIsInt )
323+
{
324+
glf.setSamples( aaLevel );
325+
}
326+
mViewerWidget->setFormat( glf );
327+
}
328+
312329
// Set a home viewpoint
313330
manip->setHomeViewpoint(
314331
osgEarth::Util::Viewpoint( osg::Vec3d( -90, 0, 0 ), 0.0, -90.0, 4e7 ),

‎src/plugins/globe/globe_plugin.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class QAction;
5050
class QToolBar;
5151
class QgisInterface;
5252

53+
namespace osgEarth { namespace QtGui { class ViewerWidget; } }
5354

5455
class GlobePlugin : public QObject, public QgisPlugin
5556
{
@@ -129,7 +130,7 @@ class GlobePlugin : public QObject, public QgisPlugin
129130
//! OSG Viewer
130131
osgViewer::Viewer* mOsgViewer;
131132
//! QT viewer widget
132-
QWidget* mViewerWidget;
133+
osgEarth::QtGui::ViewerWidget* mViewerWidget;
133134
//! Settings Dialog
134135
QgsGlobePluginDialog *mSettingsDialog;
135136
//! OSG root node

‎src/plugins/globe/globe_plugin_dialog.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
4646
loadStereoConfig(); //values from settings, default values from OSG
4747
setStereoConfig(); //overwrite with values from QSettings
4848
updateStereoDialog(); //update the dialog gui
49+
loadVideoSettings();
4950

5051
elevationPath->setText( QDir::homePath() );
5152
}
@@ -126,6 +127,7 @@ void QgsGlobePluginDialog::on_buttonBox_accepted()
126127
saveStereoConfig();
127128

128129
saveElevationDatasources();
130+
saveVideoSettings();
129131
accept();
130132
}
131133

@@ -522,6 +524,19 @@ void QgsGlobePluginDialog::setStereoMode()
522524
}
523525
}
524526

527+
void QgsGlobePluginDialog::loadVideoSettings()
528+
{
529+
mAntiAliasingGroupBox->setChecked( settings.value( "/Plugin-Globe/anti-aliasing", true ).toBool() );
530+
mAANumSamples->setValidator( new QIntValidator( mAANumSamples ) );
531+
mAANumSamples->setText( settings.value( "/Plugin-Globe/anti-aliasing-level", "" ).toString() );
532+
}
533+
534+
void QgsGlobePluginDialog::saveVideoSettings()
535+
{
536+
settings.setValue( "/Plugin-Globe/anti-aliasing", mAntiAliasingGroupBox->isChecked() );
537+
settings.setValue( "/Plugin-Globe/anti-aliasing-level", mAANumSamples->text() );
538+
}
539+
525540
void QgsGlobePluginDialog::setStereoConfig()
526541
{
527542
if ( mViewer )

‎src/plugins/globe/globe_plugin_dialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class QgsGlobePluginDialog: public QDialog, private Ui::QgsGlobePluginDialogGuiB
5959
void saveStereoConfig();
6060
//! Handle stereoMode
6161
void setStereoMode();
62+
void loadVideoSettings();
63+
void saveVideoSettings();
6264

6365
private slots:
6466
void on_buttonBox_accepted();

‎src/plugins/globe/globe_plugin_dialog_guibase.ui

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<item row="0" column="0">
3737
<widget class="QTabWidget" name="tabWidget">
3838
<property name="currentIndex">
39-
<number>0</number>
39+
<number>2</number>
4040
</property>
4141
<widget class="QWidget" name="elevation">
4242
<attribute name="title">
@@ -296,6 +296,55 @@
296296
</item>
297297
</layout>
298298
</widget>
299+
<widget class="QWidget" name="video">
300+
<attribute name="title">
301+
<string>Video</string>
302+
</attribute>
303+
<layout class="QGridLayout" name="gridLayout_8">
304+
<item row="0" column="0">
305+
<widget class="QGroupBox" name="mAntiAliasingGroupBox">
306+
<property name="sizePolicy">
307+
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
308+
<horstretch>0</horstretch>
309+
<verstretch>0</verstretch>
310+
</sizepolicy>
311+
</property>
312+
<property name="title">
313+
<string>Anti Aliasing</string>
314+
</property>
315+
<property name="checkable">
316+
<bool>true</bool>
317+
</property>
318+
<layout class="QFormLayout" name="formLayout">
319+
<property name="fieldGrowthPolicy">
320+
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
321+
</property>
322+
<item row="0" column="0">
323+
<widget class="QLabel" name="label_3">
324+
<property name="text">
325+
<string>Samples</string>
326+
</property>
327+
</widget>
328+
</item>
329+
<item row="0" column="1">
330+
<widget class="QLineEdit" name="mAANumSamples">
331+
<property name="placeholderText">
332+
<string>[Leave empty for maximum]</string>
333+
</property>
334+
</widget>
335+
</item>
336+
</layout>
337+
</widget>
338+
</item>
339+
<item row="1" column="0">
340+
<widget class="QLabel" name="label_4">
341+
<property name="text">
342+
<string>&lt;i&gt;Changing video settings requires a restart of the globe plugin&lt;/i&gt;</string>
343+
</property>
344+
</widget>
345+
</item>
346+
</layout>
347+
</widget>
299348
<widget class="QWidget" name="model">
300349
<attribute name="title">
301350
<string>Model</string>

0 commit comments

Comments
 (0)
Please sign in to comment.