]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
warning about empty regions
authorasl <asl@opencascade.com>
Tue, 14 Oct 2014 07:03:51 +0000 (07:03 +0000)
committerasl <asl@opencascade.com>
Tue, 14 Oct 2014 07:03:51 +0000 (07:03 +0000)
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_Warning.h [new file with mode: 0644]

index ba36b3270577a8a983220d0e1c3f71a136bffe2e..a3a4c3cfbddfb87953883734b5d91fb3f2e49d50 100644 (file)
@@ -44,6 +44,7 @@ set(PROJECT_HEADERS
     HYDROData_Tool.h
     HYDROData_Transform.h
     HYDROData_VisualState.h
+    HYDROData_Warning.h
     HYDROData_Zone.h
 )
 
index 1cfa75e3e70dea8a318d21fa55dc8d3202b0c64f..bceb9f81ef488b5d9687ce65e054768c5a1440d5 100644 (file)
@@ -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<QString, Handle(HYDROData_Region)> aRegionsMap; //object name to region
+  QMap<QString, QString> 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<QString, Handle(HYDROData_Region)>::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;
+}
index e851eaa3685355efc22da818014e510e6ce28303..ec3f2976ae36b80df7c718b30bad87ac6d4ffbb2 100644 (file)
@@ -7,6 +7,7 @@
 #include <HYDROData_SplitToZonesTool.h>
 #include <HYDROData_PriorityQueue.h>
 #include <HYDROData_Zone.h>
+#include <HYDROData_Warning.h>
 
 // IDL includes
 #include <SALOMEconfig.h>
@@ -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 (file)
index 0000000..b8ba7ae
--- /dev/null
@@ -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