]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1340 BR_1340_0
authorisn <isn@opencascade.com>
Mon, 30 Oct 2017 14:38:37 +0000 (17:38 +0300)
committerisn <isn@opencascade.com>
Mon, 30 Oct 2017 14:38:37 +0000 (17:38 +0300)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_Tool2.cxx
src/HYDROGUI/HYDROGUI_Tool2.h
src/HYDROGUI/HYDROGUI_ZoneTool.cxx
src/HYDROGUI/HYDROGUI_ZoneTool.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index a35f02cfc4d5397ec3868ac425b482c5e7913a86..0454e19f469287bb53029d6daa9c295f829be938 100644 (file)
@@ -148,6 +148,7 @@ set(PROJECT_HEADERS
     HYDROGUI_TransparencyDlg.h
     HYDROGUI_Overview.h
     HYDROGUI_ZoneTool.h
+       HYDROGUI_RegenerateRegionColorsOp.h
 )
 
 QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -298,6 +299,7 @@ set(PROJECT_SOURCES
     HYDROGUI_TransparencyDlg.cxx
     HYDROGUI_Overview.cxx
     HYDROGUI_ZoneTool.cxx
+       HYDROGUI_RegenerateRegionColorsOp.cxx
 )
 
 add_definitions(
index 63249c73daedf1b515ce767a6c1ffe8181ec9a77..95862a4d423727f9ff39bd971250d6c0b08002c3 100644 (file)
@@ -713,6 +713,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
     case KIND_NATURAL_OBJECT:    return "NATURAL_OBJECTS";
     case KIND_STRICKLER_TABLE:   return "STRICKLER_TABLES";
     case KIND_LAND_COVER_MAP:    return "LAND_COVER_MAPS";
+    case KIND_REGION:            return "REGIONS";
     default: break;
   }
   return QString();
index d03db928ef466eb7eb5f1cc459461b76cc750b1f..cf0954d922a3c8d89b324d02abfd19f5dfbe864c 100644 (file)
@@ -568,6 +568,14 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       }
       theMenu->addSeparator();
     }
+    else
+    {
+      Handle(HYDROData_CalculationCase) aCalcCase;
+      QString outStr;
+      HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr);
+      if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION ))
+        theMenu->addAction( action( RegenerateRegionColorsId ) );
+    }
   }
 
   if( anIsSelectedDataObjects )
index b1c5880127ccc45193f32b40bd019dce2a518962..14c473fe55a283bb18f1123b534287ee281b510c 100644 (file)
@@ -72,6 +72,7 @@
 #include "HYDROGUI_ImportLandCoverMapOp.h"
 #include "HYDROGUI_BathymetrySelectionOp.h"
 #include "HYDROGUI_BathymetryOp.h"
+#include "HYDROGUI_RegenerateRegionColorsOp.h"
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Obstacle.h>
@@ -241,6 +242,9 @@ void HYDROGUI_Module::createActions()
 
   createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
   createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
+
+  createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" );
+
 }
 
 void HYDROGUI_Module::createMenus()
@@ -714,6 +718,8 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case LandCoverScalarMapModeOffId:
     anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
     break;
+  case RegenerateRegionColorsId:
+     anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule );
   }
 
   if( !anOp )
index c558cfbd3f4f76d458d5a3ed20f8f9ce7366f2d5..e56315e8483b4e126d9ea1309978f621a1f148bf 100644 (file)
@@ -143,6 +143,8 @@ enum OperationId
   BathymetryRescaleVisibleId,
   BathymetryRescaleUserId,
   BathymetryRescaleDefaultId,
+
+  RegenerateRegionColorsId
 };
 
 #endif
index ef1962e806843c903ee22a05a0b1f0821fc2bd86..3dda8c6bd2ad89fceb4254dfae98dd670bd5b927 100644 (file)
@@ -54,7 +54,28 @@ int HYDROGUI_Tool::GetActiveStudyId()
   return 0;
 }
 
-
+static bool GetCalCaseSubT(const QString& aHydroPref, 
+  const QString& anEntry, 
+  const QString& SubTPostFix,
+  HYDROGUI_DataModel* aModel,
+  Handle(HYDROData_CalculationCase)& theOutCalCase)
+{
+  int aFiB = anEntry.lastIndexOf(SubTPostFix, -1, Qt::CaseInsensitive);
+  if (aFiB != -1)
+  {
+    QString RightTruncEntry = anEntry.left(anEntry.length() - SubTPostFix.length());
+    Handle(HYDROData_CalculationCase) CalCase = 
+      Handle(HYDROData_CalculationCase)::DownCast (aModel->objectByEntry( RightTruncEntry, KIND_CALCULATION ));
+    if (CalCase)
+    {
+      theOutCalCase = CalCase;
+      return true;
+    }
+    else
+      return false;
+  }
+  return false;
+}
 
 void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule,
                                           SUIT_ViewManager* theViewManager )
@@ -251,8 +272,71 @@ ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule )
   return KIND_UNKNOWN;
 }
 
+bool HYDROGUI_Tool::IsSelectedPartOfCalcCase( HYDROGUI_Module* theModule, Handle(HYDROData_CalculationCase)& theOutCalCase,
+  QString& theOutPart)
+{
+  HYDROGUI_DataModel* aModel = theModule->getDataModel();
+  SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
+  SUIT_DataOwnerPtrList anOwners;
+  aSelectionMgr->selected( anOwners );
 
+  if( anOwners.size() != 1 )
+    return false;
+
+  LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( anOwners.first().operator->() );
 
+  if( anOwner )
+  {
+    QString anEntry = anOwner->entry();
+    QString aHydroPref = "_" + HYDROGUI_DataObject::entryPrefix();
+    //
+    QString aPostFixBoundary = aHydroPref + HYDROGUI_DataModel::tr("CASE_BOUNDARY");
+    if (GetCalCaseSubT(anEntry, anEntry, aPostFixBoundary, aModel, theOutCalCase ))
+    {
+      theOutPart = HYDROGUI_DataModel::tr("CASE_BOUNDARY");
+      theOutPart.toUpper();
+      return true;
+    }
+    //
+    QString aPostFixAO = aHydroPref + 
+      HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( KIND_ARTIFICIAL_OBJECT ).toLatin1().constData());
+    if (GetCalCaseSubT(anEntry, anEntry, aPostFixAO, aModel, theOutCalCase ))
+    {
+      aPostFixAO.remove(0, aHydroPref.length());
+      theOutPart = aPostFixAO;
+      return true;
+    }
+    //
+    QString aPostFixNO = aHydroPref + 
+      HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( KIND_NATURAL_OBJECT ).toLatin1().constData());
+    if (GetCalCaseSubT(anEntry, anEntry, aPostFixNO, aModel, theOutCalCase ))
+    {
+      aPostFixNO.remove(0, aHydroPref.length());
+      theOutPart = aPostFixNO;
+      return true;
+    }
+    //
+    QString aPostFixLCM = aHydroPref + 
+      HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( KIND_LAND_COVER_MAP ).toLatin1().constData());
+    if (GetCalCaseSubT(anEntry, anEntry, aPostFixLCM, aModel, theOutCalCase ))
+    {
+      aPostFixLCM.remove(0, aHydroPref.length());
+      theOutPart = aPostFixLCM;
+      return true;
+    }
+    //
+    QString aPostFixReg = aHydroPref + 
+      HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( KIND_REGION ).toLatin1().constData());
+    if (GetCalCaseSubT(anEntry, anEntry, aPostFixReg, aModel, theOutCalCase ))
+    {
+      aPostFixReg.remove(0, aHydroPref.length());
+      theOutPart = aPostFixReg;
+      return true;
+    }
+    //
+  }
+  return false;
+}
 
 QStringList HYDROGUI_Tool::GetSelectedGeomObjects( HYDROGUI_Module* theModule,
                                                    QList<GEOM::shape_type> theTypes )
index 980372accdd67de3de4b3adaece5c9e10db46d46..316f2ded58b43907e06e353ba8b78a3362a6eff1 100644 (file)
@@ -34,6 +34,7 @@ class SUIT_ViewManager;
 class GraphicsView_ViewPort;
 class OCCViewer_ViewFrame;
 class HYDROData_Document;
+class HYDROData_CalculationCase;
 
 namespace HYDROGUI_Tool
 {
@@ -61,6 +62,9 @@ namespace HYDROGUI_Tool
 
   ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
 
+  bool IsSelectedPartOfCalcCase( HYDROGUI_Module* theModule, Handle(HYDROData_CalculationCase)& theOutCalCase,
+                                 QString& theOutPart);
+
   Handle(HYDROData_Entity) FindObjectByName( HYDROGUI_Module* theModule,
                                              const QString& theName,
                                              const ObjectKind theObjectKind = KIND_UNKNOWN );
index b5b75c4fa349526f9db43a8d840cd0df77eb19ee..be4034067d2a4ed1749c719cd9fa3ceee0bd06fd 100644 (file)
@@ -65,5 +65,10 @@ void AssignDefaultColors( const Handle(HYDROData_Region)& theRegion, int theSMar
   }
 }
 
+void AssignDefaultColors( const HYDROData_SequenceOfObjects& theRegions, int theSMargin, int theBMargin )
+{
+  for ( int i = 1; i <= theRegions.Length(); i++ )
+    AssignDefaultColors( Handle(HYDROData_Region)::DownCast(theRegions(i)), theSMargin, theBMargin );
+}
 
 };
index b419544be9b60d72a3def88fcba908baa1f054c0..8db9c7d2ac0dc6bbb8e10d336a22709b0df1eb63 100644 (file)
@@ -25,6 +25,7 @@ namespace HYDROGUI_ZoneTool
 {
   void AssignDefaultColors( const QList<Handle(HYDROData_Region)>&, int theSMargin = 128, int theBMargin = 90 );
   void AssignDefaultColors( const Handle(HYDROData_Region)&, int theSMargin = 128, int theBMargin = 90 );
+  void AssignDefaultColors( const HYDROData_SequenceOfObjects& theRegions, int theSMargin = 128, int theBMargin = 90 );
 };
 
 
index 64c413778fa78a2903be9d94333f1671548dd5ef..4c07b121e78209e781a852da143d6a9bbd164f72 100644 (file)
@@ -1500,6 +1500,10 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_POLYLINE_EXTRACTION</source>
       <translation>Polyline extraction</translation>
     </message>
+    <message>
+      <source>MEN_REGENERATE_REGION_COLORS</source>
+      <translation>Regenerate region colors</translation>
+    </message>
 
     <message>
       <source>STB_CREATE_CALCULATION</source>