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
b05cce2a
Commit
b05cce2a
authored
Mar 11, 2011
by
Sebastian Eichelbaum
Browse files
[ADD] - tweaked colorbar
parent
5aec16c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
2 deletions
+75
-2
src/graphicsEngine/callbacks/WGECallbackTraits.h
src/graphicsEngine/callbacks/WGECallbackTraits.h
+29
-0
src/graphicsEngine/callbacks/WGEFunctorCallback.h
src/graphicsEngine/callbacks/WGEFunctorCallback.h
+17
-0
src/modules/colormapper/WMColormapper.cpp
src/modules/colormapper/WMColormapper.cpp
+22
-2
src/modules/colormapper/WMColormapper.h
src/modules/colormapper/WMColormapper.h
+7
-0
No files found.
src/graphicsEngine/callbacks/WGECallbackTraits.h
View file @
b05cce2a
...
...
@@ -28,6 +28,7 @@
#include <osg/Node>
#include <osg/StateAttribute>
#include <osg/StateSet>
#include <osg/Drawable>
/**
* This class is needed as OSG does not define a uniform callback type.
...
...
@@ -147,5 +148,33 @@ public:
}
};
/**
* Drawables have their own callback type and do NOT provide a traverse method.
*/
template
<
>
class
WGECallbackTraits
<
osg
::
Drawable
>
{
public:
/**
* The real callback type. Some specific OSG classes have specific callbacks. Specialize this template in this case.
*/
typedef
osg
::
Drawable
::
UpdateCallback
CallbackType
;
/**
* The type of the element used as parameter in the () operator.
*/
typedef
osg
::
Drawable
HandledType
;
/**
* Call traversal method if existing for the specific callback type.
*/
static
void
traverse
(
CallbackType
*
/*inst*/
,
HandledType
*
/*handled*/
,
osg
::
NodeVisitor
*
/*nv*/
)
{
// no traverse allowed
}
};
#endif // WGECALLBACKTRAITS_H
src/graphicsEngine/callbacks/WGEFunctorCallback.h
View file @
b05cce2a
...
...
@@ -70,6 +70,15 @@ public:
*/
virtual
void
operator
()(
Type
*
handled
,
osg
::
NodeVisitor
*
nv
);
/**
* This gets called by OSG every update cycle. It calls the specified functor.
* \note we provide several versions here as the OSG does not uniformly use operator().
*
* \param handled the osg node, stateset or whatever
* \param nv the node visitor
*/
virtual
void
update
(
osg
::
NodeVisitor
*
nv
,
Type
*
handled
);
protected:
private:
...
...
@@ -101,5 +110,13 @@ void WGEFunctorCallback< Type >::operator()( Type* handled, osg::NodeVisitor* nv
WGECallbackTraits
<
Type
>::
traverse
(
this
,
handled
,
nv
);
}
template
<
typename
Type
>
void
WGEFunctorCallback
<
Type
>::
update
(
osg
::
NodeVisitor
*
nv
,
Type
*
handled
)
{
// call functor
m_functor
(
handled
);
WGECallbackTraits
<
Type
>::
traverse
(
this
,
handled
,
nv
);
}
#endif // WGEFUNCTORCALLBACK_H
src/modules/colormapper/WMColormapper.cpp
View file @
b05cce2a
...
...
@@ -32,6 +32,7 @@
#include "../../dataHandler/WDataTexture3D_2.h"
#include "../../graphicsEngine/WGEColormapping.h"
#include "../../graphicsEngine/callbacks/WGENodeMaskCallback.h"
#include "../../graphicsEngine/callbacks/WGEFunctorCallback.h"
#include "../../graphicsEngine/WGEGeodeUtils.h"
#include "../../graphicsEngine/shaders/WGEShader.h"
#include "../../graphicsEngine/widgets/labeling/WGELabel.h"
...
...
@@ -90,7 +91,7 @@ void WMColormapper::properties()
m_replace
=
m_properties
->
addProperty
(
"Keep position"
,
"If true, new texture on the input connector get placed in the list where the old one was."
,
true
);
m_showColorbar
=
m_properties
->
addProperty
(
"Show Colorbar"
,
"If true, a colorbar is shown for the current colormap."
,
tru
e
);
m_showColorbar
=
m_properties
->
addProperty
(
"Show Colorbar"
,
"If true, a colorbar is shown for the current colormap."
,
fals
e
);
WModule
::
properties
();
}
...
...
@@ -129,7 +130,7 @@ void WMColormapper::moduleMain()
boost
::
shared_ptr
<
WDataSetSingle
>
dataSet
=
m_input
->
getData
();
// add a colorbar
// add a colorbar
(HACK!)
if
(
dataSet
&&
dataSet
->
isTexture
()
)
{
// TODO(ebaum): this is not the best possible solution. Actually, its a hack.
...
...
@@ -170,6 +171,15 @@ void WMColormapper::moduleMain()
bottomLabel
->
setPosition
(
osg
::
Vec3
(
0.055
,
0.1
,
0.0
)
);
bottomLabel
->
setText
(
boost
::
lexical_cast
<
std
::
string
>
(
dataSet
->
getTexture2
()
->
minimum
()
->
get
()
)
);
bottomLabel
->
setCharacterSize
(
0.02
);
osg
::
ref_ptr
<
WGELabel
>
nameLabel
=
new
WGELabel
();
nameLabel
->
setPosition
(
osg
::
Vec3
(
0.015
,
0.9
,
0.0
)
);
nameLabel
->
setText
(
dataSet
->
getTexture2
()
->
name
()
->
get
()
);
nameLabel
->
setCharacterSize
(
0.02
);
nameLabel
->
setLayout
(
osgText
::
TextBase
::
VERTICAL
);
nameLabel
->
setAlignment
(
osgText
::
Text
::
BASE_LINE
);
nameLabel
->
setUpdateCallback
(
new
WGEFunctorCallback
<
osg
::
Drawable
>
(
boost
::
bind
(
&
WMColormapper
::
updateColorbarName
,
this
,
_1
)
)
);
// the bar and the labels need to be added in an identity modelview matrix node
osg
::
ref_ptr
<
osg
::
MatrixTransform
>
matrix
=
new
osg
::
MatrixTransform
();
...
...
@@ -180,6 +190,7 @@ void WMColormapper::moduleMain()
osg
::
ref_ptr
<
osg
::
Geode
>
labels
=
new
osg
::
Geode
();
labels
->
addDrawable
(
topLabel
);
labels
->
addDrawable
(
bottomLabel
);
labels
->
addDrawable
(
nameLabel
);
// build pipeline
matrix
->
addChild
(
colorBarBorder
);
...
...
@@ -254,3 +265,12 @@ void WMColormapper::activate()
WModule
::
activate
();
}
void
WMColormapper
::
updateColorbarName
(
osg
::
Drawable
*
label
)
{
debugLog
()
<<
"hallo:"
;
if
(
m_lastDataSet
)
{
dynamic_cast
<
WGELabel
*
>
(
label
)
->
setText
(
m_lastDataSet
->
getTexture2
()
->
name
()
->
get
()
);
}
}
src/modules/colormapper/WMColormapper.h
View file @
b05cce2a
...
...
@@ -133,6 +133,13 @@ private:
* The colorbar.
*/
osg
::
ref_ptr
<
osg
::
Geode
>
m_colorBar
;
/**
* Updates the label for the dataset name
*
* \param label the label to update
*/
void
updateColorbarName
(
osg
::
Drawable
*
label
);
};
#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