]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Sat, 23 Apr 2016 17:36:55 +0000 (12:36 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Sat, 23 Apr 2016 17:36:55 +0000 (12:36 -0500)
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpPipelineEditor/BaseQtMainWindow.cxx
lib/cpPlugins/BaseWidget.cxx
lib/cpPlugins/BaseWidget.h
lib/cpPlugins/ProcessObject.cxx
lib/cpPlugins/Workspace.cxx
lib/cpPlugins/Workspace.h
plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx [deleted file]
plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h [deleted file]
plugins/cpPluginsWidgets/SeedWidget.cxx
plugins/cpPluginsWidgets/SeedWidget.h

index 3fae553897c08cb62803721c7c9d0cac8137170d..d6542efbd25152f0870fa8b2a2645827d67407c4 100644 (file)
@@ -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)
index 0bd86218c0f9aab721e0b8fc6dcd36b9fd2154bf..b600c0ee12002dc33e7c09d49fec0a8cc5bf2ec7 100644 (file)
@@ -56,7 +56,6 @@ BaseQtMainWindow(
 
   // Prepare workspace
   this->m_Workspace.SetInterface( &( this->m_Interface ) );
-  this->m_Workspace.PrintExecutionOn( );
 }
 
 // -------------------------------------------------------------------------
index b8485c4b4d7dec5fb80446222254d742bfde720d..7bcca5266366eb932c777aaae49cbd42d2726034 100644 (file)
@@ -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", "" );
 }
 
 // -------------------------------------------------------------------------
index a2b8bd28a72f7cbff71b3638ac08cca038bd7704..7ccff1a461089b1edc4cbdec60cb57c60eb914f7 100644 (file)
@@ -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;
 
index 590de5dccc8c4d70d6714cc92beb4f4b4317ac74..29e14f8c2514cab19dead2bd8e37f7a4fb37d314 100644 (file)
@@ -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
 }
index 84188a7ebbbd31e10b368202a7dd8219608fccb9..d749829b1aaf8f0ef2b3210ac0672c09b2570921 100644 (file)
@@ -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 )
   {
index e5609629a58f8298133e9982d9f52730548ca6fa..d5884589700b5e17dc46037f00348cbae0f8930c 100644 (file)
@@ -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 (file)
index 5f2bd3b..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#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$
diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h
deleted file mode 100644 (file)
index 492d2c5..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#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$
index 8ee5abf11cfb7a72501c6557c0a4ad306d17433c..18bcdeb4b4fac7f2983268dd0bd47f20203ad48f 100644 (file)
@@ -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$
index 40813ef1a0dbbf118528280f108a2cbfc61108a2..92c744b20397e58eb28edb02cacb163b9885d2e7 100644 (file)
@@ -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