]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Implement automatic coloring of land cover maps 1) by colors of Strickler types selec...
authormkr <mkr@opencascade.com>
Fri, 13 Nov 2015 10:10:07 +0000 (13:10 +0300)
committermkr <mkr@opencascade.com>
Fri, 13 Nov 2015 10:10:07 +0000 (13:10 +0300)
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDROGUI/HYDROGUI_AbstractDisplayer.h
src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.cxx

index d33d90de40047b6a2053e075817cdea06352a0af..5d16d29e3105c8b16abab817e5bbe46a974880d2 100644 (file)
@@ -848,6 +848,14 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl
   SetShape( aResult );
 }
 
+/**
+   Checks that object has 2D presentation. Reimlemented to retun true.
+*/
+bool HYDROData_LandCoverMap::IsHas2dPrs() const
+{
+  return true;
+}
+
 /**
   Find the land cover for the given point
   @param thePoint the point laying in some land cover
index 9ce1613ef125614fd2d7ba5101b750f179af351b..8b1cce97dc0530d1b27a1e28b63bfd2f451a447d 100644 (file)
@@ -124,6 +124,11 @@ public:
 
   HYDRODATA_EXPORT void StoreLandCovers( const HYDROData_MapOfFaceToStricklerType& );
 
+  /**
+   * Checks that object has 2D presentation. Reimlemented to retun true.
+   */
+  HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
+
 protected:
   void SetShape( const TopoDS_Shape& );
 
index 7fe585820d23545f652ee993c645867a871b2a33..2973dc1db5d4e426106f261c0763a06036e0018d 100644 (file)
@@ -81,6 +81,8 @@ public:
    */
   virtual QString  GetType() const = 0;
 
+  HYDROGUI_Module* module() const {return myModule;}
+
 protected:
   /**
    * \brief Update and display all objects in the viewer.
@@ -136,7 +138,7 @@ protected:
    */
   virtual void     purgeObjects( const int theViewerId ) = 0;
 
-  HYDROGUI_Module* module() const {return myModule;}
+  //HYDROGUI_Module* module() const {return myModule;}
 
 private:
   HYDROGUI_Module* myModule;
index c365cfc49b6985c59d3c6ba32f365bd9503372ac..450a195e7525a4e0e580cdede2acfca2d3d4757f 100644 (file)
 #include "HYDROGUI_ShapeLandCoverMap.h"
 #include "HYDROGUI_OCCDisplayer.h"
 #include "HYDROGUI_LandCoverMapPrs.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Module.h"
+
+#include <LightApp_Application.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
 
 #include <HYDROData_LandCoverMap.h>
 
@@ -51,17 +59,6 @@ void HYDROGUI_ShapeLandCoverMap::update( bool theIsUpdateViewer, bool isDeactiva
     setShape( aLandCoverMapShape, false, false );
   }
 
-  /* TODO
-  if ( !myIsScalarMapMode ) {
-    QColor aFillingColor = aLandCoverMapObj->GetFillingColor();
-    QColor aBorderColor = aLandCoverMapObj->GetBorderColor();
-
-    setFillingColor( aFillingColor, false, false );
-    setBorderColor( aBorderColor, false, false );
-  } else {
-    updateShape( false, false );
-  }*/
-  
   Handle(HYDROGUI_LandCoverMapPrs) aLandCoverMapPrs = Handle(HYDROGUI_LandCoverMapPrs)::DownCast( getAISObject() );
   if ( !aLandCoverMapPrs.IsNull() )
     aLandCoverMapPrs->UpdateColors();
@@ -72,6 +69,7 @@ void HYDROGUI_ShapeLandCoverMap::update( bool theIsUpdateViewer, bool isDeactiva
 void HYDROGUI_ShapeLandCoverMap::setScalarMapModeEnabled( const bool theIsToEnable )
 {
   myIsScalarMapMode = theIsToEnable;
+  update( false, false );
 }
 
 void HYDROGUI_ShapeLandCoverMap::setVisible( const bool theState,
@@ -91,7 +89,38 @@ Handle_AIS_InteractiveObject HYDROGUI_ShapeLandCoverMap::createShape() const
 {
   Handle(HYDROData_LandCoverMap) aLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast( getObject() );
   if ( !aLandCoverMap.IsNull() )
-    return new HYDROGUI_LandCoverMapPrs( aLandCoverMap );
+  {
+    Handle(HYDROGUI_LandCoverMapPrs) aLandCoverMapPrs = new HYDROGUI_LandCoverMapPrs( aLandCoverMap );    
+    if ( myIsScalarMapMode )
+    {
+      LightApp_Application* anApp = myDisplayer->module()->getApp();
+      OCCViewer_ViewManager* aViewManager = ::qobject_cast<OCCViewer_ViewManager*>( 
+        anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+      if ( aViewManager )
+      {
+        if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
+        {
+          int aViewerId = (size_t)aViewer;
+
+          // Set Strickler table
+          Handle(HYDROData_StricklerTable) aTable = 
+            myDisplayer->module()->getLandCoverColoringTable( aViewerId );
+          if( !aTable.IsNull() )
+            aLandCoverMapPrs->SetTable( aTable );
+
+          // Set color scale
+          OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>( aViewer->getViewManager()->getActiveView() );
+          Handle(V3d_View) aView = aWnd->getViewPort()->getView();
+          if( !aView.IsNull() )
+          {
+            Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
+            aLandCoverMapPrs->SetColorScale( aColorScale );
+          }
+        }
+      }
+    }
+    return aLandCoverMapPrs;
+  }
   return NULL;
 }