OpenWalnut  1.5.0dev
WGEViewerEffect.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGEVIEWEREFFECT_H
26 #define WGEVIEWEREFFECT_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <osg/Camera>
32 #include <osg/Geode>
33 #include <osg/StateSet>
34 
35 #include "WGECamera.h"
36 #include "core/common/WObjectNDIP.h"
37 #include "core/common/WProperties.h"
38 
39 /**
40  * Base class for implementing basic fullscreen effects for the WGEViewer. It uses properties for configuration.
41  */
42 class WGEViewerEffect: public WObjectNDIP< WGECamera >
43 {
44 public:
45  /**
46  * Convenience typedef for a std::shared_ptr< WGEViewerEffect >.
47  */
48  typedef osg::ref_ptr< WGEViewerEffect > SPtr;
49 
50  /**
51  * Convenience typedef for a std::shared_ptr< const WGEViewerEffect >.
52  */
53  typedef osg::ref_ptr< const WGEViewerEffect > ConstSPtr;
54 
55  /**
56  * Create the effect.
57  *
58  * \param name the name
59  * \param description the description
60  * \param icon an icon in XPM format. Can be NULL if no icon is required.
61  */
62  WGEViewerEffect( std::string name, std::string description, const char** icon = NULL );
63 
64  /**
65  * Destructor.
66  */
67  virtual ~WGEViewerEffect();
68 
69  /**
70  * Check whether the effect is active or not.
71  *
72  * \return true if active
73  */
74  virtual bool isEnabled() const;
75 
76  /**
77  * Set the effect enabled.
78  *
79  * \param enable true to enable. False to disable.
80  */
81  virtual void setEnabled( bool enable = true );
82 
83  /**
84  * Use this to activate an effect by default. This sets the default value of the active property. It can be overwritten by user settings.
85  *
86  * \param enableByDefault activate this effect by default if true.
87  */
88  virtual void setEnabledByDefault( bool enableByDefault = true );
89 protected:
90  /**
91  * The fullscreen quad
92  */
93  osg::ref_ptr< osg::Geode > m_geode;
94 
95  /**
96  * The stateset of the cam
97  */
98  osg::ref_ptr< osg::StateSet > m_state;
99 
100  /**
101  * Enable or disable effect.
102  */
103  WPropBool m_active;
104 private:
105 };
106 
107 #endif // WGEVIEWEREFFECT_H
108 
Base class for implementing basic fullscreen effects for the WGEViewer.
WGEViewerEffect(std::string name, std::string description, const char **icon=NULL)
Create the effect.
WPropBool m_active
Enable or disable effect.
virtual void setEnabled(bool enable=true)
Set the effect enabled.
osg::ref_ptr< WGEViewerEffect > SPtr
Convenience typedef for a std::shared_ptr< WGEViewerEffect >.
virtual bool isEnabled() const
Check whether the effect is active or not.
virtual void setEnabledByDefault(bool enableByDefault=true)
Use this to activate an effect by default.
osg::ref_ptr< osg::StateSet > m_state
The stateset of the cam.
osg::ref_ptr< const WGEViewerEffect > ConstSPtr
Convenience typedef for a std::shared_ptr< const WGEViewerEffect >.
osg::ref_ptr< osg::Geode > m_geode
The fullscreen quad.
virtual ~WGEViewerEffect()
Destructor.
This is a base class for everything which has a Name,Description,Icon and Properties (=NDIP).
Definition: WObjectNDIP.h:42