From: Leonardo Florez-Valencia Date: Sat, 23 Apr 2016 17:36:55 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~177 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=8b6eaedb25048704cb0a1a3fa1dd751c4fb25db4;p=cpPlugins.git ... --- diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 3fae553..d6542ef 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -255,7 +255,7 @@ ShowPixelText( double* pos ) ); #else // defined(WIN32) std::sprintf( - this->m_TextBuffer, "Axis: %c (%d)\nPixel %s", + this->m_TextBuffer, "Axis: %c (%ld)\nPixel %s", axis, slice, str.str( ).c_str( ) ); #endif // defined(WIN32) diff --git a/lib/cpPipelineEditor/BaseQtMainWindow.cxx b/lib/cpPipelineEditor/BaseQtMainWindow.cxx index 0bd8621..b600c0e 100644 --- a/lib/cpPipelineEditor/BaseQtMainWindow.cxx +++ b/lib/cpPipelineEditor/BaseQtMainWindow.cxx @@ -56,7 +56,6 @@ BaseQtMainWindow( // Prepare workspace this->m_Workspace.SetInterface( &( this->m_Interface ) ); - this->m_Workspace.PrintExecutionOn( ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/BaseWidget.cxx b/lib/cpPlugins/BaseWidget.cxx index b8485c4..7bcca52 100644 --- a/lib/cpPlugins/BaseWidget.cxx +++ b/lib/cpPlugins/BaseWidget.cxx @@ -2,6 +2,15 @@ #ifdef cpPlugins_QT4 +// ------------------------------------------------------------------------- +itk::ModifiedTimeType cpPlugins::BaseWidget:: +GetMTime( ) const +{ + // Let time only be managed by itk -> synch issues when data is + // represented by vtk + return( this->itk::Object::GetMTime( ) ); +} + // ------------------------------------------------------------------------- const cpPlugins::BaseWidget::TMPRWidget* cpPlugins::BaseWidget:: GetMPRViewer( ) const @@ -72,6 +81,8 @@ BaseWidget( ) m_MPRViewer( NULL ), m_SingleInteractor( NULL ) { + this->m_Parameters.ConfigureAsString( "Text" ); + this->m_Parameters.SetString( "Text", "" ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/BaseWidget.h b/lib/cpPlugins/BaseWidget.h index a2b8bd2..7ccff1a 100644 --- a/lib/cpPlugins/BaseWidget.h +++ b/lib/cpPlugins/BaseWidget.h @@ -37,6 +37,8 @@ namespace cpPlugins cpPlugins_Id_Macro( Widgets::BaseWidget, Widgets ); public: + virtual itk::ModifiedTimeType GetMTime( ) const ITK_OVERRIDE; + const TMPRWidget* GetMPRViewer( ) const; const vtkRenderWindowInteractor* GetSingleInteractor( ) const; diff --git a/lib/cpPlugins/ProcessObject.cxx b/lib/cpPlugins/ProcessObject.cxx index 590de5d..29e14f8 100644 --- a/lib/cpPlugins/ProcessObject.cxx +++ b/lib/cpPlugins/ProcessObject.cxx @@ -240,17 +240,15 @@ Update( ) // Current update if( this->m_LastExecutionTime < this->GetMTime( ) || need_to_update ) { - /* if( this->m_PrintExecution && this->m_PrintExecutionStream != NULL ) { - */ *( this->m_PrintExecutionStream ) << "cpPlugins: Updating \"" << this->GetClassCategory( ) << ":" << this->GetClassName( ) << "\"... "; this->m_PrintExecutionStream->flush( ); - // } // fi + } // fi auto t_start = cpPlugins_CHRONO; this->_GenerateData( ); @@ -258,16 +256,14 @@ Update( ) 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 " << double( this->m_LastExecutionSpan ) / double( 1000 ) << " s." << std::endl; - // } // fi + } // fi } // fi } diff --git a/lib/cpPlugins/Workspace.cxx b/lib/cpPlugins/Workspace.cxx index 84188a7..d749829 100644 --- a/lib/cpPlugins/Workspace.cxx +++ b/lib/cpPlugins/Workspace.cxx @@ -7,6 +7,7 @@ cpPlugins::Workspace:: Workspace( ) : m_Interface( NULL ), + m_PrintExecution( false ), m_MPRViewer( NULL ) { this->m_Graph = TGraph::New( ); @@ -129,6 +130,7 @@ CreateFilter( f->SetInteractionObjects( interactive_objects ); } // fi + f->SetPrintExecution( this->m_PrintExecution ); Object::Pointer o = f.GetPointer( ); this->m_Graph->SetVertex( name, o ); @@ -171,6 +173,7 @@ SetParameter( const std::string& name, const std::string& value ) void cpPlugins::Workspace:: SetPrintExecution( bool b ) { + this->m_PrintExecution = b; auto vIt = this->m_Graph->BeginVertices( ); for( ; vIt != this->m_Graph->EndVertices( ); ++vIt ) { diff --git a/lib/cpPlugins/Workspace.h b/lib/cpPlugins/Workspace.h index e560962..d588458 100644 --- a/lib/cpPlugins/Workspace.h +++ b/lib/cpPlugins/Workspace.h @@ -140,6 +140,7 @@ namespace cpPlugins protected: // Plugins interface Interface* m_Interface; + bool m_PrintExecution; // Processing graph TGraph::Pointer m_Graph; diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx deleted file mode 100644 index 5f2bd3b..0000000 --- a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx +++ /dev/null @@ -1,66 +0,0 @@ -#include "NoInteractiveSeedWidget.h" - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -cpPluginsWidgets::NoInteractiveSeedWidget:: -NoInteractiveSeedWidget( ) - : Superclass( ) -{ - this->_AddInput( "ReferenceImage" ); - this->_AddOutput< cpPlugins::DataObject >( "Output" ); - this->m_Parameters.ConfigureAsString( "Text" ); - this->m_Parameters.SetString( "Text", "" ); -} - -// ------------------------------------------------------------------------- -cpPluginsWidgets::NoInteractiveSeedWidget:: -~NoInteractiveSeedWidget( ) -{ -} - -// ------------------------------------------------------------------------- -void cpPluginsWidgets::NoInteractiveSeedWidget:: -_GenerateData( ) -{ - auto image = this->GetInputData< itk::DataObject >( "ReferenceImage" ); - cpPlugins_Image_Demangle_Dim ( _GD0, image, 2 ); - else cpPlugins_Image_Demangle_Dim( _GD0, image, 3 ); - else this->_Error( "No valid input image." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -void cpPluginsWidgets::NoInteractiveSeedWidget:: -_GD0( _TImage* image ) -{ - typedef - cpExtensions::DataStructures::ImageIndexesContainer< _TImage::ImageDimension > - _TContainer; - - if( image != NULL ) - { - auto container = this->_CreateITK< _TContainer >( ); - std::string info = this->m_Parameters.GetString( "Text" ); - - std::istringstream str( info ); - double x, y, z; - str >> x >> y >> z; - typename _TImage::PointType seed; - seed[ 0 ] = x; - seed[ 1 ] = y; - seed[ 2 ] = z; - typename _TImage::IndexType idx; - if( image->TransformPhysicalPointToIndex( seed, idx ) ) - container->Get( ).push_back( idx ); - container->SetReferenceImage( image ); - this->GetOutput( "Output" )->SetITK( container ); - } - else - this->_Error( "Input image dimension not supported." ); -} - -// eof - $RCSfile$ diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h deleted file mode 100644 index 492d2c5..0000000 --- a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__ -#define __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__ - -#include -#include - -namespace cpPluginsWidgets -{ - /** - */ - class cpPluginsWidgets_EXPORT NoInteractiveSeedWidget - : public cpPlugins::BaseWidget - { - public: - typedef NoInteractiveSeedWidget Self; - typedef cpPlugins::BaseWidget Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( NoInteractiveSeedWidget, cpPlugins::BaseWidget ); - cpPlugins_Id_Macro( NoInteractiveSeedWidget, Widgets ); - - protected: - NoInteractiveSeedWidget( ); - virtual ~NoInteractiveSeedWidget( ); - - virtual void _GenerateData( ) ITK_OVERRIDE; - - template< class _TImage > - inline void _GD0( _TImage* image ); - - private: - // Purposely not implemented - NoInteractiveSeedWidget( const Self& ); - Self& operator=( const Self& ); - }; - -} // ecapseman - -#endif // __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__ - -// eof - $RCSfile$ diff --git a/plugins/cpPluginsWidgets/SeedWidget.cxx b/plugins/cpPluginsWidgets/SeedWidget.cxx index 8ee5abf..18bcdeb 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.cxx +++ b/plugins/cpPluginsWidgets/SeedWidget.cxx @@ -75,7 +75,8 @@ Off( ) cpPluginsWidgets::SeedWidget:: SeedWidget( ) : Superclass( ), - m_Configured( false ) + m_Configured( false ), + m_InitialNumberOfSeeds( 0 ) { this->_AddOutput< cpPlugins::DataObject >( "Output" ); } @@ -90,9 +91,11 @@ cpPluginsWidgets::SeedWidget:: void cpPluginsWidgets::SeedWidget:: _GenerateData( ) { + auto points = this->_CreateVTK< vtkPoints >( ); if( this->m_Configured ) { - auto points = this->_CreateVTK< vtkPoints >( ); + std::stringstream text; + points->Resize( this->m_InitialNumberOfSeeds ); for( auto wIt = this->m_Widgets.begin( ); wIt != this->m_Widgets.end( ); @@ -103,15 +106,46 @@ _GenerateData( ) for( unsigned int i = 0; i < wIt->Seed->GetNumberOfSeeds( ); ++i ) { wIt->Seed->GetSeedWorldPosition( i, pos ); + if( i > 0 ) + text << "#"; + text << pos[ 0 ] << " " << pos[ 1 ] << " " << pos[ 2 ]; points->InsertNextPoint( pos ); } // rof } // rof - this->GetOutput( "Output" )->SetVTK( points ); + this->m_Parameters.SetString( "Text", text.str( ) ); } else { + std::vector< std::string > tokens; + cpPlugins::TokenizeString( + tokens, this->m_Parameters.GetString( "Text" ), "#" + ); + this->m_InitialNumberOfSeeds = tokens.size( ); + points->SetNumberOfPoints( 0 ); + for( auto tIt = tokens.begin( ); tIt != tokens.end( ); ++tIt ) + { + std::vector< std::string > coords; + cpPlugins::TokenizeString( coords, *tIt, " \t" ); + int dim = ( coords.size( ) < 3 )? coords.size( ): 3; + double pos[ 3 ]; + for( unsigned int d = 0; d < 3; ++d ) + { + pos[ d ] = double( 0 ); + if( d < dim ) + { + std::istringstream value( coords[ d ] ); + value >> pos[ d ]; + + } // fi + + } // rof + points->InsertNextPoint( pos ); + this->m_Configured = true; + + } // rof + std::vector< vtkRenderWindowInteractor* > ints; if( this->m_MPRViewer != NULL ) { @@ -161,6 +195,7 @@ _GenerateData( ) this->_Error( "Could not create valid widget: are there any valid actors?" ); + this->GetOutput( "Output" )->SetVTK( points ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsWidgets/SeedWidget.h b/plugins/cpPluginsWidgets/SeedWidget.h index 40813ef..92c744b 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.h +++ b/plugins/cpPluginsWidgets/SeedWidget.h @@ -49,11 +49,6 @@ namespace cpPluginsWidgets virtual void _GenerateData( ) ITK_OVERRIDE; - /* TODO - template< class _TImage > - inline void _GD0( _TImage* image ); - */ - private: // Purposely not implemented SeedWidget( const Self& ); @@ -62,6 +57,7 @@ namespace cpPluginsWidgets protected: bool m_Configured; std::vector< WidgetData > m_Widgets; + unsigned int m_InitialNumberOfSeeds; }; } // ecapseman