]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #569: improve scalar map presentation of Land Covers.
authormzn <mzn@opencascade.com>
Wed, 24 Jun 2015 13:14:13 +0000 (16:14 +0300)
committermzn <mzn@opencascade.com>
Wed, 24 Jun 2015 13:14:13 +0000 (16:14 +0300)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_LandCoverOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ShapeLandCover.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ShowHideOp.cxx

index fce2c9e66ae3507b09c686ab1f831d28fd4ada0d..a77eff2c0b2aa7f9ef6e4762991fc4910c3d5181 100644 (file)
@@ -131,6 +131,7 @@ set(PROJECT_HEADERS
     HYDROGUI_RecognizeContoursDlg.h
     HYDROGUI_RecognizeContoursOp.h
     HYDROGUI_LandCoverColoringOp.h
+       HYDROGUI_ShapeLandCover.h
 )
 
 QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -265,6 +266,7 @@ set(PROJECT_SOURCES
     HYDROGUI_RecognizeContoursDlg.cxx
     HYDROGUI_RecognizeContoursOp.cxx
     HYDROGUI_LandCoverColoringOp.cxx
+       HYDROGUI_ShapeLandCover.cxx
 )
 
 add_definitions(
index 9cf2567e4ea5aa58380c420f8a81de0adfd1106b..2d2c5705a6459435b331599cbfb85420bc72c427 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "HYDROGUI_LandCoverDlg.h"
 #include "HYDROGUI_Module.h"
+#include "HYDROGUI_OCCDisplayer.h"
 #include "HYDROGUI_Shape.h"
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
@@ -233,6 +234,7 @@ bool HYDROGUI_LandCoverOp::processApply( int& theUpdateFlags,
   }
 
   module()->setIsToUpdate( aZoneObj );
+  module()->getOCCDisplayer()->SetToUpdateColorScale();
 
   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
 
index 25494cd8cf9a0e255a218613ded962f07c344140..b55b4a086e7f7ba9f95f9b50223c69d27276aabd 100644 (file)
@@ -1050,6 +1050,8 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
 
     if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
       setLandCoversScalarMapModeOff( theViewId );
+    } else if ( theObject->GetKind() == KIND_LAND_COVER && theState ) {
+      getOCCDisplayer()->SetToUpdateColorScale();
     }
   }
 }
index 5707d78b092e816914b72c652cd5ad5db5c82818..6cfbf67e20ebbfedb2ef2d6d431a2159eb88628b 100644 (file)
@@ -23,6 +23,7 @@
 #include "HYDROGUI_Tool.h"
 #include <HYDROGUI_ShapeImage.h>
 #include <HYDROGUI_ShapeBathymetry.h>
+#include <HYDROGUI_ShapeLandCover.h>
 #include "HYDROGUI_Operation.h"
 #include "HYDROGUI_DataObject.h"
 #include "HYDROGUI_ZLayers.h"
@@ -144,7 +145,9 @@ void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
     module()->removeObjectShape( (size_t)aViewer, anObj );
   }
   aViewer->update();
-  UpdateColorScale( aViewer );
+  if ( !module()->isLandCoversScalarMapModeOn( (size_t)aViewer ) ) {
+    UpdateColorScale( aViewer );
+  }
 }
 
 HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int                             theViewerId,
@@ -162,6 +165,10 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int
     aResShape = new HYDROGUI_ShapeImage( theContext, Handle_HYDROData_Image::DownCast( theObject ) );
   else if( theObject->IsKind( STANDARD_TYPE( HYDROData_Bathymetry ) ) )
     aResShape = new HYDROGUI_ShapeBathymetry( this, theContext, Handle_HYDROData_Bathymetry::DownCast( theObject ) );
+  else if( theObject->IsKind( STANDARD_TYPE( HYDROData_LandCover ) ) ) {
+    bool isScalarMode = module()->isLandCoversScalarMapModeOn( theViewerId );
+    aResShape = new HYDROGUI_ShapeLandCover( this, theContext, Handle_HYDROData_LandCover::DownCast( theObject ), -1, isScalarMode );
+  }
   else
     aResShape = new HYDROGUI_Shape( theContext, theObject );
 
@@ -403,7 +410,7 @@ void HYDROGUI_OCCDisplayer::SetToUpdateColorScale()
 
 void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer )
 {
-  if( !myToUpdateColorScale )
+  if( !myToUpdateColorScale || !theViewer )
     return;
   
   OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>( theViewer->getViewManager()->getActiveView() );
@@ -492,19 +499,21 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
       aView->ColorScaleErase();
   }
 
-  bool isScaleColoringOn = isDisplayColorScale && !aColorScale.IsNull();
   foreach( HYDROGUI_Shape* aShape, aLandCoverShapes ) {
-    if ( !aShape || !aShape->isVisible() ) {
+    HYDROGUI_ShapeLandCover* aLandCoverShape = 
+      dynamic_cast<HYDROGUI_ShapeLandCover*>( aShape );
+
+    if ( !aLandCoverShape || !aLandCoverShape->isVisible() ) {
       continue;
     }
-
+    
     Handle(HYDROData_LandCover) aLandCover = 
-      Handle(HYDROData_LandCover)::DownCast( aShape->getObject() );
+      Handle(HYDROData_LandCover)::DownCast( aLandCoverShape->getObject() );
 
     if ( aLandCover.IsNull() ) {
       continue;
     }
-
+    
     QColor aUndefinedColor( Qt::gray );
     QColor aColor = isLandCoverColoringOn ? aUndefinedColor : aLandCover->GetFillingColor();
     
@@ -523,8 +532,12 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
       }
     }
     
-    //@MZN aShape->update( false, false );
-    aShape->setFillingColor( aColor, true, true );
+    aLandCoverShape->setFillingColor( aColor, true, true );
+    aLandCoverShape->setScalarMapModeEnabled( isLandCoverColoringOn );
+    theViewer->getAISContext()->Redisplay( aLandCoverShape->getAISObject() );
+    //theViewer->getAISContext()->UpdateCurrentViewer(); //@MZN
+    //theViewer->getAISContext()->UpdateCurrent();
+    //theViewer->getAISContext()->UpdateSelected( true );
   }
 
   myToUpdateColorScale = false;
index 4d015a5c52035044665c62b4f321b1088ce480fe..7e7f3314dd378a8886e00c3015d736df8c996b85 100644 (file)
@@ -300,22 +300,6 @@ void HYDROGUI_Shape::update( bool isUpdateViewer,
 
       setShape( aCompound, false, false );  
     }
-    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) )
-    {
-      Handle(HYDROData_LandCover) aLandCoverObj =
-        Handle(HYDROData_LandCover)::DownCast( myObject );
-
-      TopoDS_Shape aLandCoverShape = aLandCoverObj->GetShape();
-      if ( !aLandCoverShape.IsNull() ) {
-        setShape( aLandCoverShape, false, false );
-      }
-
-      QColor aFillingColor = aLandCoverObj->GetFillingColor();
-      QColor aBorderColor = aLandCoverObj->GetBorderColor();
-
-      setFillingColor( aFillingColor, false, false );
-      setBorderColor( aBorderColor, false, false );
-    }
   }
  
   if ( myShape.IsNull() || !isVisible() )
diff --git a/src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx b/src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx
new file mode 100644 (file)
index 0000000..635470a
--- /dev/null
@@ -0,0 +1,94 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ShapeLandCover.h"
+#include "HYDROGUI_OCCDisplayer.h"
+
+#include <HYDROData_LandCover.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+HYDROGUI_ShapeLandCover::HYDROGUI_ShapeLandCover( HYDROGUI_OCCDisplayer*                theDisplayer,
+                                                  const Handle(AIS_InteractiveContext)& theContext,
+                                                  const Handle_HYDROData_LandCover&     theLandCover,
+                                                  const int                             theZLayer,
+                                                  const bool                            theIsScalarMode )
+: HYDROGUI_Shape( theContext, theLandCover, theZLayer ),
+  myDisplayer( theDisplayer ),
+  myIsScalarMapMode( theIsScalarMode )
+{
+}
+
+HYDROGUI_ShapeLandCover::~HYDROGUI_ShapeLandCover()
+{
+}
+
+void HYDROGUI_ShapeLandCover::update( bool theIsUpdateViewer, bool isDeactivateSelection )
+{
+  setIsToUpdate( false );
+
+  Handle(HYDROData_LandCover) aLandCoverObj =
+    Handle(HYDROData_LandCover)::DownCast( getObject() );
+
+  TopoDS_Shape aLandCoverShape = aLandCoverObj->GetShape();
+  if ( !aLandCoverShape.IsNull() ) {
+    setShape( aLandCoverShape, false, false );
+  }
+
+  if ( !myIsScalarMapMode ) {
+    QColor aFillingColor = aLandCoverObj->GetFillingColor();
+    QColor aBorderColor = aLandCoverObj->GetBorderColor();
+
+    setFillingColor( aFillingColor, false, false );
+    setBorderColor( aBorderColor, false, false );
+  } else {
+    updateShape( false, false );
+  }
+
+  HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection );
+}
+
+void HYDROGUI_ShapeLandCover::setScalarMapModeEnabled( const bool theIsToEnable )
+{
+  myIsScalarMapMode = theIsToEnable;
+}
+
+void HYDROGUI_ShapeLandCover::setVisible( const bool theState,
+                                           const bool theIsUpdateViewer )
+{
+  HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
+  myDisplayer->SetToUpdateColorScale();
+}
+
+void HYDROGUI_ShapeLandCover::displayShape( const bool theIsUpdateViewer )
+{
+  HYDROGUI_Shape::displayShape( theIsUpdateViewer );
+  myDisplayer->SetToUpdateColorScale();
+}
+
+void HYDROGUI_ShapeLandCover::display( const bool theIsUpdateViewer )
+{
+  HYDROGUI_Shape::display( theIsUpdateViewer );
+  myDisplayer->SetToUpdateColorScale();
+}
+
+void HYDROGUI_ShapeLandCover::erase( const bool theIsUpdateViewer )
+{
+  HYDROGUI_Shape::erase( theIsUpdateViewer );
+  myDisplayer->SetToUpdateColorScale();
+}
diff --git a/src/HYDROGUI/HYDROGUI_ShapeLandCover.h b/src/HYDROGUI/HYDROGUI_ShapeLandCover.h
new file mode 100644 (file)
index 0000000..3f89307
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_SHAPE_LANDCOVER_H
+#define HYDROGUI_SHAPE_LANDCOVER_H
+
+#include <HYDROGUI_Shape.h>
+
+class Handle_HYDROData_LandCover;
+class HYDROGUI_OCCDisplayer;
+
+class HYDROGUI_ShapeLandCover : public HYDROGUI_Shape
+{
+public:
+  HYDROGUI_ShapeLandCover( HYDROGUI_OCCDisplayer* theDisplayer,
+                            const Handle(AIS_InteractiveContext)& theContext,
+                            const Handle_HYDROData_LandCover&     theLandCover,
+                            const int                             theZLayer = -1,
+                            const bool                            theIsScalarMode = false );
+  virtual ~HYDROGUI_ShapeLandCover();
+  
+  virtual void              update( bool isUpdateViewer,
+                                    bool isDeactivateSelection );
+
+  virtual void display( const bool theIsUpdateViewer = true );
+  virtual void erase( const bool theIsUpdateViewer = true );
+
+  virtual void               setVisible( const bool theState,
+                                         const bool theIsUpdateViewer = true );
+
+  /**
+   * Enable/disable scalar map coloring mode.
+   * @param theIsToEnable if true - scalar map coloring mode willbe enbaled, if false - disabled
+   */
+  virtual void              setScalarMapModeEnabled( const bool theIsToEnable );
+
+protected:
+  virtual void displayShape( const bool theIsUpdateViewer );
+
+private:
+  HYDROGUI_OCCDisplayer* myDisplayer;
+  bool                   myIsScalarMapMode;
+};
+
+#endif
index 16be7aff3764b5a5c74b14143d9cb6c9ab099a2a..c3185734493165204c92c26363cb8b15e007a321 100644 (file)
@@ -172,8 +172,6 @@ void HYDROGUI_ShowHideOp::startOperation()
       anUpdateFlags |= UF_FitAll;
   }
 
-  aModule->getOCCDisplayer()->SetToUpdateColorScale(); //@MZN
-
   // Set VTK viewer active if show a bathymetry
   if ( aVTKMgr )
   {