QString anOldCaseName = GetName();
if ( anOldCaseName != theName )
{
- HYDROData_SequenceOfObjects aRegions = GetRegions();
-
- HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
- for ( ; anIter.More(); anIter.Next() )
- {
- Handle(HYDROData_Region) aRegion =
- Handle(HYDROData_Region)::DownCast( anIter.Value() );
- if ( aRegion.IsNull() )
- continue;
-
- HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aRegion );
-
- HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
- HYDROData_SequenceOfObjects::Iterator anIter( aZones );
- for ( ; anIter.More(); anIter.Next() )
- {
- Handle(HYDROData_Zone) aRegZone =
- Handle(HYDROData_Zone)::DownCast( anIter.Value() );
- if ( aRegZone.IsNull() )
- continue;
-
- HYDROData_Tool::UpdateChildObjectName( anOldCaseName, theName, aRegZone );
- }
- }
+ // Update names of regions and its zones
+ UpdateRegionsNames( GetRegions( false ), anOldCaseName, theName );
+ // Update names of land cover regions and its zones
+ UpdateRegionsNames( GetRegions( true ), anOldCaseName, theName );
HYDROData_SequenceOfObjects aGroups = GetSplittedGroups();
+ HYDROData_SequenceOfObjects::Iterator anIter;
anIter.Init( aGroups );
for ( ; anIter.More(); anIter.Next() )
{
if( aMode==MANUAL )
{
- // Now we restore the regions and zones order
- HYDROData_SequenceOfObjects aRegions = GetRegions();
- anIter.Init( aRegions );
- for ( ; anIter.More(); anIter.Next() )
- {
- Handle(HYDROData_Region) aRegion =
- Handle(HYDROData_Region)::DownCast( anIter.Value() );
- if ( aRegion.IsNull() )
- continue;
-
- theTreatedObjects.insert( aRegion->GetName(), aRegion );
- QStringList aRegDump = aRegion->DumpToPython( theTreatedObjects );
- aResList << aRegDump;
- }
+ // Now we restore the
+ // - regions and zones order
+ DumpRegionsToPython( aResList, theTreatedObjects, GetRegions( false ) );
+ // - land cover regions and zones order
+ DumpRegionsToPython( aResList, theTreatedObjects, GetRegions( true ) );
}
// Export calculation case
if ( !aBoundaryPolyline.IsNull() )
aResSeq.Append( aBoundaryPolyline );
- HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions();
+ // Regions
+ HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions( false );
aResSeq.Append( aSeqOfRegions );
+ // Land cover regions
+ HYDROData_SequenceOfObjects aSeqOfLandCoverRegions = GetRegions( true );
+ aResSeq.Append( aSeqOfLandCoverRegions );
+
return aResSeq;
}
SetWarning();
// At first we remove previously created objects
- RemoveRegions();
+ RemoveRegions( false );
+ RemoveRegions( true );
RemoveSplittedGroups();
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
if ( aDocument.IsNull() )
return;
+ // Split to zones
Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
if ( aGeomObjects.IsEmpty() )
HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline );
if ( aSplitObjects.isEmpty() )
return;
-
+
HYDROData_SplitToZonesTool::SplitDataList aZonesList, anEdgesList;
HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitObjects );
anEdgesList.append( aSplitData );
}
+ // TODO: Split to land cover zones
+ /*HYDROData_SequenceOfObjects aLandCovers = GetLandCovers();
+ if ( aLandCovers.IsEmpty() )
+ return;
+
+ HYDROData_SplitToZonesTool::SplitDataList aSplitLandCoverObjects =
+ HYDROData_SplitToZonesTool::Split( aLandCovers, ... );
+ if ( aSplitLandCoverObjects.isEmpty() )
+ return;
+
+ HYDROData_SplitToZonesTool::SplitDataList aLandCoverZonesList, aLandCoverEdgesList;
+
+ HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitLandCoverObjects );
+ while( anIter.hasNext() )
+ {
+ const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
+ if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
+ aLandCoverZonesList.append( aSplitData );
+ else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
+ aLandCoverEdgesList.append( aSplitData );
+ }*/
+
switch( GetAssignmentMode() )
{
case MANUAL:
- CreateRegionsDef( aDocument, aZonesList );
+ CreateRegionsDef( aDocument, aZonesList, false );
+ // TODO: Create land cover regions in manual mode
+ //CreateRegionsDef( aDocument, aLandCoverZonesList, true );
break;
case AUTOMATIC:
- CreateRegionsAuto( aDocument, aZonesList );
+ CreateRegionsAuto( aDocument, aZonesList, false );
+ // TODO: Create land cover regions in automatic mode
+ //CreateRegionsAuto( aDocument, aLandCoverZonesList, true );
break;
}
CreateEdgeGroupsDef( aDocument, anEdgesList );
+ // TODO: Process land cover edges
+ //CreateEdgeGroupsDef( aDocument, aLandCoverEdgesList );
}
void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
- const HYDROData_SplitToZonesTool::SplitDataList& theZones )
+ const HYDROData_SplitToZonesTool::SplitDataList& theZones,
+ const bool theLandCover )
{
// Create result regions for case, by default one zone for one region
QString aRegsPref = CALCULATION_REGIONS_PREF;
{
const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
// Create new region
- Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref );
+ Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegsPref, theLandCover );
// Add the zone for region
Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone( theDoc, aZonesPref, aSplitData.Face(), aSplitData.ObjectNames );
}
void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
- const HYDROData_SplitToZonesTool::SplitDataList& theZones )
+ const HYDROData_SplitToZonesTool::SplitDataList& theZones,
+ const bool theLandCover )
{
QMap<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
QMap<QString, QString> aRegionNameToObjNameMap;
continue;
QString anObjName = anObj->GetName();
QString aRegName = anObjName + "_reg";
- Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, false );
+ Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, theLandCover, false );
aRegionsMap.insert( anObjName, aRegion );
aRegionNameToObjNameMap.insert( aRegName, anObjName );
}
SetToUpdate( true );
}
-Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
+Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone,
+ const bool theLandCover )
{
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
- Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
+ Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF, theLandCover );
if ( aNewRegion.IsNull() )
return aNewRegion;
return aNewRegion;
}
-bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion )
+bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion,
+ const bool theLandCover )
{
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() );
if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab )
{
- Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF );
+ Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF, theLandCover );
theRegion->CopyTo( aNewRegion );
aFatherCalc->RemoveRegion( theRegion );
return true;
}
-HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions() const
+HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions( const bool theLandCover ) const
{
- return GetReferenceObjects( DataTag_Region );
+ return GetReferenceObjects( theLandCover ? DataTag_LandCoverRegion : DataTag_Region );
}
void HYDROData_CalculationCase::UpdateRegionsOrder()
if ( aDocument.IsNull() )
return;
- HYDROData_SequenceOfObjects aRegions = GetRegions();
+ HYDROData_SequenceOfObjects aRegions = GetRegions( false );
+ aRegions.Append( GetRegions( true ) );
HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
for ( ; anIter.More(); anIter.Next() )
theRegion->Remove();
}
-void HYDROData_CalculationCase::RemoveRegions()
+void HYDROData_CalculationCase::RemoveRegions( const bool theLandCover )
{
- myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes();
+ myLab.FindChild( theLandCover ? DataTag_ChildLandCoverRegion : DataTag_ChildRegion ).ForgetAllAttributes();
}
HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetSplittedGroups() const
double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) const
{
- Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
+ Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint, false );
return GetAltitudeForPoint( thePoint, aZone );
}
{
double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
- Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
+ Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint, false );
if ( !aZone.IsNull() )
{
Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
return aResSeq;
}
-Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
+Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint,
+ const bool theLandCover ) const
{
Handle(HYDROData_Region) aResRegion;
- Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
+ Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint, theLandCover );
if ( !aZone.IsNull() )
aResRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
return aResRegion;
}
-Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const
+Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint,
+ const bool theLandCover ) const
{
Handle(HYDROData_Zone) aResZone;
- HYDROData_SequenceOfObjects aRegions = GetRegions();
+ HYDROData_SequenceOfObjects aRegions = GetRegions( theLandCover );
HYDROData_SequenceOfObjects::Iterator anIter( aRegions );
for ( ; anIter.More() && aResZone.IsNull(); anIter.Next() )
Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion( const Handle(HYDROData_Document)& theDoc,
const QString& thePrefixOrName,
+ const bool theLandCover,
bool isPrefix )
{
- TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
+ TDF_Label aNewLab = myLab.FindChild( theLandCover ? DataTag_ChildLandCoverRegion : DataTag_ChildRegion ).NewChild();
int aTag = aNewLab.Tag();
Handle(HYDROData_Region) aNewRegion =
Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
- AddRegion( aNewRegion );
+ AddRegion( aNewRegion, theLandCover );
QString aRegionName = isPrefix ? HYDROData_Tool::GenerateObjectName( theDoc, thePrefixOrName ) : thePrefixOrName;
aNewRegion->SetName( aRegionName );
// Get faces
TopTools_ListOfShape aFaces;
- HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
+ HYDROData_SequenceOfObjects aCaseRegions = GetRegions( false );
+ // TODO: process land cover faces
+ //aCaseRegions.Append( GetRegions( true ) );
HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
for ( ; aRegionIter.More(); aRegionIter.Next() )
{
myLastWarning.Data = theData;
}
+void HYDROData_CalculationCase::UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
+ const QString& theOldCaseName,
+ const QString& theName )
+{
+ HYDROData_SequenceOfObjects::Iterator anIter( theRegions );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Region) aRegion =
+ Handle(HYDROData_Region)::DownCast( anIter.Value() );
+ if ( aRegion.IsNull() )
+ continue;
+
+ HYDROData_Tool::UpdateChildObjectName( theOldCaseName, theName, aRegion );
+
+ HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
+ HYDROData_SequenceOfObjects::Iterator anIter( aZones );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Zone) aRegZone =
+ Handle(HYDROData_Zone)::DownCast( anIter.Value() );
+ if ( aRegZone.IsNull() )
+ continue;
+
+ HYDROData_Tool::UpdateChildObjectName( theOldCaseName, theName, aRegZone );
+ }
+ }
+}
+
+void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList,
+ MapOfTreatedObjects& theTreatedObjects,
+ const HYDROData_SequenceOfObjects& theRegions ) const
+{
+ HYDROData_SequenceOfObjects::Iterator anIter;
+ anIter.Init( theRegions );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Region) aRegion =
+ Handle(HYDROData_Region)::DownCast( anIter.Value() );
+ if ( aRegion.IsNull() )
+ continue;
+
+ theTreatedObjects.insert( aRegion->GetName(), aRegion );
+ QStringList aRegDump = aRegion->DumpToPython( theTreatedObjects );
+ theResList << aRegDump;
+ }
+}
+
bool HYDROData_CalculationCase::GetRule( int theIndex,
Handle(HYDROData_Entity)& theObject1,
HYDROData_PriorityType& thePriority,
DataTag_StricklerTable, ///< reference Strickler table
DataTag_LandCover, ///< reference land covers
DataTag_CustomLandCoverRules, ///< custom rules for land covers priority
- DataTag_AssignmentLandCoverMode ///< assignment mode of land covers priority
+ DataTag_AssignmentLandCoverMode, ///< assignment mode of land covers priority
+ DataTag_ChildLandCoverRegion, ///< child land cover regions
+ DataTag_LandCoverRegion ///< reference land cover regions
};
public:
* Updates the name of this object.
* Reimplemented to update the names of regions, zones and splitted groups.
*/
- HYDRODATA_EXPORT virtual void SetName( const QString& theName );
+ HYDRODATA_EXPORT virtual void SetName( const QString& theName );
/**
* Dump Calculation object to Python script representation.
* The label of theZone is changed during this operation
* because of new region becomes the new parent for this zone.
*/
- HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
+ HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone,
+ const bool theLandCover );
/**
* Add new one reference region for calculation case.
* The label of theRegion is changed in case if old parent is not this calculation.
*/
- HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
+ HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion,
+ const bool theLandCover );
/**
* Returns all reference regions of calculation case.
*/
- HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
+ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions( const bool theLandCover ) const;
/**
* Updates names of regions to correct order.
/**
* Removes all reference regions from calculation case.
*/
- HYDRODATA_EXPORT virtual void RemoveRegions();
+ HYDRODATA_EXPORT virtual void RemoveRegions( const bool theLandCover );
-
/**
* Returns all reference geometry groups of calculation case.
*/
/**
* Returns region to which the point is belongs.
* \param thePoint the point to examine
+ * \param theLandCover the flag indicating,
+ * if it is needed to search land cover region
* \return result region
*/
- HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
+ HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint,
+ const bool theLandCover ) const;
/**
* Returns zone to which the point is belongs.
* \param thePoint the point to examine
+ * \param theLandCover the flag indicating,
+ * if it is needed to search land cover zone
* \return result zone
*/
- HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
+ HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint,
+ const bool theLandCover ) const;
/**
* Returns classification of point for given zone.
*/
Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
const QString& thePrefixOrName,
+ const bool theLandCover,
bool isPrefix = true );
/**
QString& theGeomObjEntry ) const;
void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
- const HYDROData_SplitToZonesTool::SplitDataList& theZones );
+ const HYDROData_SplitToZonesTool::SplitDataList& theZones,
+ const bool theLandCover );
void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
- const HYDROData_SplitToZonesTool::SplitDataList& theZones );
+ const HYDROData_SplitToZonesTool::SplitDataList& theZones,
+ const bool theLandCover );
void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
+ void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
+ const QString& theOldCaseName,
+ const QString& theName );
+
+ void DumpRegionsToPython( QStringList& theResList,
+ MapOfTreatedObjects& theTreatedObjects,
+ const HYDROData_SequenceOfObjects& theRegions ) const;
+
protected:
friend class HYDROData_Iterator;
addPage( createGroupsPage() );
addPage( createLandCoversPage() );
addPage( createZonesPage() );
- addPage( createLandCoversPartitionPage() );
+ addPage( createLandCoverZonesPage() );
}
HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
return aPage;
}
-QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPartitionPage() {
+QWizardPage* HYDROGUI_CalculationDlg::createLandCoverZonesPage() {
QWizardPage* aPage = new QWizardPage( mainFrame() );
QFrame* aFrame = new QFrame( aPage );
aLayout->addWidget( myLandCoverBrowser, 0, 0, 1, 2 );
+ myStricklerTypeLabel = new QLabel( tr( "STRICKLER_TYPE" ), aFrame );
+ myStricklerTypeChoice = new QComboBox( aFrame );
+
+ myStricklerTypeLabel->setVisible( false );
+ myStricklerTypeChoice->setVisible( false );
+
+ aLayout->addWidget( myBathymetryLabel, 1, 0 );
+ aLayout->addWidget( myBathymetryChoice, 1, 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;
}
emit createRegion( myBrowser->getSelected() );
}
+void HYDROGUI_CalculationDlg::OnNewLandCoverRegion()
+{
+ emit createLandCoverRegion( myLandCoverBrowser->getSelected() );
+}
+
void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
{
int aType = myBathymetryChoice->itemData( theIndex ).toInt();
myBathymetryLabel->setVisible( doShow );
}
+void HYDROGUI_CalculationDlg::onLandCoverZoneSelected( SUIT_DataObject* theObject )
+{
+ // TODO: implement this function
+}
+
+void HYDROGUI_CalculationDlg::onMergeStricklerTypeSelected( int theIndex )
+{
+ // TODO: implement this function
+}
+
+void HYDROGUI_CalculationDlg::onLandCoverZonesDropped( const QList<SUIT_DataObject*>& theList,
+ SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
+{
+ // TODO: implement this function
+}
+
void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
{
myObjectName->setText( theName );
myLandCoverPriorityWidget->setObjects( getLandCovers() );
}
+void HYDROGUI_CalculationDlg::refreshLandCoverZonesBrowser()
+{
+ SUIT_DataObject* aRoot = myLandCoverBrowser->root();
+ module()->getDataModel()->updateObjectTree( myEditedObject );
+ module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
+ 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 );
+ myLandCoverBrowser->updateTree( aRoot );
+}
+
/**
Slot called when land covers order is changed.
*/
void setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals = true );
void includeLandCovers( const QStringList& theLandCovers, bool theReset );
void excludeLandCovers( const QStringList& theLandCovers );
+ void refreshLandCoverZonesBrowser();
+ void onDataLandCoverChanged();
void onOrderLandCoverChanged();
/**
void onZonesDropped( const QList<SUIT_DataObject*>& theList,
SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction );
+ /**
+ * Process items selection: hide/show Strickler type merge type selector.
+ */
+ void onLandCoverZoneSelected( SUIT_DataObject* theObject );
+ /**
+ * Process merge type selection: set the selected Strickler type merge type for the currently selected zone.
+ */
+ void onMergeStricklerTypeSelected( int theIndex );
+ /**
+ * Process land cover zones moving. Create a new region with dropped zones or add to existing one.
+ */
+ void onLandCoverZonesDropped( const QList<SUIT_DataObject*>& theList,
+ SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction );
+
signals:
void changeMode( int theMode );
void removeLandCovers();
void landCoversSelected();
void orderLandCoverChanged( bool& isConfirmed );
+
+ void createLandCoverRegion( const QList<SUIT_DataObject*>& theLandCoverZonesList );
void StricklerTableSelected( const QString & theObjName );
protected slots:
void OnNewRegion();
+ void OnNewLandCoverRegion();
private:
QList<Handle(HYDROData_Entity)> getGeometryObjects();
QWizardPage* createGroupsPage();
QWizardPage* createLandCoversPage();
QWizardPage* createZonesPage();
- QWizardPage* createLandCoversPartitionPage();
+ QWizardPage* createLandCoverZonesPage();
QSplitter* mySplitter;
QSplitter* myLandCoverSplitter;
HYDROGUI_Zone* myCurrentZone;
HYDROGUI_DataBrowser* myLandCoverBrowser;
+ QComboBox* myStricklerTypeChoice;
+ QLabel* myStricklerTypeLabel;
};
#endif
aPanel->setObjectName( anObjectName );
aPanel->setEditedObject( myEditedObject );
- createPreview();
+ createPreview( false );
}
void HYDROGUI_CalculationOp::getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
connect( aPanel, SIGNAL( orderLandCoverChanged( bool& ) ), SLOT( onOrderLandCoverChanged( bool& ) ) );
connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
- connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) );
+ connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones( const int ) ) );
//connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
SLOT( onObjectsSelected() ) );
connect( aPanel, SIGNAL( landCoversSelected() ),
SLOT( onLandCoversSelected() ) );
+ connect( aPanel, SIGNAL( createLandCoverRegion( const QList<SUIT_DataObject*>& ) ),
+ SLOT( onCreateLandCoverRegion( const QList<SUIT_DataObject*>& ) ) );
connect( aPanel, SIGNAL( boundarySelected( const QString & ) ),
SLOT( onBoundarySelected( const QString & ) ) );
connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ),
{
aPanel->refreshZonesBrowser();
}
- createPreview();
+ createPreview( false );
}
}
}
void HYDROGUI_CalculationOp::onCreateRegion( const QList<SUIT_DataObject*>& theZonesList )
{
- QList<HYDROGUI_Zone*> aZonesList;
- HYDROGUI_Zone* aZone;
- // Get a list of dropped zones
- for ( int i = 0; i < theZonesList.length(); i++ )
+ if ( createRegion( theZonesList, false ) )
{
- aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
- if ( aZone )
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( aPanel )
{
- aZonesList.append( aZone );
+ aPanel->refreshZonesBrowser();
}
+ createPreview( false );
}
- if ( aZonesList.length() > 0 )
+}
+
+void HYDROGUI_CalculationOp::onCreateLandCoverRegion( const QList<SUIT_DataObject*>& theZonesList )
+{
+ if ( createRegion( theZonesList, true ) )
{
- module()->getDataModel()->createNewRegion( myEditedObject, aZonesList );
HYDROGUI_CalculationDlg* aPanel =
::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
if ( aPanel )
{
- aPanel->refreshZonesBrowser();
+ aPanel->refreshLandCoverZonesBrowser();
}
- createPreview();
+ createPreview( true );
}
}
if ( !anAddedList.isEmpty() )
{
aPanel->includeGeomObjects( anAddedList );
- createPreview();
+ createPreview( false );
}
}
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with zones
- HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( false );
if ( aSeq.Length() > 0 )
{
// If there are already defined zones then ask a user to confirm zones recalculation
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with zones
- HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( false );
if ( aSeq.Length() > 0 )
{
// If there are already defined zones then ask a user to confirm zones recalculation
if ( !isConfirmed )
{
// If not modified check if the case has already defined regions with zones
- HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions( false );
if ( aSeq.Length() > 0 )
{
// If there are already defined zones then ask a user to confirm zones recalculation
myShowZones = true;
myEditedObject->Update();
- AssignDefaultZonesColors();
+ AssignDefaultZonesColors( false );
//aPanel->setEditedObject( myEditedObject );
aPanel->refreshZonesBrowser();
closePreview();
- createPreview();
+ createPreview( false );
anIsToUpdateOb = true;
}
else
{
- setZonesVisible( true );
+ // Show zones
+ setZonesVisible( true, false );
if ( isNameChanged ) {
module()->getDataModel()->updateObjectTree( myEditedObject );
}
}
- // Move this code to processing od the last panel (see below)
- if ( anIsToUpdateOb ) {
- SUIT_DataBrowser* anObjBrowser = ((LightApp_Application*)module()->application())->objectBrowser();
- if ( anObjBrowser ) {
- anObjBrowser->updateTree( module()->getDataModel()->getDataObject( myEditedObject ), false );
- }
- }
-
QApplication::restoreOverrideCursor();
}
else if( theIndex==4 )
}
aPanel->setEditLandCoversEnabled( aMode == HYDROData_CalculationCase::MANUAL );
+ bool anIsToUpdateOb = false;
+ if ( myEditedObject->IsMustBeUpdated() )
+ {
+ myShowZones = true;
+ myEditedObject->Update();
+
+ AssignDefaultZonesColors( true );
+
+ aPanel->refreshLandCoverZonesBrowser();
+
+ closePreview();
+ createPreview( true );
+
+ anIsToUpdateOb = true;
+
+ myEditedObject->SetToUpdate( true );
+ }
+ else
+ {
+ // Hide zones
+ setZonesVisible( false, false );
+ // Show land cover zones
+ setZonesVisible( true, true );
+ }
+
+ if ( anIsToUpdateOb ) {
+ SUIT_DataBrowser* anObjBrowser = ((LightApp_Application*)module()->application())->objectBrowser();
+ if ( anObjBrowser ) {
+ anObjBrowser->updateTree( module()->getDataModel()->getDataObject( myEditedObject ), false );
+ }
+ }
+
QApplication::restoreOverrideCursor();
}
}
-void HYDROGUI_CalculationOp::onHideZones()
+void HYDROGUI_CalculationOp::onHideZones( const int theIndex )
{
- setZonesVisible( false );
+ if( theIndex==3 )
+ {
+ // Hide zones
+ setZonesVisible( false, false );
+ }
+ else if( theIndex==4 )
+ {
+ // Hide land cover zones
+ setZonesVisible( false, true );
+ }
}
-void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
+void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible, const bool theLandCover )
{
myShowZones = theIsVisible;
- HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
+ HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions( theLandCover );
HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
HYDROData_SequenceOfObjects aZones;
Handle(HYDROData_Region) aRegion;
}
}
-void HYDROGUI_CalculationOp::AssignDefaultZonesColors()
+void HYDROGUI_CalculationOp::AssignDefaultZonesColors( const bool theLandCover )
{
- HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
+ HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions( theLandCover );
HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
HYDROData_SequenceOfObjects aZones;
Handle(HYDROData_Region) aRegion;
aPanel->setLandCoverRules( aRules );
}
-void HYDROGUI_CalculationOp::createPreview()
+bool HYDROGUI_CalculationOp::createRegion( const QList<SUIT_DataObject*>& theZonesList,
+ const bool theLandCover )
+{
+ bool aRetValue = false;
+
+ QList<HYDROGUI_Zone*> aZonesList;
+ HYDROGUI_Zone* aZone;
+ // Get a list of dropped zones
+ for ( int i = 0; i < theZonesList.length(); i++ )
+ {
+ aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
+ if ( aZone )
+ {
+ aZonesList.append( aZone );
+ }
+ }
+ if ( aZonesList.length() > 0 )
+ {
+ module()->getDataModel()->createNewRegion( myEditedObject, aZonesList, theLandCover );
+ aRetValue = true;
+ }
+
+ return aRetValue;
+}
+
+void HYDROGUI_CalculationOp::createPreview( const bool theLandCover )
{
LightApp_Application* anApp = module()->getApp();
- HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
+ HYDROData_SequenceOfObjects aSeq;
+ if ( theLandCover )
+ aSeq = myEditedObject->GetLandCovers();
+ else
+ aSeq = myEditedObject->GetGeometryObjects();
Handle(HYDROData_Entity) anEntity;
if ( myShowZones )
{
// Gather zones for displaying
- HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
+ HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions( theLandCover );
HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
HYDROData_SequenceOfObjects aZones;
Handle(HYDROData_Region) aRegion;
if ( !anAddedList.isEmpty() )
{
aPanel->includeLandCovers( anAddedList, false );
- // TODO: create preview of included land covers
- //createPreview();
+ createPreview( true );
}
}
* Selected zones are moved to the new region to be created.
*/
void onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
+ /**
+ * Selected land cover zones are moved to the new region to be created.
+ */
+ void onCreateLandCoverRegion( const QList<SUIT_DataObject*>& theZonesList );
/**
* Case objects must be splitted to zones if the case has been modified or new.
*/
/**
* Hide zones in the viewer.
*/
- void onHideZones();
+ void onHideZones( const int );
/**
* Geometry object is selected in the list on the first wizard page
*/
void onOrderLandCoverChanged( bool& isConfirmed );
private:
- void createPreview();
+ void createPreview( const bool theLandCover);
void closePreview();
void setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
- void setZonesVisible( bool theIsVisible );
+ void setZonesVisible( bool theIsVisible, const bool theLandCover );
void getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
QStringList& theNames, QStringList& theEntries ) const;
/**
* Internal method that used to assign unique default colors for zones
*/
- void AssignDefaultZonesColors();
+ void AssignDefaultZonesColors( const bool theLandCover );
/**
* Internal method that used to generate default color for zone
* @param theIndex the index of color to be generated
void setRules( HYDROData_CalculationCase::DataTag theDataTag );
+ bool createRegion( const QList<SUIT_DataObject*>& theZonesList,
+ const bool theLandCover );
+
bool confirmRegionsChange() const;
bool confirmModeChange() const;
bool confirmOrderChange() const;
LightApp_DataObject* aCaseRegionsSect =
createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
- HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions();
+ HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions( false );
HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
for ( ; anIter.More(); anIter.Next() )
{
createRegion( aCaseRegionsSect, aCaseRegion, "", true, theIsInOperation );
}
+ // TODO: Build object tree for land cover regions
+ //HYDROData_SequenceOfObjects aCaseLandCoverRegions = aCaseObj->GetRegions( true );
+ //...
+
#ifdef DEB_GROUPS
HYDROData_SequenceOfObjects aCalcGroups = aCaseObj->GetGeometryGroups();
buildObjectPartition( aGuiObj, aCalcGroups, tr( "OBJECT_GROUPS" ), false );
new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "", true );
- HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions();
+ HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions( false );
HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
for ( ; anIter.More(); anIter.Next() )
{
if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
createRegion( theParent, aCaseRegion, "", true, true );
}
+
+ // TODO: Create land cover regions
+ //HYDROData_SequenceOfObjects aCaseLandCoverRegions = theCase->GetRegions( true );
+ //...
}
}
}
bool HYDROGUI_DataModel::createNewRegion( Handle(HYDROData_CalculationCase) theCase,
- const QList<HYDROGUI_Zone*>& theZonesList )
+ const QList<HYDROGUI_Zone*>& theZonesList,
+ const bool theLandCover )
{
bool isOk = !theCase.IsNull();
if ( isOk )
{
if ( aRegion.IsNull() )
{
- aRegion = theCase->AddNewRegion( aZone );
+ aRegion = theCase->AddNewRegion( aZone, theLandCover );
isOk = !aRegion.IsNull();
}
else
/**
* Create a new region in the given calculation case containing given zones.
*/
- bool createNewRegion( Handle(HYDROData_CalculationCase) theCase, const QList<HYDROGUI_Zone*>& theZonesList );
+ bool createNewRegion( Handle(HYDROData_CalculationCase) theCase,
+ const QList<HYDROGUI_Zone*>& theZonesList,
+ const bool theLandCover );
/**
* Correct an internal model object according to the current document mode
DataTag_StricklerTable, ///< reference Strickler table
DataTag_LandCover, ///< reference land covers
DataTag_CustomLandCoverRules, ///< custom rules for land covers priority
- DataTag_AssignmentLandCoverMode ///< assignment mode of land covers priority
+ DataTag_AssignmentLandCoverMode, ///< assignment mode of land covers priority
+ DataTag_ChildLandCoverRegion, ///< child land cover regions
+ DataTag_LandCoverRegion ///< reference land cover regions
};
public:
* The label of theZone is changed during this operation
* because of new region becomes the new parent for this zone.
*/
- HYDROData_Region AddNewRegion( HYDROData_Zone theZone ) [Handle_HYDROData_Region ( const Handle_HYDROData_Zone& )];
+ HYDROData_Region AddNewRegion( HYDROData_Zone theZone, const bool theLandCover ) [Handle_HYDROData_Region ( const Handle_HYDROData_Zone&, const bool )];
%MethodCode
Handle(HYDROData_Zone) aRef =
Handle(HYDROData_Zone)::DownCast( createHandle( a0 ) );
if ( !aRef.IsNull() )
{
Py_BEGIN_ALLOW_THREADS
- aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddNewRegion( aRef ) :
- sipCpp->AddNewRegion( aRef );
+ aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddNewRegion( aRef, a1 ) :
+ sipCpp->AddNewRegion( aRef, a1 );
Py_END_ALLOW_THREADS
}
* Add new one reference region for calculation case.
* The label of theRegion is changed in case if old parent is not this calculation.
*/
- bool AddRegion( HYDROData_Region theRegion ) [bool ( const Handle_HYDROData_Region& )];
+ bool AddRegion( HYDROData_Region theRegion, const bool theLandCover ) [bool ( const Handle_HYDROData_Region&, const bool )];
%MethodCode
Handle(HYDROData_Region) aRef =
Handle(HYDROData_Region)::DownCast( createHandle( a0 ) );
if ( !aRef.IsNull() )
{
Py_BEGIN_ALLOW_THREADS
- sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRegion( aRef ):
- sipCpp->AddRegion( aRef );
+ sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRegion( aRef, a1 ):
+ sipCpp->AddRegion( aRef, a1 );
Py_END_ALLOW_THREADS
}
%End
/**
* Returns all reference regions of calculation case.
*/
- HYDROData_SequenceOfObjects GetRegions() const;
+ HYDROData_SequenceOfObjects GetRegions( const bool theLandCover ) const;
/**
* Updates names of regions to correct order.
/**
* Removes all reference regions from calculation case.
*/
- void RemoveRegions();
+ void RemoveRegions( const bool theLandCover );
/**
* \return result region
*/
HYDROData_Region GetRegionFromPoint( const double theCoordX,
- const double theCoordY ) const
- [Handle_HYDROData_Region ( const gp_XY& )];
+ const double theCoordY,
+ const bool theLandCover ) const
+ [Handle_HYDROData_Region ( const gp_XY&, const bool )];
%MethodCode
Handle(HYDROData_Region) aRes;
gp_XY aPnt( a0, a1 );
Py_BEGIN_ALLOW_THREADS
- aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetRegionFromPoint( aPnt ) :
- sipCpp->GetRegionFromPoint( aPnt );
+ aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetRegionFromPoint( aPnt, a2 ) :
+ sipCpp->GetRegionFromPoint( aPnt, a2 );
Py_END_ALLOW_THREADS
sipRes = (HYDROData_Region*)createPointer( aRes );
* \return result zone
*/
HYDROData_Zone GetZoneFromPoint( const double theCoordX,
- const double theCoordY ) const
- [Handle_HYDROData_Zone ( const gp_XY& )];
+ const double theCoordY,
+ const bool theLandCover ) const
+ [Handle_HYDROData_Zone ( const gp_XY&, const bool )];
%MethodCode
Handle(HYDROData_Zone) aRes;
gp_XY aPnt( a0, a1 );
Py_BEGIN_ALLOW_THREADS
- aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetZoneFromPoint( aPnt ) :
- sipCpp->GetZoneFromPoint( aPnt );
+ aRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetZoneFromPoint( aPnt, a2 ) :
+ sipCpp->GetZoneFromPoint( aPnt, a2 );
Py_END_ALLOW_THREADS
sipRes = (HYDROData_Zone*)createPointer( aRes );