]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/BaseObjects/ProcessObject.cxx
debug finished
[cpPlugins.git] / lib / cpPlugins / BaseObjects / ProcessObject.cxx
index a367a3c5d5d707af087a2417d4a28089ca8977f4..35b95ff643525bf900a30ed4fe8313eea3fa646a 100644 (file)
@@ -5,6 +5,41 @@
 #include <cpPlugins/BaseObjects/Events.h>
 #include <cpPlugins/QT/ParametersDialog.h>
 
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::ProcessObject::
+PrintExecutionOn( )
+{
+  this->SetPrintExecution( true );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::ProcessObject::
+PrintExecutionOff( )
+{
+  this->SetPrintExecution( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::BaseObjects::ProcessObject::
+GetPrintExecution( ) const
+{
+  return( this->m_PrintExecution );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::BaseObjects::ProcessObject::
+SetPrintExecution( bool v )
+{
+  this->m_PrintExecution = v;
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::BaseObjects::ProcessObject::
+SetPrintExecutionStream( std::ofstream* s )
+{
+  this->m_PrintExecutionStream = s;
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::BaseObjects::Parameters*
 cpPlugins::BaseObjects::ProcessObject::
@@ -184,38 +219,41 @@ void cpPlugins::BaseObjects::ProcessObject::
 Update( )
 {
   // Force upstream updates
-  bool need_to_update = this->m_ExplicitExecution;
-  for( auto i = this->m_Inputs.begin( ); i != this->m_Inputs.end( ); ++i )
+  bool update = ( this->m_LastExecutionTime < this->GetMTime( ) );
+  for( auto input : this->m_Inputs )
   {
-    bool iv = i->second->IsValid( );
-    bool ir = i->second->IsRequired( );
-    if( !iv && ir )
-      this->_Error(
-        std::string( "Required input \"" ) + i->first +
-        std::string( "\" is not valid." )
-        );
-    if( iv )
+    for( unsigned int i = 0; i < input.second->Size( ); ++i )
     {
-      unsigned int n = i->second->Size( );
-      for( unsigned int j = 0; j < n; ++j )
+      auto obj = input.second->Get( i );
+      if( obj != NULL )
       {
-        Self* src = i->second->Get( j )->GetSource( );
+        auto src = obj->GetSource( );
         if( src != NULL )
         {
-          need_to_update |= ( this->m_LastExecutionTime < src->GetMTime( ) );
           src->Update( );
+          update |= ( this->m_LastExecutionTime < src->GetMTime( ) );
 
         } // fi
+      }
+      else
+      {
+        if( input.second->IsRequired( ) )
+          this->_Error(
+            std::string( "Required input \"" ) + input.first +
+            std::string( "\" in filter \"" ) +
+            this->m_Name +
+            std::string( "\" is not valid." )
+            );
 
-      } // rof
+      } // fi
 
-    } // fi
+    } // rof
 
   } // rof
 
-  // Current update
-  if( this->m_LastExecutionTime < this->GetMTime( ) || need_to_update )
+  if( update || this->m_ExplicitExecution )
   {
+    // Show a message, if needed...
     if( this->m_PrintExecution && this->m_PrintExecutionStream != NULL )
     {
       *( this->m_PrintExecutionStream )
@@ -227,13 +265,15 @@ Update( )
 
     } // fi
 
+    // Execute filter's algorithm and keep information about time
     auto t_start = cpPlugins_CHRONO;
     this->_GenerateData( );
     auto t_end = cpPlugins_CHRONO;
-    this->m_LastExecutionSpan = long( t_end - t_start );
     this->Modified( );
+    this->m_LastExecutionSpan = long( t_end - t_start );
     this->m_LastExecutionTime = this->GetMTime( );
 
+    // End the message, if needed...
     if( this->m_PrintExecution && this->m_PrintExecutionStream != NULL )
     {
       *( this->m_PrintExecutionStream )