X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_RecognizeContoursDlg.cxx;h=6840e2dd5632ca356460b388b27e91cbeb8baff4;hb=541470db80142c32e3812a7b79e26727df1dcece;hp=bc12c51e08fb3aa8f6f4b2ffca2e06878b80ee3d;hpb=ed7a9d24abef6457c7eb94db703c57b0406df3d6;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.cxx b/src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.cxx index bc12c51e..6840e2dd 100644 --- a/src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_RecognizeContoursDlg.cxx @@ -19,13 +19,30 @@ #include "HYDROGUI_RecognizeContoursDlg.h" #include +#include +#include #include #include - +/** + * Constructor. + * \param theModule the module + * \param theTitle the panel title + */ HYDROGUI_RecognizeContoursDlg::HYDROGUI_RecognizeContoursDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) { + // Original image + QGroupBox* anImageGroup = new QGroupBox( tr( "ORIGINAL_IMAGE" ), mainFrame() ); + QLabel* aNameLabel = new QLabel( tr("NAME") ); + myImageName = new QLineEdit; + myImageName->setReadOnly( true ); + + QHBoxLayout* anImageLayout = new QHBoxLayout(); + anImageLayout->addWidget( aNameLabel ); + anImageLayout->addWidget( myImageName ); + anImageGroup->setLayout( anImageLayout ); + // List of recognized polylines QGroupBox* aPolylinesGroup = new QGroupBox( tr( "RECOGNIZED_POLYLINES" ), mainFrame() ); myPolylines = new QListWidget( aPolylinesGroup ); @@ -35,33 +52,73 @@ HYDROGUI_RecognizeContoursDlg::HYDROGUI_RecognizeContoursDlg( HYDROGUI_Module* t myPolylines->setSortingEnabled( false ); QBoxLayout* aPolylinesLayout = new QVBoxLayout; - aPolylinesLayout->setMargin( 5 ); - aPolylinesLayout->setSpacing( 5 ); aPolylinesLayout->addWidget( myPolylines ); aPolylinesGroup->setLayout( aPolylinesLayout ); // Layout + addWidget( anImageGroup ); addWidget( aPolylinesGroup ); // Conections connect( myPolylines, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) ); } +/** + * Destructor. + */ HYDROGUI_RecognizeContoursDlg::~HYDROGUI_RecognizeContoursDlg() { } +/** + * Set the image name. + * \param theName the name + */ +void HYDROGUI_RecognizeContoursDlg::setImageName( const QString& theName ) +{ + myImageName->setText( theName ); +} + +/** + * Reset the panel. + */ void HYDROGUI_RecognizeContoursDlg::reset() { + myImageName->clear(); myPolylines->clear(); } +/** + * Refill the list of polylines names. + * \param theNames the list of names + */ void HYDROGUI_RecognizeContoursDlg::setPolylineNames( const QStringList& theNames ) { myPolylines->clear(); myPolylines->addItems( theNames ); } +/** + * Remove the given polyline names from the list. + * \param theNames the list of names + */ +void HYDROGUI_RecognizeContoursDlg::removePolylineNames( const QStringList& theNames ) +{ + QList aFoundItems; + + foreach ( const QString& aName, theNames ) { + aFoundItems = myPolylines->findItems( aName, Qt::MatchExactly ); + foreach ( QListWidgetItem* anItem, aFoundItems ) { + anItem = myPolylines->takeItem( myPolylines->row( anItem ) ); + delete anItem; + } + } +} + +/** + * Select the given polyline names in the list. + * \param theNames the list of names + */ void HYDROGUI_RecognizeContoursDlg::setSelectedPolylineNames( const QStringList& theNames ) { myPolylines->clearSelection(); @@ -74,11 +131,18 @@ void HYDROGUI_RecognizeContoursDlg::setSelectedPolylineNames( const QStringList& } } +/** + * Slot called when polyline names selection changed. + */ void HYDROGUI_RecognizeContoursDlg::onItemSelectionChanged() { emit selectionChanged( getSelectedtPolylineNames() ); } +/** + * Get the list of selected polyline names. + * \return the list of names + */ QStringList HYDROGUI_RecognizeContoursDlg::getSelectedtPolylineNames() const { QStringList aSelectedNames;