25 #ifndef WGECOLORMAPPING_H
26 #define WGECOLORMAPPING_H
35 #include <boost/function.hpp>
36 #include <boost/signals2/signal.hpp>
39 #include "../common/WBoundingBox.h"
40 #include "../common/WSharedAssociativeContainer.h"
41 #include "../common/WSharedSequenceContainer.h"
42 #include "WGETexture.h"
43 #include "callbacks/WGEFunctorCallback.h"
44 #include "shaders/WGEShader.h"
83 typedef boost::function< void ( osg::ref_ptr< WGETexture3D >, osg::ref_ptr< WGETexture3D > ) >
TextureReplaceHandler;
100 static std::shared_ptr< WGEColormapping >
instance();
105 typedef std::vector< osg::ref_ptr< osg::Node > >
NodeList;
118 osg::ref_ptr< WGEShader > shader = osg::ref_ptr< WGEShader >(),
size_t startTexUnit = 0 );
131 osg::ref_ptr< WGEShader > shader = osg::ref_ptr< WGEShader >(),
size_t startTexUnit = 0 );
141 static void apply( osg::ref_ptr< osg::Node > node, osg::ref_ptr< WGEShader > shader = osg::ref_ptr< WGEShader >(),
size_t startTexUnit = 0 );
152 osg::ref_ptr< WGEShader > shader = osg::ref_ptr< WGEShader >(),
size_t startTexUnit = 0 );
161 static void registerTexture( osg::ref_ptr< WGETexture3D > texture, std::string name =
"" );
179 static void replaceTexture( osg::ref_ptr< WGETexture3D > old, osg::ref_ptr< WGETexture3D > newTex, std::string name =
"" );
187 template <
typename Comparator >
188 void sort( Comparator comp );
196 template <
typename Comparator >
221 bool moveToTop( osg::ref_ptr< WGETexture3D > texture );
229 bool moveToBottom( osg::ref_ptr< WGETexture3D > texture );
237 bool moveUp( osg::ref_ptr< WGETexture3D > texture );
246 bool moveDown( osg::ref_ptr< WGETexture3D > texture );
256 bool moveTo( osg::ref_ptr< WGETexture3D > texture,
size_t idx );
347 osg::ref_ptr< WGEShader > shader = osg::ref_ptr< WGEShader >(),
size_t startTexUnit = 0 );
372 void replaceTextureInst( osg::ref_ptr< WGETexture3D > old, osg::ref_ptr< WGETexture3D > newTex, std::string name =
"" );
431 boost::signals2::signal< void( osg::ref_ptr< WGETexture3D >, osg::ref_ptr< WGETexture3D > ) >
m_replaceSignal;
449 template <
typename Comparator >
455 template <
typename Comparator >
std::shared_ptr< WCondition > SPtr
Shared pointer type for WCondition.
Class implements a manager for multiple 3D textures.
static void replaceTexture(osg::ref_ptr< WGETexture3D > old, osg::ref_ptr< WGETexture3D > newTex, std::string name="")
Replaces the specified texture with the given new one.
void sortByIndex()
Sort the texture list by the indices that have been stored in each texture's sortIndex.
void sort(Comparator comp)
Resorts the texture list using the specified comparator.
TextureRegisterHandler TextureDeregisterHandler
The type of handler used for being notified about removed textures.
void textureUpdate()
Called whenever the texture list is updated.
WSharedAssociativeContainer< std::map< osg::Node *, NodeInfo *, std::less< osg::Node * > > > NodeInfoContainerType
The alias for a shared container with a set of node-nodeInfo pairs.
boost::function< void(void) > TextureSortHandler
The type of handler called whenever the texture list got resorted.
boost::function< void(osg::ref_ptr< WGETexture3D >, osg::ref_ptr< WGETexture3D >) > TextureReplaceHandler
The type of handler used for being notified about replaced textures.
WBoundingBox getBoundingBox() const
This returns the bounding box of all the data textures.
void setSortIndices()
This function sets the index of a texture in the list to this texture's WGETexture::sortIndex().
void registerTextureInst(osg::ref_ptr< WGETexture3D > texture, std::string name)
Register the specified texture to the colormapper.
void stableSort(Comparator comp)
Resorts the texture list using the specified comparator using a stable sorting algorithm.
WCondition::SPtr getChangeCondition() const
Returns the condition firing if the texture list changes (sort, replace, add or remove).
TextureContainerType m_textures
The textures managed by this instance.
WSharedObject< WBoundingBox > m_boundingBox
The bounding box of all the textures.
static void registerTexture(osg::ref_ptr< WGETexture3D > texture, std::string name="")
Register the specified texture to the colormapper.
WGEColormapping()
Default constructor.
void applyInst(NodeList nodes, WMatrix4d preTransform=WMatrix4d::identity(), osg::ref_ptr< WGEShader > shader=osg::ref_ptr< WGEShader >(), size_t startTexUnit=0)
Apply the colormapping to the specified nodes.
static void apply(osg::ref_ptr< osg::Node > node, WMatrix4d preTransform=WMatrix4d::identity(), osg::ref_ptr< WGEShader > shader=osg::ref_ptr< WGEShader >(), size_t startTexUnit=0)
Apply the colormapping to the specified node.
TextureContainerType::ReadTicket getReadTicket()
Returns a read ticket to the texture array.
void callback(osg::Node *node)
This callback handles all the updates needed.
size_t size() const
Counts the number of textures in the colormapper.
boost::signals2::signal< void(osg::ref_ptr< WGETexture3D >, osg::ref_ptr< WGETexture3D >) > m_replaceSignal
Called whenever a texture got replaced.
bool moveToTop(osg::ref_ptr< WGETexture3D > texture)
Move the specified texture up in the list, directly to the top.
boost::signals2::signal< void(void) > m_sortSignal
Called whenever the texture list got resorted.
static std::shared_ptr< WGEColormapping > instance()
Returns instance of the module factory to use to create modules.
virtual ~WGEColormapping()
Destructor.
bool moveTo(osg::ref_ptr< WGETexture3D > texture, size_t idx)
Move the texture to the specified index.
TextureListSignal
Possible signals that can be subscribed for being notified about texture list changes.
@ Deregistered
texture got removed
@ Registered
texture got added
@ Sorted
texture list was resorted
@ Replaced
texture got replaced
static void deregisterTexture(osg::ref_ptr< WGETexture3D > texture)
De-register the specified texture to the colormapper.
TextureContainerType::Iterator TextureIterator
Iterator to access the texture list.
TextureContainerType::ConstIterator TextureConstIterator
Const iterator to access the texture list.
static std::shared_ptr< WGEColormapping > m_instance
Singleton instance of WGEColormapping.
WSharedSequenceContainer< std::vector< osg::ref_ptr< WGETexture3D > > > TextureContainerType
The alias for a shared container.
boost::function< void(osg::ref_ptr< WGETexture3D >) > TextureRegisterHandler
The type of handler used for being notified about added textures.
boost::signals2::signal< void(osg::ref_ptr< WGETexture3D >) > m_deregisterSignal
Called whenever a texture got removed.
void updateBounds()
Updates the bounding box information.
void replaceTextureInst(osg::ref_ptr< WGETexture3D > old, osg::ref_ptr< WGETexture3D > newTex, std::string name="")
Replaces the specified texture with the given new one.
void deregisterTextureInst(osg::ref_ptr< WGETexture3D > texture)
De-register the specified texture to the colormapper.
NodeInfoContainerType m_nodeInfo
This map is needed to keep track of several node specific settings.
bool moveToBottom(osg::ref_ptr< WGETexture3D > texture)
Move the specified texture down in the list, directly to the bottom.
void resetSortIndices()
Reset all sort indices.
bool moveDown(osg::ref_ptr< WGETexture3D > texture)
Move the specified texture one item down in the list.
std::vector< osg::ref_ptr< osg::Node > > NodeList
a bunch of nodes.
boost::signals2::signal< void(osg::ref_ptr< WGETexture3D >) > m_registerSignal
Called whenever a texture got registered.
boost::signals2::connection subscribeSignal(TextureListSignal signal, TextureRegisterHandler notifier)
Subscribe to the specified signal.
bool moveUp(osg::ref_ptr< WGETexture3D > texture)
Move the specified texture one item up in the list.
static MatrixType identity()
Returns an identity matrix.
This class provides a common interface for thread-safe access to associative containers (set,...
Wrapper around an object/type for thread safe sharing of objects among multiple threads.
std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
This class provides a common interface for thread-safe access to sequence containers (list,...
void sort(Comparator comp)
Resorts the container using the specified comparator from its begin to its end.
void stableSort(Comparator comp)
Resorts the container using the specified comparator from its begin to its end.
S::iterator Iterator
A typedef for the correct iterator to traverse this sequence container.
S::const_iterator ConstIterator
A typedef for the correct const iterator useful to traverse this sequence container.
Simple structure to store some additional node-related info like texture units and so on.
WMatrix4d m_preTransform
matrix used for transforming arbitrary texture coordinates to the proper space.
size_t m_texUnitStart
the start index of the texture unit to use
bool m_rebind
true if the node has not been callback'ed before