Commit 91a7c7f2 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX #337] viewer effects now dont influence other windows anymore.

parent 75bf983c
......@@ -53,17 +53,18 @@
#include "WGEViewer.h"
WGEViewer::WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata, int x, int y,
int width, int height, WGECamera::ProjectionMode projectionMode )
: WGEGraphicsWindow( wdata, x, y, width, height ),
boost::enable_shared_from_this< WGEViewer >(),
m_name( name ),
m_rendered( WBoolFlag::SPtr( new WBoolFlag( new WConditionOneShot(), false ) ) ),
m_screenCapture( new WGEScreenCapture() ),
m_inAnimationMode( false ),
m_effectHorizon( new WGEViewerEffectHorizon() ),
m_effectVignette( new WGEViewerEffectVignette() ),
m_effectImageOverlay( new WGEViewerEffectImageOverlay() )
WGEViewer::WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata, int x, int y, int width, int height,
WGECamera::ProjectionMode projectionMode ):
WGEGraphicsWindow( wdata, x, y, width, height ),
boost::enable_shared_from_this< WGEViewer >(),
m_name( name ),
m_scene( new WGEGroupNode ),
m_rendered( WBoolFlag::SPtr( new WBoolFlag( new WConditionOneShot(), false ) ) ),
m_screenCapture( new WGEScreenCapture() ),
m_inAnimationMode( false ),
m_effectHorizon( new WGEViewerEffectHorizon() ),
m_effectVignette( new WGEViewerEffectVignette() ),
m_effectImageOverlay( new WGEViewerEffectImageOverlay() )
{
try
{
......@@ -128,6 +129,13 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata, int
effects->addProperty( m_effectVignette->getProperties() );
effects->addProperty( m_effectImageOverlay->getProperties() );
// scene node
m_View->setSceneData( m_scene );
// add effects to it:
m_scene->insert( m_effectVignette );
m_scene->insert( m_effectImageOverlay );
m_scene->insert( m_effectHorizon );
// apply the above default
updateThrowing();
updateBgColor();
......@@ -180,20 +188,21 @@ osg::ref_ptr<WGECamera> WGEViewer::getCamera()
void WGEViewer::setScene( osg::ref_ptr< WGEGroupNode > node )
{
m_effectImageOverlay->setReferenceViewer( shared_from_this() );
m_sceneMainNode = node;
m_View->setSceneData( node );
m_scene = node;
m_effectImageOverlay->setReferenceViewer( shared_from_this() );
// add effects:
node->insert( m_effectVignette );
node->insert( m_effectImageOverlay );
node->insert( m_effectHorizon );
m_scene->clear();
m_scene->insert( m_sceneMainNode );
// add effects to scene node. We cleared it earlier.
m_scene->insert( m_effectVignette );
m_scene->insert( m_effectImageOverlay );
m_scene->insert( m_effectHorizon );
}
osg::ref_ptr< WGEGroupNode > WGEViewer::getScene()
{
return m_scene;
return m_sceneMainNode;
}
void WGEViewer::updateThrowing()
......@@ -376,3 +385,11 @@ WProperties::SPtr WGEViewer::getProperties() const
{
return m_properties;
}
void WGEViewer::setEffectsActiveDefault( bool activeByDefault )
{
getBackground()->setEnabledByDefault( activeByDefault );
getImageOverlay()->setEnabledByDefault( activeByDefault );
getVignette()->setEnabledByDefault( activeByDefault );
}
......@@ -293,6 +293,13 @@ public:
*/
WGEViewerEffectVignette::ConstSPtr getVignette() const;
/**
* Activate viewer effects by default. If the user has deactivated them, this method does not cause any change.
*
* \param activeByDefault if true all effects are active by default
*/
void setEffectsActiveDefault( bool activeByDefault = true );
/**
* Return a pointer to the properties object of the view.
*
......@@ -325,6 +332,11 @@ protected:
*/
osg::ref_ptr< WGEGroupNode > m_scene;
/**
* Keep the currently set scene node. Unlike m_scene, it is the user set node.
*/
osg::ref_ptr< WGEGroupNode > m_sceneMainNode;
/**
* This flag is true and notifies after the first rendered frame.
*/
......
......@@ -62,7 +62,7 @@ WGEViewerEffect::WGEViewerEffect( std::string name, std::string description, con
addChild( m_geode );
// Configure properties
m_active = m_properties->addProperty( "Active", "Activate this effect?", true );
m_active = m_properties->addProperty( "Active", "Activate this effect?", false );
// let this control the nodemask
addUpdateCallback( new WGENodeMaskCallback( m_active ) );
}
......@@ -81,3 +81,8 @@ void WGEViewerEffect::setEnabled( bool enable )
{
m_active->set( enable );
}
void WGEViewerEffect::setEnabledByDefault( bool enableByDefault )
{
m_active->setRecommendedValue( enableByDefault );
}
......@@ -71,15 +71,21 @@ public:
*
* \return true if active
*/
bool isEnabled() const;
virtual bool isEnabled() const;
/**
* Set the effect enabled.
*
* \param enable true to enable. False to disable.
*/
void setEnabled( bool enable = true );
virtual void setEnabled( bool enable = true );
/**
* Use this to activate an effect by default. This sets the default value of the active property. It can be overwritten by user settings.
*
* \param enableByDefault activate this effect by default if true.
*/
virtual void setEnabledByDefault( bool enableByDefault = true );
protected:
/**
* The fullscreen quad
......
......@@ -254,6 +254,8 @@ void WMainWindow::setupGUI()
m_glDock->setDocumentMode( true );
setCentralWidget( m_glDock );
m_mainGLDock = new WQtGLDockWidget( "Main View", "3D View", m_glDock );
// activate effects for this view by default
m_mainGLDock->getGLWidget()->getViewer()->setEffectsActiveDefault();
m_mainGLDock->getGLWidget()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_mainGLDock->restoreSettings();
m_mainGLWidget = m_mainGLDock->getGLWidget();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment