]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx
Kind of bored: graph editor debugged
[cpPlugins.git] / lib / cpPlugins / Plugins / BasicFilters / MacheteFilter.cxx
index 36bb0e8862e0498a60980d3ae9038b82b22f9c33..8116e211ff32895d1e5f6cf2a860de75381fede9 100644 (file)
@@ -27,7 +27,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,6 +71,7 @@ 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 );
 
@@ -89,8 +90,12 @@ accept( )
 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
 
 // -------------------------------------------------------------------------
@@ -187,17 +192,11 @@ MacheteFilter( )
     m_PlaneWidget( NULL )
 {
   this->_AddInput( "Input" );
-  this->_MakeOutput< cpPlugins::Interface::DataObject >( "Output" );
+  this->_MakeOutput< cpPlugins::Interface::DataObject >( "PositiveOutput" );
+  this->_MakeOutput< 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" );
 }
 
 // -------------------------------------------------------------------------
@@ -252,12 +251,12 @@ _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 );
 
@@ -279,18 +278,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->GetOutput< _TObj >( "PositiveOutput" )->GetName( );
+  auto neg_name = this->GetOutput< _TObj >( "NegativeOutput" )->GetName( );
+
+  // Connect outputs (and correct their types and names)
+  _TImage* pos_out = this->GetOutput< _TImage >( "PositiveOutput" );
+  if( pos_out == NULL )
   {
-    out->SetITK< I >( filter->GetOutput( ) );
-    out->SetName( name );
-    return( "" );
-  }
-  else
-    return( "MacheteFilter: output image not correctly created." );
+    this->_MakeOutput< _TImage >( "PositiveOutput" );
+    pos_out = this->GetOutput< _TImage >( "PositiveOutput" );
+    pos_out->SetName( pos_name );
+
+  } // fi
+  _TImage* neg_out = this->GetOutput< _TImage >( "NegativeOutput" );
+  if( neg_out == NULL )
+  {
+    this->_MakeOutput< _TImage >( "NegativeOutput" );
+    neg_out = this->GetOutput< _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$