From 7d58e3b62da920a493101d78d2929645ed98c8f9 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Thu, 17 Dec 2015 10:42:32 -0500 Subject: [PATCH] ... --- appli/cpPipelineEditor/QNodesEditorCanvas.cxx | 51 ++++++++----------- appli/cpPipelineEditor/cpPipelineEditor.cxx | 2 + lib/cpExtensions/DataStructures/Graph.hxx | 1 + lib/cpPlugins/Interface/Workspace.cxx | 16 ++++++ 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/appli/cpPipelineEditor/QNodesEditorCanvas.cxx b/appli/cpPipelineEditor/QNodesEditorCanvas.cxx index 6d970ad..b320930 100644 --- a/appli/cpPipelineEditor/QNodesEditorCanvas.cxx +++ b/appli/cpPipelineEditor/QNodesEditorCanvas.cxx @@ -52,11 +52,10 @@ setWorkspace( TWorkspace* ws ) if( this->m_Workspace == ws ) return; this->m_Workspace = ws; - QGraphicsScene* scene = this->scene( ); - - // Create graph this->m_Graph = TGraph::New( ); + /* TODO + QGraphicsScene* scene = this->scene( ); // Add vertices and keep track of ports std::map< std::string, std::map< std::string, QNEPort* > > in_ports, out_ports; @@ -65,32 +64,9 @@ setWorkspace( TWorkspace* ws ) for( ; vIt != vIt_end; ++vIt ) { this->_createBlock( dynamic_cast< TFilter* >( vIt->second.GetPointer( ) ) ); -#error ACA VOY - // Add block - QNEBlock* b = new QNEBlock( 0, scene ); - b->addPort( vIt->second->GetName( ), 0, QNEPort::NamePort ); - b->addPort( vIt->second->GetClassName( ).c_str( ), 0, QNEPort::TypePort ); - - // Get filter - if( f == NULL ) - continue; - - // Add input ports - std::set< std::string > inputs; - f->GetInputsNames( inputs ); - for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt ) - in_ports[ vIt->first ][ *iIt ] = b->addInputPort( iIt->c_str( ) ); - - // Add output ports - std::set< std::string > outputs; - f->GetOutputsNames( outputs ); - for( auto oIt = outputs.begin( ); oIt != outputs.end( ); ++oIt ) - out_ports[ vIt->first ][ *oIt ] = b->addOutputPort( oIt->c_str( ) ); - - // Keep a trace of this visual graph - this->m_Graph->InsertVertex( vIt->first, b ); } // rof + */ // Add edges /* TODO @@ -171,6 +147,7 @@ dragMoveEvent( QDragMoveEvent* event ) void PipelineEditor::QNodesEditorCanvas:: dropEvent( QDropEvent* event ) { + std::cout << event << " " << this->m_Workspace << std::endl; if( this->m_Workspace == NULL ) return; const QMimeData* mime = event->mimeData( ); @@ -186,12 +163,26 @@ dropEvent( QDropEvent* event ) for( auto iIt = items.begin( ); iIt != items.end( ); ++iIt ) { std::string filter = ( *iIt )->text( 0 ).toStdString( ); - std::string name = filter; + std::string name = "filtro"; //filter; if( this->m_Workspace->GetFilter( name ) != NULL ) name += std::string( "_" ); + std::cout << name << std::endl; if( this->m_Workspace->CreateFilter( filter, name ) ) { - } // fi + auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( ); + auto vIt_end = this->m_Workspace->GetGraph( )->EndVertices( ); + for( ; vIt != vIt_end; ++vIt ) + { + std::cout << "NAME: " << vIt->first << " " << vIt->second.GetPointer( ) << std::endl; + vIt->second->Print( std::cout ); + } + + + std::cout << "ok" << std::endl; + this->_createBlock( this->m_Workspace->GetFilter( name ) ); + } + else + std::cout << "no" << std::endl; } // rof } @@ -213,6 +204,8 @@ _scaleView( qreal scaleFactor ) void PipelineEditor::QNodesEditorCanvas:: _createBlock( TFilter* f ) { + std::cout << "ptr: " << f << std::endl; + if( f == NULL ) return; diff --git a/appli/cpPipelineEditor/cpPipelineEditor.cxx b/appli/cpPipelineEditor/cpPipelineEditor.cxx index 9abdd01..8d838b8 100644 --- a/appli/cpPipelineEditor/cpPipelineEditor.cxx +++ b/appli/cpPipelineEditor/cpPipelineEditor.cxx @@ -136,6 +136,7 @@ _ButtonLoadPluginsFile( ) ); // Update view + this->m_UI->Canvas->setWorkspace( this->m_Workspace ); this->_UpdateLoadedPlugins( ); } @@ -163,6 +164,7 @@ _ButtonLoadPluginsPath( ) ); // Update view + this->m_UI->Canvas->setWorkspace( this->m_Workspace ); this->_UpdateLoadedPlugins( ); } diff --git a/lib/cpExtensions/DataStructures/Graph.hxx b/lib/cpExtensions/DataStructures/Graph.hxx index c567f39..800bb8e 100644 --- a/lib/cpExtensions/DataStructures/Graph.hxx +++ b/lib/cpExtensions/DataStructures/Graph.hxx @@ -103,6 +103,7 @@ template< class V, class C, class I > V& cpExtensions::DataStructures::Graph< V, C, I >:: GetVertex( const I& index ) { + static V zero; return( this->m_Vertices[ index ] ); } diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index 849e7cc..97c3854 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -133,14 +133,27 @@ GetGraph( ) const bool cpPlugins::Interface::Workspace:: CreateFilter( const std::string& filter, const std::string& name ) { + std::cout << "wNAME: " << filter << " " << name << std::endl; + + for( + auto i = this->m_Graph->BeginVertices( ); + i != this->m_Graph->EndVertices( ); + ++i + ) + std::cout << "wOBJ: " << i->first << std::endl; + + // Get or create new filter from name if( !( this->m_Graph->HasVertexIndex( name ) ) ) { + std::cout << "wok" << std::endl; + TFilter::Pointer f = this->m_Interface.CreateObject( filter ); if( f.IsNotNull( ) ) { f->SetName( name ); TObject::Pointer o = f.GetPointer( ); + o->Print( std::cout ); this->m_Graph->InsertVertex( name, o ); return( true ); } @@ -148,7 +161,10 @@ CreateFilter( const std::string& filter, const std::string& name ) return( false ); } else + { + std::cout << "wno" << std::endl; return( true ); + } } // ------------------------------------------------------------------------- -- 2.47.1