X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpBaseQtApplication%2FEditor.cxx;h=fb911c3862875e65ea093aa8e087e759b65095f3;hb=b5417af22a8c30e05961789f4758c10e0cc1b926;hp=35b8a61ceb7f52dac45909f0d22d0c26057a51c7;hpb=1eca6dc8780b7fda231cf03e7ec56c77549bf865;p=cpPlugins.git diff --git a/lib/cpBaseQtApplication/Editor.cxx b/lib/cpBaseQtApplication/Editor.cxx index 35b8a61..fb911c3 100644 --- a/lib/cpBaseQtApplication/Editor.cxx +++ b/lib/cpBaseQtApplication/Editor.cxx @@ -68,9 +68,18 @@ void cpBaseQtApplication::Editor:: setWorkspace( TWorkspace* ws ) { this->m_Workspace = ws; - this->m_Graph = TGraph::New( ); + this->redrawWorkspace( ); +} +// ------------------------------------------------------------------------- +void cpBaseQtApplication::Editor:: +redrawWorkspace( ) +{ + if( this->m_Workspace == NULL ) + return; + // Create blocks + std::map< std::string, Block* > blocks; auto vIt = this->m_Workspace->GetGraph( )->BeginVertices( ); auto vIt_end = this->m_Workspace->GetGraph( )->EndVertices( ); for( ; vIt != vIt_end; ++vIt ) @@ -80,8 +89,7 @@ setWorkspace( TWorkspace* ws ) vIt->first.c_str( ), QPointF( vIt->second->GetViewX( ), vIt->second->GetViewY( ) ) ); - if( b != NULL ) - this->m_Graph->SetVertex( vIt->first, b ); + blocks[ vIt->first ] = b; } // rof @@ -90,11 +98,11 @@ setWorkspace( TWorkspace* ws ) auto rIt_end = this->m_Workspace->GetGraph( )->EndEdgesRows( ); for( ; rIt != rIt_end; ++rIt ) { - Block* orig = this->m_Graph->GetVertex( rIt->first ); + Block* orig = blocks[ rIt->first ]; auto cIt = rIt->second.begin( ); for( ; cIt != rIt->second.end( ); ++cIt ) { - Block* dest = this->m_Graph->GetVertex( cIt->first ); + Block* dest = blocks[ cIt->first ]; auto eIt = cIt->second.begin( ); for( ; eIt != cIt->second.end( ); ++eIt ) { @@ -108,7 +116,6 @@ setWorkspace( TWorkspace* ws ) c->setPort2( ip ); c->updatePosFromPorts( ); c->updatePath( ); - this->m_Graph->AddEdge( rIt->first, cIt->first, c ); } // rof @@ -145,8 +152,10 @@ createFilter( bool cpBaseQtApplication::Editor:: deleteFilter( const std::string& name ) { - std::cout << name << std::endl; - return( false ); + if( this->m_Workspace != NULL ) + return( this->m_Workspace->RemoveFilter( name ) ); + else + return( false ); } // ------------------------------------------------------------------------- @@ -156,19 +165,23 @@ deleteConnection( const std::string& in, const std::string& out ) { - std::cout - << src << " " - << des << " " - << in << " " - << out << std::endl; - return( false ); + if( this->m_Workspace != NULL ) + return( this->m_Workspace->Disconnect( src, des, in, out ) ); + else + return( false ); } // ------------------------------------------------------------------------- void cpBaseQtApplication::Editor:: clear( ) { - std::cout << "Editor::clear" << std::endl; + std::cout << "Editor: clear" << std::endl; + /* TODO + auto vIt = this->m_Graph.BeginVertices( ); + for( ; vIt != this->m_Graph.EndVertices( ); ++vIt ) + { + } // rof + */ } // ------------------------------------------------------------------------- @@ -356,6 +369,7 @@ cpBaseQtApplication_Editor_Callback_CODE( HoverMove ) // ------------------------------------------------------------------------- cpBaseQtApplication_Editor_Callback_CODE( MouseDoubleClick ) { + /* TODO QGraphicsItem* item = this->itemAt( evt->scenePos( ) ); if( item == NULL ) return; @@ -481,7 +495,6 @@ cpBaseQtApplication_Editor_Callback_CODE( MouseDoubleClick ) } // fi } break; - /* TODO: case Qt::RightButton: { } @@ -490,10 +503,10 @@ cpBaseQtApplication_Editor_Callback_CODE( MouseDoubleClick ) { } break; - */ default: break; } // hctiws + */ } // ------------------------------------------------------------------------- @@ -583,11 +596,6 @@ cpBaseQtApplication_Editor_Callback_CODE( MouseRelease ) port1->name( ).toStdString( ), port2->name( ).toStdString( ) ); - this->m_Graph->AddEdge( - port1->block( )->namePort( ).toStdString( ), - port2->block( )->namePort( ).toStdString( ), - this->m_ActualConnection - ); } else delete this->m_ActualConnection;