Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
d8fcfff8
Commit
d8fcfff8
authored
Apr 08, 2011
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] - added bounding box functionality to WDataTexture3D and the colormapper.
parent
fab1afb0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
160 additions
and
3 deletions
+160
-3
src/dataHandler/WDataTexture3D_2.cpp
src/dataHandler/WDataTexture3D_2.cpp
+7
-1
src/dataHandler/WDataTexture3D_2.h
src/dataHandler/WDataTexture3D_2.h
+13
-0
src/graphicsEngine/WGEColormapping.cpp
src/graphicsEngine/WGEColormapping.cpp
+40
-0
src/graphicsEngine/WGEColormapping.h
src/graphicsEngine/WGEColormapping.h
+34
-1
src/graphicsEngine/WGETexture.h
src/graphicsEngine/WGETexture.h
+15
-0
src/graphicsEngine/callbacks/WGELinearTranslationCallback.h
src/graphicsEngine/callbacks/WGELinearTranslationCallback.h
+51
-1
No files found.
src/dataHandler/WDataTexture3D_2.cpp
View file @
d8fcfff8
...
...
@@ -33,7 +33,8 @@
WDataTexture3D_2
::
WDataTexture3D_2
(
boost
::
shared_ptr
<
WValueSetBase
>
valueSet
,
boost
::
shared_ptr
<
WGridRegular3D
>
grid
)
:
WGETexture3D
(
static_cast
<
float
>
(
valueSet
->
getMaximumValue
()
-
valueSet
->
getMinimumValue
()
),
static_cast
<
float
>
(
valueSet
->
getMinimumValue
()
)
),
m_valueSet
(
valueSet
)
m_valueSet
(
valueSet
),
m_boundingBox
(
grid
->
getBoundingBox
()
)
{
// initialize members
setTextureSize
(
grid
->
getNbCoordsX
(),
grid
->
getNbCoordsY
(),
grid
->
getNbCoordsZ
()
);
...
...
@@ -137,6 +138,11 @@ void WDataTexture3D_2::create()
dirtyTextureObject
();
}
WBoundingBox
WDataTexture3D_2
::
getBoundingBox
()
const
{
return
m_boundingBox
;
}
void
wge
::
bindTexture
(
osg
::
ref_ptr
<
osg
::
Node
>
node
,
osg
::
ref_ptr
<
WDataTexture3D_2
>
texture
,
size_t
unit
,
std
::
string
prefix
)
{
wge
::
bindTexture
(
node
,
osg
::
ref_ptr
<
WGETexture3D
>
(
texture
),
unit
,
prefix
);
...
...
src/dataHandler/WDataTexture3D_2.h
View file @
d8fcfff8
...
...
@@ -111,6 +111,14 @@ public:
*/
virtual
~
WDataTexture3D_2
();
/**
* Returns the texture's bounding box. This is const. Although there exists the transformation() property, it is an information property and
* can't be changed. This represents the underlying grid.
*
* \return the bounding box.
*/
virtual
WBoundingBox
getBoundingBox
()
const
;
protected:
/**
...
...
@@ -125,6 +133,11 @@ private:
*/
boost
::
shared_ptr
<
WValueSetBase
>
m_valueSet
;
/**
* The bounding box of the underlying grid.
*/
WBoundingBox
m_boundingBox
;
/**
* The lock for securing createTexture.
*/
...
...
src/graphicsEngine/WGEColormapping.cpp
View file @
d8fcfff8
...
...
@@ -27,6 +27,7 @@
#include <sstream>
#include <string>
#include "../common/WLogger.h"
#include "WGETextureUtils.h"
#include "exceptions/WGESignalSubscriptionFailed.h"
...
...
@@ -87,6 +88,7 @@ WGEColormapping::WGEColormapping():
{
// initialize members
m_textures
.
getChangeCondition
()
->
subscribeSignal
(
boost
::
bind
(
&
WGEColormapping
::
textureUpdate
,
this
)
);
m_boundingBox
.
getWriteTicket
()
->
get
().
set
(
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
);
}
WGEColormapping
::~
WGEColormapping
()
...
...
@@ -170,6 +172,7 @@ void WGEColormapping::registerTextureInst( osg::ref_ptr< WGETexture3D > texture,
texture
->
name
()
->
set
(
name
);
}
m_textures
.
push_front
(
texture
);
updateBounds
();
m_registerSignal
(
texture
);
}
}
...
...
@@ -180,6 +183,7 @@ void WGEColormapping::deregisterTextureInst( osg::ref_ptr< WGETexture3D > textur
if
(
m_textures
.
count
(
texture
)
)
{
m_textures
.
remove
(
texture
);
updateBounds
();
m_deregisterSignal
(
texture
);
}
}
...
...
@@ -196,6 +200,7 @@ void WGEColormapping::replaceTextureInst( osg::ref_ptr< WGETexture3D > old, osg:
if
(
m_textures
.
count
(
old
)
)
{
m_textures
.
replace
(
old
,
newTex
);
updateBounds
();
m_replaceSignal
(
old
,
newTex
);
}
else
// <- if not exists: add
...
...
@@ -204,6 +209,31 @@ void WGEColormapping::replaceTextureInst( osg::ref_ptr< WGETexture3D > old, osg:
}
}
void
WGEColormapping
::
updateBounds
()
{
TextureContainerType
::
ReadTicket
r
=
m_textures
.
getReadTicket
();
WSharedObject
<
WBoundingBox
>::
WriteTicket
bbw
=
m_boundingBox
.
getWriteTicket
();
bool
first
=
true
;
for
(
TextureContainerType
::
ConstIterator
iter
=
r
->
get
().
begin
();
iter
!=
r
->
get
().
end
();
++
iter
)
{
if
(
first
)
{
bbw
->
get
()
=
(
*
iter
)
->
getBoundingBox
();
first
=
false
;
}
else
{
bbw
->
get
().
expandBy
(
(
*
iter
)
->
getBoundingBox
()
);
}
}
}
WBoundingBox
WGEColormapping
::
getBoundingBox
()
const
{
return
m_boundingBox
.
getReadTicket
()
->
get
();
}
void
WGEColormapping
::
textureUpdate
()
{
NodeInfoContainerType
::
WriteTicket
w
=
m_nodeInfo
.
getWriteTicket
();
...
...
@@ -304,6 +334,11 @@ bool WGEColormapping::moveUp( osg::ref_ptr< WGETexture3D > texture )
return
true
;
}
size_t
WGEColormapping
::
size
()
const
{
return
m_textures
.
size
();
}
boost
::
signals2
::
connection
WGEColormapping
::
subscribeSignal
(
TextureListSignal
signal
,
TextureRegisterHandler
notifier
)
{
switch
(
signal
)
...
...
@@ -344,3 +379,8 @@ WGEColormapping::TextureContainerType::ReadTicket WGEColormapping::getReadTicket
return
m_textures
.
getReadTicket
();
}
WCondition
::
SPtr
WGEColormapping
::
getChangeCondition
()
const
{
return
m_textures
.
getChangeCondition
();
}
src/graphicsEngine/WGEColormapping.h
View file @
d8fcfff8
...
...
@@ -35,7 +35,7 @@
#include <osg/Node>
#include "../common/W
Logger
.h"
#include "../common/W
BoundingBox
.h"
#include "../common/WSharedSequenceContainer.h"
#include "../common/WSharedAssociativeContainer.h"
#include "../common/math/WMatrix4x4.h"
...
...
@@ -176,6 +176,13 @@ public:
*/
bool
moveDown
(
osg
::
ref_ptr
<
WGETexture3D
>
texture
);
/**
* Counts the number of textures in the colormapper.
*
* \return the number of textures.
*/
size_t
size
()
const
;
/**
* Possible signals that can be subscribed for being notified about texture list changes.
*/
...
...
@@ -225,6 +232,22 @@ public:
*/
TextureContainerType
::
ReadTicket
getReadTicket
();
/**
* 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.
*
* \return the bounding box.
*/
WBoundingBox
getBoundingBox
()
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 \ref subscribeSignal.
*
* \return the change condition
*/
WCondition
::
SPtr
getChangeCondition
()
const
;
protected:
/**
...
...
@@ -339,6 +362,16 @@ private:
* Called whenever the texture list got resorted
*/
boost
::
signals2
::
signal
<
void
(
void
)
>
m_sortSignal
;
/**
* The bounding box of all the textures.
*/
WSharedObject
<
WBoundingBox
>
m_boundingBox
;
/**
* Updates the bounding box information. This is called for every write-update in m_textures.
*/
void
updateBounds
();
};
template
<
typename
Comparator
>
...
...
src/graphicsEngine/WGETexture.h
View file @
d8fcfff8
...
...
@@ -39,6 +39,7 @@
#include "callbacks/WGEFunctorCallback.h"
#include "../common/WLimits.h"
#include "../common/WBoundingBox.h"
#include "../common/WProperties.h"
#include "../common/WPropertyHelper.h"
#include "../common/math/WMatrix4x4.h"
...
...
@@ -195,6 +196,14 @@ public:
*/
void
setWrapSTR
(
osg
::
Texture
::
WrapMode
mode
);
/**
* Returns the texture's bounding box. This is const. Although there exists the transformation() property, it is an information property and
* can't be changed.
*
* \return the bounding box.
*/
virtual
WBoundingBox
getBoundingBox
()
const
;
protected:
/**
...
...
@@ -583,5 +592,11 @@ void WGETexture< TextureType >::initTextureSize( osg::Texture3D* texture, int wi
texture
->
setTextureSize
(
width
,
height
,
depth
);
}
template
<
typename
TextureType
>
WBoundingBox
WGETexture
<
TextureType
>::
getBoundingBox
()
const
{
return
WBoundingBox
(
0.0
,
0.0
,
0.0
,
1.0
,
1.0
,
1.0
);
}
#endif // WGETEXTURE_H
src/graphicsEngine/callbacks/WGELinearTranslationCallback.h
View file @
d8fcfff8
...
...
@@ -27,6 +27,7 @@
#include <osg/Node>
#include <osg/TexMat>
#include <osg/Uniform>
#include <osg/MatrixTransform>
#include "../../common/WProperties.h"
...
...
@@ -50,7 +51,25 @@ public:
* \param property the property containing the value
* \param texMatrix optional pointer to a texture matrix which can be modified too to contain the normalized translation.
*/
WGELinearTranslationCallback
(
osg
::
Vec3
axe
,
T
property
,
osg
::
ref_ptr
<
osg
::
TexMat
>
texMatrix
=
osg
::
ref_ptr
<
osg
::
TexMat
>
()
);
WGELinearTranslationCallback
(
osg
::
Vec3
axe
,
T
property
,
osg
::
ref_ptr
<
osg
::
TexMat
>
texMatrix
);
/**
* Constructor. Creates the callback. You still need to add it to the desired node.
*
* \param axe the axe to translate along. Should be normalized. If not, it scales the translation.
* \param property the property containing the value
* \param uniform optional pointer to a uniform that will contain the matrix. Useful if no tex-matrix is available anymore. The matrix is the
* matrix that is NOT scaled to be in texture space.
*/
WGELinearTranslationCallback
(
osg
::
Vec3
axe
,
T
property
,
osg
::
ref_ptr
<
osg
::
Uniform
>
uniform
);
/**
* Constructor. Creates the callback. You still need to add it to the desired node.
*
* \param axe the axe to translate along. Should be normalized. If not, it scales the translation.
* \param property the property containing the value
*/
WGELinearTranslationCallback
(
osg
::
Vec3
axe
,
T
property
);
/**
* Destructor.
...
...
@@ -86,6 +105,11 @@ protected:
* Texture matrix that contains normalized translation.
*/
osg
::
ref_ptr
<
osg
::
TexMat
>
m_texMat
;
/**
* The uniform to set the matrix to.
*/
osg
::
ref_ptr
<
osg
::
Uniform
>
m_uniform
;
private:
};
...
...
@@ -100,6 +124,27 @@ WGELinearTranslationCallback< T >::WGELinearTranslationCallback( osg::Vec3 axe,
// initialize members
}
template
<
typename
T
>
WGELinearTranslationCallback
<
T
>::
WGELinearTranslationCallback
(
osg
::
Vec3
axe
,
T
property
,
osg
::
ref_ptr
<
osg
::
Uniform
>
uniform
)
:
osg
::
NodeCallback
(),
m_axe
(
axe
),
m_pos
(
property
),
m_oldPos
(
-
1.0
),
m_uniform
(
uniform
)
{
// initialize members
}
template
<
typename
T
>
WGELinearTranslationCallback
<
T
>::
WGELinearTranslationCallback
(
osg
::
Vec3
axe
,
T
property
)
:
osg
::
NodeCallback
(),
m_axe
(
axe
),
m_pos
(
property
),
m_oldPos
(
-
1.0
)
{
// initialize members
}
template
<
typename
T
>
WGELinearTranslationCallback
<
T
>::~
WGELinearTranslationCallback
()
{
...
...
@@ -125,6 +170,11 @@ void WGELinearTranslationCallback< T >::operator()( osg::Node* node, osg::NodeVi
{
m_texMat
->
setMatrix
(
osg
::
Matrix
::
translate
(
translation
/
static_cast
<
float
>
(
m_pos
->
getMax
()
->
getMax
()
)
/
axeLen
)
);
}
if
(
m_uniform
)
{
m_uniform
->
set
(
osg
::
Matrix
::
translate
(
translation
)
);
}
m
->
setMatrix
(
osg
::
Matrix
::
translate
(
translation
)
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment