Salome HOME
Copyrights update 2015.
[modules/gui.git] / src / VTKViewer / VTKViewer_InteractorStyle.cxx
index 18a4960897251efb21e19ebd8c0206a37b9eec74..1553a2e0f7da78ac66d394990a959f54dbc593f8 100644 (file)
@@ -1,43 +1,38 @@
-//  SALOME VTKViewer : build VTK viewer into Salome desktop
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
 //
-//  Copyright (C) 2003  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 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// 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
 //
+
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
 //  File   : VTKViewer_InteractorStyle.cxx
 //  Author : Christophe ATTANASIO
-//  Module : SALOME
 
 #include "VTKViewer_InteractorStyle.h"
 
 #include "VTKViewer_Actor.h"
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_Trihedron.h"
-#include "VTKViewer_RectPicker.h"
 #include "VTKViewer_ViewWindow.h"
 #include "VTKViewer_RenderWindow.h"
-#include "VTKViewer_CellRectPicker.h"
 #include "VTKViewer_RenderWindowInteractor.h"
 
-//#include "SALOME_Actor.h"
-
 #include <vtkObjectFactory.h>
 #include <vtkMath.h>
 #include <vtkCommand.h>
 #include <vtkMapper.h>
 #include <vtkDataSet.h>
 #include <vtkSmartPointer.h>
+#include <vtkProperty.h>
 
-#include <qapplication.h>
-//VRV: porting on Qt 3.0.5
-#if QT_VERSION >= 0x030005
-#include <qpainter.h>
-#endif
-//VRV: porting on Qt 3.0.5
-#include <algorithm>
-
-//#include "utilities.h"
-
-using namespace std;
+#include <QApplication>
+#include <QRubberBand>
 
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
+#include <algorithm>
 
 /*
 static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){
@@ -79,22 +61,22 @@ static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId)
     float aMinDist = 1000000.0, aDist = 0;
     for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
       if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
-       int subId;  float pcoords[3], closestPoint[3], weights[3];
-       aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
-       if (aDist < aMinDist) {
-         aMinDist = aDist;
-         anEdgeId = i;
-       }
+        int subId;  float pcoords[3], closestPoint[3], weights[3];
+        aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
+        if (aDist < aMinDist) {
+          aMinDist = aDist;
+          anEdgeId = i;
+        }
       }
     }
   }
   return anEdgeId;
 }
 */
-//----------------------------------------------------------------------------
+
 vtkStandardNewMacro(VTKViewer_InteractorStyle);
 
-//----------------------------------------------------------------------------
+
 /*!Constructor.*/
 VTKViewer_InteractorStyle::VTKViewer_InteractorStyle()
 {
@@ -110,18 +92,20 @@ VTKViewer_InteractorStyle::VTKViewer_InteractorStyle()
   myPreSelectionActor->GetProperty()->SetLineWidth(5);
   myPreSelectionActor->GetProperty()->SetPointSize(5);
 
+  myRectBand = 0;
+
   OnSelectionModeChanged();
 }
 
-//----------------------------------------------------------------------------
+
 /*!Destructor.*/
 VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle() 
 {
-//  if(MYDEBUG) INFOS("VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle()");
   m_ViewWnd->RemoveActor(myPreSelectionActor);
+  endDrawRect();
 }
 
-//----------------------------------------------------------------------------
+
 /*!Set preselection properties.
  *\param theRed   - red color.
  *\param theGreen - green color.
@@ -129,7 +113,7 @@ VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle()
  *\param theWidth - width..
  */
 void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const double& theGreen, 
-                                                         const double& theBlue, const int& theWidth) 
+                                                          const double& theBlue, const int& theWidth) 
 {
   if ( myPreSelectionActor->GetProperty() == 0 )
     return;
@@ -138,7 +122,7 @@ void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const
   myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
 }
 
-//----------------------------------------------------------------------------
+
 /*!Set render window interactor
  *\param theInteractor - interactor.
  */
@@ -147,7 +131,7 @@ void VTKViewer_InteractorStyle::SetInteractor(vtkRenderWindowInteractor *theInte
   Superclass::SetInteractor(theInteractor);
 }
 
-//----------------------------------------------------------------------------
+
 /*!Set view window.
  *\param theViewWnd - SALOME VTKViewer_ViewWindow
  */
@@ -157,7 +141,7 @@ void VTKViewer_InteractorStyle::setViewWnd(VTKViewer_ViewWindow* theViewWnd ){
   myPreSelectionActor->Delete();
 }
 
-//----------------------------------------------------------------------------
+
 /*!Set GUI window.
  *\param theWindow - QWidget window.
  */
@@ -165,15 +149,14 @@ void VTKViewer_InteractorStyle::setGUIWindow(QWidget* theWindow){
   myGUIWindow = theWindow;
 }
 
-//----------------------------------------------------------------------------
-/*!Set triedron.
+
+/*!Set trihedron.
  *\param theTrihedron - SALOME VTKViewer_Trihedron
  */
 void VTKViewer_InteractorStyle::setTriedron(VTKViewer_Trihedron* theTrihedron){
   m_Trihedron = theTrihedron;
 }
 
-//----------------------------------------------------------------------------
 /*!Rotate camera.
  *\param dx - 
  *\param dy - 
@@ -205,7 +188,6 @@ void VTKViewer_InteractorStyle::RotateXY(int dx, int dy)
   myGUIWindow->update();
 }
 
-//----------------------------------------------------------------------------
 void VTKViewer_InteractorStyle::PanXY(int x, int y, int oldX, int oldY)
 {
   TranslateView(x, y, oldX, oldY);   
@@ -214,7 +196,6 @@ void VTKViewer_InteractorStyle::PanXY(int x, int y, int oldX, int oldY)
 }
 
 
-//----------------------------------------------------------------------------
 /*! Move the position of the camera along the direction of projection. (dx,dy)*/
 void VTKViewer_InteractorStyle::DollyXY(int dx, int dy)
 {
@@ -237,8 +218,6 @@ void VTKViewer_InteractorStyle::DollyXY(int dx, int dy)
   myGUIWindow->update();
 }
 
-//----------------------------------------------------------------------------
-/*!*/
 void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
 {
   vtkCamera *cam;
@@ -249,9 +228,9 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
     }
 
   double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]),
-                         (double)(x - this->CurrentRenderer->GetCenter()[0]));
+                          (double)(x - this->CurrentRenderer->GetCenter()[0]));
   double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]),
-                         (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
+                          (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
   
   newAngle *= this->RadianToDegree;
   oldAngle *= this->RadianToDegree;
@@ -265,7 +244,6 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
 }
 
 
-//----------------------------------------------------------------------------
 /*!On mouse move event.
  *\param ctrl  - CTRL (not used)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -273,8 +251,8 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
  *\param y - y coordinate
  */
 void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl), 
-                                                 int shift,
-                                                 int x, int y) 
+                                                  int shift,
+                                                  int x, int y) 
 {
   myShiftState = shift;
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
@@ -284,7 +262,6 @@ void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl),
 }
 
 
-//----------------------------------------------------------------------------
 /*!On Left button down event.
  *\param ctrl  - CTRL  (on/off - integer 0/1)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -292,7 +269,7 @@ void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl),
  *\param y - y coordinate
  */
 void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, 
-                                                      int x, int y) 
+                                                       int x, int y) 
 {
   if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
     this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
@@ -321,7 +298,6 @@ void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
 }
 
 
-//----------------------------------------------------------------------------
 /*!On left button up event.
  *\param ctrl  - CTRL  (not used)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -329,9 +305,9 @@ void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
  *\param y - y coordinate (not used)
  */
 void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
-                                                    int shift, 
-                                                    int vtkNotUsed(x),
-                                                    int vtkNotUsed(y))
+                                                     int shift, 
+                                                     int vtkNotUsed(x),
+                                                     int vtkNotUsed(y))
 {
   myShiftState = shift;
   // finishing current viewer operation
@@ -342,7 +318,6 @@ void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
 }
 
 
-//----------------------------------------------------------------------------
 /*!On left button up event.
  *\param ctrl  - CTRL  (on/off - integer 0/1)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -350,8 +325,8 @@ void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
  *\param y - y coordinate
  */
 void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl,
-                                                        int shift, 
-                                                        int x, int y) 
+                                                         int shift, 
+                                                         int x, int y) 
 {
   if (this->HasObserver(vtkCommand::MiddleButtonPressEvent)) 
     {
@@ -380,7 +355,6 @@ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl,
 }
 
 
-//----------------------------------------------------------------------------
 /*!On middle button up event.
  *\param ctrl  - CTRL  (not used)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -388,9 +362,9 @@ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl,
  *\param y - y coordinate (not used)
  */
 void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
-                                                      int shift, 
-                                                      int vtkNotUsed(x),
-                                                      int vtkNotUsed(y))
+                                                       int shift, 
+                                                       int vtkNotUsed(x),
+                                                       int vtkNotUsed(y))
 {
   myShiftState = shift;
   // finishing current viewer operation
@@ -401,7 +375,6 @@ void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
 }
 
 
-//----------------------------------------------------------------------------
 /*!On right button down event.
  *\param ctrl  - CTRL  (on/off - integer 0/1)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -409,8 +382,8 @@ void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
  *\param y - y coordinate
  */
 void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl,
-                                                       int shift, 
-                                                       int x, int y) 
+                                                        int shift, 
+                                                        int x, int y) 
 {
   if (this->HasObserver(vtkCommand::RightButtonPressEvent)) 
     {
@@ -438,7 +411,6 @@ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl,
   }
 }
 
-//----------------------------------------------------------------------------
 /*!On right button up event.
  *\param ctrl  - CTRL  (not used)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -446,9 +418,9 @@ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl,
  *\param y - y coordinate (not used)
  */
 void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
-                                                     int shift, 
-                                                     int vtkNotUsed(x),
-                                                     int vtkNotUsed(y))
+                                                      int shift, 
+                                                      int vtkNotUsed(x),
+                                                      int vtkNotUsed(y))
 {
   myShiftState = shift;
   // finishing current viewer operation
@@ -458,8 +430,7 @@ void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
   }
 }
 
-//----------------------------------------------------------------------------
-/** @name XPM - x pixmaps. */
+/*! @name XPM - x pixmaps. */
 //@{
 /*!Image Zoom cursor*/
 const char* imageZoomCursor[] = { 
@@ -540,22 +511,20 @@ const char* imageRotateCursor[] = {
 "................................"};
 //@}
 
-//----------------------------------------------------------------------------
 /*! Loads cursors for viewer operations - zoom, pan, etc...*/
 void VTKViewer_InteractorStyle::loadCursors()
 {
-  myDefCursor       = QCursor(ArrowCursor);
-  myHandCursor      = QCursor(PointingHandCursor);
-  myPanCursor       = QCursor(SizeAllCursor);
+  myDefCursor       = QCursor(Qt::ArrowCursor);
+  myHandCursor      = QCursor(Qt::PointingHandCursor);
+  myPanCursor       = QCursor(Qt::SizeAllCursor);
   myZoomCursor      = QCursor(QPixmap(imageZoomCursor));
   myRotateCursor    = QCursor(QPixmap(imageRotateCursor));
   mySpinCursor      = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
-  myGlobalPanCursor = QCursor(CrossCursor);
+  myGlobalPanCursor = QCursor(Qt::CrossCursor);
   myCursorState     = false;
 }
 
 
-//----------------------------------------------------------------------------
 /*! event filter - controls mouse and keyboard events during viewer operations*/
 bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event)
 {
@@ -569,7 +538,6 @@ bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event)
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts Zoom operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startZoom()
 {
@@ -584,7 +552,6 @@ void VTKViewer_InteractorStyle::startZoom()
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts Pan operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startPan()
 {
@@ -598,7 +565,6 @@ void VTKViewer_InteractorStyle::startPan()
   qApp->installEventFilter(this);
 }
 
-//----------------------------------------------------------------------------
 /*! starts Rotate operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startRotate()
 {
@@ -613,7 +579,6 @@ void VTKViewer_InteractorStyle::startRotate()
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts Spin operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startSpin()
 {
@@ -629,7 +594,6 @@ void VTKViewer_InteractorStyle::startSpin()
 
 
 
-//----------------------------------------------------------------------------
 /*! starts Fit Area operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startFitArea()
 {
@@ -644,7 +608,6 @@ void VTKViewer_InteractorStyle::startFitArea()
 }
 
 
-//----------------------------------------------------------------------------
 /*!View fit all.*/
 void  VTKViewer_InteractorStyle::ViewFitAll() {
   int aTriedronWasVisible = false;
@@ -666,7 +629,6 @@ void  VTKViewer_InteractorStyle::ViewFitAll() {
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts Global Panning operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startGlobalPan()
 {
@@ -690,7 +652,6 @@ void VTKViewer_InteractorStyle::startGlobalPan()
 }
 
 
-//----------------------------------------------------------------------------
 /*!\retval TRUE if needs redrawing*/
 bool VTKViewer_InteractorStyle::needsRedrawing()
 {
@@ -702,7 +663,6 @@ bool VTKViewer_InteractorStyle::needsRedrawing()
 }
 
 
-//----------------------------------------------------------------------------
 /*! fits viewer contents to rectangle
  *\param left - left side
  *\param top  - top side
@@ -741,7 +701,6 @@ void VTKViewer_InteractorStyle::fitRect(const int left,
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts viewer operation (!internal usage!)*/
 void VTKViewer_InteractorStyle::startOperation(int operation)
 {
@@ -770,7 +729,6 @@ void VTKViewer_InteractorStyle::startOperation(int operation)
 }
 
 
-//----------------------------------------------------------------------------
 /*! sets proper cursor for window when viewer operation is activated*/
 void VTKViewer_InteractorStyle::setCursor(const int operation)
 {
@@ -810,8 +768,33 @@ void VTKViewer_InteractorStyle::setCursor(const int operation)
   }
 }
 
+/*!
+  Draws rectangle by starting and current points
+*/
+void VTKViewer_InteractorStyle::drawRect()
+{
+  if ( !myRectBand ) {
+    myRectBand = new QRubberBand( QRubberBand::Rectangle, myGUIWindow );
+    QPalette palette;
+    palette.setColor(myRectBand->foregroundRole(), Qt::white);
+    myRectBand->setPalette(palette);
+  }
+  myRectBand->hide();
+
+  QRect aRect(myPoint, myOtherPoint);
+  myRectBand->setGeometry( aRect );
+  myRectBand->setVisible( aRect.isValid() );
+}
+
+/*!
+  \brief Delete rubber band on the end on the dragging operation.
+*/
+void VTKViewer_InteractorStyle::endDrawRect()
+{
+  delete myRectBand;
+  myRectBand = 0;
+}
 
-//----------------------------------------------------------------------------
 /*! called when viewer operation started (!put necessary initialization here!)*/
 void VTKViewer_InteractorStyle::onStartOperation()
 {
@@ -822,10 +805,7 @@ void VTKViewer_InteractorStyle::onStartOperation()
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      QPainter p(myGUIWindow);
-      p.setPen(Qt::lightGray);
-      p.setRasterOp(Qt::XorROP);
-      p.drawRect(QRect(myPoint, myOtherPoint));
+      drawRect();
       break;
     }
     case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
@@ -838,7 +818,6 @@ void VTKViewer_InteractorStyle::onStartOperation()
 }
 
 
-//----------------------------------------------------------------------------
 /*! called when viewer operation finished (!put necessary post-processing here!)*/
 void VTKViewer_InteractorStyle::onFinishOperation() 
 {
@@ -877,260 +856,256 @@ void VTKViewer_InteractorStyle::onFinishOperation()
       }
       else {
         if (myPoint == myOtherPoint) {
-         // process point selection
+          // process point selection
           int w, h, x, y;
           m_Interactor->GetSize(w, h);
           x = myPoint.x(); 
           y = h - myPoint.y() - 1;
 
           this->FindPokedRenderer(x, y);
-         m_Interactor->StartPickCallback();
+          m_Interactor->StartPickCallback();
 
-         vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
+          vtkPicker* aPicker = vtkPicker::SafeDownCast(m_Interactor->GetPicker());
           aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
     
-         SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
+          SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
 
           if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
-           int aVtkId = picker->GetCellId();
-           if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
-             int anObjId = SActor->GetElemObjId(aVtkId);
-             if(anObjId >= 0){
-               Handle(SALOME_InteractiveObject) IO = SActor->getIO();
-               if(aSelectionMode != EdgeOfCellSelection) {
-                 if(CheckDimensionId(aSelectionMode,SActor,anObjId)){
-                   if(MYDEBUG) INFOS(" CellId : "<<anObjId);
-                   if (IsSelected(IO,aSel)) {
-                     // This IO is already in the selection
-                     aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
-                   } else {
-                     if (!myShiftState) {
-                       this->HighlightProp( NULL );
-                       aSel->ClearIObjects();
-                     }
-                     aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
-                     aSel->AddIObject( IO, false );
-                   }
-                 }
-               }else{
-                 if (!myShiftState) {
-                   this->HighlightProp( NULL );
-                   aSel->ClearIObjects();
-                 }
-                 int anEdgeId = GetEdgeId(picker,SActor,anObjId);
-                 if (anEdgeId >= 0) {
-                   if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
-                   aSel->AddOrRemoveIndex( IO, anObjId, true, false);
-                   aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true );
-                   aSel->AddIObject( IO, false );
-                 } 
-               }
-             }
-           } else {
-             this->HighlightProp( NULL );
-             aSel->ClearIObjects();
-           }
+            int aVtkId = picker->GetCellId();
+            if ( aVtkId >= 0 && SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
+              int anObjId = SActor->GetElemObjId(aVtkId);
+              if(anObjId >= 0){
+                Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+                if(aSelectionMode != EdgeOfCellSelection) {
+                  if(CheckDimensionId(aSelectionMode,SActor,anObjId)){
+                    if (IsSelected(IO,aSel)) {
+                      // This IO is already in the selection
+                      aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+                    } else {
+                      if (!myShiftState) {
+                        this->HighlightProp( NULL );
+                        aSel->ClearIObjects();
+                      }
+                      aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+                      aSel->AddIObject( IO, false );
+                    }
+                  }
+                }else{
+                  if (!myShiftState) {
+                    this->HighlightProp( NULL );
+                    aSel->ClearIObjects();
+                  }
+                  int anEdgeId = GetEdgeId(picker,SActor,anObjId);
+                  if (anEdgeId >= 0) {
+                    aSel->AddOrRemoveIndex( IO, anObjId, true, false);
+                    aSel->AddOrRemoveIndex( IO, -anEdgeId-1, true, true );
+                    aSel->AddIObject( IO, false );
+                  } 
+                }
+              }
+            } else {
+              this->HighlightProp( NULL );
+              aSel->ClearIObjects();
+            }
           } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
-           int aVtkId = picker->GetPointId();
-           if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
-             if ( SActor && SActor->hasIO() ) {
-               int anObjId = SActor->GetNodeObjId(aVtkId);
-               if(anObjId >= 0){
-                 Handle(SALOME_InteractiveObject) IO = SActor->getIO();
-                 if(IsSelected(IO,aSel)) {
-                   // This IO is already in the selection
-                   aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
-                 } else {
-                   if(!myShiftState) {
-                     this->HighlightProp( NULL );
-                     aSel->ClearIObjects();
-                   }
-                   if(MYDEBUG) INFOS(" PointId : "<<anObjId);
-                   aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
-                   aSel->AddIObject( IO, false );
-                 }
-               }
-             }
-           } else {
-             this->HighlightProp( NULL );
-             aSel->ClearIObjects();
-           } 
-         } else {
-           if ( SActor && SActor->hasIO() ) {
-             this->PropPicked++;
-             Handle(SALOME_InteractiveObject) IO = SActor->getIO();
-             if(IsSelected(IO,aSel)) {
-               // This IO is already in the selection
-               if(myShiftState) {
-                 aSel->RemoveIObject(IO);
-               }
-             }
-             else {
-               if(!myShiftState) {
-                 this->HighlightProp( NULL );
-                 aSel->ClearIObjects();
-               }
-               aSel->AddIObject( IO, false );
-             }
-           }else{
-             // No selection clear all
-             this->PropPicked = 0;
-             this->HighlightProp( NULL );
-             aSel->ClearIObjects();
-           }
-         }
-         m_Interactor->EndPickCallback();
+            int aVtkId = picker->GetPointId();
+            if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
+              if ( SActor && SActor->hasIO() ) {
+                int anObjId = SActor->GetNodeObjId(aVtkId);
+                if(anObjId >= 0){
+                  Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+                  if(IsSelected(IO,aSel)) {
+                    // This IO is already in the selection
+                    aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+                  } else {
+                    if(!myShiftState) {
+                      this->HighlightProp( NULL );
+                      aSel->ClearIObjects();
+                    }
+                    aSel->AddOrRemoveIndex( IO, anObjId, myShiftState, false );
+                    aSel->AddIObject( IO, false );
+                  }
+                }
+              }
+            } else {
+              this->HighlightProp( NULL );
+              aSel->ClearIObjects();
+            } 
+          } else {
+            if ( SActor && SActor->hasIO() ) {
+              this->PropPicked++;
+              Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+              if(IsSelected(IO,aSel)) {
+                // This IO is already in the selection
+                if(myShiftState) {
+                  aSel->RemoveIObject(IO);
+                }
+              }
+              else {
+                if(!myShiftState) {
+                  this->HighlightProp( NULL );
+                  aSel->ClearIObjects();
+                }
+                aSel->AddIObject( IO, false );
+              }
+            }else{
+              // No selection clear all
+              this->PropPicked = 0;
+              this->HighlightProp( NULL );
+              aSel->ClearIObjects();
+            }
+          }
+          m_Interactor->EndPickCallback();
         } else {
           //processing rectangle selection
-         QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType();
-         if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
-         m_Interactor->StartPickCallback();
-
-         if (!myShiftState) {
-           this->PropPicked = 0;
-           this->HighlightProp( NULL );
-           aSel->ClearIObjects();
-         }
-
-         // Compute bounds
-         //      vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
-         QRect rect(myPoint, myOtherPoint);
-         rect = rect.normalize();
-         int w, h;
-         m_Interactor->GetSize(w, h);
-         int x1, y1, x2, y2;
-         x1 = rect.left(); 
-         y1 = h - rect.top() - 1;
-         x2 = rect.right(); 
-         y2 = h - rect.bottom() - 1;
-
-         switch (aSelectionMode) {
-         case NodeSelection: {
-           if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) {
-             vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
-             aListActors->InitTraversal();
-             while (vtkActor* aActor = aListActors->GetNextActor()) {
-               if (!aActor->GetVisibility()) 
-                 continue;
-               if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
-                 if (SActor->hasIO()) {
-                   Handle(SALOME_InteractiveObject) IO = SActor->getIO();
-                   if (IO.IsNull()) 
-                     continue;
-                   if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
-                     continue;
-                   if (vtkDataSet* aDataSet = SActor->GetInput()) {
-                     SALOME_Selection::TContainerOfId anIndices;
-                     for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
-                       float aPoint[3];
-                       aDataSet->GetPoint(i,aPoint);
-                       if (IsInRect(aPoint,x1,y1,x2,y2)){
-                         float aDisp[3];
-                         ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
-                         if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
-                           if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
-                             if(anActorCollection->IsItemPresent(SActor)){
-                               float aPickedPoint[3];
-                               aPointPicker->GetMapperPosition(aPickedPoint);
-                               vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
-                               if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
-                                 int anObjId = SActor->GetNodeObjId(aVtkId);
-                                 anIndices.insert(anObjId);
-                               }
-                             }
-                           }
-                         }
-                       }
-                     }
-                     if (!anIndices.empty()) {
-                       aSel->AddOrRemoveIndex(IO, anIndices, true, false);
-                       aSel->AddIObject(IO, false);
-                       anIndices.clear();
-                     }else{
-                       aSel->RemoveIObject(IO, false);
-                     }
-                   }
-                 }
-               }
-             }
-           }
-           break;
-         }
-         case CellSelection:
-         case EdgeOfCellSelection:
-         case EdgeSelection:
-         case FaceSelection:
-         case VolumeSelection: 
-           {
-             vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
-             picker->SetTolerance(0.001);
-             picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-             
-             vtkActorCollection* aListActors = picker->GetActors();
-             aListActors->InitTraversal();
-             while(vtkActor* aActor = aListActors->GetNextActor()) {
-               if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
-                 if (aSActor->hasIO()) {
-                   Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
-                   if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
-                     continue;
-                   VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
-                   if ( !cellList.empty() ) {
-                     if(MYDEBUG) INFOS ( " NAME Actor : " << aSActor->getName() );
-                     SALOME_Selection::TContainerOfId anIndexes;
-                     VTKViewer_CellDataSet::iterator it;
-                     for ( it = cellList.begin(); it != cellList.end(); ++it ) {
-                       int aCellId = (*it).cellId;
-                       
-                       if ( !IsValid( aSActor, aCellId ) )
-                         continue;
-                       
-                       int anObjId = aSActor->GetElemObjId(aCellId);
-                       if (anObjId != -1){
-                         if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
-                           anIndexes.insert(anObjId);
-                         }
-                       }
-                     }
-                     aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
-                     aSel->AddIObject(aIO, false);
-                   }
-                 }
-               }
-             }
-           }
-           break;          
-         case ActorSelection: // objects selection
-           {
-             vtkSmartPointer<VTKViewer_RectPicker> picker = VTKViewer_RectPicker::New();
-             picker->SetTolerance(0.001);
-             picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
-             vtkActorCollection* aListActors = picker->GetActors();
-             SALOME_ListIO aListIO;
-             aListActors->InitTraversal();
-             while(vtkActor* aActor = aListActors->GetNextActor()) {
-               if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
-                 if (aSActor->hasIO()) {
-                   Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
-                   if (!IsStored(aIO,aListIO))
-                     aListIO.Append(aIO);
-                 }
-               }
-             }
-             if (!aListIO.IsEmpty()) {
-               SALOME_ListIteratorOfListIO It(aListIO);
-               for(;It.More();It.Next()) {
-                 Handle(SALOME_InteractiveObject) IOS = It.Value();
-                 this->PropPicked++;
-                 aSel->AddIObject( IOS, false );
-               }
-             }
-           } // end case 4
-         } //end switch
-         m_Interactor->EndPickCallback();
-       }
-       aActiveStudy->update3dViewers();
+          QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType();
+          if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
+          m_Interactor->StartPickCallback();
+
+          if (!myShiftState) {
+            this->PropPicked = 0;
+            this->HighlightProp( NULL );
+            aSel->ClearIObjects();
+          }
+
+          // Compute bounds
+          //      vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
+          QRect rect(myPoint, myOtherPoint);
+          rect = rect.normalize();
+          int w, h;
+          m_Interactor->GetSize(w, h);
+          int x1, y1, x2, y2;
+          x1 = rect.left(); 
+          y1 = h - rect.top() - 1;
+          x2 = rect.right(); 
+          y2 = h - rect.bottom() - 1;
+
+          switch (aSelectionMode) {
+          case NodeSelection: {
+            if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(m_Interactor->GetPicker()) ) {
+              vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
+              aListActors->InitTraversal();
+              while (vtkActor* aActor = aListActors->GetNextActor()) {
+                if (!aActor->GetVisibility()) 
+                  continue;
+                if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
+                  if (SActor->hasIO()) {
+                    Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+                    if (IO.IsNull()) 
+                      continue;
+                    if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
+                      continue;
+                    if (vtkDataSet* aDataSet = SActor->GetInput()) {
+                      SALOME_Selection::TContainerOfId anIndices;
+                      for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
+                        float aPoint[3];
+                        aDataSet->GetPoint(i,aPoint);
+                        if (IsInRect(aPoint,x1,y1,x2,y2)){
+                          float aDisp[3];
+                          ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
+                          if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
+                            if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
+                              if(anActorCollection->IsItemPresent(SActor)){
+                                float aPickedPoint[3];
+                                aPointPicker->GetMapperPosition(aPickedPoint);
+                                vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
+                                if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
+                                  int anObjId = SActor->GetNodeObjId(aVtkId);
+                                  anIndices.insert(anObjId);
+                                }
+                              }
+                            }
+                          }
+                        }
+                      }
+                      if (!anIndices.empty()) {
+                        aSel->AddOrRemoveIndex(IO, anIndices, true, false);
+                        aSel->AddIObject(IO, false);
+                        anIndices.clear();
+                      }else{
+                        aSel->RemoveIObject(IO, false);
+                      }
+                    }
+                  }
+                }
+              }
+            }
+            break;
+          }
+          case CellSelection:
+          case EdgeOfCellSelection:
+          case EdgeSelection:
+          case FaceSelection:
+          case VolumeSelection: 
+            {
+              vtkSmartPointer<VTKViewer_CellAreaPicker> picker = VTKViewer_CellRectPicker::New();
+              picker->SetTolerance(0.001);
+              picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
+              
+              vtkActorCollection* aListActors = picker->GetActors();
+              aListActors->InitTraversal();
+              while(vtkActor* aActor = aListActors->GetNextActor()) {
+                if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
+                  if (aSActor->hasIO()) {
+                    Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
+                    if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
+                      continue;
+                    VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
+                    if ( !cellList.empty() ) {
+                      SALOME_Selection::TContainerOfId anIndexes;
+                      VTKViewer_CellDataSet::iterator it;
+                      for ( it = cellList.begin(); it != cellList.end(); ++it ) {
+                        int aCellId = (*it).cellId;
+                        
+                        if ( !IsValid( aSActor, aCellId ) )
+                          continue;
+                        
+                        int anObjId = aSActor->GetElemObjId(aCellId);
+                        if (anObjId != -1){
+                          if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
+                            anIndexes.insert(anObjId);
+                          }
+                        }
+                      }
+                      aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
+                      aSel->AddIObject(aIO, false);
+                    }
+                  }
+                }
+              }
+            }
+            break;          
+          case ActorSelection: // objects selection
+            {
+              vtkSmartPointer<VTKViewer_AreaPicker> picker = VTKViewer_AreaPicker::New();
+              picker->SetTolerance(0.001);
+              picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
+
+              vtkActorCollection* aListActors = picker->GetActors();
+              SALOME_ListIO aListIO;
+              aListActors->InitTraversal();
+              while(vtkActor* aActor = aListActors->GetNextActor()) {
+                if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
+                  if (aSActor->hasIO()) {
+                    Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
+                    if (!IsStored(aIO,aListIO))
+                      aListIO.Append(aIO);
+                  }
+                }
+              }
+              if (!aListIO.IsEmpty()) {
+                SALOME_ListIteratorOfListIO It(aListIO);
+                for(;It.More();It.Next()) {
+                  Handle(SALOME_InteractiveObject) IOS = It.Value();
+                  this->PropPicked++;
+                  aSel->AddIObject( IOS, false );
+                }
+              }
+            } // end case 4
+          } //end switch
+          m_Interactor->EndPickCallback();
+        }
+        aActiveStudy->update3dViewers();
       } 
     } 
     break;
@@ -1203,12 +1178,8 @@ void VTKViewer_InteractorStyle::onOperation(QPoint mousePos)
     }
   case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      QPainter p(myGUIWindow);
-      p.setPen(Qt::lightGray);
-      p.setRasterOp(Qt::XorROP);
-      p.drawRect(QRect(myPoint, myOtherPoint));
       myOtherPoint = mousePos;
-      p.drawRect(QRect(myPoint, myOtherPoint));
+      drawRect();
       break;
     }
   }
@@ -1252,38 +1223,36 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) {
     if ( aVtkId >= 0 ) {
       int anObjId = SActor->GetElemObjId(aVtkId);
       if ( SActor && SActor->hasIO() && IsValid( SActor, aVtkId ) ) {
-       bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId);
-       bool aResult = anIsSameObjId;
-       if(!anIsSameObjId) {
-         if(aSelectionMode != EdgeOfCellSelection) {
-           aResult = CheckDimensionId(aSelectionMode,SActor,anObjId);
-           if(aResult){
-             mySelectedActor = SActor;
-             myElemId = anObjId;
-             if(MYDEBUG) INFOS(" CellId : "<<anObjId);
-             m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor);
-           }
-         }
-       }
-       if(aSelectionMode == EdgeOfCellSelection){
-         int anEdgeId = GetEdgeId(picker,SActor,anObjId);
-         bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
-         aResult = anIsSameEdgeId;
-         if(!anIsSameEdgeId) {
-           aResult = (anEdgeId >= 0);
-           if (aResult) {
-             mySelectedActor = SActor;
-             myEdgeId = anEdgeId;
-             myElemId = anObjId;
-             if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
-             m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor);
-           } 
-         }
-       }
-       if(aResult) {
-         myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
-         myPreSelectionActor->SetVisibility(true);
-       }
+        bool anIsSameObjId = (mySelectedActor == SActor && myElemId == anObjId);
+        bool aResult = anIsSameObjId;
+        if(!anIsSameObjId) {
+          if(aSelectionMode != EdgeOfCellSelection) {
+            aResult = CheckDimensionId(aSelectionMode,SActor,anObjId);
+            if(aResult){
+              mySelectedActor = SActor;
+              myElemId = anObjId;
+              m_Interactor->setCellData(anObjId,SActor,myPreSelectionActor);
+            }
+          }
+        }
+        if(aSelectionMode == EdgeOfCellSelection){
+          int anEdgeId = GetEdgeId(picker,SActor,anObjId);
+          bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
+          aResult = anIsSameEdgeId;
+          if(!anIsSameEdgeId) {
+            aResult = (anEdgeId >= 0);
+            if (aResult) {
+              mySelectedActor = SActor;
+              myEdgeId = anEdgeId;
+              myElemId = anObjId;
+              m_Interactor->setEdgeData(anObjId,SActor,-anEdgeId-1,myPreSelectionActor);
+            } 
+          }
+        }
+        if(aResult) {
+          myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
+          myPreSelectionActor->SetVisibility(true);
+        }
       }
     }
   }
@@ -1291,46 +1260,44 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) {
     int aVtkId = picker->GetPointId();
     if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ) {
       if ( SActor && SActor->hasIO() ) {
-       int anObjId = SActor->GetNodeObjId(aVtkId);
-       bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId);
-       if(!anIsSameObjId) {
-         mySelectedActor = SActor;
-         myNodeId = anObjId;
-         if(MYDEBUG) INFOS(" PointId : "<<anObjId);
-         m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor);
-       }
-       myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
-       myPreSelectionActor->SetVisibility(true);
+        int anObjId = SActor->GetNodeObjId(aVtkId);
+        bool anIsSameObjId = (mySelectedActor == SActor && myNodeId == anObjId);
+        if(!anIsSameObjId) {
+          mySelectedActor = SActor;
+          myNodeId = anObjId;
+          m_Interactor->setPointData(anObjId,SActor,myPreSelectionActor);
+        }
+        myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
+        myPreSelectionActor->SetVisibility(true);
       }
     }
   }
   else if ( vtkPicker::SafeDownCast(aPicker) ) {
     if ( SActor ) {
       if ( myPreViewActor != SActor ) {
-       if ( myPreViewActor != NULL ) {
-         myPreViewActor->SetPreSelected( false );
-       }
-       myPreViewActor = SActor;
-             
-       if ( SActor->hasIO() ) {
-         Handle( SALOME_InteractiveObject) IO = SActor->getIO();
-         if ( !IsSelected(IO,Sel) ) {
+        if ( myPreViewActor != NULL ) {
+          myPreViewActor->SetPreSelected( false );
+        }
+        myPreViewActor = SActor;
+              
+        if ( SActor->hasIO() ) {
+          Handle( SALOME_InteractiveObject) IO = SActor->getIO();
+          if ( !IsSelected(IO,Sel) ) {
             // Find All actors with same IO
-           vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
-           theActors->InitTraversal();
-           while( vtkActor *ac = theActors->GetNextActor() ) {
-             if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
-               if ( anActor->hasIO() ) {
-                 Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
-                 if(IO->isSame(IOS)) {
-                   anActor->SetPreSelected( true );
-                 }
-               }
-             }
-           }
-           //if(MYDEBUG) INFOS ( " NAME PREVIEW " << SActor->getName() );
-         }
-       }
+            vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
+            theActors->InitTraversal();
+            while( vtkActor *ac = theActors->GetNextActor() ) {
+              if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
+                if ( anActor->hasIO() ) {
+                  Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
+                  if(IO->isSame(IOS)) {
+                    anActor->SetPreSelected( true );
+                  }
+                }
+              }
+            }
+          }
+        }
       }
     } else {
       myPreViewActor = NULL;
@@ -1381,17 +1348,17 @@ void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int f
 {
   vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
   double viewFocus[4], focalDepth, viewPoint[3];
-  float newPickPoint[4], oldPickPoint[4], motionVector[3];
+  double newPickPoint[4], oldPickPoint[4], motionVector[3];
   cam->GetFocalPoint(viewFocus);
 
   this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
-                             viewFocus[2], viewFocus);
+                              viewFocus[2], viewFocus);
   focalDepth = viewFocus[2];
 
   this->ComputeDisplayToWorld(double(toX), double(toY),
-                             focalDepth, newPickPoint);
+                              focalDepth, newPickPoint);
   this->ComputeDisplayToWorld(double(fromX),double(fromY),
-                             focalDepth, oldPickPoint);
+                              focalDepth, oldPickPoint);
   
   // camera motion is reversed
   motionVector[0] = oldPickPoint[0] - newPickPoint[0];
@@ -1401,30 +1368,30 @@ void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int f
   cam->GetFocalPoint(viewFocus);
   cam->GetPosition(viewPoint);
   cam->SetFocalPoint(motionVector[0] + viewFocus[0],
-                    motionVector[1] + viewFocus[1],
-                    motionVector[2] + viewFocus[2]);
+                     motionVector[1] + viewFocus[1],
+                     motionVector[2] + viewFocus[2]);
   cam->SetPosition(motionVector[0] + viewPoint[0],
-                  motionVector[1] + viewPoint[1],
-                  motionVector[2] + viewPoint[2]);
+                   motionVector[1] + viewPoint[1],
+                   motionVector[2] + viewPoint[2]);
 }
 
 
 /*! Checks: is the given Actor within display coordinates?*/
 bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor, 
-                                              const int left, const int top, 
-                                              const int right, const int bottom)
+                                               const int left, const int top, 
+                                               const int right, const int bottom)
 {
-  float* aBounds = theActor->GetBounds();
-  float aMin[3], aMax[3];
+  double* aBounds = theActor->GetBounds();
+  double aMin[3], aMax[3];
   ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
   ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
   if (aMin[0] > aMax[0]) {
-    float aBuf = aMin[0];
+    double aBuf = aMin[0];
     aMin[0] = aMax[0];
     aMax[0] = aBuf;
   }
   if (aMin[1] > aMax[1]) {
-    float aBuf = aMin[1];
+    double aBuf = aMin[1];
     aMin[1] = aMax[1];
     aMax[1] = aBuf;    
   }
@@ -1435,20 +1402,20 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor,
 
 /*! Checks: is the given Cell within display coordinates?*/
 bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell, 
-                                              const int left, const int top, 
-                                              const int right, const int bottom)
+                                               const int left, const int top, 
+                                               const int right, const int bottom)
 {
-  float* aBounds = theCell->GetBounds();
-  float aMin[3], aMax[3];
+  double* aBounds = theCell->GetBounds();
+  double aMin[3], aMax[3];
   ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
   ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
   if (aMin[0] > aMax[0]) {
-    float aBuf = aMin[0];
+    double aBuf = aMin[0];
     aMin[0] = aMax[0];
     aMax[0] = aBuf;
   }
   if (aMin[1] > aMax[1]) {
-    float aBuf = aMin[1];
+    double aBuf = aMin[1];
     aMin[1] = aMax[1];
     aMax[1] = aBuf;    
   }
@@ -1457,11 +1424,11 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell,
 }
 
 /*!Checks: is given point \a thePoint in rectangle*/
-bool VTKViewer_InteractorStyle::IsInRect(float* thePoint, 
-                                              const int left, const int top, 
-                                              const int right, const int bottom)
+bool VTKViewer_InteractorStyle::IsInRect(double* thePoint, 
+                                         const int left, const int top, 
+                                         const int right, const int bottom)
 {
-  float aPnt[3];
+  double aPnt[3];
   ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
 
   return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));