Salome HOME
Provide color scale for SALOME SHAPER module
authorvsv <vsv@opencascade.com>
Thu, 27 Jun 2019 13:11:03 +0000 (16:11 +0300)
committervsv <vsv@opencascade.com>
Thu, 27 Jun 2019 13:11:03 +0000 (16:11 +0300)
src/ModuleBase/ModuleBase_IViewer.h
src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp
src/SHAPERGUI/SHAPERGUI_SalomeViewer.h
src/XGUI/XGUI_ViewerProxy.cpp

index f079bd4d93bf33ec1d50f7d58033ea69a0b67acc..e264f5cb4cb53a953607e37be87a58ba8f96ec6b 100644 (file)
@@ -142,6 +142,41 @@ Q_OBJECT
     return myIs2dMode;
   }
 
+  // Methods for color scale management
+
+  //! Returns True if ColorScale is visible
+  virtual bool isColorScaleVisible() const = 0;
+
+  //! Show/Hide ColorScale object
+  virtual void setColorScaleShown(bool on) = 0;
+
+  //! Set position of color scale
+  // \param theX is X position relative to current view width
+  // \param theY is Y position relative to current view heigth
+  virtual void setColorScalePosition(double theX, double theY) = 0;
+
+  //! Set size of color scale
+  // \param theW is width relative to current view width
+  // \param theh is height relative to current view heigth
+  virtual void setColorScaleSize(double theW, double theH) = 0;
+
+  //! Set range of color scale
+  // \param theMin is a minimal value
+  // \param theMax is a maximal value
+  virtual void setColorScaleRange(double theMin, double theMax) = 0;
+
+  //! Set number of intervals of color scale
+  // \param theNb is number of intervals
+  virtual void setColorScaleIntervals(int theNb) = 0;
+
+  //! Set text heigth of color scale
+  // \param theH is number of intervals
+  virtual void setColorScaleTextHeigth(int theH) = 0;
+
+  //! Set title of color scale
+  // \param theText is a title
+  virtual void setColorScaleTitle(const QString& theText) = 0;
+
   static Handle(Prs3d_Drawer) DefaultHighlightDrawer;
 
 signals:
index 467f6a9b6f1fc5a41e40995823dc811cb43242d4..aa417a4622f585eb0de4663b7ce0dba1fdc309d4 100644 (file)
@@ -507,6 +507,69 @@ void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate)
   }
 }
 
+bool SHAPERGUI_SalomeViewer::isColorScaleVisible() const
+{
+  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);
+  }
+}
+
+void SHAPERGUI_SalomeViewer::setColorScaleTitle(const QString& theText)
+{
+  if (mySelector) {
+    mySelector->viewer()->getColorScale()->SetTitle(theText.toStdString().c_str());
+  }
+}
+
+
+
 //void SHAPERGUI_SalomeViewer::Zfitall()
 //{
 //  if (!mySelector || !mySelector->viewer())
index 6e9129bc158f34c9c2e4fcfb5fda2e82d77cbced..2b6b88792c59540c5b0af47408584186639fd51e 100644 (file)
@@ -168,6 +168,42 @@ Q_OBJECT
   /// \param toActivate - activation flag
   void activateViewer(bool toActivate);
 
+
+  // Methods for color scale management
+
+  //! Returns True if ColorScale is visible
+  virtual bool isColorScaleVisible() const;
+
+  //! Show/Hide ColorScale object
+  virtual void setColorScaleShown(bool on);
+
+  //! Set position of color scale
+  // \param theX is X position relative to current view width
+  // \param theY is Y position relative to current view heigth
+  virtual void setColorScalePosition(double theX, double theY);
+
+  //! Set size of color scale
+  // \param theW is width relative to current view width
+  // \param theh is height relative to current view heigth
+  virtual void setColorScaleSize(double theW, double theH);
+
+  //! Set range of color scale
+  // \param theMin is a minimal value
+  // \param theMax is a maximal value
+  virtual void setColorScaleRange(double theMin, double theMax);
+
+  //! Set number of intervals of color scale
+  // \param theNb is number of intervals
+  virtual void setColorScaleIntervals(int theNb);
+
+  //! Set text heigth of color scale
+  // \param theH is number of intervals
+  virtual void setColorScaleTextHeigth(int theH);
+
+  //! Set title of color scale
+  // \param theText is a title
+  virtual void setColorScaleTitle(const QString& theText);
+
   // Fit all along Z (perpendicular to display)
   //virtual void Zfitall();
 
index 753a07d9870d4d9235e4d7890d9308ab6db427db..ea1b76807110ded9c9ffeab7df3760cac5f9730b 100644 (file)
@@ -580,10 +580,10 @@ void XGUI_ViewerProxy::setColorScaleShown(bool on)
 
 void XGUI_ViewerProxy::setColorScalePosition(double theX, double theY)
 {
-  QWidget* aWindow = activeViewPort();
 #ifdef HAVE_SALOME
-  myWorkshop->salomeConnector()->viewer()->setColorScaleShown(on);
+  myWorkshop->salomeConnector()->viewer()->setColorScalePosition(theX, theY);
 #else
+  QWidget* aWindow = activeViewPort();
   Handle(AIS_ColorScale) aColorScale = myWorkshop->mainWindow()->viewer()->colorScale();
   aColorScale->SetPosition(aWindow->width() * theX, aWindow->height() * theY);
 #endif
@@ -591,10 +591,10 @@ void XGUI_ViewerProxy::setColorScalePosition(double theX, double theY)
 
 void XGUI_ViewerProxy::setColorScaleSize(double theW, double theH)
 {
-  QWidget* aWindow = activeViewPort();
 #ifdef HAVE_SALOME
-  myWorkshop->salomeConnector()->viewer()->setColorScaleShown(on);
+  myWorkshop->salomeConnector()->viewer()->setColorScaleSize(theW, theH);
 #else
+  QWidget* aWindow = activeViewPort();
   Handle(AIS_ColorScale) aColorScale = myWorkshop->mainWindow()->viewer()->colorScale();
   aColorScale->SetSize(aWindow->width() * theW, aWindow->height() * theH);
 #endif
@@ -603,7 +603,7 @@ void XGUI_ViewerProxy::setColorScaleSize(double theW, double theH)
 void XGUI_ViewerProxy::setColorScaleRange(double theMin, double theMax)
 {
 #ifdef HAVE_SALOME
-  myWorkshop->salomeConnector()->viewer()->setColorScaleShown(on);
+  myWorkshop->salomeConnector()->viewer()->setColorScaleRange(theMin, theMax);
 #else
   Handle(AIS_ColorScale) aColorScale = myWorkshop->mainWindow()->viewer()->colorScale();
   aColorScale->SetRange(theMin, theMax);
@@ -613,7 +613,7 @@ void XGUI_ViewerProxy::setColorScaleRange(double theMin, double theMax)
 void XGUI_ViewerProxy::setColorScaleIntervals(int theNb)
 {
 #ifdef HAVE_SALOME
-  myWorkshop->salomeConnector()->viewer()->setColorScaleShown(on);
+  myWorkshop->salomeConnector()->viewer()->setColorScaleIntervals(theNb);
 #else
   Handle(AIS_ColorScale) aColorScale = myWorkshop->mainWindow()->viewer()->colorScale();
   aColorScale->SetNumberOfIntervals(theNb);
@@ -623,7 +623,7 @@ void XGUI_ViewerProxy::setColorScaleIntervals(int theNb)
 void XGUI_ViewerProxy::setColorScaleTextHeigth(int theH)
 {
 #ifdef HAVE_SALOME
-  myWorkshop->salomeConnector()->viewer()->setColorScaleShown(on);
+  myWorkshop->salomeConnector()->viewer()->setColorScaleTextHeigth(theH);
 #else
   Handle(AIS_ColorScale) aColorScale = myWorkshop->mainWindow()->viewer()->colorScale();
   aColorScale->SetTextHeight(theH);
@@ -633,7 +633,7 @@ void XGUI_ViewerProxy::setColorScaleTextHeigth(int theH)
 void XGUI_ViewerProxy::setColorScaleTitle(const QString& theText)
 {
 #ifdef HAVE_SALOME
-  myWorkshop->salomeConnector()->viewer()->setColorScaleShown(on);
+  myWorkshop->salomeConnector()->viewer()->setColorScaleTitle(theText);
 #else
   Handle(AIS_ColorScale) aColorScale = myWorkshop->mainWindow()->viewer()->colorScale();
   aColorScale->SetTitle(theText.toStdString().c_str());
@@ -648,7 +648,6 @@ void XGUI_ViewerProxy::setupColorScale()
   setColorScaleSize(0.2, 0.5);
   setColorScaleTextHeigth(14);
   setColorScaleIntervals(20);
-  Handle(AIS_ColorScale) aColorScale = myWorkshop->mainWindow()->viewer()->colorScale();
 }