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