25 #ifndef WGRAPHICSENGINE_H
26 #define WGRAPHICSENGINE_H
30 #include <shared_mutex>
34 #include <boost/signals2/signal.hpp>
35 #include <boost/thread/mutex.hpp>
37 #include <osg/Texture3D>
40 #include <osg/ref_ptr>
41 #include <osgViewer/CompositeViewer>
43 #include "../common/WColor.h"
44 #include "../common/WCondition.h"
45 #include "../common/WConditionOneShot.h"
46 #include "../common/WThreadedRunner.h"
47 #include "WGEGraphicsWindow.h"
49 #include "WGESignals.h"
50 #include "WGEViewer.h"
87 std::shared_ptr< WGEViewer >
createViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata,
int x,
int y,
89 WColor bgColor = WColor( 1.0, 1.0, 1.0, 1.0 ) );
103 void closeViewer( std::shared_ptr< WGEViewer > viewer );
118 std::shared_ptr< WGEViewer >
getViewer();
143 boost::signals2::connection
subscribeSignal( GE_SIGNAL signal, t_GEGenericSignalHandlerType notifier );
207 typedef std::map< std::string, std::shared_ptr< WGEViewer > >
ViewerMap;
Implements a WCondition, but can be fired only ONCE.
ProjectionMode
List of possible camera modes.
Base class for initializing the graphics engine.
virtual boost::signals2::connection subscribeSignal(THREAD_SIGNAL signal, t_ThreadErrorSignalHandlerType notifier)
Connects a specified notify function with a signal this thread instance is offering.
static std::shared_ptr< WGraphicsEngine > getGraphicsEngine()
Returns instance of the graphics engine.
virtual void threadMain()
Handler for repainting and event handling.
std::vector< WGEViewer::SPtr > m_addViewers
List of viewers to add to m_viewer via addView.
static bool waitForStartupComplete()
Waits for the GE to come up.
std::shared_mutex m_viewersLock
Mutex used to lock the map of viewers.
virtual void notifyStop()
Gets called when the thread should be stopped.
std::shared_ptr< WGEViewer > getViewer()
Returns the unnamed view, which is the view for the default scene which can be acquired using getScen...
void waitForFinalize()
Wait until someone called finalizeStartup().
std::shared_ptr< WGEViewer > getViewerByName(std::string name)
Searches for a viewer with a given name and returns it, if found.
static std::shared_ptr< WGraphicsEngine > m_instance
Singleton instance of WGraphicsEngine.
std::shared_ptr< WGEViewer > createViewer(std::string name, osg::ref_ptr< osg::Referenced > wdata, int x, int y, int width, int height, WGECamera::ProjectionMode projectionMode=WGECamera::ORTHOGRAPHIC, WColor bgColor=WColor(1.0, 1.0, 1.0, 1.0))
Creates a new viewer.
bool m_viewersUpdate
If true, the view thread checks for updates in the m_viewers list.
ViewerMap m_viewers
All registered viewers.
std::map< std::string, std::shared_ptr< WGEViewer > > ViewerMap
Map between name of viewer and viewer.
std::vector< WGEViewer::SPtr > m_removeViewers
List of viewers to remove from m_viewer via addView.
osg::ref_ptr< WGEScene > getScene()
Returns the root node of the WGraphicsEngine (this is not the root node of the OSG).
osg::ref_ptr< WGEScene > m_rootNode
OpenSceneGraph root node.
bool isMultiThreadedViews() const
Checks whether the viewers work multithreaded.
std::vector< WCondition::SPtr > m_viewerUpdateNotifiers
A list of conditions to notify when the GE thread processed the m_addViewers and m_removeViewers list...
void closeViewer(const std::string name)
Closes a viewer and deletes it from the list of viewers.
t_GEGenericSignalType m_reloadShadersSignal
Signal getting emitted whenever a reload shader request is waiting.
osg::ref_ptr< osgViewer::CompositeViewer > m_viewer
OpenSceneGraph composite viewer.
virtual ~WGraphicsEngine()
Destructor.
static bool isRunning()
Checks whether the graphics engine is currently running or not.
void finalizeStartup()
Function notifies the viewer threads (if any) to start.
WGraphicsEngine()
Constructors are protected because this is a Singleton.
void setMultiThreadedViews(bool enable=true)
Enables multithreaded view.
void applyViewerListUpdates()
Apply updates in m_addViewers and m_removeViewers.
void requestShaderReload()
This requests all shaders to reload during the next update cycle.
bool m_running
True if graphics engine is running.
WConditionOneShot m_startThreadingCondition
This condition is fired externally if all the GUI startup is done to ensure all OGL stuff is initiali...
Base class for all classes needing to be executed in a separate thread.
virtual boost::signals2::connection subscribeSignal(THREAD_SIGNAL signal, t_ThreadErrorSignalHandlerType notifier)
Connects a specified notify function with a signal this thread instance is offering.
Extend the wge utils namespace with additional methods relating WDataTexture3D.