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 )
} // 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;
} // fi
}
+// -------------------------------------------------------------------------
+void PipelineEditor::
+_slotPrintExecutionInformation( bool show )
+{
+ if( this->m_Workspace.IsNotNull( ) )
+ this->m_Workspace->SetPrintExecution( show );
+}
+
// -------------------------------------------------------------------------
#include <cpBaseQtApplication/MainHelper.h>
cpBaseQtApplication_Main( PipelineEditor );
protected slots:
void _slotView( const std::string& name, bool show );
+ void _slotPrintExecutionInformation( bool show );
private:
Ui::PipelineEditor* m_UI;
<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&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>
}
// -------------------------------------------------------------------------
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
template< class _TImage >
void cpInstances::Image::
_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( );
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;
#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::
void cpPlugins::BaseObjects::ProcessObject::
Modified( ) const
{
+ std::cout << "Modified: " << this->m_Name << std::endl;
this->Superclass::Modified( );
cpPlugins::BaseObjects::Events::Modified evt;
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 )
} // 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 )
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;
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 );
}