267 changes: 135 additions & 132 deletions src/plugins/globe/globe_plugin_dialog.cpp

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/plugins/globe/globe_plugin_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#include <qgsproject.h>
#include <qgsvectorlayer.h>

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

public:
QgsGlobePluginDialog( QgsOsgViewer* viewer, QWidget * parent = 0, Qt::WFlags fl = 0 );
Expand All @@ -45,12 +45,12 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
private:
QString openRasterFile();
void updateStereoDialog();
bool validateResource( QString type, QString uri, QString& error);
bool validateResource( QString type, QString uri, QString& error );
void saveElevationDatasources();
void moveRow( QTableWidget* widget, bool up);
QList<QTableWidgetItem*> takeRow( QTableWidget* widget, int row);
void setRow( QTableWidget* widget, int row, const QList< QTableWidgetItem* >& rowItems);
void showMessageBox( QString text);
void moveRow( QTableWidget* widget, bool up );
QList<QTableWidgetItem*> takeRow( QTableWidget* widget, int row );
void setRow( QTableWidget* widget, int row, const QList< QTableWidgetItem* >& rowItems );
void showMessageBox( QString text );
QList<QgsVectorLayer*> pointLayers();
//! Set osg/DisplaySettings
void setStereoConfig();
Expand All @@ -66,22 +66,22 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
void on_buttonBox_rejected();

//STEREO
void on_comboStereoMode_currentIndexChanged(QString value);
void on_eyeSeparation_valueChanged(double value);
void on_screenDistance_valueChanged(double value);
void on_screenWidth_valueChanged(double value);
void on_screenHeight_valueChanged(double value);
void on_splitStereoHorizontalSeparation_valueChanged(int value);
void on_splitStereoVerticalSeparation_valueChanged(int value);
void on_splitStereoHorizontalEyeMapping_currentIndexChanged(int value);
void on_splitStereoVerticalEyeMapping_currentIndexChanged(int value);
void on_comboStereoMode_currentIndexChanged( QString value );
void on_eyeSeparation_valueChanged( double value );
void on_screenDistance_valueChanged( double value );
void on_screenWidth_valueChanged( double value );
void on_screenHeight_valueChanged( double value );
void on_splitStereoHorizontalSeparation_valueChanged( int value );
void on_splitStereoVerticalSeparation_valueChanged( int value );
void on_splitStereoHorizontalEyeMapping_currentIndexChanged( int value );
void on_splitStereoVerticalEyeMapping_currentIndexChanged( int value );
void on_resetStereoDefaults_clicked();

//MODEL
void on_modelBrowse_clicked();

//ELEVATION
void on_elevationCombo_currentIndexChanged(QString type);
void on_elevationCombo_currentIndexChanged( QString type );
void on_elevationBrowse_clicked();
void on_elevationAdd_clicked();
void on_elevationRemove_clicked();
Expand All @@ -92,4 +92,4 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
void elevationDatasourcesChanged();
};

#endif // QGIS_GLOBE_PLUGIN_DIALOG_H
#endif // QGIS_GLOBE_PLUGIN_DIALOG_H
166 changes: 83 additions & 83 deletions src/plugins/globe/qgsosgearthtilesource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,96 +30,96 @@ using namespace osgEarth;
using namespace osgEarth::Drivers;


QgsOsgEarthTileSource::QgsOsgEarthTileSource( QgisInterface* theQgisInterface, const TileSourceOptions& options ) : TileSource(options), mQGisIface(theQgisInterface), mCoordTranform(0)
QgsOsgEarthTileSource::QgsOsgEarthTileSource( QgisInterface* theQgisInterface, const TileSourceOptions& options ) : TileSource( options ), mQGisIface( theQgisInterface ), mCoordTranform( 0 )
{
}

void QgsOsgEarthTileSource::initialize( const std::string& referenceURI, const Profile* overrideProfile )
{
setProfile( osgEarth::Registry::instance()->getGlobalGeodeticProfile() );
QgsMapRenderer* mainRenderer = mQGisIface->mapCanvas()->mapRenderer();
mMapRenderer = new QgsMapRenderer();
setProfile( osgEarth::Registry::instance()->getGlobalGeodeticProfile() );
QgsMapRenderer* mainRenderer = mQGisIface->mapCanvas()->mapRenderer();
mMapRenderer = new QgsMapRenderer();

long epsgGlobe = 4326;
if (mainRenderer->destinationSrs().epsg() != epsgGlobe)
{
QgsCoordinateReferenceSystem srcCRS;
srcCRS.createFromEpsg(mainRenderer->destinationSrs().epsg()); //FIXME: crs from canvas or first layer?
QgsCoordinateReferenceSystem destCRS;
destCRS.createFromEpsg(epsgGlobe);
//QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectionsEnabled",1);
mMapRenderer->setDestinationSrs(destCRS);
mMapRenderer->setProjectionsEnabled(true);
mCoordTranform = new QgsCoordinateTransform( srcCRS, destCRS );
}
mMapRenderer->setOutputUnits(mainRenderer->outputUnits());
mMapRenderer->setMapUnits( QGis::Degrees );
long epsgGlobe = 4326;
if ( mainRenderer->destinationSrs().epsg() != epsgGlobe )
{
QgsCoordinateReferenceSystem srcCRS;
srcCRS.createFromEpsg( mainRenderer->destinationSrs().epsg() ); //FIXME: crs from canvas or first layer?
QgsCoordinateReferenceSystem destCRS;
destCRS.createFromEpsg( epsgGlobe );
//QgsProject::instance()->writeEntry("SpatialRefSys","/ProjectionsEnabled",1);
mMapRenderer->setDestinationSrs( destCRS );
mMapRenderer->setProjectionsEnabled( true );
mCoordTranform = new QgsCoordinateTransform( srcCRS, destCRS );
}
mMapRenderer->setOutputUnits( mainRenderer->outputUnits() );
mMapRenderer->setMapUnits( QGis::Degrees );

mMapRenderer->setLabelingEngine( new QgsPalLabeling() );
mMapRenderer->setLabelingEngine( new QgsPalLabeling() );
}

osg::Image* QgsOsgEarthTileSource::createImage( const TileKey& key, ProgressCallback* progress )
{
osg::ref_ptr<osg::Image> image;
if (intersects(&key))
osg::ref_ptr<osg::Image> image;
if ( intersects( &key ) )
{
//Get the extents of the tile
double xmin, ymin, xmax, ymax;
key.getExtent().getBounds( xmin, ymin, xmax, ymax );

int tileSize = getPixelsPerTile();
int target_width = tileSize;
int target_height = tileSize;

QgsDebugMsg( "QGIS: xmin:" + QString::number( xmin ) + " ymin:" + QString::number( ymin ) + " ymax:" + QString::number( ymax ) + " ymax " + QString::number( ymax ) );

//Return if parameters are out of range.
if ( target_width <= 0 || target_height <= 0 )
{
//Get the extents of the tile
double xmin, ymin, xmax, ymax;
key.getExtent().getBounds(xmin, ymin, xmax, ymax);

int tileSize = getPixelsPerTile();
int target_width = tileSize;
int target_height = tileSize;

QgsDebugMsg("QGIS: xmin:" + QString::number(xmin) + " ymin:" + QString::number(ymin) + " ymax:" + QString::number(ymax) + " ymax " + QString::number(ymax));

//Return if parameters are out of range.
if (target_width <= 0 || target_height <= 0)
{
return 0;
}

QImage* qImage = createImage(target_width, target_height);
if(!qImage)
{
return 0;
}

QgsMapRenderer* mainRenderer = mQGisIface->mapCanvas()->mapRenderer();
mMapRenderer->setLayerSet(mainRenderer->layerSet());

mMapRenderer->setOutputSize(QSize(qImage->width(), qImage->height()), qImage->logicalDpiX());

QgsRectangle mapExtent(xmin, ymin, xmax, ymax);
mMapRenderer->setExtent(mapExtent);

QPainter thePainter(qImage);
//thePainter.setRenderHint(QPainter::Antialiasing); //make it look nicer
mMapRenderer->render(&thePainter);

unsigned char* data = qImage->bits();

image = new osg::Image;
//The pixel format is always RGBA to support transparency
image->setImage(qImage->width(), qImage->height(), 1,
4,
GL_BGRA,GL_UNSIGNED_BYTE, //Why not GL_RGBA - QGIS bug?
data,
osg::Image::NO_DELETE, 1);
image->flipVertical();
return 0;
}

//Create a transparent image if we don't have an image
if (!image.valid())
QImage* qImage = createImage( target_width, target_height );
if ( !qImage )
{
return ImageUtils::createEmptyImage();
return 0;
}
return image.release();

QgsMapRenderer* mainRenderer = mQGisIface->mapCanvas()->mapRenderer();
mMapRenderer->setLayerSet( mainRenderer->layerSet() );

mMapRenderer->setOutputSize( QSize( qImage->width(), qImage->height() ), qImage->logicalDpiX() );

QgsRectangle mapExtent( xmin, ymin, xmax, ymax );
mMapRenderer->setExtent( mapExtent );

QPainter thePainter( qImage );
//thePainter.setRenderHint(QPainter::Antialiasing); //make it look nicer
mMapRenderer->render( &thePainter );

unsigned char* data = qImage->bits();

image = new osg::Image;
//The pixel format is always RGBA to support transparency
image->setImage( qImage->width(), qImage->height(), 1,
4,
GL_BGRA, GL_UNSIGNED_BYTE, //Why not GL_RGBA - QGIS bug?
data,
osg::Image::NO_DELETE, 1 );
image->flipVertical();
}

//Create a transparent image if we don't have an image
if ( !image.valid() )
{
return ImageUtils::createEmptyImage();
}
return image.release();
}

QImage* QgsOsgEarthTileSource::createImage( int width, int height ) const
{
if( width < 0 || height < 0 )
if ( width < 0 || height < 0 )
{
return 0;
}
Expand All @@ -132,21 +132,21 @@ QImage* QgsOsgEarthTileSource::createImage( int width, int height ) const
bool transparent = true;

//use alpha channel only if necessary because it slows down performance
if( transparent && !jpeg )
if ( transparent && !jpeg )
{
qImage = new QImage( width, height, QImage::Format_ARGB32_Premultiplied );
qImage->fill( 0 );
}
else
{
qImage = new QImage( width, height, QImage::Format_RGB32 );
qImage->fill( qRgb(255, 255, 255) );
qImage->fill( qRgb( 255, 255, 255 ) );
}

if(!qImage)
{
return 0;
}
if ( !qImage )
{
return 0;
}

//apply DPI parameter if present.
/*
Expand All @@ -157,12 +157,12 @@ QImage* QgsOsgEarthTileSource::createImage( int width, int height ) const
return qImage;
}

bool QgsOsgEarthTileSource::intersects(const TileKey* key)
bool QgsOsgEarthTileSource::intersects( const TileKey* key )
{
//Get the native extents of the tile
double xmin, ymin, xmax, ymax;
key->getExtent().getBounds(xmin, ymin, xmax, ymax);
QgsRectangle extent = mQGisIface->mapCanvas()->fullExtent();
if (mCoordTranform) extent = mCoordTranform->transformBoundingBox(extent);
return ! ( xmin >= extent.xMaximum() || xmax <= extent.xMinimum() || ymin >= extent.yMaximum() || ymax <= extent.yMinimum() );
//Get the native extents of the tile
double xmin, ymin, xmax, ymax;
key->getExtent().getBounds( xmin, ymin, xmax, ymax );
QgsRectangle extent = mQGisIface->mapCanvas()->fullExtent();
if ( mCoordTranform ) extent = mCoordTranform->transformBoundingBox( extent );
return !( xmin >= extent.xMaximum() || xmax <= extent.xMinimum() || ymin >= extent.yMaximum() || ymax <= extent.yMinimum() );
}
39 changes: 21 additions & 18 deletions src/plugins/globe/qgsosgearthtilesource.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,51 @@ class QgisInterface;

using namespace osgEarth;

namespace osgEarth { namespace Drivers
namespace osgEarth
{
namespace Drivers
{
class QgsOsgEarthTileSource : public TileSource
{
public:
QgsOsgEarthTileSource( QgisInterface* theQgisInterface, const TileSourceOptions& options =TileSourceOptions() );
public:
QgsOsgEarthTileSource( QgisInterface* theQgisInterface, const TileSourceOptions& options = TileSourceOptions() );

void initialize( const std::string& referenceURI, const Profile* overrideProfile = NULL );

osg::Image* createImage( const TileKey& key, ProgressCallback* progress );

osg::HeightField* createHeightField( const TileKey* key,
ProgressCallback* progress)
ProgressCallback* progress )
{
//NI
OE_WARN << "[QGIS] Driver does not support heightfields" << std::endl;
return NULL;
//NI
OE_WARN << "[QGIS] Driver does not support heightfields" << std::endl;
return NULL;
}

virtual std::string getExtension() const
{
//All QGIS tiles are in JPEG format
return "jpg";
//All QGIS tiles are in JPEG format
return "jpg";
}

virtual bool supportsPersistentCaching() const
{
return false;
return false;
}

private:
private:

QImage* createImage( int width, int height ) const;
bool intersects(const TileKey* key);
QImage* createImage( int width, int height ) const;
bool intersects( const TileKey* key );

//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
QgsCoordinateTransform *mCoordTranform;
QgsMapRenderer* mMapRenderer;
//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
QgsCoordinateTransform *mCoordTranform;
QgsMapRenderer* mMapRenderer;

};
} } // namespace osgEarth::Drivers
}
} // namespace osgEarth::Drivers

#endif // OSGEARTH_DRIVER_QGIS_DRIVEROPTIONS

88 changes: 44 additions & 44 deletions src/plugins/globe/qgsosgviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,94 +23,94 @@
#include <QString>
#include <QMessageBox>

QDockWidgetGlobe::QDockWidgetGlobe(const QString &title, QWidget *parent, Qt::WindowFlags flags):
QDockWidget(title, parent, flags)
QDockWidgetGlobe::QDockWidgetGlobe( const QString &title, QWidget *parent, Qt::WindowFlags flags ):
QDockWidget( title, parent, flags )
{
};

QDockWidgetGlobe::QDockWidgetGlobe(QWidget *parent, Qt::WindowFlags flags):
QDockWidget(parent, flags)
QDockWidgetGlobe::QDockWidgetGlobe( QWidget *parent, Qt::WindowFlags flags ):
QDockWidget( parent, flags )
{
};

//reimplement the close event to emit a signal
void QDockWidgetGlobe::closeEvent(QCloseEvent* event)
void QDockWidgetGlobe::closeEvent( QCloseEvent* event )
{
emit globeClosed();
event->accept();
}

QgsGLWidgetAdapter::QgsGLWidgetAdapter( QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f):
QGLWidget(parent, shareWidget, f)
QgsGLWidgetAdapter::QgsGLWidgetAdapter( QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f ):
QGLWidget( parent, shareWidget, f )
{
_gw = new osgViewer::GraphicsWindowEmbedded(0,0,width(),height());
setFocusPolicy(Qt::ClickFocus);
setMouseTracking ( true );
_gw = new osgViewer::GraphicsWindowEmbedded( 0, 0, width(), height() );
setFocusPolicy( Qt::ClickFocus );
setMouseTracking( true );
}

void QgsGLWidgetAdapter::resizeGL( int width, int height )
{
_gw->getEventQueue()->windowResize(0, 0, width, height );
_gw->resized(0,0,width,height);
_gw->getEventQueue()->windowResize( 0, 0, width, height );
_gw->resized( 0, 0, width, height );
}

void QgsGLWidgetAdapter::keyPressEvent( QKeyEvent* event )
{
_gw->getEventQueue()->keyPress( (osgGA::GUIEventAdapter::KeySymbol) *(event->text().toAscii().data() ) );
_gw->getEventQueue()->keyPress(( osgGA::GUIEventAdapter::KeySymbol ) *( event->text().toAscii().data() ) );
}

void QgsGLWidgetAdapter::keyReleaseEvent( QKeyEvent* event )
{
_gw->getEventQueue()->keyRelease( (osgGA::GUIEventAdapter::KeySymbol) *(event->text().toAscii().data() ) );
_gw->getEventQueue()->keyRelease(( osgGA::GUIEventAdapter::KeySymbol ) *( event->text().toAscii().data() ) );
}

void QgsGLWidgetAdapter::mousePressEvent( QMouseEvent* event )
{
adaptModifiers( event );
int button = 0;
switch(event->button())
{
case(Qt::LeftButton): button = 1; break;
case(Qt::MidButton): button = 2; break;
case(Qt::RightButton): button = 3; break;
case(Qt::NoButton): button = 0; break;
default: button = 0; break;
}
_gw->getEventQueue()->mouseButtonPress(event->x(), event->y(), button);
adaptModifiers( event );
int button = 0;
switch ( event->button() )
{
case( Qt::LeftButton ): button = 1; break;
case( Qt::MidButton ): button = 2; break;
case( Qt::RightButton ): button = 3; break;
case( Qt::NoButton ): button = 0; break;
default: button = 0; break;
}
_gw->getEventQueue()->mouseButtonPress( event->x(), event->y(), button );
}

void QgsGLWidgetAdapter::adaptModifiers( QInputEvent* event )
{
int modkey = event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier);
int modkey = event->modifiers() & ( Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier );

unsigned int modkeyosg = 0;
if (modkey & Qt::ShiftModifier) modkeyosg |= osgGA::GUIEventAdapter::MODKEY_SHIFT;
if (modkey & Qt::ControlModifier) modkeyosg |= osgGA::GUIEventAdapter::MODKEY_CTRL;
if (modkey & Qt::AltModifier) modkeyosg |= osgGA::GUIEventAdapter::MODKEY_ALT;
unsigned int modkeyosg = 0;
if ( modkey & Qt::ShiftModifier ) modkeyosg |= osgGA::GUIEventAdapter::MODKEY_SHIFT;
if ( modkey & Qt::ControlModifier ) modkeyosg |= osgGA::GUIEventAdapter::MODKEY_CTRL;
if ( modkey & Qt::AltModifier ) modkeyosg |= osgGA::GUIEventAdapter::MODKEY_ALT;

_gw->getEventQueue()->getCurrentEventState()->setModKeyMask( modkeyosg );
_gw->getEventQueue()->getCurrentEventState()->setModKeyMask( modkeyosg );
}

void QgsGLWidgetAdapter::mouseReleaseEvent( QMouseEvent* event )
{
int button = 0;
switch(event->button())
{
case(Qt::LeftButton): button = 1; break;
case(Qt::MidButton): button = 2; break;
case(Qt::RightButton): button = 3; break;
case(Qt::NoButton): button = 0; break;
default: button = 0; break;
}
_gw->getEventQueue()->mouseButtonRelease(event->x(), event->y(), button);
int button = 0;
switch ( event->button() )
{
case( Qt::LeftButton ): button = 1; break;
case( Qt::MidButton ): button = 2; break;
case( Qt::RightButton ): button = 3; break;
case( Qt::NoButton ): button = 0; break;
default: button = 0; break;
}
_gw->getEventQueue()->mouseButtonRelease( event->x(), event->y(), button );
}

void QgsGLWidgetAdapter::mouseMoveEvent( QMouseEvent* event )
{
_gw->getEventQueue()->mouseMotion(event->x(), event->y());
_gw->getEventQueue()->mouseMotion( event->x(), event->y() );
}

void QgsGLWidgetAdapter::wheelEvent(QWheelEvent *event)
void QgsGLWidgetAdapter::wheelEvent( QWheelEvent *event )
{
_gw->getEventQueue()->mouseScroll((event->delta()>0) ? osgGA::GUIEventAdapter::SCROLL_DOWN : osgGA::GUIEventAdapter::SCROLL_UP);
_gw->getEventQueue()->mouseScroll(( event->delta() > 0 ) ? osgGA::GUIEventAdapter::SCROLL_DOWN : osgGA::GUIEventAdapter::SCROLL_UP );
}
88 changes: 44 additions & 44 deletions src/plugins/globe/qgsosgviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,78 +30,78 @@ using Qt::WindowFlags;

class QDockWidgetGlobe : public QDockWidget
{
Q_OBJECT
Q_OBJECT

public:
QDockWidgetGlobe(const QString& title, QWidget* parent = 0, WindowFlags flags = 0);
QDockWidgetGlobe(QWidget *parent = 0, Qt::WindowFlags flags = 0);
public:
QDockWidgetGlobe( const QString& title, QWidget* parent = 0, WindowFlags flags = 0 );
QDockWidgetGlobe( QWidget *parent = 0, Qt::WindowFlags flags = 0 );

virtual ~QDockWidgetGlobe() {}
virtual ~QDockWidgetGlobe() {}

protected:
virtual void closeEvent(QCloseEvent *event);
protected:
virtual void closeEvent( QCloseEvent *event );

signals:
void globeClosed();
signals:
void globeClosed();
};


class QgsGLWidgetAdapter : public QGLWidget
{
Q_OBJECT
public:
Q_OBJECT
public:

QgsGLWidgetAdapter( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0 );
QgsGLWidgetAdapter( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0 );

virtual ~QgsGLWidgetAdapter() {}
virtual ~QgsGLWidgetAdapter() {}

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

protected:
protected:

void init();
virtual void resizeGL( int width, int height );
virtual void keyPressEvent( QKeyEvent* event );
virtual void keyReleaseEvent( QKeyEvent* event );
//! converts QT modifiers key to OSG modifiers key
virtual void adaptModifiers( QInputEvent* event );
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseReleaseEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent * event );
void init();
virtual void resizeGL( int width, int height );
virtual void keyPressEvent( QKeyEvent* event );
virtual void keyReleaseEvent( QKeyEvent* event );
//! converts QT modifiers key to OSG modifiers key
virtual void adaptModifiers( QInputEvent* event );
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseReleaseEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent * event );

osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;


};


class QgsOsgViewer : public osgViewer::Viewer, public QgsGLWidgetAdapter
{
public:
public:

QgsOsgViewer(QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0):
QgsGLWidgetAdapter( parent, name, shareWidget, f )
{
getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);
getCamera()->setGraphicsContext(getGraphicsWindow());
QgsOsgViewer( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WindowFlags f = 0 ):
QgsGLWidgetAdapter( parent, name, shareWidget, f )
{
getCamera()->setViewport( new osg::Viewport( 0, 0, width(), height() ) );
getCamera()->setProjectionMatrixAsPerspective( 30.0f, static_cast<double>( width() ) / static_cast<double>( height() ), 1.0f, 10000.0f );
getCamera()->setGraphicsContext( getGraphicsWindow() );

setThreadingModel(osgViewer::Viewer::SingleThreaded);
setThreadingModel( osgViewer::Viewer::SingleThreaded );

connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
_timer.start(10);
}
connect( &_timer, SIGNAL( timeout() ), this, SLOT( updateGL() ) );
_timer.start( 10 );
}

virtual void paintGL()
{
frame();
}
virtual void paintGL()
{
frame();
}

protected:
protected:

QTimer _timer;
QTimer _timer;
};

#endif // QGS_OSG_VIEWER_H