OpenWalnut
1.3.1
|
Class implements a manager for multiple 3D textures. More...
#include <WGEColormapping.h>
Classes | |
struct | NodeInfo |
Simple structure to store some additional node-related info like texture units and so on. More... | |
Public Types | |
enum | TextureListSignal { Registered = 0, Deregistered, Replaced, Sorted } |
Possible signals that can be subscribed for being notified about texture list changes. More... | |
typedef WSharedSequenceContainer < std::vector< osg::ref_ptr < WGETexture3D > > > | TextureContainerType |
The alias for a shared container. More... | |
typedef TextureContainerType::Iterator | TextureIterator |
Iterator to access the texture list. More... | |
typedef TextureContainerType::ConstIterator | TextureConstIterator |
Const iterator to access the texture list. More... | |
typedef boost::function< void(osg::ref_ptr < WGETexture3D >) > | TextureRegisterHandler |
The type of handler used for being notified about added textures. More... | |
typedef TextureRegisterHandler | TextureDeregisterHandler |
The type of handler used for being notified about removed textures. More... | |
typedef boost::function< void(osg::ref_ptr < WGETexture3D >, osg::ref_ptr < WGETexture3D >) > | TextureReplaceHandler |
The type of handler used for being notified about replaced textures. More... | |
typedef boost::function< void(void) > | TextureSortHandler |
The type of handler called whenever the texture list got resorted. More... | |
typedef std::vector < osg::ref_ptr< osg::Node > > | NodeList |
a bunch of nodes. More... | |
Public Member Functions | |
virtual | ~WGEColormapping () |
Destructor. More... | |
template<typename Comparator > | |
void | sort (Comparator comp) |
Resorts the texture list using the specified comparator. More... | |
bool | moveUp (osg::ref_ptr< WGETexture3D > texture) |
Move the specified texture one item up in the list. More... | |
bool | moveDown (osg::ref_ptr< WGETexture3D > texture) |
Move the specified texture one item down in the list. More... | |
size_t | size () const |
Counts the number of textures in the colormapper. More... | |
boost::signals2::connection | subscribeSignal (TextureListSignal signal, TextureRegisterHandler notifier) |
Subscribe to the specified signal. More... | |
boost::signals2::connection | subscribeSignal (TextureListSignal signal, TextureReplaceHandler notifier) |
Subscribe to the specified signal. More... | |
boost::signals2::connection | subscribeSignal (TextureListSignal signal, TextureSortHandler notifier) |
Subscribe to the specified signal. More... | |
TextureContainerType::ReadTicket | getReadTicket () |
Returns a read ticket to the texture array. More... | |
WBoundingBox | getBoundingBox () const |
This returns the bounding box of all the data textures. More... | |
WCondition::SPtr | getChangeCondition () const |
Returns the condition firing if the texture list changes (sort, replace, add or remove). More... | |
Static Public Member Functions | |
static boost::shared_ptr < WGEColormapping > | instance () |
Returns instance of the module factory to use to create modules. More... | |
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. More... | |
static void | apply (NodeList nodes, WMatrix4d preTransform=WMatrix4d::identity(), osg::ref_ptr< WGEShader > shader=osg::ref_ptr< WGEShader >(), size_t startTexUnit=0) |
Apply the colormapping to a list of nodes using the same shader. More... | |
static void | apply (osg::ref_ptr< osg::Node > node, osg::ref_ptr< WGEShader > shader=osg::ref_ptr< WGEShader >(), size_t startTexUnit=0) |
Apply the colormapping to the specified node. More... | |
static void | apply (NodeList nodes, osg::ref_ptr< WGEShader > shader=osg::ref_ptr< WGEShader >(), size_t startTexUnit=0) |
Apply the colormapping to a list of nodes which all use the same shader. More... | |
static void | registerTexture (osg::ref_ptr< WGETexture3D > texture, std::string name="") |
Register the specified texture to the colormapper. More... | |
static void | deregisterTexture (osg::ref_ptr< WGETexture3D > texture) |
De-register the specified texture to the colormapper. More... | |
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. More... | |
Protected Member Functions | |
WGEColormapping () | |
Default constructor. More... | |
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. More... | |
void | registerTextureInst (osg::ref_ptr< WGETexture3D > texture, std::string name) |
Register the specified texture to the colormapper. More... | |
void | deregisterTextureInst (osg::ref_ptr< WGETexture3D > texture) |
De-register the specified texture to the colormapper. More... | |
void | replaceTextureInst (osg::ref_ptr< WGETexture3D > old, osg::ref_ptr< WGETexture3D > newTex, std::string name="") |
Replaces the specified texture with the given new one. More... | |
void | callback (osg::Node *node) |
This callback handles all the updates needed. More... | |
void | textureUpdate () |
Called whenever the texture list is updated. More... | |
Private Types | |
typedef WSharedAssociativeContainer < std::map< osg::Node *, NodeInfo *, std::less < osg::Node * > > > | NodeInfoContainerType |
The alias for a shared container with a set of node-nodeInfo pairs. More... | |
Private Member Functions | |
void | updateBounds () |
Updates the bounding box information. More... | |
Private Attributes | |
TextureContainerType | m_textures |
The textures managed by this instance. More... | |
NodeInfoContainerType | m_nodeInfo |
This map is needed to keep track of several node specific settings. More... | |
boost::signals2::signal< void(osg::ref_ptr < WGETexture3D >) > | m_registerSignal |
Called whenever a texture got registered. More... | |
boost::signals2::signal< void(osg::ref_ptr < WGETexture3D >) > | m_deregisterSignal |
Called whenever a texture got removed. More... | |
boost::signals2::signal< void(osg::ref_ptr < WGETexture3D >, osg::ref_ptr < WGETexture3D >) > | m_replaceSignal |
Called whenever a texture got replaced. More... | |
boost::signals2::signal< void(void) > | m_sortSignal |
Called whenever the texture list got resorted. More... | |
WSharedObject< WBoundingBox > | m_boundingBox |
The bounding box of all the textures. More... | |
Static Private Attributes | |
static boost::shared_ptr < WGEColormapping > | m_instance = boost::shared_ptr< WGEColormapping >() |
Singleton instance of WGEColormapping. More... | |
Class implements a manager for multiple 3D textures.
They can be applied to arbitrary osg::Node. This allows very comfortable use of dataset based colormapping. The only requirement is that your geometry/node needs to specify texture coordinates in Object Space. That means: the texture coordinates equal the regular 3D grid of the texture.
Definition at line 55 of file WGEColormapping.h.
|
private |
The alias for a shared container with a set of node-nodeInfo pairs.
Definition at line 362 of file WGEColormapping.h.
typedef std::vector< osg::ref_ptr< osg::Node > > WGEColormapping::NodeList |
a bunch of nodes.
Definition at line 108 of file WGEColormapping.h.
Const iterator to access the texture list.
Definition at line 71 of file WGEColormapping.h.
typedef WSharedSequenceContainer< std::vector< osg::ref_ptr< WGETexture3D > > > WGEColormapping::TextureContainerType |
The alias for a shared container.
Definition at line 61 of file WGEColormapping.h.
The type of handler used for being notified about removed textures.
Definition at line 81 of file WGEColormapping.h.
Iterator to access the texture list.
Definition at line 66 of file WGEColormapping.h.
typedef boost::function< void ( osg::ref_ptr< WGETexture3D > ) > WGEColormapping::TextureRegisterHandler |
The type of handler used for being notified about added textures.
Definition at line 76 of file WGEColormapping.h.
typedef boost::function< void ( osg::ref_ptr< WGETexture3D >, osg::ref_ptr< WGETexture3D > ) > WGEColormapping::TextureReplaceHandler |
The type of handler used for being notified about replaced textures.
Definition at line 86 of file WGEColormapping.h.
typedef boost::function< void ( void ) > WGEColormapping::TextureSortHandler |
The type of handler called whenever the texture list got resorted.
Definition at line 91 of file WGEColormapping.h.
Possible signals that can be subscribed for being notified about texture list changes.
Enumerator | |
---|---|
Registered |
texture got added |
Deregistered |
texture got removed |
Replaced |
texture got replaced |
Sorted |
texture list was resorted |
Definition at line 219 of file WGEColormapping.h.
|
virtual |
Destructor.
Definition at line 95 of file WGEColormapping.cpp.
|
protected |
Default constructor.
Definition at line 88 of file WGEColormapping.cpp.
References WSharedObject< T >::getChangeCondition(), m_boundingBox, m_textures, and textureUpdate().
Referenced by instance().
|
static |
Apply the colormapping to the specified node.
node | the node. |
shader | the shader to use for colormapping. Provide your own shader here to let WGEColormap set some defines needed. If not specified, a default shader is used. |
preTransform | Transformation matrix getting applied to your texture coordinates before applying texture matrices. This allows you to specify any kind of texture coordinates as long as you use this matrix to transform them to the right space. |
startTexUnit | the first texture unit allowed to be used |
Definition at line 115 of file WGEColormapping.cpp.
References instance().
|
static |
Apply the colormapping to a list of nodes using the same shader.
nodes | the node-list. |
shader | the shader to use for colormapping. Provide your own shader here to let WGEColormap set some defines needed. If not specified, a default shader is used. |
preTransform | Transformation matrix getting applied to your texture coordinates before applying texture matrices. This allows you to specify any kind of texture coordinates as long as you use this matrix to transform them to the right space. |
startTexUnit | the first texture unit allowed to be used |
Definition at line 121 of file WGEColormapping.cpp.
References instance().
|
static |
Apply the colormapping to the specified node.
node | the node. |
shader | the shader to use for colormapping. Provide your own shader here to let WGEColormap set some defines needed. If not specified, a default shader is used. |
startTexUnit | the first texture unit allowed to be used |
Definition at line 110 of file WGEColormapping.cpp.
References WMatrixFixed< double, 4, 4 >::identity(), and instance().
|
static |
Apply the colormapping to a list of nodes which all use the same shader.
nodes | the node list. |
shader | the shader to use for colormapping. Provide your own shader here to let WGEColormap set some defines needed. If not specified, a default shader is used. |
startTexUnit | the first texture unit allowed to be used |
Definition at line 126 of file WGEColormapping.cpp.
References WMatrixFixed< double, 4, 4 >::identity(), and instance().
|
protected |
Apply the colormapping to the specified nodes.
nodes | the nodes. |
preTransform | Transformation matrix getting applied to your texture coordinates before applying texture matrices. This allows you to specify any kind of texture coordinates as long as you use this matrix to transform them to the right space. |
shader | the shader to use for colormapping. Provide your own shader here to let WGEColormap set some defines needed. If not specified, a default shader is used. |
startTexUnit | the first texture unit allowed to be used |
Definition at line 146 of file WGEColormapping.cpp.
References callback(), WSharedAssociativeContainer< T >::insert(), m_nodeInfo, WGEColormapping::NodeInfo::m_preTransform, WGEColormapping::NodeInfo::m_rebind, and WGEColormapping::NodeInfo::m_texUnitStart.
|
protected |
This callback handles all the updates needed.
It is called by the callback instance every update cycle for each node using this WGEColormapping instance.
node |
Definition at line 257 of file WGEColormapping.cpp.
References wge::bindTexture(), wge::getMaxTexUnits(), WSharedObject< T >::getReadTicket(), m_nodeInfo, WGEColormapping::NodeInfo::m_rebind, m_textures, WGEColormapping::NodeInfo::m_texUnitStart, string_utils::toString(), and wge::unbindTexture().
Referenced by applyInst().
|
static |
De-register the specified texture to the colormapper.
The texture is the automatically removed from all users of WGEColormapping. If the texture is not in the list, nothing happens.
texture | the texture to remove |
Definition at line 136 of file WGEColormapping.cpp.
References instance().
|
protected |
De-register the specified texture to the colormapper.
The texture is the automatically removed from all users of WGEColormapping.
texture | the texture to remove |
Definition at line 191 of file WGEColormapping.cpp.
References WSharedSequenceContainer< S >::count(), wlog::debug(), m_deregisterSignal, m_textures, WSharedSequenceContainer< S >::remove(), and updateBounds().
WBoundingBox WGEColormapping::getBoundingBox | ( | ) | const |
This returns the bounding box of all the data textures.
This is very useful if you implement an universal color-mapped exploration tool. It returns a copy of the current bounding box. Please note that this can change any moment.
Definition at line 243 of file WGEColormapping.cpp.
References m_boundingBox.
WCondition::SPtr WGEColormapping::getChangeCondition | ( | ) | const |
Returns the condition firing if the texture list changes (sort, replace, add or remove).
If you are interested in a certain event only, use subscribeSignal.
Definition at line 393 of file WGEColormapping.cpp.
References WSharedObject< T >::getChangeCondition(), and m_textures.
WGEColormapping::TextureContainerType::ReadTicket WGEColormapping::getReadTicket | ( | ) |
Returns a read ticket to the texture array.
Useful to iterate the textures.
Definition at line 388 of file WGEColormapping.cpp.
References WSharedObject< T >::getReadTicket(), and m_textures.
|
static |
Returns instance of the module factory to use to create modules.
Definition at line 100 of file WGEColormapping.cpp.
References m_instance, and WGEColormapping().
Referenced by apply(), deregisterTexture(), registerTexture(), and replaceTexture().
bool WGEColormapping::moveDown | ( | osg::ref_ptr< WGETexture3D > | texture) |
Move the specified texture one item down in the list.
Causes the sort signal to fire.
texture | the texture swapped with its descendant |
Definition at line 294 of file WGEColormapping.cpp.
References WSharedObject< T >::getWriteTicket(), m_sortSignal, and m_textures.
bool WGEColormapping::moveUp | ( | osg::ref_ptr< WGETexture3D > | texture) |
Move the specified texture one item up in the list.
Causes the sort signal to fire.
texture | the texture swapped with its ascendant |
Definition at line 321 of file WGEColormapping.cpp.
References WSharedObject< T >::getWriteTicket(), m_sortSignal, and m_textures.
|
static |
Register the specified texture to the colormapper.
The registered texture is the automatically applied to all users of WGEColormapping. The texture gets inserted at the beginning of the texture list.
texture | the texture to add |
name | the name of the texture to add |
Definition at line 131 of file WGEColormapping.cpp.
References instance().
|
protected |
Register the specified texture to the colormapper.
The registered texture is the automatically applied to all users of WGEColormapping.
texture | the texture to add |
name | the name of the texture. |
Definition at line 176 of file WGEColormapping.cpp.
References WSharedSequenceContainer< S >::count(), wlog::debug(), m_registerSignal, m_textures, WSharedSequenceContainer< S >::push_front(), and updateBounds().
Referenced by replaceTextureInst().
|
static |
Replaces the specified texture with the given new one.
If the old texture does not exist, the new one gets inserted at the front of the list as registerTexture does.
old | the texture to remove |
newTex | the new texture to put at the position of the old one |
name | the name of the texture. |
Definition at line 141 of file WGEColormapping.cpp.
References instance().
|
protected |
Replaces the specified texture with the given new one.
If the old texture does not exist, the new one gets inserted at the front of the list as registerTexture does.
old | the texture to remove |
newTex | the new texture to put at the position of the old one |
name | the name of the texture. |
Definition at line 202 of file WGEColormapping.cpp.
References WSharedSequenceContainer< S >::count(), wlog::debug(), m_replaceSignal, m_textures, registerTextureInst(), WSharedSequenceContainer< S >::replace(), and updateBounds().
size_t WGEColormapping::size | ( | ) | const |
Counts the number of textures in the colormapper.
Definition at line 348 of file WGEColormapping.cpp.
References m_textures, and WSharedSequenceContainer< S >::size().
void WGEColormapping::sort | ( | Comparator | comp) |
Resorts the texture list using the specified comparator.
Comparator | the comparator type. Usually a boost::function or class providing the operator(). |
comp | the comparator |
Definition at line 401 of file WGEColormapping.h.
References m_textures, and WSharedSequenceContainer< S >::sort().
boost::signals2::connection WGEColormapping::subscribeSignal | ( | TextureListSignal | signal, |
TextureRegisterHandler | notifier | ||
) |
Subscribe to the specified signal.
See TextureListSignal for details about their meaning.
signal | the signal to subscribe |
notifier | the notifier |
Definition at line 353 of file WGEColormapping.cpp.
References Deregistered, m_deregisterSignal, m_registerSignal, and Registered.
boost::signals2::connection WGEColormapping::subscribeSignal | ( | TextureListSignal | signal, |
TextureReplaceHandler | notifier | ||
) |
Subscribe to the specified signal.
See TextureListSignal for details about their meaning.
signal | the signal to subscribe |
notifier | the notifier |
Definition at line 366 of file WGEColormapping.cpp.
References m_replaceSignal, and Replaced.
boost::signals2::connection WGEColormapping::subscribeSignal | ( | TextureListSignal | signal, |
TextureSortHandler | notifier | ||
) |
Subscribe to the specified signal.
See TextureListSignal for details about their meaning.
signal | the signal to subscribe |
notifier | the notifier |
Definition at line 377 of file WGEColormapping.cpp.
References m_sortSignal, and Sorted.
|
protected |
Called whenever the texture list is updated.
Definition at line 248 of file WGEColormapping.cpp.
References WSharedObject< T >::getWriteTicket(), and m_nodeInfo.
Referenced by WGEColormapping().
|
private |
Updates the bounding box information.
This is called for every write-update in m_textures.
Definition at line 223 of file WGEColormapping.cpp.
References WSharedObject< T >::getReadTicket(), m_boundingBox, and m_textures.
Referenced by deregisterTextureInst(), registerTextureInst(), and replaceTextureInst().
|
private |
The bounding box of all the textures.
Definition at line 392 of file WGEColormapping.h.
Referenced by getBoundingBox(), updateBounds(), and WGEColormapping().
|
private |
Called whenever a texture got removed.
Definition at line 377 of file WGEColormapping.h.
Referenced by deregisterTextureInst(), and subscribeSignal().
|
staticprivate |
Singleton instance of WGEColormapping.
Definition at line 342 of file WGEColormapping.h.
Referenced by instance().
|
private |
This map is needed to keep track of several node specific settings.
Definition at line 367 of file WGEColormapping.h.
Referenced by applyInst(), callback(), and textureUpdate().
|
private |
Called whenever a texture got registered.
Definition at line 372 of file WGEColormapping.h.
Referenced by registerTextureInst(), and subscribeSignal().
|
private |
Called whenever a texture got replaced.
Definition at line 382 of file WGEColormapping.h.
Referenced by replaceTextureInst(), and subscribeSignal().
|
private |
Called whenever the texture list got resorted.
Definition at line 387 of file WGEColormapping.h.
Referenced by moveDown(), moveUp(), and subscribeSignal().
|
private |
The textures managed by this instance.
Definition at line 347 of file WGEColormapping.h.
Referenced by callback(), deregisterTextureInst(), getChangeCondition(), getReadTicket(), moveDown(), moveUp(), registerTextureInst(), replaceTextureInst(), size(), sort(), updateBounds(), and WGEColormapping().