Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
9a49f614
Commit
9a49f614
authored
Feb 18, 2013
by
Sebastian Eichelbaum
Browse files
[ADD
#247
] colorbar now reacts on window level changes in a texture
parent
ea6891c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
3 deletions
+60
-3
src/core/common/math/WInterval.h
src/core/common/math/WInterval.h
+28
-0
src/modules/colormapper/WMColormapper.cpp
src/modules/colormapper/WMColormapper.cpp
+21
-3
src/modules/colormapper/WMColormapper.h
src/modules/colormapper/WMColormapper.h
+11
-0
No files found.
src/core/common/math/WInterval.h
View file @
9a49f614
...
...
@@ -110,6 +110,13 @@ public:
*/
const
T
&
getUpper
()
const
;
/**
* The length of the interval. This is upper - lower.
*
* \return length
*/
T
getLength
()
const
;
/**
* Compare this interval with another one
*
...
...
@@ -119,6 +126,15 @@ public:
*/
bool
operator
==
(
Type
interval
)
const
;
/**
* Compare this interval with another one
*
* \param interval the other one
*
* \return true if lower and upper bounds are equal
*/
bool
operator
!=
(
Type
interval
)
const
;
protected:
private:
/**
...
...
@@ -263,11 +279,23 @@ const T& WInterval< T >::getUpper() const
return
m_interval
.
second
;
}
template
<
typename
T
>
T
WInterval
<
T
>::
getLength
()
const
{
return
getUpper
()
-
getLower
();;
}
template
<
typename
T
>
bool
WInterval
<
T
>::
operator
==
(
Type
interval
)
const
{
return
(
(
interval
.
getLower
()
==
getLower
()
)
&&
(
interval
.
getUpper
()
==
getUpper
()
)
);
}
template
<
typename
T
>
bool
WInterval
<
T
>::
operator
!=
(
Type
interval
)
const
{
return
!
operator
==
(
interval
);
}
#endif // WINTERVAL_H
src/modules/colormapper/WMColormapper.cpp
View file @
9a49f614
...
...
@@ -44,7 +44,8 @@
W_LOADABLE_MODULE
(
WMColormapper
)
WMColormapper
::
WMColormapper
()
:
WModule
()
WModule
(),
m_windowLevel
(
0
,
1
)
{
// initialize
}
...
...
@@ -230,6 +231,11 @@ void WMColormapper::moduleMain()
boost
::
bind
(
&
WMColormapper
::
updateColorbarScale
,
this
,
_1
)
)
);
// we need to adapt the labels to the window level
// we therefore watch the window level properties
m_windowLevelEnabled
=
dataSet
->
getTexture
()
->
windowEnabled
()
->
get
();
m_windowLevel
=
dataSet
->
getTexture
()
->
window
()
->
get
();
// set some callbacks
colorBarBorder
->
addUpdateCallback
(
new
WGENodeMaskCallback
(
m_colorBarBorder
)
);
labels
->
addUpdateCallback
(
new
WGENodeMaskCallback
(
m_colorBarName
)
);
...
...
@@ -338,8 +344,13 @@ void WMColormapper::updateColorbarName( osg::Drawable* label )
void
WMColormapper
::
updateColorbarScale
(
osg
::
Node
*
scaleLabels
)
{
if
(
m_colorBarLabels
->
changed
(
true
)
)
if
(
m_colorBarLabels
->
changed
(
true
)
||
(
m_windowLevelEnabled
!=
m_lastDataSet
->
getTexture
()
->
windowEnabled
()
->
get
()
)
||
(
m_windowLevel
!=
m_lastDataSet
->
getTexture
()
->
window
()
->
get
()
)
)
{
m_windowLevelEnabled
=
m_lastDataSet
->
getTexture
()
->
windowEnabled
()
->
get
();
m_windowLevel
=
m_lastDataSet
->
getTexture
()
->
window
()
->
get
();
const
double
labelXPos
=
0.060
;
osg
::
Geode
*
g
=
scaleLabels
->
asGeode
();
g
->
removeDrawables
(
0
,
g
->
getNumDrawables
()
);
...
...
@@ -347,6 +358,13 @@ void WMColormapper::updateColorbarScale( osg::Node* scaleLabels )
size_t
num
=
m_colorBarLabels
->
get
(
true
);
double
coordStep
=
0.8
/
static_cast
<
double
>
(
num
-
1
);
double
valueStep
=
m_valueScale
/
static_cast
<
double
>
(
num
-
1
);
double
valueMin
=
m_valueMin
;
if
(
m_windowLevelEnabled
)
{
valueStep
=
m_windowLevel
.
getLength
()
/
static_cast
<
double
>
(
num
-
1
);
valueMin
=
m_windowLevel
.
getLower
();
}
// less than 2 labels is useless
if
(
num
<
2
)
...
...
@@ -359,7 +377,7 @@ void WMColormapper::updateColorbarScale( osg::Node* scaleLabels )
// create enough labels.
for
(
size_t
i
=
0
;
i
<
num
;
++
i
)
{
double
value
=
m_
valueMin
+
(
valueStep
*
i
);
double
value
=
valueMin
+
(
valueStep
*
i
);
// create the label
osg
::
ref_ptr
<
WGELabel
>
label
=
new
WGELabel
();
...
...
src/modules/colormapper/WMColormapper.h
View file @
9a49f614
...
...
@@ -32,6 +32,7 @@
#include "core/kernel/WModule.h"
#include "core/kernel/WModuleInputData.h"
#include "core/common/WPropertyVariable.h"
#include "core/common/math/WInterval.h"
#include "core/dataHandler/WDataSetSingle.h"
...
...
@@ -180,6 +181,16 @@ private:
* \param scaleLabels the geode containing the labels.
*/
void
updateColorbarScale
(
osg
::
Node
*
scaleLabels
);
/**
* True if window leveling is active
*/
bool
m_windowLevelEnabled
;
/**
* Window level.
*/
WIntervalDouble
m_windowLevel
;
};
#endif // WMCOLORMAPPER_H
...
...
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