Commit 18997156 authored by schultezub's avatar schultezub
Browse files

DataContainerInspector supports cycling through slices of 3D images

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@404 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 72376542
...@@ -41,7 +41,7 @@ uniform bool _is3d; ...@@ -41,7 +41,7 @@ uniform bool _is3d;
uniform int _sliceNumber; uniform int _sliceNumber;
uniform vec4 _color; uniform vec4 _color;
const vec4 checkerboardColor1 = vec4(0.75, 0.75, 0.75, 1.0); const vec4 checkerboardColor1 = vec4(0.90, 0.90, 0.90, 1.0);
const vec4 checkerboardColor2 = vec4(0.50, 0.50, 0.50, 1.0); const vec4 checkerboardColor2 = vec4(0.50, 0.50, 0.50, 1.0);
void main() { void main() {
...@@ -55,7 +55,7 @@ void main() { ...@@ -55,7 +55,7 @@ void main() {
} }
else { else {
// render the corresponding slice // render the corresponding slice
vec3 coord = vec3(ex_TexCoord.xy, _texture3d._sizeRCP.z * _sliceNumber); vec3 coord = vec3(ex_TexCoord.xy, (_sliceNumber + 0.5) / (_texture3d._size.z));
out_Color = getElement3DNormalized(_texture3d, coord); out_Color = getElement3DNormalized(_texture3d, coord);
} }
} }
......
...@@ -52,6 +52,7 @@ namespace campvis { ...@@ -52,6 +52,7 @@ namespace campvis {
, _quadSize(0, 0) , _quadSize(0, 0)
, _selectedTexture(0) , _selectedTexture(0)
, _renderFullscreen(false) , _renderFullscreen(false)
, _currentSlice(-1)
{ {
makeCurrent(); makeCurrent();
...@@ -228,10 +229,13 @@ namespace campvis { ...@@ -228,10 +229,13 @@ namespace campvis {
_paintShader->setUniform("_texture2d._sizeRCP", tgt::vec2(1.f) / tgt::vec2(texture->getDimensions().xy())); _paintShader->setUniform("_texture2d._sizeRCP", tgt::vec2(1.f) / tgt::vec2(texture->getDimensions().xy()));
} }
else { else {
// clamp current slice to texture size, since this can't be done in event handler:
_currentSlice = tgt::clamp(_currentSlice, -1, texture->getDimensions().z);
unit3d.activate(); unit3d.activate();
texture->bind(); texture->bind();
_paintShader->setUniform("_is3d", true); _paintShader->setUniform("_is3d", true);
_paintShader->setUniform("_sliceNumber", -1); _paintShader->setUniform("_sliceNumber", _currentSlice);
_paintShader->setUniform("_texture3d._size", tgt::vec3(texture->getDimensions())); _paintShader->setUniform("_texture3d._size", tgt::vec3(texture->getDimensions()));
_paintShader->setUniform("_texture3d._sizeRCP", tgt::vec3(1.f) / tgt::vec3(texture->getDimensions())); _paintShader->setUniform("_texture3d._sizeRCP", tgt::vec3(1.f) / tgt::vec3(texture->getDimensions()));
} }
...@@ -274,8 +278,25 @@ namespace campvis { ...@@ -274,8 +278,25 @@ namespace campvis {
_selectedTexture = (selectedIndex.y * _numTiles.x) + selectedIndex.x; _selectedTexture = (selectedIndex.y * _numTiles.x) + selectedIndex.x;
_renderFullscreen = true; _renderFullscreen = true;
} }
e->accept(); e->ignore();
invalidate(); invalidate();
} }
void DataContainerInspectorCanvas::wheelEvent(tgt::MouseEvent* e) {
if (_renderFullscreen) {
switch (e->button()) {
case tgt::MouseEvent::MOUSE_WHEEL_UP:
++_currentSlice; // we cant clamp the value here to the number of slices - we do this during rendering
e->ignore();
break;
case tgt::MouseEvent::MOUSE_WHEEL_DOWN:
if (_currentSlice >= -1)
--_currentSlice;
e->ignore();
break;
}
invalidate();
}
}
} }
\ No newline at end of file
...@@ -106,6 +106,12 @@ namespace campvis { ...@@ -106,6 +106,12 @@ namespace campvis {
*/ */
virtual void mouseDoubleClickEvent(tgt::MouseEvent* e); virtual void mouseDoubleClickEvent(tgt::MouseEvent* e);
/**
* Called on mouse wheel even on this canvas.
* \param e Mouse event arguments
*/
virtual void wheelEvent(tgt::MouseEvent* e);
private slots: private slots:
protected: protected:
...@@ -146,6 +152,8 @@ namespace campvis { ...@@ -146,6 +152,8 @@ namespace campvis {
size_t _selectedTexture; ///< index of selected texture for fullscreen view size_t _selectedTexture; ///< index of selected texture for fullscreen view
bool _renderFullscreen; ///< flag whether to render in full screen bool _renderFullscreen; ///< flag whether to render in full screen
int _currentSlice; ///< current slice if rendering a 3D image fullscreen, render MIP if negative
}; };
} }
......
...@@ -150,7 +150,7 @@ namespace campvis { ...@@ -150,7 +150,7 @@ namespace campvis {
DataHandle dh = tf->getImageHandle(); DataHandle dh = tf->getImageHandle();
if (dh.getData() != 0) { if (dh.getData() != 0) {
const ImageRepresentationLocal* idl = dynamic_cast<const ImageRepresentationLocal*>(dh.getData()); const ImageRepresentationLocal* idl = static_cast<const ImageData*>(dh.getData())->getRepresentation<ImageRepresentationLocal>();
if (idl != 0) { if (idl != 0) {
Interval<float> intensityInterval = idl->getNormalizedIntensityRange(); Interval<float> intensityInterval = idl->getNormalizedIntensityRange();
tf->setIntensityDomain(tgt::vec2(intensityInterval.getLeft(), intensityInterval.getRight())); tf->setIntensityDomain(tgt::vec2(intensityInterval.getLeft(), intensityInterval.getRight()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment