Skip to content
Permalink
Browse files

refactoring

TODO: Call QgsGLWidgetAdapter::setStereoMode(QString stereoMode) from GlobePlugin::settings() instead of code duplication in GlobePluginDialog::setStereoMode()
  • Loading branch information
Marco Bernasocchi authored and pka committed Nov 18, 2010
1 parent 4e3e0e1 commit 2e214cbed28ec77252788d3f5c2a0c68367878c9
@@ -22,6 +22,7 @@
#include "../qgisplugin.h"
#include "qgsosgviewer.h"
#include "qgsosgearthtilesource.h"
#include "globe_plugin_dialog.h"
#include "Controls"
#include <QObject>
#include <QDockWidget>
@@ -105,9 +106,10 @@ class GlobePlugin : public QObject, public QgisPlugin
osgEarthUtil::ElevationManager* mElevationManager;
//! Object placer
osgEarthUtil::ObjectPlacer* mObjectPlacer;
//! Settings Dialog
QgsGlobePluginDialog* settingsDialog;
};


class FlyToExtentHandler : public osgGA::GUIEventHandler
{
public:
@@ -28,11 +28,11 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
Q_OBJECT

public:
QString stereoMode;
QgsGlobePluginDialog( QWidget * parent = 0, Qt::WFlags fl = 0 );
~QgsGlobePluginDialog();

private:
QString stereoMode;
QString earthFile;
QString openFile();
QSettings settings;
@@ -21,12 +21,14 @@
#include <osgViewer/ViewerEventHandlers>

#include <QString>
#include <QMessageBox>


QgsGLWidgetAdapter::QgsGLWidgetAdapter( QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f):
QGLWidget(parent, shareWidget, f)
{
_gw = new osgViewer::GraphicsWindowEmbedded(0,0,width(),height());
setStereoMode();
//setStereoMode();
setFocusPolicy(Qt::ClickFocus);
setMouseTracking ( true );
}
@@ -87,13 +89,12 @@ void QgsGLWidgetAdapter::wheelEvent(QWheelEvent *event)

void QgsGLWidgetAdapter::setStereoMode()
{
//TODO: maybe consolidate this method somewhere else since it is repeated in globe_plugin_dialog.cpp

//osg::DisplaySettings::instance()->setStereo( (bool) settings.value( "/Plugin-Globe/stereo", 0 ).toInt() );
//osg::DisplaySettings::instance()->setStereoMode( (osg::DisplaySettings::StereoMode) settings.value( "/Plugin-Globe/stereoMode", 1 ).toInt());

QString stereoMode;
stereoMode = settings.value( "/Plugin-Globe/stereoMode", "OFF" ).toString();
setStereoMode(settings.value( "/Plugin-Globe/stereoMode", "OFF" ).toString());
}

void QgsGLWidgetAdapter::setStereoMode(QString stereoMode)
{
settings.setValue( "/Plugin-Globe/stereoMode", stereoMode );

if("OFF" == stereoMode)
{
@@ -115,9 +116,20 @@ void QgsGLWidgetAdapter::setStereoMode()
{
osg::DisplaySettings::instance()->setStereoMode( osg::DisplaySettings::VERTICAL_SPLIT );
}
else if("HORIZONTAL_SPLIT" == stereoMode)
{
osg::DisplaySettings::instance()->setStereoMode( osg::DisplaySettings::HORIZONTAL_SPLIT );
}
else if("QUAD_BUFFER" == stereoMode)
{
osg::DisplaySettings::instance()->setStereoMode( osg::DisplaySettings::QUAD_BUFFER );
}
else
{
//should never get here
QMessageBox msgBox;
msgBox.setText("This stereo mode has not been implemented yet. Defaulting to ANAGLYPHIC");
msgBox.exec();
}
}
}
@@ -39,6 +39,9 @@ class QgsGLWidgetAdapter : public QGLWidget

osgViewer::GraphicsWindow* getGraphicsWindow() { return _gw.get(); }
const osgViewer::GraphicsWindow* getGraphicsWindow() const { return _gw.get(); }

void setStereoMode();
void setStereoMode(QString stereoMode);

protected:

@@ -56,7 +59,6 @@ class QgsGLWidgetAdapter : public QGLWidget
private:

QSettings settings;
void setStereoMode();
};


@@ -76,7 +78,7 @@ class QgsOsgViewer : public osgViewer::Viewer, public QgsGLWidgetAdapter
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
_timer.start(10);
}

virtual void paintGL()
{
frame();

0 comments on commit 2e214cb

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