addPage( createGroupsPage() );
addPage( createLandCoversPage() );
addPage( createZonesPage() );
- addPage( createLandCoversPartitionPage() );
+ addPage( createLandCoverZonesPage() );
}
HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
QFrame* aFrame = new QFrame( aPage );
QGridLayout* aLayout = new QGridLayout( aPage );
+
+ QLabel* aResultsOnGeomObjectsLabel = new QLabel( tr( "RESULTS_ON_GEOMETRY_OBJECTS" ), aFrame );
myBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
myBrowser->setAutoOpenLevel( 3 );
aLayout->setMargin( 5 );
aLayout->setSpacing( 5 );
- aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
+ aLayout->addWidget( aResultsOnGeomObjectsLabel, 0, 0 );
+ aLayout->addWidget( myBrowser, 1, 0, 1, 2 );
myBathymetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
myBathymetryChoice = new QComboBox( aFrame );
myBathymetryChoice->setVisible( false );
myBathymetryLabel->setVisible( false );
- aLayout->addWidget( myBathymetryLabel, 1, 0 );
- aLayout->addWidget( myBathymetryChoice, 1, 1 );
+ aLayout->addWidget( myBathymetryLabel, 2, 0 );
+ aLayout->addWidget( myBathymetryChoice, 2, 1 );
aPage->setLayout( aLayout );
return aPage;
}
-QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPartitionPage() {
+QWizardPage* HYDROGUI_CalculationDlg::createLandCoverZonesPage() {
QWizardPage* aPage = new QWizardPage( mainFrame() );
QFrame* aFrame = new QFrame( aPage );
QGridLayout* aLayout = new QGridLayout( aPage );
- myLandCoverBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
+ QLabel* aResultsOnLandCoversLabel = new QLabel( tr( "RESULTS_ON_LAND_COVERS" ), aFrame );
+
+ myLandCoverBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage, true );
myLandCoverBrowser->setAutoOpenLevel( 3 );
aLayout->setMargin( 5 );
aLayout->setSpacing( 5 );
- aLayout->addWidget( myLandCoverBrowser, 0, 0, 1, 2 );
+ aLayout->addWidget( aResultsOnLandCoversLabel, 0, 0 );
+ aLayout->addWidget( myLandCoverBrowser, 1, 0, 1, 2 );
+
+ myStricklerTypeLabel = new QLabel( tr( "STRICKLER_TYPE" ), aFrame );
+ myStricklerTypeChoice = new QComboBox( aFrame );
+
+ myStricklerTypeLabel->setVisible( false );
+ myStricklerTypeChoice->setVisible( false );
+
+ aLayout->addWidget( myStricklerTypeLabel, 2, 0 );
+ aLayout->addWidget( myStricklerTypeChoice, 2, 1 );
aPage->setLayout( aLayout );
// Connections
- //...
+ connect( myLandCoverBrowser, SIGNAL( dataChanged() ), SLOT( onDataLandCoverChanged() ) );
+ connect( myLandCoverBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
+ connect( myLandCoverBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onLandCoverZoneSelected( SUIT_DataObject* ) ) );
+ connect( myStricklerTypeChoice, SIGNAL( activated( int ) ), SLOT( onMergeStricklerTypeSelected( int ) ) );
+ connect( myLandCoverBrowser,
+ SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
+ SLOT( onLandCoverZonesDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
+ connect( myLandCoverBrowser, SIGNAL( newRegion() ), this, SLOT( OnNewLandCoverRegion() ) );
return aPage;
}
HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
if ( aRegion )
{
- emit moveZones( theTargetParent, aZonesList );
+ emit moveZones( theTargetParent, aZonesList, false );
}
}
}
emit createRegion( myBrowser->getSelected() );
}
+void HYDROGUI_CalculationDlg::OnNewLandCoverRegion()
+{
+ emit createLandCoverRegion( myLandCoverBrowser->getSelected() );
+}
+
void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
{
int aType = myBathymetryChoice->itemData( theIndex ).toInt();
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();
+ QStringList aList = aZone->getObjects();
for ( int i = 0; i < aList.length(); i++ )
{
myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
myBathymetryLabel->setVisible( doShow );
}
+void HYDROGUI_CalculationDlg::onLandCoverZoneSelected( 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 = myStricklerTypeChoice->blockSignals( true );
+ myCurrentZone = aZone;
+ myStricklerTypeChoice->clear();
+ myStricklerTypeChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
+ QStringList aList = aZone->getObjects();
+ for ( int i = 0; i < aList.length(); i++ )
+ {
+ myStricklerTypeChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
+ }
+ // Select the current choice if any
+ int aCurIndex = 0;
+ switch ( aZone->getMergeType() )
+ {
+ case HYDROData_Zone::Merge_Object:
+ aCurIndex = 1 + aList.indexOf( aZone->text( HYDROGUI_DataObject::AltitudeObjId ) );
+ break;
+ default:
+ aCurIndex = 0; // Select unknown by default
+ }
+ myStricklerTypeChoice->setCurrentIndex( aCurIndex );
+ myStricklerTypeChoice->blockSignals( prevBlock );
+ }
+
+ myStricklerTypeChoice->setVisible( doShow );
+ myStricklerTypeChoice->setEnabled( getLandCoverMode() == HYDROData_CalculationCase::MANUAL );
+ myStricklerTypeLabel->setVisible( doShow );
+}
+
+void HYDROGUI_CalculationDlg::onMergeStricklerTypeSelected( int theIndex )
+{
+ int aType = myStricklerTypeChoice->itemData( theIndex ).toInt();
+ QString aText = myStricklerTypeChoice->itemText( theIndex );
+ emit setMergeStricklerType( aType, aText );
+}
+
+void HYDROGUI_CalculationDlg::onLandCoverZonesDropped( 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 land cover 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 createLandCoverRegion( aZonesList );
+ }
+ else
+ {
+ HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
+ if ( aRegion )
+ {
+ emit moveZones( theTargetParent, aZonesList, true );
+ }
+ }
+ }
+}
+
void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
{
myObjectName->setText( theName );
myValidator->setEditedObject( theCase );
// Build the calculation case subtree
- module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject );
+ module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject, false );
myBrowser->updateTree();
myBrowser->openLevels();
myBrowser->adjustColumnsWidth();
myBrowser->setAutoUpdate( true );
myBrowser->setUpdateModified( true );
+
+ // Build the calculation case subtree for Land Cover regions
+ module()->getDataModel()->buildCaseTree( myLandCoverBrowser->root(), myEditedObject, true );
+
+ myLandCoverBrowser->updateTree();
+ myLandCoverBrowser->openLevels();
+ myLandCoverBrowser->adjustColumnsWidth();
+ myLandCoverBrowser->setAutoUpdate( true );
+ myLandCoverBrowser->setUpdateModified( true );
}
HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
{
SUIT_DataObject* aRoot = myBrowser->root();
module()->getDataModel()->updateObjectTree( myEditedObject );
- module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
+ module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, false );
myBrowser->updateTree( aRoot );
}
void HYDROGUI_CalculationDlg::onDataChanged()
{
SUIT_DataObject* aRoot = myBrowser->root();
- module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
+ module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, false );
myBrowser->updateTree( aRoot );
}
Enable/disable land covers drag'n'drop and renaming.
@param theIsEnabled if true - land covers drag'n'drop and renaming will be enabled
*/
-void HYDROGUI_CalculationDlg::setEditLandCoversEnabled( const bool theIsEnabled )
+void HYDROGUI_CalculationDlg::setEditLandCoverZonesEnabled( const bool theIsEnabled )
{
myLandCoverBrowser->setReadOnly( !theIsEnabled );
}
myLandCoverPriorityWidget->setObjects( getLandCovers() );
}
+void HYDROGUI_CalculationDlg::refreshLandCoverZonesBrowser()
+{
+ SUIT_DataObject* aRoot = myLandCoverBrowser->root();
+ module()->getDataModel()->updateObjectTree( myEditedObject );
+ module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, true );
+ myLandCoverBrowser->updateTree( aRoot );
+}
+
+/**
+ Slot called when zones created on land covers are changed.
+ */
+void HYDROGUI_CalculationDlg::onDataLandCoverChanged()
+{
+ SUIT_DataObject* aRoot = myLandCoverBrowser->root();
+ module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, true );
+ myLandCoverBrowser->updateTree( aRoot );
+}
+
/**
Slot called when land covers order is changed.
*/