Salome HOME
Updated copyright comment
[modules/gui.git] / src / VTKViewer / VTKViewer_ViewWindow.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 20185b3..f088c2e
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  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 "VTKViewer_ViewWindow.h"
 #include "VTKViewer_ViewModel.h"
 #include "VTKViewer_RenderWindow.h"
 #include "VTKViewer_Trihedron.h"
 #include "VTKViewer_Transform.h"
 #include "VTKViewer_Utilities.h"
+#include "VTKViewer_Texture.h"
+#include "VTKViewer_OpenGLRenderer.h"
 
 #include <SUIT_Session.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_Tools.h>
 #include <SUIT_ResourceMgr.h>
 
+#include <QFileInfo>
 #include <QImage>
 
-#include <vtkRenderer.h>
 #include <vtkCamera.h>
+#include <vtkJPEGReader.h>
+#include <vtkBMPReader.h>
+#include <vtkTIFFReader.h>
+#include <vtkPNGReader.h>
+#include <vtkMetaImageReader.h>
+#include <vtkImageMapToColors.h>
+#include <vtkTexture.h>
 
 #include <QtxToolBar.h>
 #include <QtxMultiAction.h>
 /*! Construction*/
 VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop, 
                                             VTKViewer_Viewer* theModel,
-                                           VTKViewer_InteractorStyle* iStyle,
-                                           VTKViewer_RenderWindowInteractor* rw )
+                                            VTKViewer_InteractorStyle* iStyle,
+                                            VTKViewer_RenderWindowInteractor* rw )
 : SUIT_ViewWindow( theDesktop )
 {
   myModel = theModel;
 
   myTrihedron = VTKViewer_Trihedron::New();
   myTransform = VTKViewer_Transform::New();
-  myRenderer  = vtkRenderer::New() ;
+  myRenderer  = VTKViewer_OpenGLRenderer::New() ;
 
   myTrihedron->AddToRender( myRenderer );
 
@@ -67,16 +77,6 @@ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop,
   myRenderer->LightFollowCameraOn();
   myRenderer->TwoSidedLightingOn();
 
-  // Set BackgroundColor
-  QString BgrColorRed   = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
-  QString BgrColorGreen = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
-  QString BgrColorBlue  = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
-
-  if( !BgrColorRed.isEmpty() && !BgrColorGreen.isEmpty() && !BgrColorBlue.isEmpty() ) 
-    myRenderer->SetBackground( BgrColorRed.toInt()/255., BgrColorGreen.toInt()/255., BgrColorBlue.toInt()/255. );
-  else
-    myRenderer->SetBackground( 0, 0, 0 );
-  
   // Create an interactor.
   myRWInteractor = rw ? rw : VTKViewer_RenderWindowInteractor::New();
   myRWInteractor->SetRenderWindow( myRenderWindow->getRenderWindow() );
@@ -92,6 +92,8 @@ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop,
   setCentralWidget( myRenderWindow );
 
   myToolBar = new QtxToolBar( true, tr("LBL_TOOLBAR_LABEL"), this );
+  myToolBar->setObjectName( "VTKViewerViewOperations" );
+  myToolBar->setFloatable( false );
 
   createActions();
   createToolBar();
@@ -118,6 +120,9 @@ VTKViewer_ViewWindow::VTKViewer_ViewWindow( SUIT_Desktop* theDesktop,
            this,           SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
 
 
+  // set default background
+  setBackground( Qtx::BackgroundData( Qt::black ) );
+  // reset view
   onResetView();
 }
 
@@ -186,105 +191,126 @@ void VTKViewer_ViewWindow::createActions()
   aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
                            tr( "MNU_DUMP_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
   myActionsMap[ DumpId ] = aAction;
 
   //! \li FitAll
   aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
                            tr( "MNU_FITALL" ), 0, this);
   aAction->setStatusTip(tr("DSC_FITALL"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
   myActionsMap[ FitAllId ] = aAction;
 
   //! \li FitRect
   aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
                            tr( "MNU_FITRECT" ), 0, this);
   aAction->setStatusTip(tr("DSC_FITRECT"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
   myActionsMap[ FitRectId ] = aAction;
 
+  //! \li FitSelection
+  aAction = new QtxAction(tr("MNU_FITSELECTION"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
+                           tr( "MNU_FITSELECTION" ), 0, this);
+  aAction->setStatusTip(tr("DSC_FITSELECTION"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onFitSelection()));
+  myActionsMap[ FitSelectionId ] = aAction;
+
   //! \li Zoom
   aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
                            tr( "MNU_ZOOM_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
   myActionsMap[ ZoomId ] = aAction;
 
   //! \li Panning
   aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
                            tr( "MNU_PAN_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_PAN_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
   myActionsMap[ PanId ] = aAction;
 
   //! \li Global Panning
   aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
                            tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
   myActionsMap[ GlobalPanId ] = aAction;
 
   //! \li Rotation
   aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
                            tr( "MNU_ROTATE_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
   myActionsMap[ RotationId ] = aAction;
 
   //! \li Projections
   aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
                            tr( "MNU_FRONT_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
   myActionsMap[ FrontId ] = aAction;
 
   //! \li Back view
   aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
                            tr( "MNU_BACK_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_BACK_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onBackView()));
   myActionsMap[ BackId ] = aAction;
 
   //! \li Top view
   aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
                            tr( "MNU_TOP_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_TOP_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onTopView()));
   myActionsMap[ TopId ] = aAction;
 
   //! \li Bottom view
   aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
                            tr( "MNU_BOTTOM_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
   myActionsMap[ BottomId ] = aAction;
 
   //! \li Left view
   aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
                            tr( "MNU_LEFT_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
   myActionsMap[ LeftId ] = aAction;
 
   //! \li Right view
   aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
                            tr( "MNU_RIGHT_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onRightView()));
   myActionsMap[ RightId ] = aAction;
 
+  // \li Rotate anticlockwise
+  aAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
+                         tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
+  myActionsMap[ AntiClockWiseId ] = aAction;
+
+  // \li Rotate clockwise
+  aAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
+                         tr( "MNU_CLOCKWISE_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
+  myActionsMap[ ClockWiseId ] = aAction;
+
   //! \li Reset
   aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
                            tr( "MNU_RESET_VIEW" ), 0, this);
   aAction->setStatusTip(tr("DSC_RESET_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onResetView()));
   myActionsMap[ ResetId ] = aAction;
 
   //! \li Trihedron shown
   aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
                            tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
   aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onTrihedronShow()));
+  connect(aAction, SIGNAL(triggered()), this, SLOT(onTrihedronShow()));
   myActionsMap[ TrihedronShowId ] = aAction;
 }
 
@@ -297,6 +323,7 @@ void VTKViewer_ViewWindow::createToolBar()
   QtxMultiAction* aScaleAction = new QtxMultiAction( this );
   aScaleAction->insertAction( myActionsMap[FitAllId] );
   aScaleAction->insertAction( myActionsMap[FitRectId] );
+  aScaleAction->insertAction( myActionsMap[FitSelectionId] );
   aScaleAction->insertAction( myActionsMap[ZoomId] );
   myToolBar->addAction( aScaleAction );
 
@@ -316,6 +343,9 @@ void VTKViewer_ViewWindow::createToolBar()
   aViewsAction->insertAction( myActionsMap[RightId] );
   myToolBar->addAction( aViewsAction );
 
+  myToolBar->addAction( myActionsMap[AntiClockWiseId] );
+  myToolBar->addAction( myActionsMap[ClockWiseId] );
+
   myToolBar->addAction( myActionsMap[ResetId] );
 }
 
@@ -379,6 +409,28 @@ void VTKViewer_ViewWindow::onRightView()
   onFitAll();
 }
 
+/*!
+  \brief Rotate view 90 degrees clockwise
+*/
+void VTKViewer_ViewWindow::onClockWiseView()
+{
+  vtkCamera* aCamera = myRenderer->GetActiveCamera(); 
+  aCamera->Roll(-90);
+  aCamera->OrthogonalizeViewUp();
+  Repaint();
+}
+
+/*!
+  \brief Rotate view 90 degrees conterclockwise
+*/
+void VTKViewer_ViewWindow::onAntiClockWiseView()
+{
+  vtkCamera* aCamera = myRenderer->GetActiveCamera(); 
+  aCamera->Roll(90);
+  aCamera->OrthogonalizeViewUp();
+  Repaint();
+}
+
 /*!On reset view slot.*/
 void VTKViewer_ViewWindow::onResetView()
 {
@@ -391,7 +443,7 @@ void VTKViewer_ViewWindow::onResetView()
   ::ResetCamera(myRenderer,true);  
   if(aTriedronIsVisible) myTrihedron->VisibilityOn();
   else myTrihedron->VisibilityOff();
-  static vtkFloatingPointType aCoeff = 3.0;
+  static double aCoeff = 3.0;
   aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
   Repaint();
 }
@@ -403,22 +455,173 @@ void VTKViewer_ViewWindow::onFitAll()
   Repaint();
 }
 
-/*!Set background of the viewport*/
-void VTKViewer_ViewWindow::setBackgroundColor( const QColor& color )
+/*!On fit selection slot.*/
+void VTKViewer_ViewWindow::onFitSelection()
 {
-  if ( myRenderer )
-    myRenderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. );
+  myRWInteractor->GetInteractorStyle()->ViewFitSelection();
+  Repaint();
 }
 
-/*!Returns background of the viewport*/
+/*!Set background color of the viewport [obsolete]*/
+void VTKViewer_ViewWindow::setBackgroundColor( const QColor& c )
+{
+  Qtx::BackgroundData bg = background();
+  bg.setColor( c );
+  setBackground( bg );
+}
+
+/*!Returns background color of the viewport [obsolete]*/
 QColor VTKViewer_ViewWindow::backgroundColor() const
 {
-  vtkFloatingPointType backint[3];
-  if ( myRenderer ) {
-    myRenderer->GetBackground( backint );
-    return QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255));
+  return background().color();
+}
+
+/*!Set background of the viewport*/
+void VTKViewer_ViewWindow::setBackground( const Qtx::BackgroundData& bgData )
+{
+  bool ok = false;
+  if ( bgData.isValid() ) {
+    switch ( bgData.mode() ) {
+    case Qtx::ColorBackground:
+      {
+       QColor c = bgData.color();
+       if ( c.isValid() ) {
+         // show solid-colored background
+         getRenderer()->SetTexturedBackground( false );  // cancel texture mode
+         getRenderer()->SetGradientBackground( false );  // cancel gradient mode
+         getRenderer()->SetBackground( c.red()/255.0,
+                                       c.green()/255.0,
+                                       c.blue()/255.0 ); // set background color
+         ok = true;
+       }
+       break;
+      }
+    case Qtx::SimpleGradientBackground:
+      {
+       QColor c1, c2;
+       int type = bgData.gradient( c1, c2 );
+        if ( c1.isValid() )
+        {
+          if ( !c2.isValid() )
+            c2 = c1;
+
+          // show two-color gradient background
+          getRenderer()->SetTexturedBackground( false );    // cancel texture mode
+          getRenderer()->SetGradientBackground( true );     // switch to gradient mode
+
+          VTKViewer_OpenGLRenderer* aRenderer =
+            VTKViewer_OpenGLRenderer::SafeDownCast( getRenderer() );
+          if( aRenderer )
+          {
+            aRenderer->SetGradientType( type );
+            aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() );
+            aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() );
+            ok = true;
+          }
+        }
+       break;
+      }
+    case Qtx::CustomGradientBackground:
+      {
+       // NOT IMPLEMENTED YET
+       getRenderer()->SetTexturedBackground( false );  // cancel texture mode
+       getRenderer()->SetGradientBackground( false );  // cancel gradient mode
+       // .........
+       break;
+      }
+    default:
+      break;
+    }
+    if ( bgData.isTextureShown() ) {
+      QString fileName;
+      int textureMode = bgData.texture( fileName );
+      QFileInfo fi( fileName );
+      if ( !fileName.isEmpty() && fi.exists() ) {
+       // read texture from file
+       QString extension = fi.suffix().toLower();
+       vtkImageReader2* aReader = 0;
+       if ( extension == "jpg" || extension == "jpeg" )
+         aReader = vtkJPEGReader::New();
+       else if ( extension == "bmp" )
+         aReader = vtkBMPReader::New();
+       else if ( extension == "tif" || extension == "tiff" )
+         aReader = vtkTIFFReader::New();
+       else if ( extension == "png" )
+         aReader = vtkPNGReader::New();
+       else if ( extension == "mhd" || extension == "mha" )
+         aReader = vtkMetaImageReader::New();           
+       if ( aReader ) {
+         // create texture
+         aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() );
+         aReader->Update();
+         
+         VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
+         vtkImageMapToColors* aMap = 0;
+         vtkAlgorithmOutput* anOutput;
+         /*
+         // special processing for BMP reader
+         vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
+         if ( aBMPReader ) {
+           // Special processing for BMP file
+           aBMPReader->SetAllow8BitBMP(1);
+           
+           aMap = vtkImageMapToColors::New();
+           aMap->SetInputConnection( aBMPReader->GetOutputPort() );
+           aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
+           aMap->SetOutputFormatToRGB();
+           
+           anOutput = aMap->GetOutputPort();
+         }
+         else {
+          }
+         */
+         anOutput = aReader->GetOutputPort( 0 );
+         aTexture->SetInputConnection( anOutput );
+         // set texture mode
+         // VSR: Currently, VTK only supports Stretch mode, so below code will give
+         // the same results for all modes
+         switch ( textureMode ) {
+         case Qtx::TileTexture:
+           aTexture->RepeatOn();
+           aTexture->EdgeClampOff();
+           aTexture->InterpolateOff();
+           break;
+         case Qtx::StretchTexture:
+           aTexture->RepeatOff();
+           aTexture->EdgeClampOff();
+           aTexture->InterpolateOn();
+           break;
+         case Qtx::CenterTexture:
+         default:
+           aTexture->RepeatOff();
+           aTexture->EdgeClampOn();
+           aTexture->InterpolateOff();
+           break;
+         }
+         // show textured background
+         getRenderer()->SetTexturedBackground( true );     // switch to texture mode
+         getRenderer()->SetBackgroundTexture( aTexture );  // set texture image
+         
+         // clean-up resources
+         if ( aMap )
+           aMap->Delete();
+         aReader->Delete();
+         aTexture->Delete();
+         ok = true;
+       }
+      }
+    }
   }
-  return palette().color( backgroundRole() );
+
+  if ( ok )
+    myBackground = bgData;
+}
+
+/*!Returns background of the viewport*/
+Qtx::BackgroundData VTKViewer_ViewWindow::background() const
+{
+  return myBackground;
 }
 
 /*!Repaint window. If \a theUpdateTrihedron is true - recalculate trihedron.*/
@@ -447,11 +650,11 @@ void VTKViewer_ViewWindow::onAdjustTrihedron(){
   int aVisibleNum = myTrihedron->GetVisibleActorCount(myRenderer);
   if(aVisibleNum){
     // calculating diagonal of visible props of the renderer
-    vtkFloatingPointType bnd[6];
+    double bnd[6];
     myTrihedron->VisibilityOff();
     ::ComputeVisiblePropBounds(myRenderer,bnd);
     myTrihedron->VisibilityOn();
-    vtkFloatingPointType aLength = 0;
+    double aLength = 0;
     static bool CalcByDiag = false;
     if(CalcByDiag){
       aLength = sqrt((bnd[1]-bnd[0])*(bnd[1]-bnd[0])+
@@ -463,13 +666,13 @@ void VTKViewer_ViewWindow::onAdjustTrihedron(){
       aLength = qMax((bnd[5]-bnd[4]),aLength);
     }
    
-    static vtkFloatingPointType aSizeInPercents = 105;
+    static double aSizeInPercents = 105;
     QString aSetting;// = SUIT_CONFIG->getSetting("Viewer:TrihedronSize");
     if(!aSetting.isEmpty()) aSizeInPercents = aSetting.toFloat();
 
-    static vtkFloatingPointType EPS_SIZE = 5.0E-3;
-    vtkFloatingPointType aSize = myTrihedron->GetSize();
-    vtkFloatingPointType aNewSize = aLength*aSizeInPercents/100.0;
+    static double EPS_SIZE = 5.0E-3;
+    double aSize = myTrihedron->GetSize();
+    double aNewSize = aLength*aSizeInPercents/100.0;
     // if the new trihedron size have sufficient difference, then apply the value
     if(fabs(aNewSize-aSize) > aSize*EPS_SIZE || fabs(aNewSize-aSize) > aNewSize*EPS_SIZE){
       myTrihedron->SetSize(aNewSize);
@@ -579,8 +782,8 @@ QString VTKViewer_ViewWindow::getVisualParameters()
 
   QString retStr;
   retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", 
-                 pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1], 
-                 viewUp[2], parScale, scale[0], scale[1], scale[2] );
+                  pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2], viewUp[0], viewUp[1], 
+                  viewUp[2], parScale, scale[0], scale[1], scale[2] );
   return retStr;
 }