// -------------------------------------------------------------------------
PipelineEditor::QNodesEditorCanvas::
QNodesEditorCanvas( QWidget* parent )
- : QGraphicsView( parent ),
- m_Workspace( NULL )
+ : QGraphicsView( parent )
{
QGraphicsScene* scene = new QGraphicsScene( this );
this->setScene( scene );
}
// -------------------------------------------------------------------------
-PipelineEditor::QNodesEditorCanvas::
-TWorkspace* PipelineEditor::QNodesEditorCanvas::
-workspace( )
-{
- return( this->m_Workspace );
-}
-
-// -------------------------------------------------------------------------
-const PipelineEditor::QNodesEditorCanvas::
-TWorkspace* PipelineEditor::QNodesEditorCanvas::
-workspace( ) const
+PipelineEditor::
+QNodesEditor* PipelineEditor::QNodesEditorCanvas::
+editor( )
{
- return( this->m_Workspace );
+ return( this->m_Editor );
}
// -------------------------------------------------------------------------
-void PipelineEditor::QNodesEditorCanvas::
-setWorkspace( TWorkspace* ws )
+const PipelineEditor::
+QNodesEditor* PipelineEditor::QNodesEditorCanvas::
+editor( ) const
{
- if( this->m_Workspace == ws )
- return;
- this->m_Workspace = ws;
- 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;
- auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( );
- auto vIt_end = this->m_Workspace->GetGraph( )->EndVertices( );
- for( ; vIt != vIt_end; ++vIt )
- {
- this->_createBlock( dynamic_cast< TFilter* >( vIt->second.GetPointer( ) ) );
-
- } // rof
- */
-
- // Add edges
- /* TODO
- auto rIt = this->m_Workspace->GetGraph( )->BeginEdgesRows( );
- auto rIt_end = this->m_Workspace->GetGraph( )->EndEdgesRows( );
- for( ; rIt != rIt_end; ++rIt )
- {
- auto cIt = rIt->second.begin( );
- for( ; cIt != rIt->second.end( ); ++cIt )
- {
- auto eIt = cIt->second.begin( );
- for( ; eIt != cIt->second.end( ); ++eIt )
- {
- QNEPort* p1 = out_ports[ rIt->first ][ eIt->first ];
- QNEPort* p2 = in_ports[ cIt->first ][ eIt->second ];
- if( p1 != NULL && p2 != NULL )
- {
- QNEConnection* conn = new QNEConnection( 0, scene );
- conn->setPort1( p1 );
- conn->setPort2( p2 );
- this->m_Graph->AddConnection( rIt->first, cIt->first, conn );
-
- } // fi
-
- } // rof
-
- } // rof
-
- } // rof
- */
+ return( this->m_Editor );
}
// -------------------------------------------------------------------------
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( );
if( !( mime->hasFormat( "application/x-qabstractitemmodeldatalist" ) ) )
return;
QList< QTreeWidgetItem* > items = tree->selectedItems( );
for( auto iIt = items.begin( ); iIt != items.end( ); ++iIt )
- {
- std::string filter = ( *iIt )->text( 0 ).toStdString( );
- 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 ) )
- {
- 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
+ this->m_Editor->createFilter(
+ ( *iIt )->text( 0 ).toStdString( ), event->pos( )
+ );
}
// -------------------------------------------------------------------------
}
// -------------------------------------------------------------------------
+ /*
void PipelineEditor::QNodesEditorCanvas::
_createBlock( TFilter* f )
{
- std::cout << "ptr: " << f << std::endl;
-
if( f == NULL )
return;
this->m_Graph->InsertVertex( f->GetName( ), b );
// Add vertices and keep track of ports
- /*
std::map< std::string, std::map< std::string, QNEPort* > >
in_ports, out_ports;
auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( );
this->m_Graph->InsertVertex( vIt->first, b );
} // rof
- */
}
+ */
// eof - $RCSfile$