Commit 560725ab authored by schurade's avatar schurade

[ADD] vector plot

[ADD] switch for filtering on textures
parent 870b2d50
......@@ -38,7 +38,8 @@ WDataTexture3D::WDataTexture3D( boost::shared_ptr<WValueSetBase> valueSet, boost
m_valueSet( valueSet ),
m_grid( boost::shared_dynamic_cast< WGridRegular3D >( grid ) ),
m_changeCondition( new WCondition() ),
m_globalActive( true )
m_globalActive( true ),
m_interpolation( true )
{
// initialize members
}
......@@ -463,3 +464,14 @@ float WDataTexture3D::scaleInterval( float value ) const
//return ( value - m_minValue ) / m_scale;
}
bool WDataTexture3D::isInterpolated()
{
return m_interpolation;
}
void WDataTexture3D::setInterpolation( bool interpol )
{
m_interpolation = interpol;
notifyChange();
}
......@@ -158,6 +158,18 @@ public:
*/
float getMinMaxScale();
/**
* getter
*/
bool isInterpolated();
/**
* setter
*
* \param interpol
*/
void setInterpolation( bool interpol );
protected:
/**
......@@ -249,6 +261,11 @@ protected:
*/
bool m_globalActive;
/**
* flag denotes whether the texture filter should active or not
*/
bool m_interpolation;
/**
* This method finds the minimum and maximum value of a dataset. These values get used to scale the texture to use the maximum precision.
*
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WCrosshair.h"
WCrosshair::WCrosshair()
{
}
WCrosshair::~WCrosshair()
{
}
wmath::WPosition WCrosshair::getPosition()
{
return m_position;
}
void WCrosshair::setPosition( wmath::WPosition position )
{
m_position = position;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WCROSSHAIR_H
#define WCROSSHAIR_H
#include <boost/shared_ptr.hpp>
#include "../common/math/WVector3D.h"
/**
* TODO(schurade): Document this!
*/
class WCrosshair
{
public:
/**
* TODO(schurade): Document this!
*/
WCrosshair();
/**
* TODO(schurade): Document this!
*/
~WCrosshair();
/**
* getter
*/
wmath::WPosition getPosition();
/**
* setter
*
* \param position
*/
void setPosition( wmath::WPosition position );
protected:
private:
wmath::WPosition m_position; //!< stores the position
};
#endif // WCROSSHAIR_H
......@@ -96,6 +96,8 @@ void WKernel::init()
findAppPath();
m_roiManager = boost::shared_ptr< WROIManagerFibers >( new WROIManagerFibers() );
m_selectionManager = boost::shared_ptr< WSelectionManager >( new WSelectionManager() );
// get module factory
m_moduleFactory = WModuleFactory::getModuleFactory();
......@@ -256,3 +258,8 @@ std::string WKernel::getFontPath()
findAppPath();
return WKernel::m_fontPath.file_string();
}
boost::shared_ptr< WSelectionManager>WKernel::getSelectionManager()
{
return m_selectionManager;
}
......@@ -37,6 +37,7 @@
#include "../graphicsEngine/WGraphicsEngine.h"
#include "../gui/WGUI.h"
#include "../modules/fiberDisplay/WROIManagerFibers.h"
#include "WSelectionManager.h"
#include "WModule.h"
#include "WModuleContainer.h"
#include "WModuleFactory.h"
......@@ -167,6 +168,10 @@ public:
*/
boost::shared_ptr< WROIManagerFibers>getRoiManager();
/**
* get for selection manager
*/
boost::shared_ptr< WSelectionManager>getSelectionManager();
/**
* getter for font path
......@@ -196,6 +201,11 @@ protected:
*/
boost::shared_ptr< WROIManagerFibers >m_roiManager;
/**
* pointer to a selection manager
*/
boost::shared_ptr< WSelectionManager >m_selectionManager;
/**
* The module factory to use.
*/
......
......@@ -53,6 +53,7 @@
#include "../modules/voxelizer/WMVoxelizer.h"
#include "../modules/triangleMeshRenderer/WMTriangleMeshRenderer.h"
#include "../modules/writeNIfTI/WMWriteNIfTI.h"
#include "../modules/vectorPlot/WMVectorPlot.h"
#include "WModuleFactory.h"
#include "exceptions/WPrototypeNotUnique.h"
#include "exceptions/WPrototypeUnknown.h"
......@@ -104,6 +105,7 @@ void WModuleFactory::load()
m_prototypes.insert( boost::shared_ptr< WModule >( new WMFiberSelection() ) );
m_prototypes.insert( boost::shared_ptr< WModule >( new WMSurfaceParticles() ) );
m_prototypes.insert( boost::shared_ptr< WModule >( new WMClusterSlicer() ) );
m_prototypes.insert( boost::shared_ptr< WModule >( new WMVectorPlot() ) );
lock.unlock();
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WSelectionManager.h"
WSelectionManager::WSelectionManager()
{
m_crosshair = boost::shared_ptr< WCrosshair >( new WCrosshair() );
}
WSelectionManager::~WSelectionManager()
{
}
boost::shared_ptr< WCrosshair >WSelectionManager::getCrosshair()
{
return m_crosshair;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WSELECTIONMANAGER_H
#define WSELECTIONMANAGER_H
#include <boost/shared_ptr.hpp>
#include "WCrosshair.h"
/**
* manages the several selection tools
*/
class WSelectionManager
{
public:
/**
* standard constructor
*/
WSelectionManager();
/**
* destructor
*/
virtual ~WSelectionManager();
/**
* getter
*/
boost::shared_ptr< WCrosshair >getCrosshair();
protected:
private:
boost::shared_ptr< WCrosshair >m_crosshair; //!< stores pointer to crosshair
};
#endif // WSELECTIONMANAGER_H
......@@ -7,3 +7,4 @@ ADD_SUBDIRECTORY( voxelizer )
ADD_SUBDIRECTORY( clusterParamDisplay )
ADD_SUBDIRECTORY( clusterSlicer )
ADD_SUBDIRECTORY( contourTree )
ADD_SUBDIRECTORY( vectorPlot )
......@@ -130,6 +130,10 @@ void WMData::propertyChanged( boost::shared_ptr< WPropertyBase > property )
{
m_dataSet->getTexture()->setGloballyActive( m_active->get() );
}
else if ( property == m_interpolation )
{
m_dataSet->getTexture()->setInterpolation( m_interpolation->get() );
}
}
else
{
......
......@@ -34,7 +34,6 @@
#include "../../kernel/WModuleInputData.h"
#include "../../graphicsEngine/WShader.h"
#include "../../common/math/WPosition.h"
#include "WTubeDrawable.h"
......
......@@ -460,6 +460,8 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
quad->push_back( 0 );
sliceGeometry->addPrimitiveSet( quad );
}
WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->setPosition(
wmath::WPosition( m_sagittalPos->get(), m_coronalPos->get(), m_axialPos->get() ) );
return sliceGeometry;
}
......@@ -537,6 +539,17 @@ void WMNavSlices::updateTextures()
for ( std::vector< boost::shared_ptr< WDataTexture3D > >::const_iterator iter = tex.begin(); iter != tex.end(); ++iter )
{
osg::ref_ptr<osg::Texture3D> texture3D = ( *iter )->getTexture();
if ( ( *iter )->isInterpolated() )
{
texture3D->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR );
texture3D->setFilter( osg::Texture::MAG_FILTER, osg::Texture::LINEAR );
}
else
{
texture3D->setFilter( osg::Texture::MIN_FILTER, osg::Texture::NEAREST );
texture3D->setFilter( osg::Texture::MAG_FILTER, osg::Texture::NEAREST );
}
rootState->setTextureAttributeAndModes( c, texture3D, osg::StateAttribute::ON );
// set threshold/opacity as uniforms
......
This diff is collapsed.
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMVECTORPLOT_H
#define WMVECTORPLOT_H
#include <string>
#include <vector>
#include <osg/Geode>
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/WModuleOutputData.h"
#include "../../common/math/WVector3D.h"
/**
* This module is intended to be a simple template and example module. It can be used for fast creation of new modules by copying and refactoring
* the files. It shows the basic usage of properties, update callbacks and how to wait for data.
* \ingroup modules
*/
class WMVectorPlot: public WModule
{
public:
/**
* Default constructor.
*/
WMVectorPlot();
/**
* Destructor.
*/
virtual ~WMVectorPlot();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual const std::string getName() const;
/**
* Gives back a description of this module.
* \return description to module.
*/
virtual const std::string getDescription() const;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Get the icon for this module in XPM format.
*/
virtual const char** getXPMIcon() const;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual void moduleMain();
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
* Initialize the properties for this module.
*/
virtual void properties();
/**
* The root node used for this modules graphics. For OSG nodes, always use osg::ref_ptr to ensure proper resource management.
*/
osg::ref_ptr<osg::Geode> m_rootNode;
/**
* Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
*/
virtual void activate();
private:
/**
* creates a vector plot on the currently selected slices
*/
osg::ref_ptr<osg::Geometry> buildPlotSlices();
/**
* An input connector used to get datasets from other modules. The connection management between connectors must not be handled by the module.
*/
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input;
/**
* This is a pointer to the dataset the module is currently working on.
*/
boost::shared_ptr< WDataSetSingle > m_dataSet;
/**
* A condition used to notify about changes in several properties.
*/
boost::shared_ptr< WCondition > m_propCondition;
/**
* list of positions to plot vectors on, this will come from a selection tool class
*/
boost::shared_ptr< std::vector< wmath::WPosition > > m_positions;
/**
* projects the vectors on the slice.
*/
WPropBool m_projectOnSlice;
/**
* Switches between a set color or direction color coding.
*/
WPropBool m_coloringMode;
/**
* An integer value.
*/
WPropInt m_xPos;
/**
* An integer value.
*/
WPropInt m_yPos;
/**
* An integer value.
*/
WPropInt m_zPos;
/**
* A color.
*/
WPropColor m_aColor;
/**
* Node callback to change the color of the shapes inside the root node. For more details on this class, refer to the documentation in
* moduleMain().
*/
class SafeUpdateCallback : public osg::NodeCallback
{
public: // NOLINT
/**
* Constructor.
*
* \param module just set the creating module as pointer for later reference.
*/
explicit SafeUpdateCallback( WMVectorPlot* module ): m_module( module ), m_initialUpdate( true )
{
};
/**
* operator () - called during the update traversal.
*
* \param node the osg node
* \param nv the node visitor
*/
virtual void operator()( osg::Node* node, osg::NodeVisitor* nv );
/**
* Pointer used to access members of the module to modify the node.
*/
WMVectorPlot* m_module;
/**
* Denotes whether the update callback is called the first time.
*/
bool m_initialUpdate;
};
/**
* This shows how to write custom constraints for your modules. Please refer to the documentation in properties() for more details.
*
* \note: always use WPVBaseTypes to specialize the PropertyVariable template.
*/
class StringLength: public WPropertyVariable< WPVBaseTypes::PV_STRING >::PropertyConstraint
{
/**
* You need to overwrite this method. It decides whether the specified new value should be accepted or not.
*
* \param property the property thats going to be changed.
* \param value the new value
*
* \return true if the new value is OK.
*/
virtual bool accept( boost::shared_ptr< WPropertyVariable< WPVBaseTypes::PV_STRING > > property, WPVBaseTypes::PV_STRING value );
};
};
#endif // WMVECTORPLOT_H
/* XPM */
static const char * template_xpm[] = {
"16 16 2 1",
" c None",
". c #000000",
" ",
" ",
" .......... ",
" .......... ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",
" .. ",