Salome HOME
Copyright update 2022
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI_SalomeViewer.cpp
index f116db2333d94f09e03568feb2945f5f11c8d614..1f4fb0712b7e1a0fef205b67682f866c7d1c6d76 100644 (file)
@@ -1,28 +1,52 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-#include "NewGeom_SalomeViewer.h"
-#include "NewGeom_OCCSelector.h"
+// Copyright (C) 2014-2022  CEA/DEN, 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 "SHAPERGUI_SalomeViewer.h"
+#include "SHAPERGUI_OCCSelector.h"
 
 #include <OCCViewer_ViewPort3d.h>
 #include <OCCViewer_ViewFrame.h>
-
+#include <SOCC_ViewModel.h>
 #include <SUIT_ViewManager.h>
 
 #include <QtxActionToolMgr.h>
+#include <SALOME_AISShape.hxx>
 
+#include <Standard_Version.hxx>
 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 
 #include <QMouseEvent>
 #include <QContextMenuEvent>
+#include <QTimer>
+
+#if OCC_VERSION_HEX < 0x070400
+  #define SALOME_PATCH_FOR_CTRL_WHEEL
+#endif
 
-NewGeom_SalomeView::NewGeom_SalomeView(OCCViewer_Viewer* theViewer)
+SHAPERGUI_SalomeView::SHAPERGUI_SalomeView(OCCViewer_Viewer* theViewer)
 : ModuleBase_IViewWindow(), myCurrentView(0)
 {
   myViewer = theViewer;
 }
 
 
-Handle(V3d_View) NewGeom_SalomeView::v3dView() const
+Handle(V3d_View) SHAPERGUI_SalomeView::v3dView() const
 {
   Handle(V3d_View) aView;
   if (myCurrentView) {
@@ -32,7 +56,7 @@ Handle(V3d_View) NewGeom_SalomeView::v3dView() const
   return aView;
 }
 
-QWidget* NewGeom_SalomeView::viewPort() const
+QWidget* SHAPERGUI_SalomeView::viewPort() const
 {
   QWidget* aViewPort = 0;
   if (myCurrentView) {
@@ -48,13 +72,13 @@ QWidget* NewGeom_SalomeView::viewPort() const
 
 
 
-NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent)
+SHAPERGUI_SalomeViewer::SHAPERGUI_SalomeViewer(QObject* theParent)
     : ModuleBase_IViewer(theParent),
       mySelector(0), myView(0), myIsSelectionChanged(false)
 {
 }
 
-NewGeom_SalomeViewer::~NewGeom_SalomeViewer()
+SHAPERGUI_SalomeViewer::~SHAPERGUI_SalomeViewer()
 {
   if (myView)
     delete myView;
@@ -62,7 +86,7 @@ NewGeom_SalomeViewer::~NewGeom_SalomeViewer()
 
 
 //**********************************************
-Handle(AIS_InteractiveContext) NewGeom_SalomeViewer::AISContext() const
+Handle(AIS_InteractiveContext) SHAPERGUI_SalomeViewer::AISContext() const
 {
   if (mySelector && mySelector->viewer())
     return mySelector->viewer()->getAISContext();
@@ -71,7 +95,7 @@ Handle(AIS_InteractiveContext) NewGeom_SalomeViewer::AISContext() const
 }
 
 //**********************************************
-Handle(V3d_Viewer) NewGeom_SalomeViewer::v3dViewer() const
+Handle(V3d_Viewer) SHAPERGUI_SalomeViewer::v3dViewer() const
 {
   if (mySelector)
     return mySelector->viewer()->getViewer3d();
@@ -79,13 +103,13 @@ Handle(V3d_Viewer) NewGeom_SalomeViewer::v3dViewer() const
 }
 
 //**********************************************
-Handle(AIS_Trihedron) NewGeom_SalomeViewer::trihedron() const
+Handle(AIS_Trihedron) SHAPERGUI_SalomeViewer::trihedron() const
 {
   return mySelector->viewer()->getTrihedron();
 }
 
 //**********************************************
-Handle(V3d_View) NewGeom_SalomeViewer::activeView() const
+Handle(V3d_View) SHAPERGUI_SalomeViewer::activeView() const
 {
   if (mySelector) {
     OCCViewer_Viewer* aViewer = mySelector->viewer();
@@ -97,9 +121,9 @@ Handle(V3d_View) NewGeom_SalomeViewer::activeView() const
 }
 
 //**********************************************
-QWidget* NewGeom_SalomeViewer::activeViewPort() const
+QWidget* SHAPERGUI_SalomeViewer::activeViewPort() const
 {
-  QWidget* aViewPort;
+  QWidget* aViewPort = 0;
   if (mySelector) {
     OCCViewer_Viewer* aViewer = mySelector->viewer();
     SUIT_ViewManager* aMgr = aViewer->getViewManager();
@@ -110,7 +134,7 @@ QWidget* NewGeom_SalomeViewer::activeViewPort() const
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel)
+void SHAPERGUI_SalomeViewer::setSelector(SHAPERGUI_OCCSelector* theSel)
 {
   if (mySelector) {
     if (mySelector == theSel)
@@ -128,18 +152,18 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel)
   OCCViewer_Viewer* aViewer = mySelector->viewer();
   SUIT_ViewManager* aMgr = aViewer->getViewManager();
 
-  myView = new NewGeom_SalomeView(mySelector->viewer());
+  myView = new SHAPERGUI_SalomeView(mySelector->viewer());
 
   // TODO: Provide ModuleBase_IViewWindow interface
   connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), this, SIGNAL(lastViewClosed()));
 
-  connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewWindow*)), 
+  connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewWindow*)),
           this, SLOT(onTryCloseView(SUIT_ViewWindow*)));
-  connect(aMgr, SIGNAL(deleteView(SUIT_ViewWindow*)), 
+  connect(aMgr, SIGNAL(deleteView(SUIT_ViewWindow*)),
           this, SLOT(onDeleteView(SUIT_ViewWindow*)));
-  connect(aMgr, SIGNAL(viewCreated(SUIT_ViewWindow*)), 
+  connect(aMgr, SIGNAL(viewCreated(SUIT_ViewWindow*)),
           this, SLOT(onViewCreated(SUIT_ViewWindow*)));
-  connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)), 
+  connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)),
           this, SLOT(onActivated(SUIT_ViewManager*)));
 
   connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this,
@@ -160,21 +184,21 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel)
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onSelectionChanged()
+void SHAPERGUI_SalomeViewer::onSelectionChanged()
 {
   // Selection event must be sent only after mouse release
   myIsSelectionChanged = true;
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
+void SHAPERGUI_SalomeViewer::onMousePress(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
 {
   myView->setCurrentView(theView);
   emit mousePress(myView, theEvent);
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
+void SHAPERGUI_SalomeViewer::onMouseRelease(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
 {
   myView->setCurrentView(theView);
   emit mouseRelease(myView, theEvent);
@@ -185,21 +209,21 @@ void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow* theView, QMouseEvent*
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
+void SHAPERGUI_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
 {
   myView->setCurrentView(theView);
   emit mouseDoubleClick(myView, theEvent);
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
+void SHAPERGUI_SalomeViewer::onMouseMove(SUIT_ViewWindow* theView, QMouseEvent* theEvent)
 {
   myView->setCurrentView(theView);
   emit mouseMove(myView, theEvent);
 }
 
 //**********************************************
-bool NewGeom_SalomeViewer::canDragByMouse() const
+bool SHAPERGUI_SalomeViewer::canDragByMouse() const
 {
   OCCViewer_Viewer* aViewer = mySelector->viewer();
   SUIT_ViewWindow* aWnd = aViewer->getViewManager()->getActiveView();
@@ -212,25 +236,25 @@ bool NewGeom_SalomeViewer::canDragByMouse() const
 
 
 //**********************************************
-void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent)
+void SHAPERGUI_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent)
 {
   emit keyPress(myView, theEvent);
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onKeyRelease(SUIT_ViewWindow* theView, QKeyEvent* theEvent)
+void SHAPERGUI_SalomeViewer::onKeyRelease(SUIT_ViewWindow* theView, QKeyEvent* theEvent)
 {
   emit keyRelease(myView, theEvent);
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onTryCloseView(SUIT_ViewWindow*)
+void SHAPERGUI_SalomeViewer::onTryCloseView(SUIT_ViewWindow*)
 {
   emit tryCloseView(myView);
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
+void SHAPERGUI_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
 {
   if(myWindowScale.contains(myView->v3dView()))
     myWindowScale.remove(myView->v3dView());
@@ -238,7 +262,7 @@ void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView)
+void SHAPERGUI_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView)
 {
   myView->setCurrentView(theView);
 
@@ -254,22 +278,31 @@ void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView)
   }
   reconnectActions(aWnd, true);
 
-  myWindowScale.insert (aView->getViewPort()->getView(), aView->getViewPort()->getView()->Camera()->Scale());
+  myWindowScale.insert(aView->getViewPort()->getView(),
+                       aView->getViewPort()->getView()->Camera()->Scale());
 
-  emit viewCreated(myView);
+  QTimer::singleShot(10, this, SLOT(onAfterViewCreated()));
 
+  emit viewCreated(myView);
+}
 
+//**********************************************
+void SHAPERGUI_SalomeViewer::onAfterViewCreated()
+{
+  // Update trihedron and dimension arrows
+  emit onViewTransformed(OCCViewer_ViewWindow::ZOOMVIEW);
 }
 
+
 //**********************************************
-void NewGeom_SalomeViewer::onActivated(SUIT_ViewManager* theMgr)
+void SHAPERGUI_SalomeViewer::onActivated(SUIT_ViewManager* theMgr)
 {
   myView->setCurrentView(theMgr->getActiveView());
   emit activated(myView);
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
+void SHAPERGUI_SalomeViewer::enableSelection(bool isEnabled)
 {
   if (mySelector)
     if (mySelector->viewer()->isSelectionEnabled() != isEnabled)
@@ -281,7 +314,7 @@ void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
 }
 
 //**********************************************
-bool NewGeom_SalomeViewer::isSelectionEnabled() const
+bool SHAPERGUI_SalomeViewer::isSelectionEnabled() const
 {
   if (mySelector)
     return mySelector->viewer()->isSelectionEnabled();
@@ -289,14 +322,14 @@ bool NewGeom_SalomeViewer::isSelectionEnabled() const
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::enableMultiselection(bool isEnable)
+void SHAPERGUI_SalomeViewer::enableMultiselection(bool isEnable)
 {
   if (mySelector)
     mySelector->viewer()->enableMultiselection(isEnable);
 }
 
 //**********************************************
-bool NewGeom_SalomeViewer::isMultiSelectionEnabled() const
+bool SHAPERGUI_SalomeViewer::isMultiSelectionEnabled() const
 {
   if (mySelector)
     return mySelector->viewer()->isMultiSelectionEnabled();
@@ -304,7 +337,7 @@ bool NewGeom_SalomeViewer::isMultiSelectionEnabled() const
 }
 
 //**********************************************
-bool NewGeom_SalomeViewer::enableDrawMode(bool isEnabled)
+bool SHAPERGUI_SalomeViewer::enableDrawMode(bool isEnabled)
 {
   // TODO: Has to be replaced when SALOME patch become available
   if (mySelector)
@@ -313,8 +346,8 @@ bool NewGeom_SalomeViewer::enableDrawMode(bool isEnabled)
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::reconnectActions(SUIT_ViewWindow* theWindow,
-                                            const bool theUseNewGeomSlot)
+void SHAPERGUI_SalomeViewer::reconnectActions(SUIT_ViewWindow* theWindow,
+                                            const bool theUseSHAPERSlot)
 {
   OCCViewer_ViewWindow* aWindow = dynamic_cast<OCCViewer_ViewWindow*>(theWindow);
   if (!aWindow)
@@ -324,7 +357,7 @@ void NewGeom_SalomeViewer::reconnectActions(SUIT_ViewWindow* theWindow,
   if (!anAction)
     return;
 
-  if (theUseNewGeomSlot) {
+  if (theUseSHAPERSlot) {
     anAction->disconnect(anAction, SIGNAL(toggled(bool)),
                          theWindow, SLOT(onTrihedronShow(bool)));
     anAction->connect(anAction, SIGNAL(toggled(bool)),
@@ -339,7 +372,7 @@ void NewGeom_SalomeViewer::reconnectActions(SUIT_ViewWindow* theWindow,
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::fitAll()
+void SHAPERGUI_SalomeViewer::fitAll()
 {
   if (mySelector) {
     SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
@@ -351,9 +384,29 @@ void NewGeom_SalomeViewer::fitAll()
 }
 
 //**********************************************
-void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double theZ, double theTwist)
+void SHAPERGUI_SalomeViewer::eraseAll()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (aContext.IsNull())
+    return;
+  AIS_ListOfInteractive aList;
+  aContext->DisplayedObjects(aList);
+  AIS_ListIteratorOfListOfInteractive aLIt;
+  Handle(AIS_InteractiveObject) anAISIO;
+  for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) {
+    anAISIO = aLIt.Value();
+    Handle(Standard_Type) aType = anAISIO->DynamicType();
+    if (anAISIO->IsKind(STANDARD_TYPE(SALOME_AISShape))) {
+      aContext->Erase(anAISIO, false);
+    }
+  }
+}
+
+//**********************************************
+void SHAPERGUI_SalomeViewer::setViewProjection(double theX, double theY,
+                                               double theZ, double theTwist)
 {
-  if (!mySelector) 
+  if (!mySelector)
     return;
 
   SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
@@ -364,7 +417,7 @@ void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double th
       aView3d->SetProj(theX, theY, theZ);
       aView3d->SetTwist( theTwist );
       aView3d->FitAll(0.01, false);
-      aView3d->SetZSize(0.);
+      //aView3d->SetZSize(0.);
       if (aView3d->Depth() < 0.1)
         aView3d->DepthFitAll();
     }
@@ -372,7 +425,7 @@ void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double th
 }
 
 //***************************************
-void NewGeom_SalomeViewer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
+void SHAPERGUI_SalomeViewer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!aContext.IsNull()) {
@@ -381,7 +434,7 @@ void NewGeom_SalomeViewer::addSelectionFilter(const Handle(SelectMgr_Filter)& th
 }
 
 //***************************************
-void NewGeom_SalomeViewer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
+void SHAPERGUI_SalomeViewer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!aContext.IsNull()) {
@@ -390,7 +443,7 @@ void NewGeom_SalomeViewer::removeSelectionFilter(const Handle(SelectMgr_Filter)&
 }
 
 //***************************************
-bool NewGeom_SalomeViewer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
+bool SHAPERGUI_SalomeViewer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
 {
   bool aFoundFilter = false;
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -398,14 +451,14 @@ bool NewGeom_SalomeViewer::hasSelectionFilter(const Handle(SelectMgr_Filter)& th
     const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
     SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
     for (; aIt.More() && !aFoundFilter; aIt.Next()) {
-      aFoundFilter = theFilter.Access() == aIt.Value().Access();
+      aFoundFilter = theFilter.get() == aIt.Value().get();
     }
   }
   return aFoundFilter;
 }
 
 //***************************************
-void NewGeom_SalomeViewer::clearSelectionFilters()
+void SHAPERGUI_SalomeViewer::clearSelectionFilters()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!aContext.IsNull()) {
@@ -414,7 +467,7 @@ void NewGeom_SalomeViewer::clearSelectionFilters()
 }
 
 //***************************************
-void NewGeom_SalomeViewer::update()
+void SHAPERGUI_SalomeViewer::update()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!aContext.IsNull()) {
@@ -423,23 +476,28 @@ void NewGeom_SalomeViewer::update()
 }
 
 //***************************************
-void NewGeom_SalomeViewer::onViewTransformed(OCCViewer_ViewWindow::OperationType theType)
+void SHAPERGUI_SalomeViewer::onViewTransformed(OCCViewer_ViewWindow::OperationType theType)
 {
   emit viewTransformed((int) theType);
 }
 
 //***************************************
-void NewGeom_SalomeViewer::onViewPortMapped()
+void SHAPERGUI_SalomeViewer::onViewPortMapped()
 {
   emit trihedronVisibilityChanged(true);
 }
 
 //***************************************
-void NewGeom_SalomeViewer::activateViewer(bool toActivate)
+void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate)
 {
   if (!mySelector || !mySelector->viewer())
     return;
   SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
+#ifdef SALOME_PATCH_FOR_CTRL_WHEEL
+  OCCViewer_Viewer* aViewer = dynamic_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
+  if (aViewer)
+    aViewer->setUseLocalSelection(toActivate);
+#endif
   QVector<SUIT_ViewWindow*> aViews = aMgr->getViews();
   if (toActivate) {
     foreach (SUIT_ViewWindow* aView, aViews) {
@@ -453,24 +511,112 @@ void NewGeom_SalomeViewer::activateViewer(bool toActivate)
     foreach (SUIT_ViewWindow* aView, aViews) {
       OCCViewer_ViewFrame* aOCCView = dynamic_cast<OCCViewer_ViewFrame*>(aView);
       OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
-      disconnect((OCCViewer_ViewWindow*)aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
+      disconnect((OCCViewer_ViewWindow*)aWnd,
+                 SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
         this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
       reconnectActions(aWnd, false);
     }
   }
 }
 
-void NewGeom_SalomeViewer::Zfitall()
+bool SHAPERGUI_SalomeViewer::isColorScaleVisible() const
 {
-  if (!mySelector || !mySelector->viewer())
-    return;
-  SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
-  OCCViewer_ViewFrame* aView = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
-  if (aView) {
-    OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
-    Handle(V3d_View) aView3d = aWnd->getViewPort()->getView();
-    aView3d->ZFitAll();
-    if (aView3d->Depth() < 0.1)
-      aView3d->DepthFitAll();
+  if (mySelector) {
+    return mySelector->viewer()->isColorScaleVisible();
+  }
+  return false;
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleShown(bool on)
+{
+  if (mySelector) {
+    mySelector->viewer()->setColorScaleShown(on);
+  }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScalePosition(double theX, double theY)
+{
+  if (mySelector) {
+    QWidget* aWindow = activeViewPort();
+    mySelector->viewer()->getColorScale()->SetPosition(aWindow->width() * theX,
+      aWindow->height() * theY);
+  }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleSize(double theW, double theH)
+{
+  if (mySelector) {
+    QWidget* aWindow = activeViewPort();
+    mySelector->viewer()->getColorScale()->SetSize(aWindow->width() * theW,
+      aWindow->height() * theH);
+  }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleRange(double theMin, double theMax)
+{
+  if (mySelector) {
+    mySelector->viewer()->getColorScale()->SetRange(theMin, theMax);
+  }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleIntervals(int theNb)
+{
+  if (mySelector) {
+    mySelector->viewer()->getColorScale()->SetNumberOfIntervals(theNb);
+  }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleTextHeigth(int theH)
+{
+  if (mySelector) {
+    mySelector->viewer()->getColorScale()->SetTextHeight(theH);
   }
-}
\ No newline at end of file
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleTextColor(const QColor& theColor)
+{
+  if (mySelector) {
+    Quantity_Color aColor(theColor.redF(), theColor.greenF(), theColor.blueF(), Quantity_TOC_RGB);
+    mySelector->viewer()->getColorScale()->SetColor(aColor);
+  }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleTitle(const QString& theText)
+{
+  if (mySelector) {
+    mySelector->viewer()->getColorScale()->SetTitle(theText.toStdString().c_str());
+  }
+}
+
+void SHAPERGUI_SalomeViewer::setFitter(OCCViewer_Fitter* theFitter)
+{
+  if (mySelector)
+    mySelector->viewer()->setFitter(theFitter);
+}
+
+OCCViewer_Fitter* SHAPERGUI_SalomeViewer::fitter() const
+{
+  if (mySelector)
+    return mySelector->viewer()->fitter();
+  return 0;
+}
+
+
+//void SHAPERGUI_SalomeViewer::Zfitall()
+//{
+//  if (!mySelector || !mySelector->viewer())
+//    return;
+//  SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
+//  /// WORKAROUND for issue #1798. SUIT_ViewManager::closeAllViews() should nullify myActiveView
+//  /// As a result, we need to check views count in manager
+//  if (aMgr->getViews().size() > 0) {
+//    OCCViewer_ViewFrame* aView = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
+//    if (aView) {
+//      OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
+//      Handle(V3d_View) aView3d = aWnd->getViewPort()->getView();
+//      aView3d->ZFitAll();
+//      if (aView3d->Depth() < 0.1)
+//        aView3d->DepthFitAll();
+//    }
+//  }
+//}
\ No newline at end of file