X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FBasicFilters%2FMacheteFilter.cxx;h=4dfcd5a09be548afabfbc31dd74f52fbca6e85d7;hb=1b600247da314fe62d007ca8a0ce24d0006931f4;hp=36bb0e8862e0498a60980d3ae9038b82b22f9c33;hpb=7478fcc087fe32cee83c18bd98ccf8afb2e8818b;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx index 36bb0e8..4dfcd5a 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx @@ -1,8 +1,5 @@ #include "MacheteFilter.h" -#include -#include - #include #include #include @@ -27,7 +24,7 @@ cpPlugins::BasicFilters::MacheteFilter_Dialog:: MacheteFilter_Dialog( QWidget* parent, MacheteFilter* filter, Qt::WindowFlags f ) - : QDialog( parent, f ), + : QDialog( parent, f | Qt::WindowStaysOnTopHint ), m_Filter( filter ) { this->m_Title = new QLabel( this ); @@ -71,26 +68,37 @@ accept( ) double center[ 3 ], normal[ 3 ]; wdg->GetCenter( center ); wdg->GetNormal( normal ); - this->m_Filter->GetParameters( )->SetPoint( "PlaneCenter", 3, center ); - this->m_Filter->GetParameters( )->SetVector( "PlaneNormal", 3, normal ); - // Update filter - auto plugins = this->m_Filter->GetPlugins( ); - if( plugins != NULL ) - { - auto app = plugins->GetApplication( ); - if( app != NULL ) - app->UpdateActualFilter( ); + /* TODO + this->m_Filter->GetParameters( )->SetPoint( "PlaneCenter", 3, center ); + this->m_Filter->GetParameters( )->SetVector( "PlaneNormal", 3, normal ); + */ - } // fi + // Update filter + /* TODO + auto plugins = this->m_Filter->GetPlugins( ); + if( plugins != NULL ) + { + auto app = plugins->GetApplication( ); + if( app != NULL ) + app->UpdateActualFilter( ); + + } // fi + */ } // ------------------------------------------------------------------------- void cpPlugins::BasicFilters::MacheteFilter_Dialog:: reject( ) { - std::cout << "reject" << std::endl; + /* + auto plugins = this->m_Filter->GetPlugins( ); + if( plugins != NULL ) + plugins->DeactivateFilter( ); + */ + this->Superclass::reject( ); } + #endif // cpPlugins_Interface_QT4 // ------------------------------------------------------------------------- @@ -104,6 +112,7 @@ ExecConfigurationDialog( QWidget* parent ) // Choose a valid 3D interactor vtkRenderWindowInteractor* iren = NULL; + /* TODO auto iIt = this->m_Interactors.begin( ); for( ; iIt != this->m_Interactors.end( ) && iren == NULL; ++iIt ) { @@ -115,13 +124,13 @@ ExecConfigurationDialog( QWidget* parent ) iren = *iIt; } // rof + */ if( iren == NULL ) - return( Self::DialogResult_Cancel ); - + return( false ); + // Get bounding box double bbox[ 6 ]; - cpPlugins::Interface::Image* image = - this->GetInput< cpPlugins::Interface::Image >( "Input" ); + auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); bool input_found = false; if( image != NULL ) { @@ -129,8 +138,7 @@ ExecConfigurationDialog( QWidget* parent ) input_found = true; } // fi - cpPlugins::Interface::Mesh* mesh = - this->GetInput< cpPlugins::Interface::Mesh >( "Input" ); + auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" ); if( mesh != NULL ) { mesh->GetVTK< vtkPolyData >( )->GetBounds( bbox ); @@ -138,7 +146,7 @@ ExecConfigurationDialog( QWidget* parent ) } // fi if( !input_found ) - return( Self::DialogResult_Cancel ); + return( false ); // Create plane widget if( this->m_PlaneWidget != NULL ) @@ -174,9 +182,9 @@ ExecConfigurationDialog( QWidget* parent ) this->m_Dialog = new MacheteFilter_Dialog( NULL, this ); this->m_Dialog->show( ); - return( Self::DialogResult_Modal ); + return( true ); #else // cpPlugins_Interface_QT4 - return( Self::DialogResult_Cancel ); + return( false ); #endif // cpPlugins_Interface_QT4 } @@ -187,17 +195,13 @@ MacheteFilter( ) m_PlaneWidget( NULL ) { this->_AddInput( "Input" ); - this->_MakeOutput< cpPlugins::Interface::DataObject >( "Output" ); + this->_AddOutput< cpPlugins::Interface::DataObject >( "PositiveOutput" ); + this->_AddOutput< cpPlugins::Interface::DataObject >( "NegativeOutput" ); - itk::Point< double, 3 > center; - itk::Vector< double, 3 > normal; - - center.Fill( double( 0 ) ); - normal.Fill( double( 0 ) ); - normal[ 0 ] = double( 1 ); - - this->m_Parameters->ConfigureAsPoint( "PlaneCenter", 3, center ); - this->m_Parameters->ConfigureAsVector( "PlaneNormal", 3, normal ); + /* + this->m_Parameters->ConfigureAsPoint( "PlaneCenter" ); + this->m_Parameters->ConfigureAsVector( "PlaneNormal" ); + */ } // ------------------------------------------------------------------------- @@ -212,12 +216,10 @@ cpPlugins::BasicFilters::MacheteFilter:: std::string cpPlugins::BasicFilters::MacheteFilter:: _GenerateData( ) { - cpPlugins::Interface::Image* image = - this->GetInput< cpPlugins::Interface::Image >( "Input" ); + auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); if( image != NULL ) return( this->_FromImage( image ) ); - cpPlugins::Interface::Mesh* mesh = - this->GetInput< cpPlugins::Interface::Mesh >( "Input" ); + auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" ); if( mesh == NULL ) return( this->_FromMesh( mesh ) ); return( "MacheteFilter: No valid input." ); @@ -252,21 +254,25 @@ _RealImage( itk::DataObject* dobj ) InfinitePlaneSpatialObject< I::ImageDimension > _TPlane; typedef cpExtensions::Algorithms:: - SpatialObjectMaskImageFilter< I > _TFilter; - typedef cpPlugins::Interface::DataObject _TDataObject; + SpatialObjectMaskImageFilter< I, I > _TFilter; + typedef cpPlugins::Interface::DataObject _TObj; typedef cpPlugins::Interface::Image _TImage; - typedef typename _TPlane::PointType _TPoint; - typedef typename _TPlane::VectorType _TVector; - typedef typename I::PixelType _TPixel; + typedef typename _TPlane::PointType _TPoint; + typedef typename _TPlane::VectorType _TVector; + typedef typename I::PixelType _TPixel; I* image = dynamic_cast< I* >( dobj ); + /* _TPoint c = this->m_Parameters->GetPoint< _TPoint >( "PlaneCenter", I::ImageDimension ); _TVector n = this->m_Parameters->GetVector< _TVector >( "PlaneNormal", I::ImageDimension ); + */ + _TPoint c; + _TVector n; typename _TPlane::Pointer plane = _TPlane::New( ); plane->SetCenter( c ); @@ -279,18 +285,32 @@ _RealImage( itk::DataObject* dobj ) filter->SetOutsideValue( _TPixel( 0 ) ); filter->Update( ); - // Connect output (and correct its type) - auto name = this->GetOutput< _TDataObject >( "Output" )->GetName( ); - this->_MakeOutput< _TImage >( "Output" ); - _TImage* out = this->GetOutput< _TImage >( "Output" ); - if( out != NULL ) + // Get output names + auto pos_name = this->GetOutputData< _TObj >( "PositiveOutput" )->GetName( ); + auto neg_name = this->GetOutputData< _TObj >( "NegativeOutput" )->GetName( ); + + // Connect outputs (and correct their types and names) + _TImage* pos_out = this->GetOutputData< _TImage >( "PositiveOutput" ); + if( pos_out == NULL ) + { + this->_AddOutput< _TImage >( "PositiveOutput" ); + pos_out = this->GetOutputData< _TImage >( "PositiveOutput" ); + pos_out->SetName( pos_name ); + + } // fi + _TImage* neg_out = this->GetOutputData< _TImage >( "NegativeOutput" ); + if( neg_out == NULL ) { - out->SetITK< I >( filter->GetOutput( ) ); - out->SetName( name ); - return( "" ); - } - else - return( "MacheteFilter: output image not correctly created." ); + this->_AddOutput< _TImage >( "NegativeOutput" ); + neg_out = this->GetOutputData< _TImage >( "NegativeOutput" ); + neg_out->SetName( neg_name ); + + } // fi + + // Assign outputs + pos_out->SetITK< I >( filter->GetPositiveOutput( ) ); + neg_out->SetITK< I >( filter->GetNegativeOutput( ) ); + return( "" ); } // eof - $RCSfile$