);
#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)
// Prepare workspace
this->m_Workspace.SetInterface( &( this->m_Interface ) );
- this->m_Workspace.PrintExecutionOn( );
}
// -------------------------------------------------------------------------
#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
m_MPRViewer( NULL ),
m_SingleInteractor( NULL )
{
+ this->m_Parameters.ConfigureAsString( "Text" );
+ this->m_Parameters.SetString( "Text", "" );
}
// -------------------------------------------------------------------------
cpPlugins_Id_Macro( Widgets::BaseWidget, Widgets );
public:
+ virtual itk::ModifiedTimeType GetMTime( ) const ITK_OVERRIDE;
+
const TMPRWidget* GetMPRViewer( ) const;
const vtkRenderWindowInteractor* GetSingleInteractor( ) const;
// 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( );
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
}
cpPlugins::Workspace::
Workspace( )
: m_Interface( NULL ),
+ m_PrintExecution( false ),
m_MPRViewer( NULL )
{
this->m_Graph = TGraph::New( );
f->SetInteractionObjects( interactive_objects );
} // fi
+ f->SetPrintExecution( this->m_PrintExecution );
Object::Pointer o = f.GetPointer( );
this->m_Graph->SetVertex( name, o );
void cpPlugins::Workspace::
SetPrintExecution( bool b )
{
+ this->m_PrintExecution = b;
auto vIt = this->m_Graph->BeginVertices( );
for( ; vIt != this->m_Graph->EndVertices( ); ++vIt )
{
protected:
// Plugins interface
Interface* m_Interface;
+ bool m_PrintExecution;
// Processing graph
TGraph::Pointer m_Graph;
+++ /dev/null
-#include "NoInteractiveSeedWidget.h"
-
-#include <cpPlugins/Image.h>
-#include <cpExtensions/DataStructures/ImageIndexesContainer.h>
-#include <itkSimpleDataObjectDecorator.h>
-#include <itkSimpleDataObjectDecorator.hxx>
-
-// -------------------------------------------------------------------------
-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$
+++ /dev/null
-#ifndef __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__
-#define __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__
-
-#include <plugins/cpPluginsWidgets/cpPluginsWidgets_Export.h>
-#include <cpPlugins/BaseWidget.h>
-
-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$
cpPluginsWidgets::SeedWidget::
SeedWidget( )
: Superclass( ),
- m_Configured( false )
+ m_Configured( false ),
+ m_InitialNumberOfSeeds( 0 )
{
this->_AddOutput< cpPlugins::DataObject >( "Output" );
}
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( );
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 )
{
this->_Error(
"Could not create valid widget: are there any valid actors?"
);
+ this->GetOutput( "Output" )->SetVTK( points );
}
// eof - $RCSfile$
virtual void _GenerateData( ) ITK_OVERRIDE;
- /* TODO
- template< class _TImage >
- inline void _GD0( _TImage* image );
- */
-
private:
// Purposely not implemented
SeedWidget( const Self& );
protected:
bool m_Configured;
std::vector< WidgetData > m_Widgets;
+ unsigned int m_InitialNumberOfSeeds;
};
} // ecapseman