]> Creatis software - cpPlugins.git/commitdiff
debug
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 1 Dec 2016 00:30:59 +0000 (19:30 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 1 Dec 2016 00:30:59 +0000 (19:30 -0500)
appli/PipelineEditor/PipelineEditor.cxx
appli/PipelineEditor/PipelineEditor.h
appli/PipelineEditor/PipelineEditor.ui
lib/cpInstances/Image.cxx
lib/cpPlugins/BaseObjects/Port.h
lib/cpPlugins/BaseObjects/ProcessObject.cxx
lib/cpPlugins/BaseObjects/ProcessObject.h
lib/cpPlugins/Interface/Plugins.cxx

index fec6efdeee90f9f1076b48cb46f8a5543af97de7..32a4546eb595f42aef59ca177847a71b5eda2f1f 100644 (file)
@@ -31,6 +31,10 @@ PipelineEditor( int argc, char* argv[], QWidget* parent )
   this->m_UI->Canvas->connectOutputPortSlot(
     this, SLOT( _slotView( const std::string&, bool ) )
     );
+  this->connect(
+    this->m_UI->actionPrintExecutionInformation, SIGNAL( triggered( bool ) ),
+    this, SLOT( _slotPrintExecutionInformation( bool ) )
+    );
 
   // Load command-line given workspace (if any)
   if( argc > 1 )
@@ -93,7 +97,8 @@ _slotView( const std::string& name, bool show )
       } // fi
       if(
         dynamic_cast< QWidget* >( viewer ) !=
-        dynamic_cast< QWidget* >( this->m_UI->Viewer )
+        dynamic_cast< QWidget* >( this->m_UI->Viewer ) &&
+        viewer != NULL
         )
       {
         delete this->m_UI->Viewer;
@@ -136,6 +141,14 @@ _slotView( const std::string& name, bool show )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+void PipelineEditor::
+_slotPrintExecutionInformation( bool show )
+{
+  if( this->m_Workspace.IsNotNull( ) )
+    this->m_Workspace->SetPrintExecution( show );
+}
+
 // -------------------------------------------------------------------------
 #include <cpBaseQtApplication/MainHelper.h>
 cpBaseQtApplication_Main( PipelineEditor );
index 8c8db3547fcb39f21678933bb8245201ceba1f38..1b6674e8cc4c5ac7fdfcccf857900cf26ab094a6 100644 (file)
@@ -25,6 +25,7 @@ public:
 
 protected slots:
   void _slotView( const std::string& name, bool show );
+  void _slotPrintExecutionInformation( bool show );
 
 private:
   Ui::PipelineEditor* m_UI;
index 45dc1fd74bb97bcc85671fb2465941e6408c7ad9..0e615126255a342dddc34a5739939ac7307b5cf0 100644 (file)
    <addaction name="menuPlu_gins"/>
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
+  <widget class="QToolBar" name="toolBar">
+   <property name="windowTitle">
+    <string>toolBar</string>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+   <addaction name="actionPrintExecutionInformation"/>
+  </widget>
   <action name="actionExit">
    <property name="text">
     <string>E&amp;xit</string>
     <string>Ctrl+Shift+D</string>
    </property>
   </action>
+  <action name="actionPrintExecutionInformation">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Print execution information?</string>
+   </property>
+   <property name="toolTip">
+    <string>Print execution information?</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>
index dc52b37a9e573f5315c70b5e19a6360d3e427377..6cdae033097a11d8a9fbd177d2806043bae927f2 100644 (file)
@@ -130,6 +130,8 @@ _ITK_2_VTK_0( _TImage* image ) const
 }
 
 // -------------------------------------------------------------------------
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
 template< class _TImage >
 void cpInstances::Image::
 _ITK_2_VTK_1( _TImage* image ) const
@@ -145,6 +147,13 @@ _ITK_2_VTK_1( _TImage* image ) const
     f = nf.GetPointer( );
 
   } // fi
+
+  std::string name = "<noname>";
+  if( this->m_Source != NULL )
+    name = this->m_Source->GetName( );
+
+  std::cout << "HOLALALAL: " << name << " " << image << " " << f->GetInput( ) << std::endl;
+
   f->SetInput( image );
   f->Update( );
 
index 49ac16a2a0e00570c712d517ee3be194a6686109..eef1616c122155023861a3b8a4b781c5113c7db6 100644 (file)
@@ -29,7 +29,7 @@ namespace cpPlugins
       virtual void Clear( );
 
       template< class _TType >
-        inline void Configure( ) { this->m_Sample = _TType::New( ); }
+      inline void Configure( ) { this->m_Sample = _TType::New( ); }
 
     protected:
       bool                m_Required;
index a367a3c5d5d707af087a2417d4a28089ca8977f4..0192ea61167b5c7de37242257d3782e9c451e766 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::
@@ -171,6 +206,7 @@ Disconnect( )
 void cpPlugins::BaseObjects::ProcessObject::
 Modified( ) const
 {
+  std::cout << "Modified: " << this->m_Name << std::endl;
   this->Superclass::Modified( );
 
   cpPlugins::BaseObjects::Events::Modified evt;
@@ -184,38 +220,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 +266,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 )
index 60ee6512baddee480695a53339accd3d874b1b4b..5dbf8b315ea6fd8a510eb011248a9224037115e8 100644 (file)
@@ -31,21 +31,23 @@ namespace cpPlugins
       cpPlugins_Id_Macro( ProcessObject, Object );
 
       itkBooleanMacro( ExplicitExecution );
-      itkBooleanMacro( PrintExecution );
 
       itkGetStringMacro( Name );
       itkGetStringMacro( PluginName );
       itkGetConstMacro( ExplicitExecution, bool );
       itkGetConstMacro( LastExecutionSpan, long );
-      itkGetConstMacro( PrintExecution, bool );
 
       itkSetStringMacro( Name );
       itkSetStringMacro( PluginName );
       itkSetMacro( ExplicitExecution, bool );
-      itkSetMacro( PrintExecution, bool );
-      itkSetObjectMacro( PrintExecutionStream, std::ofstream );
 
     public:
+      void PrintExecutionOn( );
+      void PrintExecutionOff( );
+      bool GetPrintExecution( ) const;
+      bool SetPrintExecution( bool v );
+      void SetPrintExecutionStream( std::ofstream* s );
+
       Parameters* GetParameters( );
       const Parameters* GetParameters( ) const;
 
index 2f8d7adfc0de960afddbda32a36eb91af4c6235f..1543d314a25443d1ce8e7068b01bc990ea6d2099 100644 (file)
@@ -123,48 +123,76 @@ cpPlugins::BaseObjects::ProcessObject::Pointer
 cpPlugins::Interface::Plugins::
 CreateFilter( const std::string& category, const std::string& name )
 {
+  std::cout << "1" << std::endl;
   typedef void* ( *_TCreator )( );
+  std::cout << "2" << std::endl;
   typedef cpPlugins::BaseObjects::ProcessObject::Pointer _TPtr;
+  std::cout << "3" << std::endl;
   _TPtr o = NULL;
+  std::cout << "4" << std::endl;
   auto cat = this->m_Filters.find( category );
+  std::cout << "5" << std::endl;
   if( cat != this->m_Filters.end( ) )
   {
+  std::cout << "6" << std::endl;
     auto nam = cat->second.find( name );
+  std::cout << "7" << std::endl;
     if( nam != cat->second.end( ) )
     {
+  std::cout << "8" << std::endl;
       void* l_hnd = nam->second.second.first;
+  std::cout << "9" << std::endl;
       void* f_hnd = nam->second.second.second;
+  std::cout << "10" << std::endl;
       if( l_hnd == NULL )
       {
+  std::cout << "11" << std::endl;
         l_hnd = cpPlugins::OS::DLLManager::LoadPlugins( nam->second.first );
+  std::cout << "12" << std::endl;
         nam->second.second.first = l_hnd;
+  std::cout << "13" << std::endl;
 
       } // fi
       if( f_hnd == NULL )
       {
+  std::cout << "14" << std::endl;
         f_hnd =
           cpPlugins::OS::DLLManager::LoadCreator( l_hnd, category, name );
+  std::cout << "15" << std::endl;
         nam->second.second.second = f_hnd;
+  std::cout << "16" << std::endl;
 
       } // fi
+  std::cout << "17" << std::endl;
       _TCreator creator = reinterpret_cast< _TCreator >( f_hnd );
+  std::cout << "18" << std::endl;
       if( creator != NULL )
       {
-        o = reinterpret_cast< _TPtr* >( creator( ) )->GetPointer( );
+        std::cout << "19 " << creator << " " << f_hnd << std::endl;
+        void* a = creator( );
+  std::cout << "20" << std::endl;
+        std::cout << "20 " << creator << " " << a << std::endl;
+  std::cout << "21" << std::endl;
+        o = reinterpret_cast< _TPtr* >( a )->GetPointer( );
+  std::cout << "22" << std::endl;
         o->SetName( name );
+  std::cout << "23" << std::endl;
         o->SetPluginName( nam->second.first );
+  std::cout << "24" << std::endl;
 
       } // fi
 
     } // fi
 
   } // fi
+  std::cout << "25" << std::endl;
   if( o.IsNull( ) )
     throw std::runtime_error(
       std::string( "Could not create a valid ProcessObject of type \"" ) +
       category + std::string( ":" ) +
       name + std::string( "\"" )
       );
+  std::cout << "26" << std::endl;
   return( o );
 }