Salome HOME
Fix for the bug #45: check and warning when the same image is used in 2 arguments.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationDlg.cxx
index 76c0a83d071d33b2eb886a79c36a080127366f4c..5d39423bb634636b4b64654d6e34e9ffeaeb51fa 100644 (file)
@@ -65,8 +65,6 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
 {
   addPage( createObjectsPage() );
   addPage( createZonesPage() );
-  connect( button( QWizard::NextButton ), SIGNAL( clicked() ), SIGNAL( splitZones() ) );
-  connect( button( QWizard::BackButton ), SIGNAL( clicked() ), SIGNAL( hideZones() ) );
 }
 
 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
@@ -77,6 +75,8 @@ void HYDROGUI_CalculationDlg::reset()
 {
   myObjectName->clear();
   myGeomObjects->clear();
+  myPolylineName->clear();
+  myAvailableGeomObjects->clear();
 }
 
 QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
@@ -92,6 +92,8 @@ QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
   connect( myValidator, SIGNAL( alreadyExists( QString ) ), SLOT( onAlreadyExists( QString ) ) );
 
   myPolylineName = new QComboBox( aPage );
+  connect( myPolylineName, SIGNAL( activated( const QString & ) ), 
+    SIGNAL( boundarySelected( const QString & ) ) );
 
   myGeomObjects = new QListWidget( aPage );
   myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
@@ -160,20 +162,6 @@ QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
   return aPage;
 }
 
-void HYDROGUI_CalculationDlg::onEmptyName()
-{
-  QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
-  QString aMessage = QObject::tr( "INCORRECT_OBJECT_NAME" );
-  SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
-}
-
-void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
-{
-  QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
-  QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
-  SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
-}
-
 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
   QWizardPage* aPage = new QWizardPage( mainFrame() );
   QFrame* aFrame = new QFrame( aPage );
@@ -208,6 +196,42 @@ QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
   return aPage;
 }
 
+
+bool HYDROGUI_CalculationDlg::acceptCurrent() const
+{
+  QString anErrorMsg;
+
+  if ( myGeomObjects->count() == 0 )
+  {
+    anErrorMsg = tr( "EMPTY_GEOMETRY_OBJECTS" );
+  }
+
+  if ( !anErrorMsg.isEmpty() )
+  {
+    anErrorMsg += "\n" + tr( "INPUT_VALID_DATA" );
+    
+    QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
+    SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, anErrorMsg );
+  }
+
+  return anErrorMsg.isEmpty();
+}
+
+void HYDROGUI_CalculationDlg::onEmptyName()
+{
+  QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
+  QString aMessage = tr( "INCORRECT_OBJECT_NAME" ) + "\n" + tr( "INPUT_VALID_DATA" );
+  SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
+}
+
+void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
+{
+  QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
+  QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName ) +
+                     "\n" + tr( "INPUT_VALID_DATA" );
+  SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
+}
+
 void HYDROGUI_CalculationDlg::onZonesDropped( const QList<SUIT_DataObject*>& theList, 
     SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
 {
@@ -348,6 +372,23 @@ void HYDROGUI_CalculationDlg::excludeGeomObjects( const QStringList& theObjects
   }
 }
 
+void HYDROGUI_CalculationDlg::setBoundary( const QString& theObjName )
+{
+  bool isBlocked = myPolylineName->blockSignals( true );
+  myPolylineName->setCurrentIndex( myPolylineName->findText( theObjName ) );
+  myPolylineName->blockSignals( isBlocked );
+}
+
+void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
+{
+  myPolylineName->clear();
+  myPolylineName->addItem( "", "" ); // No boundary item
+
+  for ( int i = 0, n = theObjects.length(); i < n; ++i )
+  {
+    myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
+  }
+}
 void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
 {
   myAvailableGeomObjects->clear();