Salome HOME
0023450: Fields are not displayed in GEOM
authorvsr <vsr@opencascade.com>
Thu, 28 Sep 2017 13:01:08 +0000 (16:01 +0300)
committervsr <vsr@opencascade.com>
Thu, 28 Sep 2017 13:01:08 +0000 (16:01 +0300)
- Make color scale a property of the OCC view model

src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h

index adb29592d77652fe62d14e538bf5123f2f0c6815..9de784810e69250fd77e09f0b2327e36216d7cd9 100644 (file)
@@ -125,6 +125,11 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
   
   // display isoline on planar faces (box for ex.)
   myAISContext->IsoOnPlane( true );
+
+  // create color scale
+  myColorScale = new AIS_ColorScale();
+  myColorScale->SetZLayer( Graphic3d_ZLayerId_TopOSD );
+  myColorScale->SetTransformPersistence( Graphic3d_TransformPers::FromDeprecatedParams( Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0) ) );
   
   /* create trihedron */
   if ( DisplayTrihedron )
@@ -1229,6 +1234,28 @@ void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj
     myV3dViewer->Update();
 }
 
+bool OCCViewer_Viewer::isColorScaleVisible() const
+{
+  return !myColorScale.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myColorScale );
+}
+
+void OCCViewer_Viewer::setColorScaleShown( const bool on )
+{
+  if ( myColorScale.IsNull() )
+    return;
+  if ( on )
+  {
+    if ( !myAISContext->IsDisplayed( myColorScale ) )
+      myAISContext->Display( myColorScale, Standard_True );
+    myAISContext->Redisplay( myColorScale, Standard_True, Standard_True );
+  }
+  else
+  {
+    if ( myAISContext->IsDisplayed( myColorScale ) )
+      myAISContext->Erase( myColorScale, Standard_True );
+  }
+}
+
 /*!
   Changes visibility of trihedron to opposite
 */
index 329bb05bd9702c905daf3c8f9859078771af65a2..6e80da203a4445d60673929e59faf2369306c6e0 100755 (executable)
@@ -34,6 +34,7 @@
 #include "SUIT_ViewModel.h"
 
 #include <V3d_View.hxx>
+#include <AIS_ColorScale.hxx>
 #include <AIS_Trihedron.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_ListOfInteractive.hxx>
@@ -111,6 +112,9 @@ public:
   Qtx::BackgroundData             background(int theViewId) const;
   void                            setBackground( int theViewId, const Qtx::BackgroundData& );
 
+  bool                            isColorScaleVisible() const;
+  virtual void                    setColorScaleShown( const bool );
+
   //! returns true if 3d Trihedron in viewer was created
   bool                            trihedronActivated() const { return !myTrihedron.IsNull(); }
 
@@ -138,6 +142,7 @@ public:
 public:
   Handle(V3d_Viewer)              getViewer3d()    const { return myV3dViewer;}
   Handle(AIS_InteractiveContext)  getAISContext()  const { return myAISContext; }
+  Handle(AIS_ColorScale)          getColorScale()  const { return myColorScale; }
   Handle(AIS_Trihedron)           getTrihedron()   const { return myTrihedron; }
 
   int                             getTopLayerId();
@@ -240,7 +245,7 @@ protected slots:
 protected:
 
   Handle(V3d_Viewer)              myV3dViewer;
-
+  Handle(AIS_ColorScale)          myColorScale;
   Handle(AIS_Trihedron)           myTrihedron;
   Handle(AIS_InteractiveContext)  myAISContext;