X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpBaseQtApplication%2FEditor.cxx;h=f379f6416d0672e10bce9a12e49fc5b51f69eeb1;hb=f14984e5d680d5dab9da5833d2c54e182d5e175f;hp=35b8a61ceb7f52dac45909f0d22d0c26057a51c7;hpb=201c5026430f9bcc33f9db6a39f5d03db096c860;p=cpPlugins.git diff --git a/lib/cpBaseQtApplication/Editor.cxx b/lib/cpBaseQtApplication/Editor.cxx index 35b8a61..f379f64 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 + */ } // ------------------------------------------------------------------------- @@ -383,10 +396,6 @@ cpBaseQtApplication_Editor_Callback_CODE( MouseDoubleClick ) ); if( ok && !new_name.isEmpty( ) && old_name != new_name ) { - ok = this->m_Graph->RenameVertex( - old_name.toStdString( ), - new_name.toStdString( ) - ); block->setNamePort( new_name ); this->m_Workspace->RenameFilter( old_name.toStdString( ), @@ -481,16 +490,14 @@ cpBaseQtApplication_Editor_Callback_CODE( MouseDoubleClick ) } // fi } break; - /* TODO: - case Qt::RightButton: - { - } - break; - case Qt::MiddleButton: - { - } - break; - */ + case Qt::RightButton: + { + } + break; + case Qt::MiddleButton: + { + } + break; default: break; } // hctiws @@ -583,11 +590,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;