Salome HOME
updated copyright message
[modules/gui.git] / src / SVTK / SVTK_ViewModel.cxx
index f49b3ebd1921ecf54ed5c7a2c27687275c6404a6..998464b940c1e7f49f92341277d4613578c17379 100644 (file)
@@ -1,40 +1,43 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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.
+// 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include <QMenu>
 #include <QColorDialog>
 #include <QToolBar>
+#include <QTimer>
 
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
 #include <vtkActorCollection.h>
 
 //#include "SUIT_Session.h"
-#include "SVTK_Selection.h"
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewWindow.h"
 #include "SVTK_View.h"
+#include "SVTK_Renderer.h"
 //#include "SVTK_MainWindow.h"
 #include "SVTK_Prs.h"
 
+#include "VTKViewer_Algorithm.h"
 #include "VTKViewer_ViewModel.h"
 
 #include "SUIT_ViewModel.h"
 
 #include "SALOME_Actor.h"
 
-#include <QtxActionToolMgr.h>
-
-// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
-// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from 
-// SALOMEDS::StudyManager - no linkage with SalomeApp. 
-
-// Temporarily commented to avoid awful dependecy on SALOMEDS
-// TODO: better mechanism of storing display/erse status in a study
-// should be provided...
-//static _PTR(Study) getStudyDS() 
-//{
-//  SALOMEDSClient_Study* aStudy = NULL;
-//  _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
-  // get id of SUIT_Study, if it's a SalomeApp_Study, it will return
-  //    id of its underlying SALOMEDS::Study
-//  SUIT_Application* app = SUIT_Session::session()->activeApplication();
-//  if ( !app )  return _PTR(Study)(aStudy); 
-//  SUIT_Study* stud = app->activeStudy();
-//  if ( !stud ) return _PTR(Study)(aStudy);  
-//  const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
-  // get SALOMEDS_Study with this id from StudyMgr
-//  return aMgr->GetStudyByID( id );
-//}
+#include "QtxActionToolMgr.h"
+#include "QtxBackgroundTool.h"
+
+// VSR: Uncomment below line to allow texture background support in VTK viewer
+#define VTK_ENABLE_TEXTURED_BACKGROUND
 
 /*!
   Constructor
@@ -73,13 +58,21 @@ SVTK_Viewer::SVTK_Viewer()
 {
   myTrihedronSize = 105;
   myTrihedronRelative = true;
+  myIsStaticTrihedronVisible = true;
   myIncrementSpeed = 10;
   myIncrementMode = 0;
   myProjMode = 0;
+  myStereoType = 0;
+  myAnaglyphFilter = 0;
   myStyle = 0;
+  myZoomingStyle = 0;
+  mySelectionEnabled = true;
+  myPreSelectionMode = Standard_Preselection;
   mySpaceBtn[0] = 1;
   mySpaceBtn[1] = 2;
   mySpaceBtn[2] = 9;
+  myDefaultBackground = Qtx::BackgroundData( Qt::black );
+  myQuadBufferSupport = false;
 }
 
 /*!
@@ -89,33 +82,83 @@ SVTK_Viewer::~SVTK_Viewer()
 {
 }
 
-/*!
-  \return background color
-*/
+/*! Get data for supported background modes: gradient types, identifiers and supported image formats */
+QString SVTK_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList )
+{
+  gradList << tr( "GT_HORIZONTALGRADIENT" )
+           << tr( "GT_VERTICALGRADIENT" )
+           << tr( "GT_FIRSTDIAGONALGRADIENT" )
+           << tr( "GT_SECONDDIAGONALGRADIENT" )
+           << tr( "GT_FIRSTCORNERGRADIENT" )
+           << tr( "GT_SECONDCORNERGRADIENT" )
+           << tr( "GT_THIRDCORNERGRADIENT" )
+           << tr( "GT_FOURTHCORNERGRADIENT" );
+  idList   << HorizontalGradient
+           << VerticalGradient
+           << FirstDiagonalGradient
+           << SecondDiagonalGradient
+           << FirstCornerGradient
+           << SecondCornerGradient
+           << ThirdCornerGradient
+           << FourthCornerGradient;
+#ifdef VTK_ENABLE_TEXTURED_BACKGROUND
+  txtList  << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
+#endif
+  return tr("BG_IMAGE_FILES");
+}
+
+/*! Get data for supported background modes: gradient types, identifiers and supported image formats */
+void SVTK_Viewer::stereoData( QStringList& typeList, QIntList& idList )
+{
+  typeList << tr("ST_CRYSTALEYES") << tr("ST_REDBLUE")      <<
+              tr("ST_INTERLACED")  << tr("ST_LEFT")         <<
+              tr("ST_RIGHT")       << tr("ST_DRESDEN")      <<
+              tr("ST_ANAGLYPH")    << tr("ST_CHECKERBOARD") <<
+              tr("ST_SPLITVIEWPORTHORIZONTAL");
+  idList   << CrystalEyesType << RedBlueType      <<
+              InterlacedType  << LeftType         <<
+              RightType       << DresdenType      <<
+              AnaglyphType    << CheckerboardType <<
+              SplitViewPortHorizontalType;
+}
+
+//! Get background color of the viewer [obsolete]
 QColor SVTK_Viewer::backgroundColor() const
 {
-  return myBgColor;
+  return background().color();
+}
+
+//! Set background color to the viewer [obsolete]
+void SVTK_Viewer::setBackgroundColor( const QColor& c )
+{
+  Qtx::BackgroundData bg = background();
+  bg.setColor( c );
+  setBackground( bg );
 }
 
 /*!
-  Changes background color
-  \param theColor - new background color
+  \return background data
 */
-void SVTK_Viewer::setBackgroundColor( const QColor& theColor )
+Qtx::BackgroundData SVTK_Viewer::background() const
 {
-  if ( !theColor.isValid() )
-    return;
+  return myDefaultBackground;
+}
 
+/*!
+  Changes background
+  \param theBackground - new background data
+*/
+void SVTK_Viewer::setBackground( const Qtx::BackgroundData& theBackground )
+{
+  myDefaultBackground = theBackground.isValid() ? theBackground : Qtx::BackgroundData( Qt::black );
   QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
   for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
     if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
       if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViewWindow)){
-       aView->setBackgroundColor(theColor);
+        aView->setBackground(myDefaultBackground);
       }
     }
-  }
-
-  myBgColor = theColor;
+  }  
 }
 
 /*!Create new instance of view window on desktop \a theDesktop.
@@ -126,25 +169,32 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop )
   TViewWindow* aViewWindow = new TViewWindow(theDesktop);
   aViewWindow->Initialize(this);
 
-  aViewWindow->setBackgroundColor( backgroundColor() );
+  aViewWindow->setBackground( background() );
   aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() );
+  aViewWindow->SetStaticTrihedronVisible( isStaticTrihedronVisible() );
   aViewWindow->SetProjectionMode( projectionMode() );
+  aViewWindow->SetStereoType( stereoType() );
+  aViewWindow->SetAnaglyphFilter( anaglyphFilter() );
+  aViewWindow->SetQuadBufferSupport( isQuadBufferSupport() );
   aViewWindow->SetInteractionStyle( interactionStyle() );
+  aViewWindow->SetZoomingStyle( zoomingStyle() );
+  aViewWindow->SetPreSelectionMode( preSelectionMode() );
+  aViewWindow->SetSelectionEnabled( isSelectionEnabled() );
   aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() );
   aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) );
 
   connect(aViewWindow, SIGNAL( actorAdded(VTKViewer_Actor*) ), 
-         this,  SLOT(onActorAdded(VTKViewer_Actor*)));
+          this,  SLOT(onActorAdded(VTKViewer_Actor*)));
   connect(aViewWindow, SIGNAL( actorRemoved(VTKViewer_Actor*) ), 
-         this,  SLOT(onActorRemoved(VTKViewer_Actor*)));
-
+          this,  SLOT(onActorRemoved(VTKViewer_Actor*)));
+  
   return aViewWindow;
 }
 
 /*!
   \return trihedron size
 */
-vtkFloatingPointType SVTK_Viewer::trihedronSize() const
+double SVTK_Viewer::trihedronSize() const
 {
   return myTrihedronSize;
 }
@@ -162,21 +212,46 @@ bool SVTK_Viewer::trihedronRelative() const
   \param theSize - new size
   \param theRelative - new relativeness
 */
-void SVTK_Viewer::setTrihedronSize( const vtkFloatingPointType theSize, const bool theRelative )
+void SVTK_Viewer::setTrihedronSize( const double theSize, const bool theRelative )
 {
   myTrihedronSize = theSize;
   myTrihedronRelative = theRelative;
 
   if (SUIT_ViewManager* aViewManager = getViewManager()) {
     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
-    for ( uint i = 0; i < aViews.count(); i++ )
+    for ( int i = 0; i < aViews.count(); i++ )
     {
       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
-             aView->SetTrihedronSize( theSize, theRelative );
+              aView->SetTrihedronSize( theSize, theRelative );
     }
   }
 }
 
+/*!
+  \return visibility status of the static trihedron
+*/
+bool SVTK_Viewer::isStaticTrihedronVisible() const
+{
+  return myIsStaticTrihedronVisible;
+}
+
+/*!
+  Sets visibility status of the static trihedron
+  \param theIsVisible - new visibility status
+*/
+void SVTK_Viewer::setStaticTrihedronVisible( const bool theIsVisible )
+{
+  myIsStaticTrihedronVisible = theIsVisible;
+
+  if (SUIT_ViewManager* aViewManager = getViewManager()) {
+    QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+    for ( int i = 0; i < aViews.count(); i++ )
+    {
+      if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+        aView->SetStaticTrihedronVisible( theIsVisible );
+    }
+  }
+}
 
 /*!
   \return projection mode
@@ -194,19 +269,102 @@ int SVTK_Viewer::projectionMode() const
 void SVTK_Viewer::setProjectionMode( const int theMode )
 {
   if ( myProjMode != theMode ) {
-    myProjMode = theMode;
+    if ( theMode != SVTK_ViewWindow::Stereo )
+      myProjMode = theMode;
+    if (SUIT_ViewManager* aViewManager = getViewManager()) {
+      QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+      for ( int i = 0; i < aViews.count(); i++ )
+      {
+        if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+          aView->SetProjectionMode( theMode );
+      }
+    }
+  }
+}
+
+/*!
+  \return stereo type
+*/
+int SVTK_Viewer::stereoType() const
+{
+  return myStereoType;
+}
+
+/*!
+  Sets stereo type
+  \param theType - new stereo type
+*/
+void SVTK_Viewer::setStereoType( const int theType )
+{
+  if ( myStereoType != theType ) {
+    myStereoType = theType;
+
+    if (SUIT_ViewManager* aViewManager = getViewManager()) {
+      QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+      for ( int i = 0; i < aViews.count(); i++ )
+      {
+        if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+          aView->SetStereoType( theType );
+      }
+    }
+  }
+}
+
+/*!
+  \return anaglyph filter
+*/
+int SVTK_Viewer::anaglyphFilter() const
+{
+  return myAnaglyphFilter;
+}
+
+/*!
+  Sets anaglyph filter
+  \param theFilter - new anaglyph filter
+*/
+void SVTK_Viewer::setAnaglyphFilter( const int theFilter )
+{
+  if ( myAnaglyphFilter != theFilter ) {
+         myAnaglyphFilter = theFilter;
 
     if (SUIT_ViewManager* aViewManager = getViewManager()) {
       QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
-      for ( uint i = 0; i < aViews.count(); i++ )
+      for ( int i = 0; i < aViews.count(); i++ )
       {
-       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
-         aView->SetProjectionMode( theMode );
+        if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+          aView->SetAnaglyphFilter( theFilter );
       }
     }
   }
 }
 
+/*!
+  \return support quad-buffered stereo
+*/
+bool SVTK_Viewer::isQuadBufferSupport() const
+{
+  return myQuadBufferSupport;
+}
+
+/*!
+  Set support quad-buffered stereo
+  \param theEnable - enable/disable support quad-buffered stereo
+*/
+void SVTK_Viewer::setQuadBufferSupport( const bool theEnable )
+{
+  if ( myQuadBufferSupport != theEnable ) {
+    myQuadBufferSupport = theEnable;
+
+    if (SUIT_ViewManager* aViewManager = getViewManager()) {
+      QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+      for ( int i = 0; i < aViews.count(); i++ )
+      {
+        if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+          aView->SetQuadBufferSupport( theEnable );
+      }
+    }
+  }
+}
 /*!
   \return interaction style
 */
@@ -225,10 +383,62 @@ void SVTK_Viewer::setInteractionStyle( const int theStyle )
   
   if (SUIT_ViewManager* aViewManager = getViewManager()) {
     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
-    for ( uint i = 0; i < aViews.count(); i++ )
+    for ( int i = 0; i < aViews.count(); i++ )
     {
       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
-       aView->SetInteractionStyle( theStyle );
+        aView->SetInteractionStyle( theStyle );
+    }
+  }
+}
+
+/*!
+  \return zooming style
+*/
+int SVTK_Viewer::zoomingStyle() const
+{
+  return myZoomingStyle;
+}
+
+/*!
+  Sets zooming style: 0 - standard, 1 - advanced (at cursor)
+  \param theStyle - new zooming style
+*/
+void SVTK_Viewer::setZoomingStyle( const int theStyle )
+{
+  myZoomingStyle = theStyle;
+  
+  if (SUIT_ViewManager* aViewManager = getViewManager()) {
+    QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+    for ( int i = 0; i < aViews.count(); i++ )
+    {
+      if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+        aView->SetZoomingStyle( theStyle );
+    }
+  }
+}
+
+/*!
+  \return current preselection mode
+*/
+Preselection_Mode SVTK_Viewer::preSelectionMode() const
+{
+  return myPreSelectionMode;
+}
+
+/*!
+  Sets preselection mode
+  \param theMode - new preselection mode
+*/
+void SVTK_Viewer::setPreSelectionMode( Preselection_Mode theMode )
+{
+  myPreSelectionMode = theMode;
+  
+  if (SUIT_ViewManager* aViewManager = getViewManager()) {
+    QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+    for ( int i = 0; i < aViews.count(); i++ )
+    {
+      if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+        aView->SetPreSelectionMode( theMode );
     }
   }
 }
@@ -261,10 +471,10 @@ void SVTK_Viewer::setIncrementalSpeed( const int theValue, const int theMode )
 
   if (SUIT_ViewManager* aViewManager = getViewManager()) {
     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
-    for ( uint i = 0; i < aViews.count(); i++ )
+    for ( int i = 0; i < aViews.count(); i++ )
     {
       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
-       aView->SetIncrementalSpeed( theValue, theMode );
+        aView->SetIncrementalSpeed( theValue, theMode );
     }
   }
 }
@@ -292,10 +502,10 @@ void SVTK_Viewer::setSpacemouseButtons( const int theBtn1, const int theBtn2, co
 
   if (SUIT_ViewManager* aViewManager = getViewManager()) {
     QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
-    for ( uint i = 0; i < aViews.count(); i++ )
+    for ( int i = 0; i < aViews.count(); i++ )
     {
       if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
-       aView->SetSpacemouseButtons( theBtn1, theBtn2, theBtn3 );
+        aView->SetSpacemouseButtons( theBtn1, theBtn2, theBtn3 );
     }
   }
 }
@@ -319,6 +529,9 @@ void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
   
   connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), 
           this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+
+  connect(theViewManager, SIGNAL(viewCreated(SUIT_ViewWindow*)), 
+         this, SLOT(onViewCreated(SUIT_ViewWindow*)));
 }
 
 /*!
@@ -327,13 +540,13 @@ void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
 void SVTK_Viewer::contextMenuPopup( QMenu* thePopup )
 {
   thePopup->addAction( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
-  thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );
+  thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) );
 
   thePopup->addSeparator();
 
   if(TViewWindow* aView = dynamic_cast<TViewWindow*>(myViewManager->getActiveView())){
     //Support of several toolbars in the popup menu
-    QList<QToolBar*> lst = qFindChildren<QToolBar*>( aView );
+    QList<QToolBar*> lst = aView->findChildren<QToolBar*>();
     QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
     for( ; it!=last; it++ )
       thePopup->addAction( (*it)->toggleViewAction() );
@@ -344,19 +557,19 @@ void SVTK_Viewer::contextMenuPopup( QMenu* thePopup )
 /*!
   SLOT: called on mouse button press, empty implementation
 */
-void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
+void SVTK_Viewer::onMousePress(SUIT_ViewWindow* /*vw*/, QMouseEvent* /*event*/)
 {}
 
 /*!
   SLOT: called on mouse move, empty implementation
 */
-void SVTK_Viewer::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)
+void SVTK_Viewer::onMouseMove(SUIT_ViewWindow* /*vw*/, QMouseEvent* /*event*/)
 {}
 
 /*!
   SLOT: called on mouse button release, empty implementation
 */
-void SVTK_Viewer::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)
+void SVTK_Viewer::onMouseRelease(SUIT_ViewWindow* /*vw*/, QMouseEvent* /*event*/)
 {}
 
 /*!
@@ -367,6 +580,32 @@ void SVTK_Viewer::enableSelection(bool isEnabled)
 {
   mySelectionEnabled = isEnabled;
   //!! To be done for view windows
+   
+  if (SUIT_ViewManager* aViewManager = getViewManager()) {
+    QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+    for ( int i = 0; i < aViews.count(); i++ )
+    {
+      if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+        aView->SetSelectionEnabled( isEnabled );
+    }
+  }
+
+  if(!isEnabled) {
+    //clear current selection in the viewer
+    bool blocked = blockSignals( true );
+    if ( SUIT_ViewManager* aViewMgr = getViewManager() ) {
+      if( SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewMgr->getActiveView() ) ){
+       if( SVTK_Selector* aSelector = aViewWindow->GetSelector() ) {
+         if(SVTK_View* aView = aViewWindow->getView()){
+           aSelector->ClearIObjects();
+           aView->onSelectionChanged();
+         }
+       }
+      }
+    }
+    blockSignals( blocked );  
+  }
+
 }
 
 /*!
@@ -391,12 +630,32 @@ void SVTK_Viewer::onDumpView()
 /*!
   SLOT: called if background color is to be changed changed, passes new color to view port
 */
-void SVTK_Viewer::onChangeBgColor()
+void SVTK_Viewer::onChangeBackground()
 {
-  if(SUIT_ViewWindow* aView = myViewManager->getActiveView()){
-    QColor aColor = QColorDialog::getColor( backgroundColor(), aView);
-    setBackgroundColor(aColor);
-  }
+  SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(myViewManager->getActiveView());
+  if ( !aView )
+    return;
+
+  // get supported gradient types
+  QStringList gradList;
+  QIntList    idList, txtList;
+  QString     formats = backgroundData( gradList, idList, txtList );
+
+  // invoke dialog box
+  Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(),  // initial background
+                                                                  aView,                // parent for dialog box
+                                                                  txtList,              // allowed texture modes
+                                                                  true,                 // enable solid color mode
+                                                                  true,                 // enable gradient mode
+                                                                  false,                // disable custom gradient mode
+                                                                  !txtList.isEmpty(),   // enable texture mode
+                                                                  gradList,             // gradient names
+                                                                  idList,               // gradient identifiers
+                                                                  formats );            // image formats
+
+  // set chosen background data to the viewer
+  if ( bgData.isValid() )
+    aView->setBackground( bgData );
 }
 
 /*!
@@ -410,36 +669,33 @@ void SVTK_Viewer::Display( const SALOME_VTKPrs* prs )
     if(aPrs->IsNull())
       return;
     if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
-      // get SALOMEDS Study
-      // Temporarily commented to avoid awful dependecy on SALOMEDS
-      // TODO: better mechanism of storing display/erse status in a study
-      // should be provided...
-      // _PTR(Study) aStudy(getStudyDS());
       anActorCollection->InitTraversal();
       while(vtkActor* anActor = anActorCollection->GetNextActor()){
-       if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
-         // Set visibility flag
+        if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
+          if(!anAct->ShouldBeDisplayed())
+            continue;
+          // Set visibility flag
           // Temporarily commented to avoid awful dependecy on SALOMEDS
           // TODO: better mechanism of storing display/erse status in a study
           // should be provided...
-         //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
-         //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
-         //  ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this);
-         //}
-         // just display the object
-         QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
-         for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
-           if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
-             if(SVTK_View* aView = aViewWindow->getView()){
-               aView->Display(anAct,false);
-               if(anAct->IsSetCamera()){
-                 vtkRenderer* aRenderer = aView->getRenderer();
-                 anAct->SetCamera( aRenderer->GetActiveCamera() );
-               }
-             }
-           }
-         }
-       }
+          //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+          //if(!anObj.IsNull() && anObj->hasEntry()){
+          //  ToolsGUI::SetVisibility(anObj->getEntry(),true,this);
+          //}
+          // just display the object
+          QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
+          for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+            if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
+              if(SVTK_View* aView = aViewWindow->getView()){
+                aView->Display(anAct,false);
+                if(anAct->IsSetCamera()){
+                  vtkRenderer* aRenderer = aView->getRenderer();
+                  anAct->SetCamera( aRenderer->GetActiveCamera() );
+                }
+              }
+            }
+          }
+        }
       }
     }
   }
@@ -457,33 +713,30 @@ void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced )
     if(aPrs->IsNull())
       return;
     if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
-      // get SALOMEDS Study
-      // Temporarily commented to avoid awful dependecy on SALOMEDS
-      // TODO: better mechanism of storing display/erse status in a study
-      // should be provided...
-      //_PTR(Study) aStudy(getStudyDS());
       anActorCollection->InitTraversal();
       while(vtkActor* anActor = anActorCollection->GetNextActor())
-       if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
-         // Set visibility flag
+        if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
+          // Set visibility flag
           // Temporarily commented to avoid awful dependecy on SALOMEDS
-          // TODO: better mechanism of storing display/erse status in a study
+          // TODO: better mechanism of storing display/erase status in a study
           // should be provided...
-         //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
-         //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
-         //  ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
-         //}
-         // just display the object
-         QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
-         for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
-           if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
-             if(SVTK_View* aView = aViewWindow->getView())
-               if ( forced )
-                 aView->Remove(anAct,false);
-               else
-                 aView->Erase(anAct,forced);
-         }
-       }
+          //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+          //if(!anObj.IsNull() && anObj->hasEntry()){
+          //  ToolsGUI::SetVisibility(anObj->getEntry(),false,this);
+          //}
+          // just display the object
+          QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
+          for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+            if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
+              if(SVTK_View* aView = aViewWindow->getView())
+              {
+                if ( forced )
+                  aView->Remove(anAct,false);
+                else
+                  aView->Erase(anAct,forced);
+              }
+          }
+        }
     }
   }
 }
@@ -492,45 +745,46 @@ void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced )
   Erase all presentations
   \param forced - removes all objects from view
 */
-void SVTK_Viewer::EraseAll( const bool forced )
+void SVTK_Viewer::EraseAll( SALOME_Displayer* d, const bool forced )
 {
-  // Temporarily commented to avoid awful dependecy on SALOMEDS
-  // TODO: better mechanism of storing display/erse status in a study
-  // should be provided...
-  //_PTR(Study) aStudy(getStudyDS());
   QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
   for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
     if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
       if(SVTK_View* aView = aViewWindow->getView()){
-       vtkRenderer* aRenderer =  aView->getRenderer();
-       vtkActorCollection* anActorCollection = aRenderer->GetActors();
-       anActorCollection->InitTraversal();
-       while(vtkActor* anActor = anActorCollection->GetNextActor()){
-         if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
-           // Set visibility flag
+        vtkRenderer* aRenderer =  aView->getRenderer();
+        VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+        vtkActorCollection* anActorCollection = aCopy.GetActors();
+        anActorCollection->InitTraversal();
+        while(vtkActor* anActor = anActorCollection->GetNextActor()){
+          if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
+            // Set visibility flag
             // Temporarily commented to avoid awful dependecy on SALOMEDS
             // TODO: better mechanism of storing display/erse status in a study
             // should be provided...
-           //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
-           //if(!anObj.IsNull() && anObj->hasEntry() && aStudy)
-           //  ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
-           if(forced)
-             aRenderer->RemoveActor(anAct);
-           else{
-             // just erase actor
-             anAct->SetVisibility( false );
-             // erase dependent actors
-             vtkActorCollection* aCollection = vtkActorCollection::New();
-             anAct->GetChildActors( aCollection );
-             aCollection->InitTraversal();
-             while(vtkActor* aSubAct = aCollection->GetNextActor())
-               aSubAct->SetVisibility( false );
-             aCollection->Delete();
-           }
-         }
-       }
+            //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+            //if(!anObj.IsNull() && anObj->hasEntry())
+            //  ToolsGUI::SetVisibility(anObj->getEntry(),false,this);
+            if(forced){
+              if(SVTK_Renderer* aRnd = aView->GetRenderer())
+                aRnd->RemoveActor(anAct);
+            }else{
+              // just erase actor
+              anAct->SetVisibility( false );
+              // erase dependent actors
+              vtkActorCollection* aCollection = vtkActorCollection::New();
+              anAct->GetChildActors( aCollection );
+              aCollection->InitTraversal();
+              while(vtkActor* aSubAct = aCollection->GetNextActor())
+                aSubAct->SetVisibility( false );
+              aCollection->Delete();
+            }
+          }
+        }
       }
   }
+
+  SALOME_View::EraseAll( d, forced );
+
   Repaint();
 }
 
@@ -540,41 +794,26 @@ void SVTK_Viewer::EraseAll( const bool forced )
 */
 SALOME_Prs* SVTK_Viewer::CreatePrs( const char* entry )
 {
-  SVTK_Prs* prs = new SVTK_Prs();
+  SVTK_Prs* prs = new SVTK_Prs( entry );
   if ( entry ) {
     if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(getViewManager()->getActiveView()))
       if(SVTK_View* aView = aViewWindow->getView()){
-       vtkRenderer* aRenderer =  aView->getRenderer();
-       vtkActorCollection* theActors = aRenderer->GetActors();
-       theActors->InitTraversal();
-       vtkActor* ac;
-       while( ( ac = theActors->GetNextActor() ) ) {
-         SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
-         if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {
-           prs->AddObject( ac );
-         }
-       }
+        vtkRenderer* aRenderer =  aView->getRenderer();
+        VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+        vtkActorCollection* theActors = aCopy.GetActors();
+        theActors->InitTraversal();
+        vtkActor* ac;
+        while( ( ac = theActors->GetNextActor() ) ) {
+          SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
+          if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {
+            prs->AddObject( ac );
+          }
+        }
       }
   }
   return prs;
 }
 
-/*!
-  Auxiliary method called before displaying of objects
-*/
-void SVTK_Viewer::BeforeDisplay( SALOME_Displayer* d )
-{
-  d->BeforeDisplay( this, SALOME_VTKViewType() );
-}
-
-/*!
-  Auxiliary method called after displaying of objects
-*/
-void SVTK_Viewer::AfterDisplay( SALOME_Displayer* d )
-{
-  d->AfterDisplay( this, SALOME_VTKViewType() );
-}
-
 /*!
   \return true if object is displayed in viewer
   \param obj - object to be checked
@@ -592,6 +831,21 @@ bool SVTK_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& io )
   return true;
 }
 
+/*!
+  \Collect objects visible in viewer
+  \param theList - visible objects collection
+*/
+void SVTK_Viewer::GetVisible( SALOME_ListIO& theList )
+{
+  // here we collect object if it is disaplaed even one view
+  QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
+  for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
+    if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
+      if(TViewWindow* aViewWnd = dynamic_cast<TViewWindow*>(aViewWindow))
+        if(SVTK_View* aView = aViewWnd->getView())
+          aView->GetVisible( theList );
+}
+
 /*!
   Updates current viewer
 */
@@ -602,7 +856,7 @@ void SVTK_Viewer::Repaint()
   for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
     if(TViewWindow* aViewWindow = dynamic_cast<TViewWindow*>(aViews.at(i)))
       if(SVTK_View* aView = aViewWindow->getView())
-       aView->Repaint();
+        aView->Repaint();
 }
  
 
@@ -615,3 +869,10 @@ void SVTK_Viewer::onActorRemoved(VTKViewer_Actor* theActor)
 {
   emit actorRemoved((SVTK_ViewWindow*)sender(), theActor);
 }
+
+void SVTK_Viewer::onViewCreated( SUIT_ViewWindow* view) {
+#ifdef VGL_WORKAROUND
+  if ( SVTK_ViewWindow* svw = dynamic_cast<SVTK_ViewWindow*>( view ) )
+    QTimer::singleShot(500, [svw] () { svw->Repaint(); } );
+#endif
+}