QMap<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
QMap<QString, QString> aRegionNameToObjNameMap;
QString aZonesPref = CALCULATION_ZONES_PREF;
- HYDROData_PriorityQueue aPr( this );
+ HYDROData_PriorityQueue aPr( this, DataTag_CustomRules );
// 1. First we create a default region for each object included into the calculation case
HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
{
const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
HYDROData_Zone::MergeAltitudesType aMergeType;
- Handle(HYDROData_Object) aRegObj = aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType );
+ Handle(HYDROData_Object) aRegObj =
+ Handle(HYDROData_Object)::DownCast( aPr.GetMostPriorityObject( aSplitData.ObjectNames, aMergeType ) );
if( aRegObj.IsNull() )
continue;
Handle(HYDROData_Region) aRegion = aRegionsMap[aRegObj->GetName()];
return aGeomObj._retn();
}
-void HYDROData_CalculationCase::ClearRules( const bool theIsSetToUpdate )
+void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
+ const bool theIsSetToUpdate )
{
- TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
+ TDF_Label aRulesLab = myLab.FindChild( theDataTag );
HYDROData_PriorityQueue::ClearRules( aRulesLab );
// Indicate model of the need to update splitting
}
}
-void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Object)& theObject1,
+void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theObject1,
HYDROData_PriorityType thePriority,
- const Handle(HYDROData_Object)& theObject2,
- HYDROData_Zone::MergeAltitudesType theMergeType )
+ const Handle(HYDROData_Entity)& theObject2,
+ HYDROData_Zone::MergeAltitudesType theMergeType,
+ HYDROData_CalculationCase::DataTag theDataTag )
{
- TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
+ TDF_Label aRulesLab = myLab.FindChild( theDataTag );
HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType );
// Indicate model of the need to update splitting
}
bool HYDROData_CalculationCase::GetRule( int theIndex,
- Handle(HYDROData_Object)& theObject1,
+ Handle(HYDROData_Entity)& theObject1,
HYDROData_PriorityType& thePriority,
- Handle(HYDROData_Object)& theObject2,
- HYDROData_Zone::MergeAltitudesType& theMergeType ) const
+ Handle(HYDROData_Entity)& theObject2,
+ HYDROData_Zone::MergeAltitudesType& theMergeType,
+ HYDROData_CalculationCase::DataTag& theDataTag) const
{
- TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
+ TDF_Label aRulesLab = myLab.FindChild( theDataTag );
return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
theObject1, thePriority, theObject2, theMergeType );
}
else
return MANUAL;
}
-
-void HYDROData_CalculationCase::ClearLandCoverRules( const bool theIsSetToUpdate )
-{
- TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
- // TODO: adapt HYDROData_PriorityQueue to use with land covers
- //HYDROData_PriorityQueue::ClearRules( aRulesLab );
-
- // Indicate model of the need to update land covers partition
- if ( theIsSetToUpdate ) {
- SetToUpdate( true );
- }
-}
-
-void HYDROData_CalculationCase::AddLandCoverRule( const Handle(HYDROData_LandCover)& theLandCover1,
- HYDROData_PriorityType thePriority,
- const Handle(HYDROData_LandCover)& theLandCover2/*,
- HYDROData_LandCover::MergeStricklerCoefficientType theMergeType*/ )
-{
- TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
- // TODO: adapt HYDROData_PriorityQueue to use with land covers
- //HYDROData_PriorityQueue::AddRule( aRulesLab, theLandCover1, thePriority, theLandCover2, theMergeType );
-
- // Indicate model of the need to update splitting
- SetToUpdate( true );
-}
-
-bool HYDROData_CalculationCase::GetLandCoverRule( int theIndex,
- Handle(HYDROData_LandCover)& theLandCover1,
- HYDROData_PriorityType& thePriority,
- Handle(HYDROData_LandCover)& theLandCover2/*,
- HYDROData_LandCover::MergeStricklerCoefficientType& theMergeType*/ ) const
-{
- TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
- // TODO: adapt HYDROData_PriorityQueue to use with land covers
- //return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
- // theLandCover1, thePriority, theLandCover2, theMergeType );
- return true;
-}
HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
- HYDRODATA_EXPORT void ClearRules( const bool theIsSetToUpdate = true );
- HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Object)& theObject1,
- HYDROData_PriorityType thePriority,
- const Handle(HYDROData_Object)& theObject2,
- HYDROData_Zone::MergeAltitudesType theMergeType );
+ HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
+ const bool theIsSetToUpdate = true );
+ HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
+ HYDROData_PriorityType thePriority,
+ const Handle(HYDROData_Entity)& theObject2,
+ HYDROData_Zone::MergeAltitudesType theMergeType,
+ HYDROData_CalculationCase::DataTag theDataTag );
HYDRODATA_EXPORT bool GetRule( int theIndex,
- Handle(HYDROData_Object)& theObject1,
+ Handle(HYDROData_Entity)& theObject1,
HYDROData_PriorityType& thePriority,
- Handle(HYDROData_Object)& theObject2,
- HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
+ Handle(HYDROData_Entity)& theObject2,
+ HYDROData_Zone::MergeAltitudesType& theMergeType,
+ HYDROData_CalculationCase::DataTag& theDataTag ) const;
HYDRODATA_EXPORT void SetAssignmentLandCoverMode( AssignmentMode theMode );
HYDRODATA_EXPORT AssignmentMode GetAssignmentLandCoverMode() const;
- HYDRODATA_EXPORT void ClearLandCoverRules( const bool theIsSetToUpdate = true );
- HYDRODATA_EXPORT void AddLandCoverRule( const Handle(HYDROData_LandCover)& theLandCover1,
- HYDROData_PriorityType thePriority,
- const Handle(HYDROData_LandCover)& theLandCover2/*,
- HYDROData_LandCover::MergeStricklerCoefficientType theMergeType*/ );
- HYDRODATA_EXPORT bool GetLandCoverRule( int theIndex,
- Handle(HYDROData_LandCover)& theLandCover1,
- HYDROData_PriorityType& thePriority,
- Handle(HYDROData_LandCover)& theLandCover2/*,
- HYDROData_LandCover::MergeStricklerCoefficientType& theMergeType*/ ) const;
-
HYDRODATA_EXPORT QString DumpRules() const;
HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
#include <HYDROData_PriorityQueue.h>
#include <HYDROData_CalculationCase.h>
#include <HYDROData_Iterator.h>
+#include <HYDROData_LandCover.h>
#include <TDataStd_ReferenceList.hxx>
#include <TDataStd_Integer.hxx>
#include <TDF_ChildIterator.hxx>
-HYDROData_PriorityQueue::HYDROData_PriorityQueue( HYDROData_CalculationCase* theCalcCase )
+HYDROData_PriorityQueue::HYDROData_PriorityQueue( HYDROData_CalculationCase* theCalcCase,
+ Standard_Integer aTag )
{
myGeomObjects = theCalcCase->GetGeometryObjects();
for( int i=myGeomObjects.Lower(), n=myGeomObjects.Upper(); i<=n; i++ )
{
- Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( myGeomObjects.Value( i ) );
+ Handle(HYDROData_Entity) anObj = myGeomObjects.Value( i );
if( !anObj.IsNull() )
{
QString anObjName = anObj->GetName();
}
}
- myRules = GetRules( theCalcCase->Label().FindChild( HYDROData_CalculationCase::DataTag_CustomRules ) );
+ myRules = GetRules( theCalcCase->Label().FindChild( aTag ) );
}
HYDROData_PriorityQueue::~HYDROData_PriorityQueue()
{
}
-Handle(HYDROData_Object) HYDROData_PriorityQueue::GetMostPriorityObject( const QStringList& theZoneObjects,
+Handle(HYDROData_Entity) HYDROData_PriorityQueue::GetMostPriorityObject( const QStringList& theZoneObjects,
HYDROData_Zone::MergeAltitudesType& theMergeType ) const
{
QStringList aSortedZoneObjects;
aSortedZoneObjects.append( aName );
}
- Handle(HYDROData_Object) aMostPriorityObj;
+ Handle(HYDROData_Entity) aMostPriorityObj;
theMergeType = HYDROData_Zone::Merge_UNKNOWN;
QStringList::const_iterator anIt = aSortedZoneObjects.begin(), aLast = aSortedZoneObjects.end();
for( ; anIt!=aLast; anIt++ )
{
HYDROData_Zone::MergeAltitudesType aLocalMerge = HYDROData_Zone::Merge_UNKNOWN;
- Handle(HYDROData_Object) anObj = myNames[*anIt];
+ Handle(HYDROData_Entity) anObj = myNames[*anIt];
if( !anObj.IsNull() )
{
if( aMostPriorityObj.IsNull() )
return aMostPriorityObj;
}
-bool HYDROData_PriorityQueue::IsMorePriority( const Handle(HYDROData_Object)& theObj1,
- const Handle(HYDROData_Object)& theObj2,
+bool HYDROData_PriorityQueue::IsMorePriority( const Handle(HYDROData_Entity)& theObj1,
+ const Handle(HYDROData_Entity)& theObj2,
HYDROData_Zone::MergeAltitudesType& theMergeType ) const
{
// 1. First we check custom rules
};
void HYDROData_PriorityQueue::AddRule( TDF_Label& theRulesLabel,
- const Handle(HYDROData_Object)& theObject1,
+ const Handle(HYDROData_Entity)& theObject1,
HYDROData_PriorityType thePriority,
- const Handle(HYDROData_Object)& theObject2,
+ const Handle(HYDROData_Entity)& theObject2,
HYDROData_Zone::MergeAltitudesType theMergeType )
{
// Get the last rule index
if( isObj1OK && isPriorityOK && isObj2OK && isMergeOK )
{
HYDROData_CustomRule aRule;
- aRule.Object1 = Handle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs1->First() ) );
+ aRule.Object1 = HYDROData_Iterator::Object( aRefs1->First() );
aRule.Priority = ( HYDROData_PriorityType ) aPriorityAttr->Get();
- aRule.Object2 = Handle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs2->First() ) );
+ aRule.Object2 = HYDROData_Iterator::Object( aRefs2->First() );
aRule.MergeType = ( HYDROData_Zone::MergeAltitudesType ) aMergeAttr->Get();
aRules.append( aRule );
}
QString aPriority = anIt->Priority == LESS ? "LESS" : "GREATER";
QString aMergeType;
+ HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules;
+ Handle(HYDROData_LandCover) aLandCover1 = Handle(HYDROData_LandCover)::DownCast( anIt->Object1 );
+ Handle(HYDROData_LandCover) aLandCover2 = Handle(HYDROData_LandCover)::DownCast( anIt->Object2 );
+ if ( !aLandCover1.IsNull() && !aLandCover2.IsNull() )
+ aDataTag = HYDROData_CalculationCase::DataTag_CustomLandCoverRules;
+
switch( anIt->MergeType )
{
case HYDROData_Zone::Merge_UNKNOWN:
break;
}
- QString aRule = QString( "%0.AddRule( %1, %2, %3, %4 )" ).
- arg( theCalcCaseName ).arg( anObj1 ).arg( aPriority ).arg( anObj2 ).arg( aMergeType );
+ QString aRule = QString( "%0.AddRule( %1, %2, %3, %4, %5 )" ).
+ arg( theCalcCaseName ).arg( anObj1 ).arg( aPriority ).arg( anObj2 ).arg( aMergeType ).arg( aDataTag );
theScript << aRule;
}
bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab,
int theIndex,
- Handle(HYDROData_Object)& theObject1,
+ Handle(HYDROData_Entity)& theObject1,
HYDROData_PriorityType& thePriority,
- Handle(HYDROData_Object)& theObject2,
+ Handle(HYDROData_Entity)& theObject2,
HYDROData_Zone::MergeAltitudesType& theMergeType )
{
TDF_Label aRuleLabel = theRulesLab.FindChild( theIndex );
bool isOK = isObj1OK && isPriorityOK && isObj2OK && isMergeOK;
if( isOK )
{
- theObject1 = Handle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs1->First() ) );
+ theObject1 = HYDROData_Iterator::Object( aRefs1->First() );
thePriority = ( HYDROData_PriorityType ) aPriorityAttr->Get();
- theObject2 = Handle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs2->First() ) );
+ theObject2 = HYDROData_Iterator::Object( aRefs2->First() );
theMergeType = ( HYDROData_Zone::MergeAltitudesType ) aMergeAttr->Get();
}
return isOK;
#define HYDROData_PriorityQueue_HeaderFile
#include <QMap>
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
#include <HYDROData_Zone.h>
class HYDROData_CalculationCase;
struct HYDROData_CustomRule
{
- Handle(HYDROData_Object) Object1;
+ Handle(HYDROData_Entity) Object1;
HYDROData_PriorityType Priority;
- Handle(HYDROData_Object) Object2;
+ Handle(HYDROData_Entity) Object2;
HYDROData_Zone::MergeAltitudesType MergeType;
};
class HYDROData_PriorityQueue
{
public:
- HYDROData_PriorityQueue( HYDROData_CalculationCase* );
+ HYDROData_PriorityQueue( HYDROData_CalculationCase* theCalcCase,
+ Standard_Integer aTag );
~HYDROData_PriorityQueue();
- Handle_HYDROData_Object GetMostPriorityObject( const QStringList& theZoneObjects,
+ Handle_HYDROData_Entity GetMostPriorityObject( const QStringList& theZoneObjects,
HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
- bool IsMorePriority( const Handle(HYDROData_Object)& theObj1,
- const Handle(HYDROData_Object)& theObj2,
+ bool IsMorePriority( const Handle(HYDROData_Entity)& theObj1,
+ const Handle(HYDROData_Entity)& theObj2,
HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
static void ClearRules( TDF_Label& theRulesLabel );
static void AddRule( TDF_Label& theRulesLabel,
- const Handle(HYDROData_Object)& theObject1,
+ const Handle(HYDROData_Entity)& theObject1,
HYDROData_PriorityType thePriority,
- const Handle(HYDROData_Object)& theObject2,
+ const Handle(HYDROData_Entity)& theObject2,
HYDROData_Zone::MergeAltitudesType theMergeType );
static HYDROData_ListOfRules GetRules( const TDF_Label& theRulesLabel );
static QString DumpRules( const TDF_Label& theRulesLab );
QStringList& theScript );
static bool GetRule( const TDF_Label& theRulesLab,
int theIndex,
- Handle(HYDROData_Object)& theObject1,
+ Handle(HYDROData_Entity)& theObject1,
HYDROData_PriorityType& thePriority,
- Handle(HYDROData_Object)& theObject2,
+ Handle(HYDROData_Entity)& theObject2,
HYDROData_Zone::MergeAltitudesType& theMergeType );
private:
- typedef QMap<QString, Handle(HYDROData_Object)> MapNameToObject;
+ typedef QMap<QString, Handle(HYDROData_Entity)> MapNameToObject;
HYDROData_SequenceOfObjects myGeomObjects; ///< the ordered list of objects (default priority)
MapNameToObject myNames; ///< the map of name to object
#include "HYDROGUI_Zone.h"
#include "HYDROGUI_OrderedListWidget.h"
#include "HYDROGUI_PriorityWidget.h"
+#include "HYDROGUI_PriorityTableModel.h"
#include <HYDROData_Document.h>
#include <HYDROData_Entity.h>
setLandCoverMode( HYDROData_CalculationCase::AUTOMATIC );
// Reset the priority widget state
- QList<Handle(HYDROData_Object)> anObjects;
+ QList<Handle(HYDROData_Entity)> anObjects;
myPriorityWidget->setObjects( anObjects );
+ myLandCoverPriorityWidget->setObjects( anObjects );
}
QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
// Bottom of the page
myLandCoverPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() );
+ HYDROGUI_PriorityTableModel* aModel =
+ dynamic_cast<HYDROGUI_PriorityTableModel*>( myLandCoverPriorityWidget->getTable()->model() );
+ if ( aModel )
+ aModel->setColumnCount( 3 );
QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) );
QBoxLayout* aPriorityLayout = new QHBoxLayout;
Get included geometry objects.
@return the list of geometry objects
*/
-QList<Handle(HYDROData_Object)> HYDROGUI_CalculationDlg::getGeometryObjects()
+QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getGeometryObjects()
{
QList<Handle(HYDROData_Entity)> anEntities = myGeomObjects->getObjects();
- QList<Handle(HYDROData_Object)> anObjects;
+ QList<Handle(HYDROData_Entity)> anObjects;
foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
Get included land covers.
@return the list of land covers
*/
-QList<Handle(HYDROData_LandCover)> HYDROGUI_CalculationDlg::getLandCovers()
+QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getLandCovers()
{
QList<Handle(HYDROData_Entity)> anEntities = myLandCovers->getObjects();
- QList<Handle(HYDROData_LandCover)> aLandCovers;
+ QList<Handle(HYDROData_Entity)> aLandCovers;
foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
myPriorityWidget->setRules( theRules );
}
+/**
+ Get rules defined for land covers.
+ @return the list of rules
+ */
+HYDROData_ListOfRules HYDROGUI_CalculationDlg::getLandCoverRules() const
+{
+ return myLandCoverPriorityWidget->getRules();
+}
+
+/**
+ Set rules for land covers.
+ @param theRules the list of rules
+ */
+void HYDROGUI_CalculationDlg::setLandCoverRules( const HYDROData_ListOfRules& theRules ) const
+{
+ myLandCoverPriorityWidget->setRules( theRules );
+}
+
/**
Slot called when objects order is changed.
*/
myGeomObjects->undoLastMove();
}
-void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName )
+void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals )
{
- bool isBlocked = myStricklerTableName->blockSignals( true );
+ bool isBlocked;
+ if ( theBlockSignals )
+ isBlocked = myStricklerTableName->blockSignals( true );
+
myStricklerTableName->setCurrentIndex( myStricklerTableName->findText( theStricklerTableName ) );
- myStricklerTableName->blockSignals( isBlocked );
+
+ if ( theBlockSignals )
+ myStricklerTableName->blockSignals( isBlocked );
+ else
+ emit StricklerTableSelected( theStricklerTableName );
}
-void HYDROGUI_CalculationDlg::includeLandCovers( const QStringList& theLandCovers )
+void HYDROGUI_CalculationDlg::includeLandCovers( const QStringList& theLandCovers, bool theReset )
{
+ if ( theReset )
+ {
+ HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
+ myLandCovers->setObjects(anObject2VisibleList);
+ }
+
HYDROGUI_ListModel::Object2VisibleList anObjectsToInclude;
QList<QListWidgetItem*> aFoundItems;
foreach ( const QString& anObjName, theLandCovers ) {
myLandCovers->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
}
- // TODO: adapt HYDROGUI_PriorityWidget to process land covers
- //myLandCoverPriorityWidget->setObjects( getLandCovers() );
+ myLandCoverPriorityWidget->setObjects( getLandCovers() );
}
void HYDROGUI_CalculationDlg::excludeLandCovers( const QStringList& theLandCovers )
myLandCovers->removeObjectByName( anObjName );
}
- // TODO: adapt HYDROGUI_PriorityWidget to process land covers
- //myLandCoverPriorityWidget->setObjects( getLandCovers() );
+ myLandCoverPriorityWidget->setObjects( getLandCovers() );
}
/**
{
bool isConfirmed = true;
emit orderLandCoverChanged( isConfirmed );
- // TODO: adapt HYDROGUI_PriorityWidget to process land covers
- /*if( isConfirmed )
+ if( isConfirmed )
myLandCoverPriorityWidget->setObjects( getLandCovers() );
- else*/
+ else
myLandCovers->undoLastMove();
}
HYDROData_ListOfRules getRules() const;
void setRules( const HYDROData_ListOfRules& theRules ) const;
+ HYDROData_ListOfRules getLandCoverRules() const;
+ void setLandCoverRules( const HYDROData_ListOfRules& theRules ) const;
+
public slots:
void setMode( int theMode );
void setBoundary( const QString& theObjName );
void onOrderChanged();
void setLandCoverMode( int theMode );
- void setStricklerTable( const QString& theStricklerTableName );
- void includeLandCovers( const QStringList& theLandCovers );
+ void setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals = true );
+ void includeLandCovers( const QStringList& theLandCovers, bool theReset );
void excludeLandCovers( const QStringList& theLandCovers );
void onOrderLandCoverChanged();
void OnNewRegion();
private:
- QList<Handle(HYDROData_Object)> getGeometryObjects();
- QList<Handle(HYDROData_LandCover)> getLandCovers();
+ QList<Handle(HYDROData_Entity)> getGeometryObjects();
+ QList<Handle(HYDROData_Entity)> getLandCovers();
QWizardPage* createObjectsPage();
QWizardPage* createGroupsPage();
aPanel->includeGeomObjects( aList );
// set rules
- HYDROData_ListOfRules aRules;
- Handle(HYDROData_Object) anObject1, anObject2;
- HYDROData_PriorityType aPriority;
- HYDROData_Zone::MergeAltitudesType aMergeType;
- for ( int anIndex = 0; ; anIndex++ )
- {
- if ( myEditedObject->GetRule( anIndex, anObject1, aPriority, anObject2, aMergeType ) ) {
- HYDROData_CustomRule aRule;
- aRule.Object1 = anObject1;
- aRule.Object2 = anObject2;
- aRule.Priority = aPriority;
- aRule.MergeType = aMergeType;
-
- aRules << aRule;
- }
- else
- break;
- }
- aPanel->setRules( aRules );
+ setRules( HYDROData_CalculationCase::DataTag_CustomRules );
}
}
else
// For manual mode priority rules are redundant
if ( aPanel->getMode() == HYDROData_CalculationCase::MANUAL ) {
- myEditedObject->ClearRules( false );
+ myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, false );
}
if ( aPanel->getLandCoverMode() == HYDROData_CalculationCase::MANUAL ) {
- myEditedObject->ClearLandCoverRules( false );
+ myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules, false );
}
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
QStringList aList;
QStringList anEntryList;
+ HYDROData_SequenceOfObjects aSeq;
+
+ Handle(HYDROData_StricklerTable) aStricklerTableObj;
+ QString aStricklerTableName;
// Get all Strickler table objects to fill in combo-box
aList.clear();
anEntryList.clear();
- HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE );
- Handle(HYDROData_StricklerTable) aStricklerTableObj;
- QString aStricklerTableName;
+ HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE );
for ( ; anIter.More(); anIter.Next() )
{
aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() );
}
}
aPanel->setStricklerTableNames( aList, anEntryList );
+ if ( !aList.isEmpty() )
+ aPanel->setStricklerTable( aList.at( 0 ), false );
// Fill in list widget with all available land covers
- HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetLandCovers( module() );
+ aSeq = HYDROGUI_Tool::GetLandCovers( module() );
getNamesAndEntries( aSeq, aList, anEntryList );
aPanel->setAllLandCovers( aList, anEntryList );
+
+ // Set list of included land covers
+ aSeq = myEditedObject->GetLandCovers();
+ getNamesAndEntries( aSeq, aList, anEntryList );
+ aPanel->includeLandCovers( aList, true );
if ( !myEditedObject.IsNull() )
{
// Set mode (Auto or Manual) to defined priority of land covers
aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() );
+
+ // Set rules defined on land covers
+ setRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules );
}
else
{
// Clear priority rules
//@ASL if ( myEditedObject->GetRulesCount() > 0 ) {
- myEditedObject->ClearRules( true );
+ myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, true );
//@ASL }
// Set priority rules
foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) {
myEditedObject->AddRule( aRule.Object1, aRule.Priority,
- aRule.Object2, aRule.MergeType );
+ aRule.Object2, aRule.MergeType,
+ HYDROData_CalculationCase::DataTag_CustomRules );
}
}
}
createPreview();
anIsToUpdateOb = true;
+
+ myEditedObject->SetToUpdate( true );
}
else
{
}
}
+ // Move this code to processing od the last panel (see below)
if ( anIsToUpdateOb ) {
SUIT_DataBrowser* anObjBrowser = ((LightApp_Application*)module()->application())->objectBrowser();
if ( anObjBrowser ) {
QApplication::setOverrideCursor( Qt::WaitCursor );
- //...
-
// Set parameters for automatic mode
int aMode = aPanel->getLandCoverMode();
if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
}
// Clear priority rules
- myEditedObject->ClearLandCoverRules( true );
- // TODO: Set priority rules
- //foreach ( const HYDROData_CustomRule& aRule, aPanel->getLandCoverRules() ) {
- // myEditedObject->AddLandCoverRule( aRule.Object1, aRule.Priority,
- // aRule.Object2, aRule.MergeType );
+ myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomLandCoverRules, true );
+ // Set priority rules
+ foreach ( const HYDROData_CustomRule& aRule, aPanel->getLandCoverRules() ) {
+ myEditedObject->AddRule( aRule.Object1, aRule.Priority,
+ aRule.Object2, HYDROData_Zone::Merge_Object,
+ HYDROData_CalculationCase::DataTag_CustomLandCoverRules );
+ }
}
}
aPanel->setEditLandCoversEnabled( aMode == HYDROData_CalculationCase::MANUAL );
return ( aColor.isValid() ? aColor : HYDROData_ImmersibleZone::DefaultFillingColor() );
}
+void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDataTag )
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ HYDROData_ListOfRules aRules;
+ Handle(HYDROData_Entity) anObject1, anObject2;
+ HYDROData_PriorityType aPriority;
+ HYDROData_Zone::MergeAltitudesType aMergeType;
+ HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules;
+ for ( int anIndex = 0; ; anIndex++ )
+ {
+ if ( myEditedObject->GetRule( anIndex, anObject1, aPriority, anObject2, aMergeType, theDataTag ) ) {
+ HYDROData_CustomRule aRule;
+ aRule.Object1 = anObject1;
+ aRule.Object2 = anObject2;
+ aRule.Priority = aPriority;
+ aRule.MergeType = aMergeType;
+
+ aRules << aRule;
+ }
+ else
+ break;
+ }
+
+ if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomRules )
+ aPanel->setRules( aRules );
+ else if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomLandCoverRules )
+ aPanel->setLandCoverRules( aRules );
+}
+
void HYDROGUI_CalculationOp::createPreview()
{
LightApp_Application* anApp = module()->getApp();
if ( !anAddedList.isEmpty() )
{
- aPanel->includeLandCovers( anAddedList );
+ aPanel->includeLandCovers( anAddedList, false );
// TODO: create preview of included land covers
//createPreview();
}
float theSaturation = 0.5,
float theValue = 0.95 ) const;
+ void setRules( HYDROData_CalculationCase::DataTag theDataTag );
+
bool confirmRegionsChange() const;
bool confirmModeChange() const;
bool confirmOrderChange() const;
#include "HYDROGUI_PriorityTableModel.h"
+#include <HYDROData_LandCover.h>
/**
Constructor.
@param theParent the parent object
*/
HYDROGUI_PriorityTableModel::HYDROGUI_PriorityTableModel( QObject* theParent )
- : QAbstractTableModel( theParent )
+ : QAbstractTableModel( theParent ),
+ myColumnCount( 4 )
{
}
if ( aColumn == 0 || aColumn == 2 ) {
QStringList aNames;
HYDROData_CustomRule aRule = myRules.at( aRow );
- Handle(HYDROData_Object) aUsedObject = aColumn == 0 ? aRule.Object2 : aRule.Object1;
+ Handle(HYDROData_Entity) aUsedObject = aColumn == 0 ? aRule.Object2 : aRule.Object1;
if ( !aUsedObject.IsNull() ) {
aNames = getAvailablePairs( aUsedObject );
}
int aColumn = theIndex.column();
if ( aColumn == 0 || aColumn == 2 ) {
- Handle(HYDROData_Object) anObject;
+ Handle(HYDROData_Entity) anObject;
QString anObjName = theValue.toString();
- foreach ( const Handle(HYDROData_Object) anObj, myObjects ) {
+ foreach ( const Handle(HYDROData_Entity) anObj, myObjects ) {
if ( anObj->GetName() == anObjName ) {
anObject = anObj;
break;
*/
int HYDROGUI_PriorityTableModel::columnCount( const QModelIndex &theParent ) const
{
- return 4;
+ return myColumnCount;
}
/**
aData = tr( "OBJECT2" );
break;
case 3:
- aData = tr( "BATHYMETRY" );
+ {
+ if ( getObjectsKind() != KIND_LAND_COVER )
+ aData = tr( "BATHYMETRY" );
+ }
break;
};
} else if ( theOrientation == Qt::Vertical ) {
Set objects which could be used for rules definition.
@param theObjects the ordered list of objects
*/
-void HYDROGUI_PriorityTableModel::setObjects( const QList<Handle(HYDROData_Object)>& theObjects )
+void HYDROGUI_PriorityTableModel::setObjects( const QList<Handle(HYDROData_Entity)>& theObjects )
{
myObjects = theObjects;
// Try to find:
// 1. the new pair of objects
// 2. the priority type corresponding to the objects order
- Handle(HYDROData_Object) anObject1, anObject2;
+ Handle(HYDROData_Entity) anObject1, anObject2;
HYDROData_PriorityType aPriorityType = GREATER;
int aNbObjects = myObjects.count();
@param theObject the object
@return the list of object names
*/
-QStringList HYDROGUI_PriorityTableModel::getAvailablePairs( const Handle(HYDROData_Object)& theObject ) const
+QStringList HYDROGUI_PriorityTableModel::getAvailablePairs( const Handle(HYDROData_Entity)& theObject ) const
{
QStringList aNames;
Check if the given pair of objects is already used.
@return true if the pair is used
*/
-bool HYDROGUI_PriorityTableModel::isUsed( const Handle(HYDROData_Object)& theObj1,
- const Handle(HYDROData_Object)& theObj2 ) const
+bool HYDROGUI_PriorityTableModel::isUsed( const Handle(HYDROData_Entity)& theObj1,
+ const Handle(HYDROData_Entity)& theObj2 ) const
{
bool isUsed = false;
{
QStringList aNames;
- foreach ( const Handle(HYDROData_Object) anObj, myObjects ) {
+ foreach ( const Handle(HYDROData_Entity) anObj, myObjects ) {
if ( !anObj.IsNull() ) {
aNames << anObj->GetName();
}
}
return aNames;
-}
\ No newline at end of file
+}
+
+/**
+ Set number of columns in the table.
+ @param theColumnCount the number of columns
+ */
+void HYDROGUI_PriorityTableModel::setColumnCount( int theColumnCount )
+{
+ myColumnCount = theColumnCount;
+}
+
+/**
+ Get type of objects for which rules are defined assuming,
+ that all objects in the list have the same type.
+ @return the type of objects
+ */
+const ObjectKind HYDROGUI_PriorityTableModel::getObjectsKind() const
+{
+ if ( myObjects.isEmpty() )
+ return KIND_UNKNOWN;
+
+ return myObjects.at( 0 )->GetKind();
+}
bool removeRows( const QList<int> theRows );
bool removeAll();
- void setObjects( const QList<Handle(HYDROData_Object)>& theObjects );
+ void setObjects( const QList<Handle(HYDROData_Entity)>& theObjects );
void setRules( const HYDROData_ListOfRules& theObjects );
HYDROData_ListOfRules getRules() const;
bool createNewRule();
bool canCreateNewRule() const;
+
+ void setColumnCount( int theColumnCount );
protected:
- bool isUsed( const Handle(HYDROData_Object)& theObj1,
- const Handle(HYDROData_Object)& theObj2 ) const;
+ bool isUsed( const Handle(HYDROData_Entity)& theObj1,
+ const Handle(HYDROData_Entity)& theObj2 ) const;
- QStringList getAvailablePairs( const Handle(HYDROData_Object)& theObject ) const;
+ QStringList getAvailablePairs( const Handle(HYDROData_Entity)& theObject ) const;
QStringList getAvailableObjectNames() const;
QString priorityToString( const int thePriority ) const;
void showError( const QString& theMsg );
private:
+ const ObjectKind getObjectsKind() const;
+
friend class test_HYDROGUI_PriorityTableModel;
HYDROGUI_Module* myModule;
HYDROData_ListOfRules myRules;
- QList<Handle(HYDROData_Object)> myObjects;
+ QList<Handle(HYDROData_Entity)> myObjects;
+
+ int myColumnCount;
};
#endif
\ No newline at end of file
Set objects which could be used for rules definition.
@param theObjects the ordered list of objects
*/
-void HYDROGUI_PriorityWidget::setObjects( const QList<Handle(HYDROData_Object)>& theObjects )
+void HYDROGUI_PriorityWidget::setObjects( const QList<Handle(HYDROData_Entity)>& theObjects )
{
HYDROGUI_PriorityTableModel* aModel =
dynamic_cast<HYDROGUI_PriorityTableModel*>( myTable->model() );
}
}
+/**
+ Get table view.
+ @return the table view
+ */
+QTableView* HYDROGUI_PriorityWidget::getTable() const
+{
+ return myTable;
+}
+
/**
Slot called on table selection change.
*/
#include <HYDROGUI.h>
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
#include <HYDROData_PriorityQueue.h>
#include <QStyledItemDelegate>
HYDROGUI_PriorityWidget( QWidget* theParent );
virtual ~HYDROGUI_PriorityWidget();
- void setObjects( const QList<Handle(HYDROData_Object)>& theObjects );
+ void setObjects( const QList<Handle(HYDROData_Entity)>& theObjects );
HYDROData_ListOfRules getRules() const;
void setRules( const HYDROData_ListOfRules& theRules );
+ QTableView* getTable() const;
+
protected:
void updateControls();
AUTOMATIC,
};
+public:
+
+ enum DataTag
+ {
+ DataTag_First = 100, ///< first tag, to reserve
+ DataTag_GeometryObject, ///< reference geometry objects
+ DataTag_ChildRegion, ///< child regions
+ DataTag_Region, ///< reference regions
+ DataTag_Polyline, ///< reference boundary polyline
+ DataTag_GeometryGroup, ///< reference geometry groups
+ DataTag_SplittedGroups, ///< reference splitted groups
+ DataTag_CustomRules, ///< custom rules
+ DataTag_AssignmentMode, ///< assignment 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
+ };
+
public:
/**
* Add new one reference geometry object for calculation case.
%End
- void ClearRules();
+ void ClearRules( HYDROData_CalculationCase::DataTag theDataTag );
- void AddRule( HYDROData_Object theObject1,
+ void AddRule( HYDROData_Entity theObject1,
HYDROData_PriorityType thePriority,
- HYDROData_Object theObject2,
- HYDROData_Zone::MergeAltitudesType theMergeType )
- [void ( const Handle_HYDROData_Object&, HYDROData_PriorityType, const Handle_HYDROData_Object&, HYDROData_Zone::MergeAltitudesType )];
+ HYDROData_Entity theObject2,
+ HYDROData_Zone::MergeAltitudesType theMergeType,
+ HYDROData_CalculationCase::DataTag theDataTag )
+ [void ( const Handle_HYDROData_Entity&, HYDROData_PriorityType, const Handle_HYDROData_Entity&, HYDROData_Zone::MergeAltitudesType, HYDROData_CalculationCase::DataTag )];
%MethodCode
- Handle(HYDROData_Object) anObject1 =
- Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
- Handle(HYDROData_Object) anObject2 =
- Handle(HYDROData_Object)::DownCast( createHandle( a2 ) );
+ Handle(HYDROData_Entity) anObject1 =
+ Handle(HYDROData_Entity)::DownCast( createHandle( a0 ) );
+ Handle(HYDROData_Entity) anObject2 =
+ Handle(HYDROData_Entity)::DownCast( createHandle( a2 ) );
Py_BEGIN_ALLOW_THREADS
- sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRule( anObject1, a1, anObject2, a3 ) :
- sipCpp->AddRule( anObject1, a1, anObject2, a3 );
+ sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::AddRule( anObject1, a1, anObject2, a3, a4 ) :
+ sipCpp->AddRule( anObject1, a1, anObject2, a3, a4 );
Py_END_ALLOW_THREADS
%End