From: asl Date: Tue, 14 Oct 2014 07:03:51 +0000 (+0000) Subject: warning about empty regions X-Git-Tag: BR_hydro_v_1_0_4~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2a9d4ce272648b60a053b3c569483b8bc74cf46a;p=modules%2Fhydro.git warning about empty regions --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index ba36b327..a3a4c3cf 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -44,6 +44,7 @@ set(PROJECT_HEADERS HYDROData_Tool.h HYDROData_Transform.h HYDROData_VisualState.h + HYDROData_Warning.h HYDROData_Zone.h ) diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 1cfa75e3..bceb9f81 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -211,6 +211,7 @@ HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() void HYDROData_CalculationCase::Update() { HYDROData_Entity::Update(); + SetWarning(); // At first we remove previously created objects RemoveRegions(); @@ -279,6 +280,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume const HYDROData_SplitToZonesTool::SplitDataList& theZones ) { QMap aRegionsMap; //object name to region + QMap aRegionNameToObjNameMap; QString aZonesPref = CALCULATION_ZONES_PREF; HYDROData_PriorityQueue aPr( this ); @@ -293,6 +295,7 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume QString aRegName = anObjName + "_reg"; Handle(HYDROData_Region) aRegion = addNewRegion( theDoc, aRegName, false ); aRegionsMap.insert( anObjName, aRegion ); + aRegionNameToObjNameMap.insert( aRegName, anObjName ); } // 2. Now for each zone it is necessary to determine the most priority object @@ -323,7 +326,25 @@ void HYDROData_CalculationCase::CreateRegionsAuto( const Handle(HYDROData_Docume } } - //TODO: inform if some regions remain empty + QStringList anObjectsWithEmptyRegions; + QMap::const_iterator + anIt = aRegionsMap.begin(), aLast = aRegionsMap.end(); + for( ; anIt!=aLast; anIt++ ) + { + Handle(HYDROData_Region) aRegion = anIt.value(); + if( aRegion->GetZones().IsEmpty() ) + { + QString aRegName = aRegion->GetName(); + QString anObjName = aRegionNameToObjNameMap[aRegName]; + anObjectsWithEmptyRegions.append( anObjName ); + } + } + + if( !anObjectsWithEmptyRegions.empty() ) + { + QString aData = anObjectsWithEmptyRegions.join( ", " ); + SetWarning( WARN_EMPTY_REGIONS, aData ); + } } void HYDROData_CalculationCase::CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc, @@ -1079,7 +1100,7 @@ void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Object)& theO HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType ); } -QString HYDROData_CalculationCase::DumpRules() +QString HYDROData_CalculationCase::DumpRules() const { TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules ); return HYDROData_PriorityQueue::DumpRules( aRulesLab ); @@ -1107,3 +1128,14 @@ void HYDROData_CalculationCase::DumpRulesToPython( const QString& theCalcCaseNam TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules ); HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript ); } + +HYDROData_Warning HYDROData_CalculationCase::GetLastWarning() const +{ + return myLastWarning; +} + +void HYDROData_CalculationCase::SetWarning( HYDROData_WarningType theType, const QString& theData ) +{ + myLastWarning.Type = theType; + myLastWarning.Data = theData; +} diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index e851eaa3..ec3f2976 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -7,6 +7,7 @@ #include #include #include +#include // IDL includes #include @@ -297,7 +298,9 @@ public: const Handle(HYDROData_Object)& theObject2, HYDROData_Zone::MergeAltitudesType theMergeType ); - HYDRODATA_EXPORT QString DumpRules(); + HYDRODATA_EXPORT QString DumpRules() const; + + HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const; private: @@ -350,6 +353,8 @@ private: void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const; + void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" ); + protected: friend class HYDROData_Iterator; @@ -363,6 +368,9 @@ protected: * Destructs properties of the object and object itself, removes it from the document. */ HYDRODATA_EXPORT ~HYDROData_CalculationCase(); + +private: + HYDROData_Warning myLastWarning; }; #endif diff --git a/src/HYDROData/HYDROData_Warning.h b/src/HYDROData/HYDROData_Warning.h new file mode 100644 index 00000000..b8ba7ae3 --- /dev/null +++ b/src/HYDROData/HYDROData_Warning.h @@ -0,0 +1,18 @@ + +#ifndef HYDROData_Warnings_HeaderFile +#define HYDROData_Warnings_HeaderFile + +enum HYDROData_WarningType +{ + WARN_OK = 0, + WARN_EMPTY_REGIONS = 1, +}; + +struct HYDROData_Warning +{ + HYDROData_WarningType Type; + QString Data; +}; + + +#endif