From: Leonardo Florez-Valencia Date: Sun, 17 Apr 2016 03:02:02 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~186 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=5d6714fd6192f9f76571ab145d46951f301eb0e2;p=cpPlugins.git ... --- diff --git a/lib/cpPipelineEditor/BaseQtMainWindow.cxx b/lib/cpPipelineEditor/BaseQtMainWindow.cxx index e507f19..c19dd6f 100644 --- a/lib/cpPipelineEditor/BaseQtMainWindow.cxx +++ b/lib/cpPipelineEditor/BaseQtMainWindow.cxx @@ -326,30 +326,30 @@ _ExecFilter( const std::string& filter_name ) } catch( itk::ExceptionObject& err1 ) { + this->_UnBlock( ); QMessageBox::critical( this, QMessageBox::tr( "Error executing filter" ), QMessageBox::tr( err1.GetDescription( ) ) ); - this->_UnBlock( ); } catch( std::exception& err2 ) { + this->_UnBlock( ); QMessageBox::critical( this, QMessageBox::tr( "Error executing filter" ), QMessageBox::tr( err2.what( ) ) ); - this->_UnBlock( ); } catch( ... ) { + this->_UnBlock( ); QMessageBox::critical( this, QMessageBox::tr( "Error executing filter" ), QMessageBox::tr( "Unknown error" ) ); - this->_UnBlock( ); } // yrt } diff --git a/lib/cpPlugins/Image.hxx b/lib/cpPlugins/Image.hxx index d0f3de4..19dbcda 100644 --- a/lib/cpPlugins/Image.hxx +++ b/lib/cpPlugins/Image.hxx @@ -117,8 +117,8 @@ _ITK_2_VTK_2( itk::LightObject* o ) this->F( dynamic_cast< itk::Image< itk::C##Pixel< P >, D >* >( I ) ) #define cpPlugins_Image_Demangle_VectorPixel_Dim( F, I, V, P, D ) \ - if( dynamic_cast< itk::Image< V< P, D >, D >* >( I ) != NULL ) \ - this->F( dynamic_cast< itk::Image< V< P, D >, D >* >( I ) ) + if( dynamic_cast< itk::Image< itk::V< P, D >, D >* >( I ) != NULL ) \ + this->F( dynamic_cast< itk::Image< itk::V< P, D >, D >* >( I ) ) #define cpPlugins_Image_Demangle_Pixel_AllInts( F, I, D ) \ cpPlugins_Image_Demangle_Pixel_Dim ( F, I, char, D ); \ @@ -136,10 +136,10 @@ _ITK_2_VTK_2( itk::LightObject* o ) cpPlugins_Image_Demangle_Pixel_Dim ( F, I, float, D ); \ else cpPlugins_Image_Demangle_Pixel_Dim( F, I, double, D ) -#define cpPlugins_Image_Demangle_Pixel_AllScalars( F, I, D ) \ - cpPlugins_Image_Demangle_Pixel_AllInts ( F, I, D ); \ - else cpPlugins_Image_Demangle_Pixel_AllUInts( F, I, D ); \ - else cpPlugins_Image_Demangle_Pixel_AllInts ( F, I, D ) +#define cpPlugins_Image_Demangle_Pixel_AllScalars( F, I, D ) \ + cpPlugins_Image_Demangle_Pixel_AllInts ( F, I, D ); \ + else cpPlugins_Image_Demangle_Pixel_AllUInts ( F, I, D ); \ + else cpPlugins_Image_Demangle_Pixel_AllFloats( F, I, D ) #define cpPlugins_Image_Demangle_ColorPixel_AllInts( F, I, C, D ) \ cpPlugins_Image_Demangle_ColorPixel_Dim ( F, I, C, char, D ); \ @@ -158,12 +158,16 @@ _ITK_2_VTK_2( itk::LightObject* o ) else cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, double, D ) #define cpPlugins_Image_Demangle_ColorPixel_AllScalars( F, I, C, D ) \ - cpPlugins_Image_Demangle_ColorPixel_AllInts ( F, I, C, D ); \ - else cpPlugins_Image_Demangle_ColorPixel_AllUInts( F, I, C, D ); \ - else cpPlugins_Image_Demangle_ColorPixel_AllInts ( F, I, C, D ) + cpPlugins_Image_Demangle_ColorPixel_AllInts ( F, I, C, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_AllUInts ( F, I, C, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_AllFloats( F, I, C, D ) + +#define cpPlugins_Image_Demangle_VectorPixel_AllFloats( F, I, V, D ) \ + cpPlugins_Image_Demangle_VectorPixel_Dim ( F, I, V, float, D ); \ + else cpPlugins_Image_Demangle_VectorPixel_Dim( F, I, V, double, D ) /* TODO - #define cpPlugins_Image_Demangle_Pixel_AllColor( r, FUNC, INPUT, D ) \ + #define cpPlugins_Image_Demangle_Pixel_AllVector( r, FUNC, INPUT, D ) \ r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< char >, D ); \ if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< short >, D ); \ if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< int >, D ); \ diff --git a/lib/cpPlugins/ProcessObject.cxx b/lib/cpPlugins/ProcessObject.cxx index 02beb88..eecfd8b 100644 --- a/lib/cpPlugins/ProcessObject.cxx +++ b/lib/cpPlugins/ProcessObject.cxx @@ -250,16 +250,17 @@ Update( ) } // fi - this->m_LastExecutionSpan = cpPlugins_CHRONO; + auto t_start = cpPlugins_CHRONO; this->_GenerateData( ); - this->m_LastExecutionSpan = cpPlugins_CHRONO - this->m_LastExecutionSpan; + auto t_end = cpPlugins_CHRONO; + this->m_LastExecutionSpan = long( t_end - t_start ); this->m_LastExecutionTime = this->GetMTime( ); if( this->m_PrintExecution && this->m_PrintExecutionStream != NULL ) { *( this->m_PrintExecutionStream ) << "done in " - << this->m_LastExecutionSpan + << double( this->m_LastExecutionSpan ) / double( 1000 ) << " ms." << std::endl; } // fi diff --git a/lib/cpPlugins/Workspace.cxx b/lib/cpPlugins/Workspace.cxx index a63b749..b29309a 100644 --- a/lib/cpPlugins/Workspace.cxx +++ b/lib/cpPlugins/Workspace.cxx @@ -167,6 +167,34 @@ SetParameter( const std::string& name, const std::string& value ) } // fi } +// ------------------------------------------------------------------------- +void cpPlugins::Workspace:: +SetPrintExecution( bool b ) +{ + auto vIt = this->m_Graph->BeginVertices( ); + for( ; vIt != this->m_Graph->EndVertices( ); ++vIt ) + { + auto f = dynamic_cast< ProcessObject* >( vIt->second.GetPointer( ) ); + if( f != NULL ) + f->SetPrintExecution( b ); + + } // rof +} + +// ------------------------------------------------------------------------- +void cpPlugins::Workspace:: +PrintExecutionOn( ) +{ + this->SetPrintExecution( true ); +} + +// ------------------------------------------------------------------------- +void cpPlugins::Workspace:: +PrintExecutionOff( ) +{ + this->SetPrintExecution( false ); +} + // ------------------------------------------------------------------------- vtkRenderWindowInteractor* cpPlugins::Workspace:: GetSingleInteractor( ) diff --git a/lib/cpPlugins/Workspace.h b/lib/cpPlugins/Workspace.h index e779b07..e560962 100644 --- a/lib/cpPlugins/Workspace.h +++ b/lib/cpPlugins/Workspace.h @@ -80,6 +80,10 @@ namespace cpPlugins void RemoveFilter( const std::string& name ); void SetParameter( const std::string& name, const std::string& value ); + void SetPrintExecution( bool b ); + void PrintExecutionOn( ); + void PrintExecutionOff( ); + // Widgets management vtkRenderWindowInteractor* GetSingleInteractor( ); const vtkRenderWindowInteractor* GetSingleInteractor( ) const; diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx index a968a5b..85ff059 100644 --- a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx +++ b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx @@ -26,7 +26,7 @@ cpPluginsWidgets::NoInteractiveSeedWidget:: void cpPluginsWidgets::NoInteractiveSeedWidget:: _GenerateData( ) { - auto image = this->GetInputData( "ReferenceImage" ); + auto image = this->GetInputData( "ReferenceImage" )->GetITK< itk::DataObject >( ); cpPlugins_Image_Demangle_Dim ( _GD0, image, 2 ); else cpPlugins_Image_Demangle_Dim( _GD0, image, 3 ); else this->_Error( "No valid input image." ); diff --git a/plugins/cpPluginsWidgets/SeedWidget.cxx b/plugins/cpPluginsWidgets/SeedWidget.cxx index 20db639..da3109d 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.cxx +++ b/plugins/cpPluginsWidgets/SeedWidget.cxx @@ -36,7 +36,7 @@ cpPluginsWidgets::SeedWidget:: void cpPluginsWidgets::SeedWidget:: _GenerateData( ) { - auto image = this->GetInputData( "ReferenceImage" ); + auto image = this->GetInputData( "ReferenceImage" )->GetITK< itk::DataObject >( ); cpPlugins_Image_Demangle_Dim ( _GD0, image, 2 ); else cpPlugins_Image_Demangle_Dim( _GD0, image, 3 ); else this->_Error( "No valid input image." );