Salome HOME
Merge branch 'master' of https://git.salome-platform.org/git/modules/hydro
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_RecognizeContoursDlg.cxx
index bc12c51e08fb3aa8f6f4b2ffca2e06878b80ee3d..6840e2dd5632ca356460b388b27e91cbeb8baff4 100644 (file)
 #include "HYDROGUI_RecognizeContoursDlg.h"
 
 #include <QGroupBox>
+#include <QLabel>
+#include <QLineEdit>
 #include <QListWidget>
 #include <QVBoxLayout>
 
-
+/**
+ * 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<QListWidgetItem*> 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;