Commit bf76b613 authored by schurade's avatar schurade

[ADD] abillity to transfer a cluster into a roi

parent 86ff39dc
//---------------------------------------------------------------------------
//
// 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 <vector>
#include "WROIBitfield.h"
WROIBitfield::WROIBitfield( boost::shared_ptr< std::vector<bool> > bitfield ) :
WROI(),
m_bitfield( bitfield )
{
}
WROIBitfield::~WROIBitfield()
{
}
void WROIBitfield::updateGFX()
{
}
//---------------------------------------------------------------------------
//
// 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 WROIBITFIELD_H
#define WROIBITFIELD_H
#include <vector>
#include "WROI.h"
/**
* defines a roi by a simple bitfield that never changes
* while a normal roi computes it's bitfield from it's location in space and the fibers passing through,
* this roi simply stores a bitfield of previously selected fibers
*/
class WROIBitfield : public WROI
{
public:
/**
* constructor
* \param bitfield pointer to a bitfield
*/
explicit WROIBitfield( boost::shared_ptr< std::vector<bool> > bitfield );
/**
* destructor
*/
virtual ~WROIBitfield();
/**
* getter
* \return the bitfield of selected fibers
*/
boost::shared_ptr< std::vector<bool> >getBitfield();
protected:
private:
/**
* does nothing but had to be implemented beccause it's pure virtual in WROI
*/
void updateGFX();
boost::shared_ptr< std::vector<bool> >m_bitfield; //!< stores pointer to the bitfield
};
inline boost::shared_ptr< std::vector<bool> >WROIBitfield::getBitfield()
{
return m_bitfield;
}
#endif // WROIBITFIELD_H
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "../../../graphicsEngine/WGraphicsEngine.h" #include "../../../graphicsEngine/WGraphicsEngine.h"
#include "../../../graphicsEngine/WROIBox.h" #include "../../../graphicsEngine/WROIBox.h"
#include "../../../graphicsEngine/WROIArbitrary.h" #include "../../../graphicsEngine/WROIArbitrary.h"
#include "../../../graphicsEngine/WROIBitfield.h"
#include "WRMBranch.h" #include "WRMBranch.h"
#include "WROIManagerFibers.h" #include "WROIManagerFibers.h"
...@@ -164,6 +165,13 @@ void WRMROIRepresentation::recalculate() ...@@ -164,6 +165,13 @@ void WRMROIRepresentation::recalculate()
} }
} }
} }
if ( osg::dynamic_pointer_cast<WROIBitfield>( m_roi ).get() )
{
osg::ref_ptr<WROIBitfield>roi = osg::dynamic_pointer_cast<WROIBitfield>( m_roi );
m_workerBitfield = roi->getBitfield();
}
m_dirty = false; m_dirty = false;
m_outputBitfield = m_workerBitfield; m_outputBitfield = m_workerBitfield;
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "../../common/WPathHelper.h" #include "../../common/WPathHelper.h"
#include "../../common/WPropertyHelper.h" #include "../../common/WPropertyHelper.h"
#include "../../graphicsEngine/WROISphere.h" #include "../../graphicsEngine/WROIBitfield.h"
#include "../../graphicsEngine/WGEUtils.h" #include "../../graphicsEngine/WGEUtils.h"
#include "../../kernel/WKernel.h" #include "../../kernel/WKernel.h"
...@@ -344,6 +344,8 @@ void WMClusterDisplay::properties() ...@@ -344,6 +344,8 @@ void WMClusterDisplay::properties()
m_propTreeFile = m_properties->addProperty( "Tree file", "", WPathHelper::getAppPath() ); m_propTreeFile = m_properties->addProperty( "Tree file", "", WPathHelper::getAppPath() );
m_readTriggerProp = m_properties->addProperty( "Do read", "Press!", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition ); m_readTriggerProp = m_properties->addProperty( "Do read", "Press!", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
WPropertyHelper::PC_PATHEXISTS::addTo( m_propTreeFile ); WPropertyHelper::PC_PATHEXISTS::addTo( m_propTreeFile );
m_createRoiTrigger = m_properties->addProperty( "Create Roi", "Press!", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
} }
void WMClusterDisplay::moduleMain() void WMClusterDisplay::moduleMain()
...@@ -482,6 +484,12 @@ void WMClusterDisplay::moduleMain() ...@@ -482,6 +484,12 @@ void WMClusterDisplay::moduleMain()
{ {
WKernel::getRunningKernel()->getRoiManager()->setUseExternalBitfield( m_active->get( true ) ); WKernel::getRunningKernel()->getRoiManager()->setUseExternalBitfield( m_active->get( true ) );
} }
if ( m_createRoiTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
handleCreateRoi();
m_createRoiTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, true );
}
} }
con.disconnect(); con.disconnect();
...@@ -495,10 +503,12 @@ void WMClusterDisplay::handleSelectedClusterChanged() ...@@ -495,10 +503,12 @@ void WMClusterDisplay::handleSelectedClusterChanged()
m_propSelectedClusterOffset->setMin( 0 - m_tree.getLevel( m_propSelectedCluster->get() ) ); m_propSelectedClusterOffset->setMin( 0 - m_tree.getLevel( m_propSelectedCluster->get() ) );
m_propSelectedClusterOffset->set( 0 ); m_propSelectedClusterOffset->set( 0 );
m_propSelectedClusterOffset->get( true ); m_propSelectedClusterOffset->get( true );
m_propMinSizeToColor->setMax( m_tree.size( m_biggestClusters.back() ) );
WKernel::getRunningKernel()->getRoiManager()->setExternalBitfield( m_tree.getOutputBitfield( m_rootCluster ) ); WKernel::getRunningKernel()->getRoiManager()->setExternalBitfield( m_tree.getOutputBitfield( m_rootCluster ) );
m_propSubLevelsToColor->setMax( m_tree.getLevel( m_rootCluster ) ); m_propSubLevelsToColor->setMax( m_tree.getLevel( m_rootCluster ) );
//colorClusters( m_propSelectedCluster->get( true ) ); //colorClusters( m_propSelectedCluster->get( true ) );
m_dendrogramDirty = true; m_dendrogramDirty = true;
} }
...@@ -555,9 +565,12 @@ void WMClusterDisplay::handleBiggestClustersChanged() ...@@ -555,9 +565,12 @@ void WMClusterDisplay::handleBiggestClustersChanged()
{ {
m_biggestClusters = m_tree.findXBiggestClusters( m_propSelectedCluster->get(), m_propSubClusters->get( true ) ); m_biggestClusters = m_tree.findXBiggestClusters( m_propSelectedCluster->get(), m_propSubClusters->get( true ) );
m_propMinSizeToColor->setMax( m_tree.size( m_biggestClusters.back() ) );
WKernel::getRunningKernel()->getRoiManager()->setExternalBitfield( m_tree.getOutputBitfield( m_biggestClusters ) ); WKernel::getRunningKernel()->getRoiManager()->setExternalBitfield( m_tree.getOutputBitfield( m_biggestClusters ) );
m_tree.colorCluster( m_tree.getClusterCount() - 1, WColor( 0.3, 0.3, 0.3, 1.0 ) ); m_tree.colorCluster( m_tree.getClusterCount() - 1, WColor( 0.3, 0.3, 0.3, 1.0 ) );
setColor( m_tree.getLeafesForCluster( m_rootCluster ), WColor( 0.3, 0.3, 0.3, 1.0 ) );
for ( size_t k = 0; k < m_biggestClusters.size(); ++k ) for ( size_t k = 0; k < m_biggestClusters.size(); ++k )
{ {
...@@ -606,9 +619,21 @@ void WMClusterDisplay::handleRoiChanged() ...@@ -606,9 +619,21 @@ void WMClusterDisplay::handleRoiChanged()
if ( ( m_propMaxSubClusters->get( true ) == 1 ) && ( m_biggestClusters.size() > 0 ) ) if ( ( m_propMaxSubClusters->get( true ) == 1 ) && ( m_biggestClusters.size() > 0 ) )
{ {
m_propSelectedCluster->set( m_biggestClusters[0] ); m_propSelectedCluster->set( m_biggestClusters[0] );
m_tree.colorCluster( m_tree.getClusterCount() - 1, WColor( 0.3, 0.3, 0.3, 1.0 ) );
setColor( m_tree.getLeafesForCluster( m_rootCluster ), WColor( 0.3, 0.3, 0.3, 1.0 ) );
m_tree.colorCluster( m_propSelectedCluster->get(), WColor( 1.0, 0.3, 0.3, 1.0 ) );
setColor( m_tree.getLeafesForCluster( m_propSelectedCluster->get() ), WColor( 1.0, 0.3, 0.3, 1.0 ) );
} }
} }
void WMClusterDisplay::handleCreateRoi()
{
osg::ref_ptr< WROI > newRoi = osg::ref_ptr< WROI >( new WROIBitfield( m_tree.getOutputBitfield( m_propSelectedCluster->get() ) ) );
WKernel::getRunningKernel()->getRoiManager()->addRoi( newRoi );
}
void WMClusterDisplay::updateWidgets() void WMClusterDisplay::updateWidgets()
{ {
...@@ -736,7 +761,7 @@ void WMClusterDisplay::updateWidgets() ...@@ -736,7 +761,7 @@ void WMClusterDisplay::updateWidgets()
if ( m_propShowDendrogram->get( true ) ) if ( m_propShowDendrogram->get( true ) )
{ {
m_dendrogramGeode = new WDendrogram( &m_tree, m_rootCluster, m_propMinSizeToColor->get(), width - 120, height / 2 , 100 ); m_dendrogramGeode = new WDendrogram( &m_tree, m_tree.getClusterCount() - 1, m_propMinSizeToColor->get(), width - 120, height / 2 , 100 );
m_camera->addChild( m_dendrogramGeode ); m_camera->addChild( m_dendrogramGeode );
} }
m_dendrogramDirty = false; m_dendrogramDirty = false;
......
...@@ -185,6 +185,11 @@ private: ...@@ -185,6 +185,11 @@ private:
*/ */
void handleRoiChanged(); void handleRoiChanged();
/**
* function to handle user input
*/
void handleCreateRoi();
/** /**
* creates a label depending ont he current labeling setting * creates a label depending ont he current labeling setting
* *
...@@ -195,6 +200,7 @@ private: ...@@ -195,6 +200,7 @@ private:
/** /**
* listenes to the pickhandler and determines if a click into the dendrogram happened * listenes to the pickhandler and determines if a click into the dendrogram happened
* \param pickInfo the pickInfo object as sent out by the pickhandler
*/ */
void dendrogramClick( WPickInfo pickInfo ); void dendrogramClick( WPickInfo pickInfo );
...@@ -259,6 +265,7 @@ private: ...@@ -259,6 +265,7 @@ private:
WPropTrigger m_readTriggerProp; //!< This property triggers the actual reading, WPropTrigger m_readTriggerProp; //!< This property triggers the actual reading,
WPropFilename m_propTreeFile; //!< The tree will be read from this file, i hope we will get a real load button some time WPropFilename m_propTreeFile; //!< The tree will be read from this file, i hope we will get a real load button some time
WPropTrigger m_createRoiTrigger; //!< when triggered the selected cluster will be transfered into a WRoiBitfield
/** /**
* stores the tree object * stores the tree object
......
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