X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPipelineEditor%2FEditor.cxx;h=289ee46431d2e8e51dc0e5f51eb64a658396cd67;hb=733108d258a27799df875ceda2d84c3cafea64d3;hp=237bb5815cb76af3a14b05dbca88498be9083c72;hpb=46f2cf7aa39bda8301b22fcfddd43daf0dc13770;p=cpPlugins.git diff --git a/lib/cpPipelineEditor/Editor.cxx b/lib/cpPipelineEditor/Editor.cxx index 237bb58..289ee46 100644 --- a/lib/cpPipelineEditor/Editor.cxx +++ b/lib/cpPipelineEditor/Editor.cxx @@ -11,6 +11,7 @@ #include #include #include +#include #include "Port.h" #include "Connection.h" @@ -73,10 +74,16 @@ setWorkspace( TWorkspace* ws ) auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( ); auto vIt_end = this->m_Workspace->GetGraph( )->EndVertices( ); for( ; vIt != vIt_end; ++vIt ) - this->_createBlock( + { + auto b = this->_createBlock( dynamic_cast< TFilter* >( vIt->second.GetPointer( ) ), + vIt->first.c_str( ), QPointF( vIt->second->GetViewX( ), vIt->second->GetViewY( ) ) ); + if( b != NULL ) + this->m_Graph->SetVertex( vIt->first, b ); + + } // rof // Add edges auto rIt = this->m_Workspace->GetGraph( )->BeginEdgesRows( ); @@ -112,20 +119,51 @@ setWorkspace( TWorkspace* ws ) // ------------------------------------------------------------------------- std::string cpPipelineEditor::Editor:: -createFilter( const std::string& filter, const QPointF& pnt ) +createFilter( + const std::string& category, + const std::string& filter, + const QPointF& pnt + ) { std::string name = filter; while( this->m_Workspace->HasFilter( name ) ) name += std::string( "_" ); - if( this->m_Workspace->CreateFilter( filter, name ) ) + if( this->m_Workspace->CreateFilter( category, filter, name ) ) { - this->_createBlock( this->m_Workspace->GetFilter( name ), pnt ); + auto b = this->_createBlock( + this->m_Workspace->GetFilter( name ), + name.c_str( ), + pnt + ); return( name ); } else return( "" ); } +// ------------------------------------------------------------------------- +bool cpPipelineEditor::Editor:: +deleteFilter( const std::string& name ) +{ + std::cout << name << std::endl; + return( false ); +} + +// ------------------------------------------------------------------------- +bool cpPipelineEditor::Editor:: +deleteConnection( + const std::string& src, const std::string& des, + const std::string& in, const std::string& out + ) +{ + std::cout + << src << " " + << des << " " + << in << " " + << out << std::endl; + return( false ); +} + // ------------------------------------------------------------------------- void cpPipelineEditor::Editor:: install( QGraphicsScene* s ) @@ -148,18 +186,56 @@ itemAt( const QPointF& pos ) } // ------------------------------------------------------------------------- -void cpPipelineEditor::Editor:: -_createBlock( TFilter* f, const QPointF& pnt ) +cpPipelineEditor::Block* cpPipelineEditor::Editor:: +_createBlock( TFilter* f, const QString& name, const QPointF& pnt ) { if( f == NULL ) - return; + return( NULL ); // Add block - Block* b = new Block( f, 0, this->m_Scene ); + Block* b = new Block( f, name, 0, this->m_Scene ); + b->setEditor( this ); b->setPos( pnt ); - // Keep a trace of this visual graph - this->m_Graph->SetVertex( f->GetName( ), b ); + // Mark exposed inputs + auto& e_in = this->m_Workspace->GetExposedInputPorts( ); + auto f_in = f->GetInputsNames( ); + for( auto iIt = f_in.begin( ); iIt != f_in.end( ); ++iIt ) + { + auto eIt = e_in.begin( ); + auto fIt = e_in.end( ); + for( ; eIt != e_in.end( ) && fIt == e_in.end( ); ++eIt ) + if( eIt->second.second == *iIt ) + fIt = eIt; + if( fIt == e_in.end( ) ) + continue; + + auto port = b->inputPort( iIt->c_str( ) ); + port->setExtendedName( fIt->first.c_str( ) ); + port->setExtend( true ); + + } // rof + + // Mark exposed outputs + auto& e_out = this->m_Workspace->GetExposedOutputPorts( ); + auto f_out = f->GetOutputsNames( ); + for( auto iIt = f_out.begin( ); iIt != f_out.end( ); ++iIt ) + { + auto eIt = e_out.begin( ); + auto fIt = e_out.end( ); + for( ; eIt != e_out.end( ) && fIt == e_out.end( ); ++eIt ) + if( eIt->second.second == *iIt ) + fIt = eIt; + if( fIt == e_out.end( ) ) + continue; + + auto port = b->outputPort( iIt->c_str( ) ); + port->setExtendedName( fIt->first.c_str( ) ); + port->setExtend( true ); + + } // rof + + return( b ); } // ------------------------------------------------------------------------- @@ -191,6 +267,40 @@ eventFilter( QObject* o, QEvent* e ) return( this->Superclass::eventFilter( o, e ) ); } +// ------------------------------------------------------------------------- +void cpPipelineEditor::Editor:: +updateFilter( const std::string& filter_name ) +{ + emit execFilter( filter_name ); +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Editor:: +showOutputData( + const std::string& filter_name, const std::string& output_name + ) +{ + emit showFilterOutput( filter_name, output_name ); +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Editor:: +hideOutputData( + const std::string& filter_name, const std::string& output_name + ) +{ + emit hideFilterOutput( filter_name, output_name ); +} + +// ------------------------------------------------------------------------- +void cpPipelineEditor::Editor:: +visualPropertiesOutputData( + const std::string& filter_name, const std::string& output_name + ) +{ + emit visualPropertiesFilterOutput( filter_name, output_name ); +} + // ------------------------------------------------------------------------- cpPipelineEditor_Editor_Callback_CODE( ContextMenu ) { @@ -270,15 +380,11 @@ cpPipelineEditor_Editor_Callback_CODE( MouseDoubleClick ) old_name.toStdString( ), new_name.toStdString( ) ); - if( ok ) - { - block->setNamePort( new_name ); - this->m_Workspace->RenameFilter( - old_name.toStdString( ), - new_name.toStdString( ) - ); - - } // fi + block->setNamePort( new_name ); + this->m_Workspace->RenameFilter( + old_name.toStdString( ), + new_name.toStdString( ) + ); } // fi }