From: asl Date: Tue, 14 Oct 2014 11:50:39 +0000 (+0000) Subject: methods for getting rules are implemented X-Git-Tag: BR_hydro_v_1_0_4~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c9c47e169e49bb19286024fe7a22fdb3cfd148f1;p=modules%2Fhydro.git methods for getting rules are implemented --- diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index bceb9f81..732e218a 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -1139,3 +1139,20 @@ void HYDROData_CalculationCase::SetWarning( HYDROData_WarningType theType, const myLastWarning.Type = theType; myLastWarning.Data = theData; } + +int HYDROData_CalculationCase::GetRulesCount() const +{ + TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules ); + return HYDROData_PriorityQueue::GetRulesCount( aRulesLab ); +} + +bool HYDROData_CalculationCase::GetRule( int theIndex, + Handle(HYDROData_Object)& theObject1, + HYDROData_PriorityType& thePriority, + Handle(HYDROData_Object)& theObject2, + HYDROData_Zone::MergeAltitudesType& theMergeType ) const +{ + TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules ); + return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex, + theObject1, thePriority, theObject2, theMergeType ); +} diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index ec3f2976..e0b07892 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -297,6 +297,12 @@ public: HYDROData_PriorityType thePriority, const Handle(HYDROData_Object)& theObject2, HYDROData_Zone::MergeAltitudesType theMergeType ); + HYDRODATA_EXPORT int GetRulesCount() const; + HYDRODATA_EXPORT bool GetRule( int theIndex, + Handle(HYDROData_Object)& theObject1, + HYDROData_PriorityType& thePriority, + Handle(HYDROData_Object)& theObject2, + HYDROData_Zone::MergeAltitudesType& theMergeType ) const; HYDRODATA_EXPORT QString DumpRules() const; diff --git a/src/HYDROData/HYDROData_PriorityQueue.cxx b/src/HYDROData/HYDROData_PriorityQueue.cxx index e3c5a133..52ba2b2e 100644 --- a/src/HYDROData/HYDROData_PriorityQueue.cxx +++ b/src/HYDROData/HYDROData_PriorityQueue.cxx @@ -216,3 +216,36 @@ void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab, theScript << aRule; } } + +int HYDROData_PriorityQueue::GetRulesCount( const TDF_Label& theRulesLab ) +{ + return theRulesLab.NbChildren(); +} + +bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab, + int theIndex, + Handle(HYDROData_Object)& theObject1, + HYDROData_PriorityType& thePriority, + Handle(HYDROData_Object)& theObject2, + HYDROData_Zone::MergeAltitudesType& theMergeType ) +{ + TDF_Label aRuleLabel = theRulesLab.FindChild( theIndex ); + + Handle(TDataStd_ReferenceList) aRefs1, aRefs2; + Handle(TDataStd_Integer) aPriorityAttr, aMergeAttr; + + bool isObj1OK = aRuleLabel.FindChild ( Object1_Tag ). FindAttribute( TDataStd_ReferenceList::GetID(), aRefs1 ); + bool isPriorityOK = aRuleLabel.FindChild( Priority_Tag ).FindAttribute( TDataStd_Integer::GetID(), aPriorityAttr ); + bool isObj2OK = aRuleLabel.FindChild ( Object2_Tag ). FindAttribute( TDataStd_ReferenceList::GetID(), aRefs2 ); + bool isMergeOK = aRuleLabel.FindChild ( Merge_Tag ). FindAttribute( TDataStd_Integer::GetID(), aMergeAttr ); + + bool isOK = isObj1OK && isPriorityOK && isObj2OK && isMergeOK; + if( isOK ) + { + theObject1 = Handle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs1->First() ) ); + thePriority = ( HYDROData_PriorityType ) aPriorityAttr->Get(); + theObject2 = Handle_HYDROData_Object::DownCast( HYDROData_Iterator::Object( aRefs2->First() ) ); + theMergeType = ( HYDROData_Zone::MergeAltitudesType ) aMergeAttr->Get(); + } + return isOK; +} diff --git a/src/HYDROData/HYDROData_PriorityQueue.h b/src/HYDROData/HYDROData_PriorityQueue.h index bb11ef63..0864ee5a 100644 --- a/src/HYDROData/HYDROData_PriorityQueue.h +++ b/src/HYDROData/HYDROData_PriorityQueue.h @@ -48,7 +48,13 @@ public: static void DumpRulesToPython( const TDF_Label& theRulesLab, const QString& theCalcCaseName, QStringList& theScript ); - + static int GetRulesCount( const TDF_Label& theRulesLab ); + static bool GetRule( const TDF_Label& theRulesLab, + int theIndex, + Handle(HYDROData_Object)& theObject1, + HYDROData_PriorityType& thePriority, + Handle(HYDROData_Object)& theObject2, + HYDROData_Zone::MergeAltitudesType& theMergeType ); private: typedef QMap MapNameToObject;