Commit 6cadbd0d authored by schurade's avatar schurade
Browse files

[CHANGE] major refactoring of the roi structure

parent f1e9c793
......@@ -29,12 +29,33 @@
WROI::WROI() :
osg::Geode()
{
properties();
}
WROI::~WROI()
{
}
void WROI::properties()
{
m_properties = boost::shared_ptr< WProperties >( new WProperties( "Properties", "This ROI's properties" ) );
m_active = m_properties->addProperty( "active", "description", true, boost::bind( &WROI::propertyChanged, this ) );
m_active->setHidden( true );
m_dirty = m_properties->addProperty( "Dirty", "description", true, boost::bind( &WROI::propertyChanged, this ) );
m_not = m_properties->addProperty( "NOT", "description", false, boost::bind( &WROI::propertyChanged, this ) );
}
void WROI::propertyChanged()
{
}
boost::shared_ptr<WProperties> WROI::getProperties()
{
return m_properties;
}
boost::signals2::signal0< void >* WROI::getSignalIsModified()
{
return &m_signalIsModified;
......@@ -42,31 +63,38 @@ boost::signals2::signal0< void >* WROI::getSignalIsModified()
void WROI::setNot( bool isNot )
{
m_isNot = isNot;
m_isModified = true;
m_not->set( isNot );
m_dirty->set( true );
}
bool WROI::isNot()
{
return m_isNot;
return m_not->get();
}
bool WROI::isActive()
bool WROI::active()
{
return m_isActive;
return m_active->get();
}
void WROI::setActive( bool active )
{
m_isActive = active;
m_isModified = true;
m_active->set( active );
m_dirty->set( true );
}
bool WROI::isModified()
bool WROI::dirty( bool reset )
{
bool tmp = m_isModified;
m_isModified = false;
return tmp;
if ( reset )
{
bool tmp = m_dirty->get();
m_dirty->set( false );
return tmp;
}
else
{
return m_dirty->get();
}
}
void WROI::hide()
......
......@@ -32,7 +32,9 @@
#include <osg/Geode>
#include "../common/WColor.h"
#include "../common/WProperties.h"
#include "WExportWGE.h"
class WPickHandler;
......@@ -76,7 +78,7 @@ public:
*
* \return the active flag
*/
bool isActive();
bool active();
/**
* setter
......@@ -97,27 +99,62 @@ public:
/**
* Getter for modified flag
* \param reset if true the dirty flag will be set to false
* \return the dirty flag
*/
bool isModified();
bool dirty( bool reset = false );
/**
* Getter
* \return the properties object for this roi
*/
boost::shared_ptr< WProperties > getProperties();
protected:
osg::ref_ptr< WPickHandler > m_pickHandler; //!< A pointer to the pick handler used to get gui events for moving the box.
/**
* initializes the roi's properties
*/
void properties();
/**
* callback when a property gets changed
*/
void propertyChanged();
bool m_isModified; //!< Indicates whether a changed ROI has already taken effect. Means: if true, still some updates needed.
osg::ref_ptr< WPickHandler > m_pickHandler; //!< A pointer to the pick handler used to get gui events for moving the box.
/**
* boost signal object to indicate box manipulation
*/
boost::signals2::signal0< void >m_signalIsModified;
bool m_isNot; //!< Indivated whether the region of interest is inside the WROI (false) oroutside (true).
/**
* the property object for the module
*/
boost::shared_ptr< WProperties > m_properties;
WPropBool m_dirty; //!< dirty flag, indicates the bit fields need updating
/**
* indicates if the roi is active
*/
WPropBool m_active;
/**
* indicates if the roi is negated
*/
WPropBool m_not;
WColor m_color; //!< The selected onject (Fibers, region on surface, ...) will have this color if m_useColor.
/**
* threshold for an arbitrary roi
*/
WPropDouble m_threshold;
bool m_useColor; //!< Indicated whether m_color should be used for display.
/**
* A color for painting the roi in the scene
*/
WPropColor m_color;
bool m_isActive; //!< active or not
private:
/**
......
......@@ -51,18 +51,22 @@ WROIArbitrary::WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoord
m_matrix( mat ),
m_vals( vals ),
m_triMesh( triMesh ),
m_threshold( threshold ),
m_maxThreshold( maxThreshold ),
m_color( color )
{
m_nbCoordsVec[0] = nbCoordsX;
m_nbCoordsVec[1] = nbCoordsY;
m_nbCoordsVec[2] = nbCoordsZ;
properties();
updateGFX();
m_isModified = true;
m_dirty->set( true );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( this );
setUserData( this );
setUpdateCallback( osg::ref_ptr<ROIArbNodeCallback>( new ROIArbNodeCallback ) );
m_threshold->set( threshold );
m_threshold->setMax( maxThreshold );
}
WROIArbitrary::WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
......@@ -74,19 +78,22 @@ WROIArbitrary::WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoord
m_nbCoordsVec( 3 ),
m_matrix( mat ),
m_vals( vals ),
m_threshold( 0.01 ),
m_maxThreshold( maxThreshold ),
m_color( color )
{
m_nbCoordsVec[0] = nbCoordsX;
m_nbCoordsVec[1] = nbCoordsY;
m_nbCoordsVec[2] = nbCoordsZ;
properties();
updateGFX();
m_isModified = true;
m_dirty->set( true );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( this );
setUserData( this );
setUpdateCallback( osg::ref_ptr< ROIArbNodeCallback >( new ROIArbNodeCallback ) );
m_threshold->set( 0.01 );
m_threshold->setMax( maxThreshold );
}
WROIArbitrary::~WROIArbitrary()
......@@ -97,20 +104,20 @@ WROIArbitrary::~WROIArbitrary()
// WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_geode );
}
void WROIArbitrary::setThreshold( double threshold )
void WROIArbitrary::properties()
{
m_threshold = threshold;
m_isModified = true;
m_threshold = m_properties->addProperty( "Threshold", "description", 0. ); // , boost::bind( &WROI::propertyChanged, this )
}
double WROIArbitrary::getThreshold()
void WROIArbitrary::setThreshold( double threshold )
{
return m_threshold;
m_threshold->set( threshold );
m_dirty->set( true );
}
double WROIArbitrary::getMaxThreshold()
double WROIArbitrary::getThreshold()
{
return m_maxThreshold;
return m_threshold->get();
}
std::vector< size_t > WROIArbitrary::getCoordDimensions()
......@@ -134,14 +141,14 @@ float WROIArbitrary::getValue( size_t i )
void WROIArbitrary::updateGFX()
{
if ( m_isModified )
if ( m_dirty->get() )
{
boost::shared_ptr< WProgressCombiner > progress = boost::shared_ptr< WProgressCombiner >( new WProgressCombiner() );
WMarchingCubesAlgorithm mcAlgo;
m_triMesh = mcAlgo.generateSurface( m_nbCoordsVec[0], m_nbCoordsVec[1], m_nbCoordsVec[2],
m_matrix,
&m_vals,
m_threshold,
m_threshold->get(),
progress );
osg::Geometry* surfaceGeometry = new osg::Geometry();
......@@ -190,6 +197,6 @@ void WROIArbitrary::updateGFX()
// state->setAttribute( material );
// }
m_isModified = false;
m_dirty->set( false );
}
}
......@@ -92,6 +92,11 @@ public:
*/
virtual ~WROIArbitrary();
/**
* initalizes the properties
*/
void properties();
/**
* setter
* \param threshold
......@@ -136,8 +141,7 @@ private:
wmath::WMatrix< double > m_matrix; //!< The 4x4 transformation matrix for the vertices.
const std::vector< float > m_vals; //!< The data at the vertices.
boost::shared_ptr< WTriangleMesh2 > m_triMesh; //!< This triangle mesh is provided as output through the connector.
float m_threshold; //!< the threshold
float m_maxThreshold; //!< the threshold
WPropDouble m_threshold; //!< the threshold
/**
* The ROI color
......
......@@ -174,8 +174,8 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
state->setAttributeAndModes( lightModel.get(), osg::StateAttribute::ON );
state->setMode( GL_BLEND, osg::StateAttribute::ON );
m_isModified = true;
m_isNot = false;
m_dirty->set( true );
m_not->set( false );
assert( WGraphicsEngine::getGraphicsEngine() );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( this );
......@@ -276,7 +276,7 @@ void WROIBox::updateGFX()
if( m_pickInfo.getModifierKey() == WPickInfo::NONE )
{
osg::ref_ptr<osg::Vec4Array> colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array );
if ( m_isNot )
if ( m_not->get() )
{
colors->push_back( m_notColor );
}
......@@ -294,7 +294,7 @@ void WROIBox::updateGFX()
}
}
m_oldPixelPosition = newPixelPos;
m_isModified = true;
m_dirty->set( true );
m_isPicked = true;
m_signalIsModified();
......@@ -304,7 +304,7 @@ void WROIBox::updateGFX()
// Perform all actions necessary for finishing a pick
osg::ref_ptr<osg::Vec4Array> colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array );
if ( m_isNot )
if ( m_not->get() )
{
colors->push_back( m_notColor );
}
......@@ -317,10 +317,10 @@ void WROIBox::updateGFX()
m_isPicked = false;
}
if ( isModified() )
if ( m_dirty->get() )
{
osg::ref_ptr<osg::Vec4Array> colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array );
if ( m_isNot )
if ( m_not->get() )
{
colors->push_back( m_notColor );
}
......
......@@ -58,8 +58,7 @@ WROISphere::WROISphere( wmath::WPosition position, float radius ) :
redrawSphere();
//**********************************************************
m_isModified = true;
m_isNot = false;
m_dirty->set( true );
setUserData( this );
setUpdateCallback( osg::ref_ptr<ROISphereNodeCallback>( new ROISphereNodeCallback ) );
......@@ -97,7 +96,7 @@ void WROISphere::setPosition( wmath::WPosition position )
{
m_position = position;
m_originalPosition = position;
m_isModified = true;
m_dirty->set( true );
}
void WROISphere::registerRedrawRequest( WPickInfo pickInfo )
......@@ -142,7 +141,7 @@ void WROISphere::updateGFX()
}
m_oldPixelPosition = newPixelPos;
m_isModified = true;
m_dirty->set( true );
m_isPicked = true;
m_signalIsModified();
......@@ -154,7 +153,7 @@ void WROISphere::updateGFX()
m_isPicked = false;
}
if ( isModified() )
if ( m_dirty->get() )
{
redrawSphere();
}
......
......@@ -361,12 +361,7 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
else if( dataModule->getDataSet()->isA< WDataSetFibers >() )
{
// it is a fiber dataset -> add the FiberDisplay module
// if it not already is running: add it
if( !WMFiberDisplay::isRunning() )
{
autoAdd( module, "Fiber Display" );
}
autoAdd( module, "Fiber Display" );
}
else if( dataModule->getDataSet()->isA< WEEG2 >() )
{
......@@ -967,12 +962,6 @@ void WMainWindow::closeCustomDockWidget( std::string title )
void WMainWindow::newRoi()
{
// do nothing if we can not get
if( !WKernel::getRunningKernel()->getRoiManager()->getBitField() )
{
wlog::warn( "WMainWindow" ) << "Refused to add ROI, as ROIManager does not have computed its bitfield yet.";
return;
}
wmath::WPosition crossHairPos = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
wmath::WPosition minROIPos = crossHairPos - wmath::WPosition( 10., 10., 10. );
wmath::WPosition maxROIPos = crossHairPos + wmath::WPosition( 10., 10., 10. );
......@@ -985,7 +974,7 @@ void WMainWindow::newRoi()
else
{
osg::ref_ptr< WROIBox > newRoi = osg::ref_ptr< WROIBox >( new WROIBox( minROIPos, maxROIPos ) );
WKernel::getRunningKernel()->getRoiManager()->addRoi( newRoi, m_controlPanel->getFirstRoiInSelectedBranch()->getROI() );
WKernel::getRunningKernel()->getRoiManager()->addRoi( newRoi, m_controlPanel->getFirstRoiInSelectedBranch() );
}
}
......
......@@ -192,10 +192,10 @@ int WQt4Gui::run()
t_GenericSignalHandlerType connectionClosedSignal = boost::bind( &WQt4Gui::slotConnectionClosed, this, _1, _2 );
m_kernel->getRootContainer()->addDefaultNotifier( CONNECTION_CLOSED, connectionClosedSignal );
boost::function< void( boost::shared_ptr< WRMROIRepresentation > ) > assocRoiSignal =
boost::function< void( osg::ref_ptr< WROI > ) > assocRoiSignal =
boost::bind( &WQt4Gui::slotAddRoiToTree, this, _1 );
m_kernel->getRoiManager()->addAddNotifier( assocRoiSignal );
boost::function< void( boost::shared_ptr< WRMROIRepresentation > ) > removeRoiSignal =
boost::function< void( osg::ref_ptr< WROI > ) > removeRoiSignal =
boost::bind( &WQt4Gui::slotRemoveRoiFromTree, this, _1 );
m_kernel->getRoiManager()->addRemoveNotifier( removeRoiSignal );
......@@ -282,12 +282,12 @@ void WQt4Gui::slotAddDatasetOrModuleToTree( boost::shared_ptr< WModule > module
QCoreApplication::postEvent( m_mainWindow->getControlPanel(), new WModuleAssocEvent( module ) );
}
void WQt4Gui::slotAddRoiToTree( boost::shared_ptr< WRMROIRepresentation > roi )
void WQt4Gui::slotAddRoiToTree( osg::ref_ptr< WROI > roi )
{
QCoreApplication::postEvent( m_mainWindow->getControlPanel(), new WRoiAssocEvent( roi ) );
}
void WQt4Gui::slotRemoveRoiFromTree( boost::shared_ptr< WRMROIRepresentation > roi )
void WQt4Gui::slotRemoveRoiFromTree( osg::ref_ptr< WROI > roi )
{
QCoreApplication::postEvent( m_mainWindow->getControlPanel(), new WRoiRemoveEvent( roi ) );
}
......
......@@ -30,8 +30,10 @@
#include <boost/program_options.hpp>
#include "../../graphicsEngine/WROI.h"
#include "../../kernel/WModule.h"
#include "../../kernel/modules/fiberDisplay/WRMROIRepresentation.h"
#include "../WGUI.h"
class WMainWindow;
......@@ -91,14 +93,14 @@ public:
*
* \param roi the roi to be added
*/
virtual void slotAddRoiToTree( boost::shared_ptr< WRMROIRepresentation > roi );
virtual void slotAddRoiToTree( osg::ref_ptr< WROI > roi );
/**
* Slot gets called whenever a roi is removed.
*
* \param roi the roi to be removed
*/
virtual void slotRemoveRoiFromTree( boost::shared_ptr< WRMROIRepresentation > roi );
virtual void slotRemoveRoiFromTree( osg::ref_ptr< WROI > roi );
/**
* Slot gets called whenever a module switches its state to "ready".
......
......@@ -39,7 +39,7 @@ WQtBranchTreeItem::~WQtBranchTreeItem()
{
}
WQtRoiTreeItem* WQtBranchTreeItem::addRoiItem( boost::shared_ptr< WRMROIRepresentation > roi )
WQtRoiTreeItem* WQtBranchTreeItem::addRoiItem( osg::ref_ptr< WROI > roi )
{
WQtRoiTreeItem* rti = new WQtRoiTreeItem( this, roi, ROI );
......
......@@ -29,8 +29,10 @@
#include <QtGui/QProgressBar>
#include <QtGui/QTreeWidgetItem>
#include "../../../kernel/modules/fiberDisplay/WRMBranch.h"
#include "../../../kernel/modules/fiberDisplay/WRMROIRepresentation.h"
#include "../../../graphicsEngine/WROI.h"
#include "../../../kernel/WRMBranch.h"
#include "WQtTreeItem.h"
class WQtRoiTreeItem;
......@@ -58,7 +60,7 @@ public:
* Add a roi to the tree view.
* \param roi The new roi.
*/
WQtRoiTreeItem* addRoiItem( boost::shared_ptr< WRMROIRepresentation > roi );
WQtRoiTreeItem* addRoiItem( osg::ref_ptr< WROI > );
/**
* getter
......
......@@ -513,7 +513,7 @@ WQtModuleTreeItem* WQtControlPanel::addModule( boost::shared_ptr< WModule > modu
return item;
}
void WQtControlPanel::addRoi( boost::shared_ptr< WRMROIRepresentation > roi )
void WQtControlPanel::addRoi( osg::ref_ptr< WROI > roi )
{
WQtRoiTreeItem* newItem;
WQtBranchTreeItem* branchItem;
......@@ -526,7 +526,7 @@ void WQtControlPanel::addRoi( boost::shared_ptr< WRMROIRepresentation > roi )
{
branchItem = dynamic_cast< WQtBranchTreeItem* >( m_tiRois->child( branchID ) );
// if branch == roi branch
if ( branchItem->getBranch() == roi->getBranch() )
if ( branchItem->getBranch() == WKernel::getRunningKernel()->getRoiManager()->getBranch( roi ) )
{
found = true;
break;
......@@ -535,7 +535,7 @@ void WQtControlPanel::addRoi( boost::shared_ptr< WRMROIRepresentation > roi )
if ( !found )
{
branchItem = m_tiRois->addBranch( roi->getBranch() );
branchItem = m_tiRois->addBranch( WKernel::getRunningKernel()->getRoiManager()->getBranch( roi ) );
}
m_tabWidget2->setCurrentIndex( m_tabWidget2->indexOf( m_roiTreeWidget ) );
......@@ -546,7 +546,7 @@ void WQtControlPanel::addRoi( boost::shared_ptr< WRMROIRepresentation > roi )
WKernel::getRunningKernel()->getRoiManager()->setSelectedRoi( getSelectedRoi() );
}
void WQtControlPanel::removeRoi( boost::shared_ptr< WRMROIRepresentation > roi )
void WQtControlPanel::removeRoi( osg::ref_ptr< WROI > roi )
{
for( int branchID = 0; branchID < m_tiRois->childCount(); ++branchID )
{
......@@ -900,7 +900,7 @@ void WQtControlPanel::changeRoiTreeItem()
{
if ( m_roiTreeWidget->selectedItems().size() == 1 && m_roiTreeWidget->selectedItems().at( 0 )->type() == ROI )
{
boost::shared_ptr< WRMROIRepresentation > roi =( static_cast< WQtRoiTreeItem* >( m_roiTreeWidget->selectedItems().at( 0 ) ) )->getRoi();
osg::ref_ptr< WROI > roi = ( static_cast< WQtRoiTreeItem* >( m_roiTreeWidget->selectedItems().at( 0 ) ) )->getRoi();
roi->getProperties()->getProperty( "active" )->toPropBool()->set( m_roiTreeWidget->selectedItems().at( 0 )->checkState( 0 ) );
}
}
......@@ -933,9 +933,9 @@ int WQtControlPanel::getFirstSubject()
return c;
}
boost::shared_ptr< WRMROIRepresentation > WQtControlPanel::getSelectedRoi()
osg::ref_ptr< WROI > WQtControlPanel::getSelectedRoi()
{
boost::shared_ptr< WRMROIRepresentation >roi;
osg::ref_ptr< WROI > roi;
if ( m_roiTreeWidget->selectedItems().count() == 0 )
{
return roi;
......@@ -947,9 +947,9 @@ boost::shared_ptr< WRMROIRepresentation > WQtControlPanel::getSelectedRoi()
return roi;
}
boost::shared_ptr< WRMROIRepresentation > WQtControlPanel::getFirstRoiInSelectedBranch()
osg::ref_ptr< WROI > WQtControlPanel::getFirstRoiInSelectedBranch()
{
boost::shared_ptr< WRMROIRepresentation >roi;
osg::ref_ptr< WROI >roi;
if ( m_roiTreeWidget->selectedItems().count() == 0 )
{
return roi;
......@@ -1003,7 +1003,7 @@ void WQtControlPanel::deleteModuleTreeItem()
void WQtControlPanel::deleteROITreeItem()
{
boost::shared_ptr< WRMROIRepresentation >roi;
osg::ref_ptr< WROI >roi;
if ( m_roiTreeWidget->selectedItems().count() > 0 )
{
if ( m_roiTreeWidget->selectedItems().at( 0 )->type() == ROIBRANCH )
......
......@@ -37,7 +37,7 @@
#include "../../../dataHandler/WDataSet.h"
#include "../../../graphicsEngine/WROI.h"
#include "../../../kernel/modules/fiberDisplay/WRMROIRepresentation.h"
#include "../WQtCombinerToolbar.h"
#include "WQtPropertyGroupWidget.h"
#include "WQtModuleHeaderTreeItem.h"
......@@ -110,14 +110,14 @@ public:
*
* \param roi pointer to the roi representation object
*/
void addRoi( boost::shared_ptr< WRMROIRepresentation > roi );
void addRoi( osg::ref_ptr< WROI > roi );
/**
* Removes a roi entry from the control panel
*
* \param roi pointer to the roi representation object
*/
void removeRoi( boost::shared_ptr< WRMROIRepresentation > roi );
void removeRoi( osg::ref_ptr< WROI > roi );