]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 13 Apr 2016 23:54:49 +0000 (18:54 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 13 Apr 2016 23:54:49 +0000 (18:54 -0500)
lib/cpPlugins/ProcessObject.cxx
lib/cpPlugins/Workspace.cxx
lib/cpPlugins/Workspace.h
plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx [new file with mode: 0644]
plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h [new file with mode: 0644]

index d93fd18dc5a358c2358feca50cc0277ca3594f0b..136b45cd3f6a734529b72dacf40525aa251fd74b 100644 (file)
@@ -1,6 +1,7 @@
 #include <cpPlugins/ProcessObject.h>
 #include <cpPlugins/ParametersQtDialog.h>
 #include <itkProcessObject.h>
+#include <chrono>
 
 // -------------------------------------------------------------------------
 cpPlugins::Parameters* cpPlugins::ProcessObject::
@@ -235,8 +236,22 @@ Update( )
   {
     if( this->m_LastExecutionTime < this->GetMTime( ) || need_to_update )
     {
+      std::cout
+        << "cpPlugins: Updating \""
+        << this->GetClassName( ) << ":" << this->GetClassCategory( )
+        << "\"... ";
+      std::cout.flush( );
+      long start =
+        std::chrono::duration_cast< std::chrono::milliseconds >(
+          std::chrono::system_clock::now( ).time_since_epoch( )
+          ).count( );
       r = this->_GenerateData( );
+      long end =
+        std::chrono::duration_cast< std::chrono::milliseconds >(
+          std::chrono::system_clock::now( ).time_since_epoch( )
+          ).count( );
       this->m_LastExecutionTime = this->GetMTime( );
+      std::cout << "done in " << ( ( end - start ) / 1000 ) << "ms!" << std::endl;
 
     } // fi
 
index 9476679f34344bc70254024052ebe3e808f920b7..7ba11d1688feab1b435e6745d1fdf0bb7fede5bd 100644 (file)
@@ -152,6 +152,21 @@ RemoveFilter( const std::string& name )
 {
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Workspace::
+SetParameter( const std::string& name, const std::string& value )
+{
+  std::vector< std::string > tokens;
+  cpPlugins::TokenizeString( tokens, name, "@" );
+
+  if( this->HasFilter( tokens[ 1 ] ) )
+  {
+    auto filter = this->GetFilter( tokens[ 1 ] );
+    filter->GetParameters( )->SetString( tokens[ 0 ], value );
+
+  } // fi
+}
+
 // -------------------------------------------------------------------------
 vtkRenderWindowInteractor* cpPlugins::Workspace::
 GetSingleInteractor( )
index c45006323d6481e9ea2c974ffd061683c3697bb7..d99831bf1fcfa4738eb6eb982388805eac9ff1c5 100644 (file)
@@ -78,6 +78,7 @@ namespace cpPlugins
       const std::string& old_name, const std::string& new_name
       );
     void RemoveFilter( const std::string& name );
+    void SetParameter( const std::string& name, const std::string& value );
 
     // Widgets management
     vtkRenderWindowInteractor* GetSingleInteractor( );
diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx
new file mode 100644 (file)
index 0000000..d5f8df8
--- /dev/null
@@ -0,0 +1,67 @@
+#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( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPluginsWidgets::NoInteractiveSeedWidget::
+_GenerateData( )
+{
+  auto image = this->GetInputData( "ReferenceImage" );
+  std::string   r = cpPlugin_Image_Demangle_Dim( _GD0, image, 3 );
+  if( r != "" ) r = cpPlugin_Image_Demangle_Dim( _GD0, image, 2 );
+  return( r );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+std::string 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->GetOutputData( "Output" )->SetITK( container );
+    return( "" );
+  }
+  else
+    return( "Widgets::NoInteractiveSeedWidget: Input image dimension not supported." );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h
new file mode 100644 (file)
index 0000000..9319879
--- /dev/null
@@ -0,0 +1,44 @@
+#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 std::string _GenerateData( ) ITK_OVERRIDE;
+
+    template< class _TImage >
+      inline std::string _GD0( _TImage* image );
+
+  private:
+    // Purposely not implemented
+    NoInteractiveSeedWidget( const Self& );
+    Self& operator=( const Self& );
+  };
+
+} // ecapseman
+
+#endif // __CPPLUGINSWIDGETS__NOINTERACTIVESEEDWIDGET__H__
+
+// eof - $RCSfile$