+
+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 )
+{
+ QList<SUIT_DataObject*> aZonesList;
+ HYDROGUI_Zone* aZone;
+ // Get a list of dropped zones
+ for ( int i = 0; i < theList.length(); i++ )
+ {
+ aZone = dynamic_cast<HYDROGUI_Zone*>( theList.at( i ) );
+ if ( aZone )
+ {
+ aZonesList.append( aZone );
+ }
+ }
+ if ( aZonesList.length() > 0 )
+ {
+ // Get the target region
+ HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast<HYDROGUI_NamedObject*>(theTargetParent);
+ if ( aRegionsRoot )
+ {
+ // Create a new region
+ emit createRegion( aZonesList );
+ }
+ else
+ {
+ HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
+ if ( aRegion )
+ {
+ emit moveZones( theTargetParent, aZonesList );
+ }
+ }
+ }
+}
+
+void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
+{
+ int aType = myBathymetryChoice->itemData( theIndex ).toInt();
+ QString aText = myBathymetryChoice->itemText( theIndex );
+ emit setMergeType( aType, aText );
+}
+
+void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
+{
+ bool doShow = false;
+ HYDROGUI_Zone* aZone = dynamic_cast<HYDROGUI_Zone*>( theObject );
+ if ( aZone )
+ {
+ doShow = aZone->isMergingNeed();
+ }
+
+ if ( doShow )
+ {
+ // Fill the merge type combo box
+ bool prevBlock = myBathymetryChoice->blockSignals( true );
+ myCurrentZone = aZone;
+ myBathymetryChoice->clear();
+ myBathymetryChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
+ myBathymetryChoice->addItem( tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN );
+ myBathymetryChoice->addItem( tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX );
+ QStringList aList = aZone->getAltitudes();
+ for ( int i = 0; i < aList.length(); i++ )
+ {
+ myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
+ }
+ // Select the current choice if any
+ int aCurIndex = 0;
+ switch ( aZone->getMergeType() )
+ {
+ case HYDROData_Zone::Merge_ZMIN:
+ aCurIndex = 1;
+ break;
+ case HYDROData_Zone::Merge_ZMAX:
+ aCurIndex = 2;
+ break;
+ case HYDROData_Zone::Merge_Object:
+ aCurIndex = 3 + aList.indexOf( aZone->text( HYDROGUI_DataObject::AltitudeObjId ) );
+ break;
+ default:
+ aCurIndex = 0; // Select unknown by default
+ }
+ myBathymetryChoice->setCurrentIndex( aCurIndex );
+ myBathymetryChoice->blockSignals( prevBlock );
+ }
+
+ myBathymetryChoice->setVisible( doShow );
+ myBatimetryLabel->setVisible( doShow );
+}
+