Salome HOME
introduction of penta18 in VTK viewer
[modules/gui.git] / src / VTKViewer / VTKViewer_InteractorStyle.cxx
index 3e4f69719ba91c9b1c8e6b245a930bf2652e8f08..53221dd592c555c6cec874e0cec2ab9c3505e375 100644 (file)
@@ -1,43 +1,38 @@
-//  SALOME VTKViewer : build VTK viewer into Salome desktop
+// Copyright (C) 2007-2016  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
 //
-//  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 free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  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,23 @@ 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()
 {
   m_Trihedron = 0;
@@ -109,19 +92,28 @@ 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.
+ *\param theBlue  - blue color.
+ *\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;
@@ -130,30 +122,45 @@ void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const
   myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
 }
 
-//----------------------------------------------------------------------------
+
+/*!Set render window interactor
+ *\param theInteractor - interactor.
+ */
 void VTKViewer_InteractorStyle::SetInteractor(vtkRenderWindowInteractor *theInteractor){
   m_Interactor = dynamic_cast<VTKViewer_RenderWindowInteractor*>(theInteractor);
   Superclass::SetInteractor(theInteractor);
 }
 
-//----------------------------------------------------------------------------
+
+/*!Set view window.
+ *\param theViewWnd - SALOME VTKViewer_ViewWindow
+ */
 void VTKViewer_InteractorStyle::setViewWnd(VTKViewer_ViewWindow* theViewWnd ){
   m_ViewWnd = theViewWnd;
   m_ViewWnd->AddActor(myPreSelectionActor);
   myPreSelectionActor->Delete();
 }
 
-//----------------------------------------------------------------------------
+
+/*!Set GUI window.
+ *\param theWindow - QWidget window.
+ */
 void VTKViewer_InteractorStyle::setGUIWindow(QWidget* theWindow){
   myGUIWindow = theWindow;
 }
 
-//----------------------------------------------------------------------------
+
+/*!Set trihedron.
+ *\param theTrihedron - SALOME VTKViewer_Trihedron
+ */
 void VTKViewer_InteractorStyle::setTriedron(VTKViewer_Trihedron* theTrihedron){
   m_Trihedron = theTrihedron;
 }
 
-//----------------------------------------------------------------------------
+/*!Rotate camera.
+ *\param dx - 
+ *\param dy - 
+ */
 void VTKViewer_InteractorStyle::RotateXY(int dx, int dy)
 {
   double rxf;
@@ -181,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);   
@@ -190,7 +196,7 @@ 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)
 {
   if (this->CurrentRenderer == NULL) return;
@@ -212,7 +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;
@@ -223,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;
@@ -239,10 +244,15 @@ 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)
+ *\param x - x coordinate
+ *\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)
@@ -252,9 +262,14 @@ 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)
+ *\param x - x coordinate
+ *\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);
@@ -283,11 +298,16 @@ 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)
+ *\param x - x coordinate (not used)
+ *\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
@@ -298,10 +318,15 @@ 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)
+ *\param x - x coordinate
+ *\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)) 
     {
@@ -330,11 +355,16 @@ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl,
 }
 
 
-//----------------------------------------------------------------------------
+/*!On middle button up event.
+ *\param ctrl  - CTRL  (not used)
+ *\param shift - SHIFT (on/off - integer 0/1)
+ *\param x - x coordinate (not used)
+ *\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
@@ -345,10 +375,15 @@ 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)
+ *\param x - x coordinate
+ *\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)) 
     {
@@ -376,11 +411,16 @@ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl,
   }
 }
 
-//----------------------------------------------------------------------------
+/*!On right button up event.
+ *\param ctrl  - CTRL  (not used)
+ *\param shift - SHIFT (on/off - integer 0/1)
+ *\param x - x coordinate (not used)
+ *\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
@@ -390,8 +430,9 @@ void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
   }
 }
 
-//----------------------------------------------------------------------------
-/* XPM */
+/*! @name XPM - x pixmaps. */
+//@{
+/*!Image Zoom cursor*/
 const char* imageZoomCursor[] = { 
 "32 32 3 1",
 ". c None",
@@ -430,6 +471,7 @@ const char* imageZoomCursor[] = {
 "................................",
 "................................"};
 
+/*!Image rotate cursor*/
 const char* imageRotateCursor[] = { 
 "32 32 3 1",
 ". c None",
@@ -467,25 +509,23 @@ const char* imageRotateCursor[] = {
 "................................",
 "................................",
 "................................"};
+//@}
 
-
-//----------------------------------------------------------------------------
-// loads cursors for viewer operations - zoom, pan, etc...
+/*! 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
+/*! event filter - controls mouse and keyboard events during viewer operations*/
 bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event)
 {
   if (!myGUIWindow) return false;
@@ -498,8 +538,7 @@ bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event)
 }
 
 
-//----------------------------------------------------------------------------
-// starts Zoom operation (e.g. through menu command)
+/*! starts Zoom operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startZoom()
 {
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
@@ -513,8 +552,7 @@ void VTKViewer_InteractorStyle::startZoom()
 }
 
 
-//----------------------------------------------------------------------------
-// starts Pan operation (e.g. through menu command)
+/*! starts Pan operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startPan()
 {
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
@@ -527,8 +565,7 @@ void VTKViewer_InteractorStyle::startPan()
   qApp->installEventFilter(this);
 }
 
-//----------------------------------------------------------------------------
-// starts Rotate operation (e.g. through menu command)
+/*! starts Rotate operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startRotate()
 {
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
@@ -542,8 +579,7 @@ void VTKViewer_InteractorStyle::startRotate()
 }
 
 
-//----------------------------------------------------------------------------
-// starts Spin operation (e.g. through menu command)
+/*! starts Spin operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startSpin()
 {
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
@@ -558,8 +594,7 @@ void VTKViewer_InteractorStyle::startSpin()
 
 
 
-//----------------------------------------------------------------------------
-// starts Fit Area operation (e.g. through menu command)
+/*! starts Fit Area operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startFitArea()
 {
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
@@ -573,7 +608,7 @@ void VTKViewer_InteractorStyle::startFitArea()
 }
 
 
-//----------------------------------------------------------------------------
+/*!View fit all.*/
 void  VTKViewer_InteractorStyle::ViewFitAll() {
   int aTriedronWasVisible = false;
   if(m_Trihedron){
@@ -593,9 +628,30 @@ void  VTKViewer_InteractorStyle::ViewFitAll() {
   ::ResetCameraClippingRange(CurrentRenderer);
 }
 
+/*!View fit selection.*/
+void  VTKViewer_InteractorStyle::ViewFitSelection() {
+
+  vtkActorCollection* aSelectedCollection = vtkActorCollection::New();
+
+  VTK::ActorCollectionCopy aCopy( CurrentRenderer->GetActors() );
+  vtkActorCollection* aCollection = aCopy.GetActors();
+  aCollection->InitTraversal();
+  while ( vtkActor* aProp = aCollection->GetNextActor() )
+    if ( VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast( aProp ) )
+      if ( anActor->isPreselected() )
+        aSelectedCollection->AddItem( aProp );
+
+  double bounds[6];
+  ::ComputeBounds( aSelectedCollection, bounds );
+
+  if ( aSelectedCollection->GetNumberOfItems() && ::isBoundValid( bounds ) ) {
+    CurrentRenderer->ResetCamera( bounds );
+    CurrentRenderer->ResetCameraClippingRange( bounds );
+  }
+}
+
 
-//----------------------------------------------------------------------------
-// starts Global Panning operation (e.g. through menu command)
+/*! starts Global Panning operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startGlobalPan()
 {
   if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
@@ -618,8 +674,7 @@ void VTKViewer_InteractorStyle::startGlobalPan()
 }
 
 
-//----------------------------------------------------------------------------
-// returns TRUE if needs redrawing
+/*!\retval \c true if needs redrawing*/
 bool VTKViewer_InteractorStyle::needsRedrawing()
 {
   return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM   ||
@@ -630,8 +685,12 @@ bool VTKViewer_InteractorStyle::needsRedrawing()
 }
 
 
-//----------------------------------------------------------------------------
-// fits viewer contents to rect
+/*! fits viewer contents to rectangle
+ *\param left - left side
+ *\param top  - top side
+ *\param right  - right side
+ *\param bottom  - bottom side 
+ */
 void VTKViewer_InteractorStyle::fitRect(const int left, 
                                        const int top, 
                                        const int right, 
@@ -664,8 +723,7 @@ void VTKViewer_InteractorStyle::fitRect(const int left,
 }
 
 
-//----------------------------------------------------------------------------
-// starts viewer operation (!internal usage!)
+/*! starts viewer operation (!internal usage!)*/
 void VTKViewer_InteractorStyle::startOperation(int operation)
 {
   switch(operation)
@@ -693,8 +751,7 @@ void VTKViewer_InteractorStyle::startOperation(int operation)
 }
 
 
-//----------------------------------------------------------------------------
-// sets proper cursor for window when viewer operation is activated
+/*! sets proper cursor for window when viewer operation is activated*/
 void VTKViewer_InteractorStyle::setCursor(const int operation)
 {
   if (!myGUIWindow) return;
@@ -733,9 +790,34 @@ 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!)
+/*! called when viewer operation started (!put necessary initialization here!)*/
 void VTKViewer_InteractorStyle::onStartOperation()
 {
   if (!myGUIWindow) return;
@@ -745,10 +827,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:
@@ -761,8 +840,7 @@ void VTKViewer_InteractorStyle::onStartOperation()
 }
 
 
-//----------------------------------------------------------------------------
-// called when viewer operation finished (!put necessary post-processing here!)
+/*! called when viewer operation finished (!put necessary post-processing here!)*/
 void VTKViewer_InteractorStyle::onFinishOperation() 
 {
   if (!myGUIWindow) return;
@@ -800,260 +878,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;
@@ -1076,7 +1150,7 @@ void VTKViewer_InteractorStyle::onFinishOperation()
 */
 }
 
-// called during viewer operation when user moves mouse (!put necessary processing here!)
+/*! called during viewer operation when user moves mouse (!put necessary processing here!)*/
 void VTKViewer_InteractorStyle::onOperation(QPoint mousePos) 
 {
   if (!myGUIWindow) return;
@@ -1126,12 +1200,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;
     }
   }
@@ -1139,7 +1209,7 @@ void VTKViewer_InteractorStyle::onOperation(QPoint mousePos)
   this->LastPos[1] = h - mousePos.y() - 1;
 }
 
-// called when selection mode changed (!put necessary initialization here!)
+/*! called when selection mode changed (!put necessary initialization here!)*/
 void VTKViewer_InteractorStyle::OnSelectionModeChanged()
 {
   
@@ -1148,8 +1218,9 @@ void VTKViewer_InteractorStyle::OnSelectionModeChanged()
   mySelectedActor = NULL;
 }
 
-// called when user moves mouse inside viewer window and there is no active viewer operation 
-// (!put necessary processing here!)
+/*! called when user moves mouse inside viewer window and there is no active viewer operation \n
+ * (!put necessary processing here!)
+ */
 void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) {
   // processing highlighting
 //  SUIT_Study* anActiveStudy = SUIT_Application::getDesktop()->getActiveStudy();
@@ -1174,38 +1245,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);
+        }
       }
     }
   }
@@ -1213,46 +1282,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;
@@ -1273,7 +1340,7 @@ void VTKViewer_InteractorStyle::onCursorMove(QPoint mousePos) {
   this->LastPos[1] = y;*/
 }
 
-// called on finsh GlobalPan operation 
+/*! called on finsh GlobalPan operation */
 void VTKViewer_InteractorStyle::Place(const int theX, const int theY) 
 {
   if (this->CurrentRenderer == NULL) {
@@ -1298,22 +1365,22 @@ void VTKViewer_InteractorStyle::Place(const int theX, const int theY)
 
 
 
-// Translates view from Point to Point
+/*! Translates view from Point to Point*/
 void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int fromY)
 {
   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];
@@ -1323,30 +1390,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?
+/*! 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;    
   }
@@ -1355,22 +1422,22 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor,
 }
 
 
-/// Checks: is the given Cell within display coordinates?
+/*! 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;    
   }
@@ -1378,34 +1445,45 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell,
   return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
 }
 
-
-bool VTKViewer_InteractorStyle::IsInRect(float* thePoint, 
-                                              const int left, const int top, 
-                                              const int right, const int bottom)
+/*!Checks: is given point \a thePoint in rectangle*/
+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));
 }
 
+/*!Set filter \a theFilter*/
 void  VTKViewer_InteractorStyle::SetFilter( const Handle(VTKViewer_Filter)& theFilter )
 {
   myFilters[ theFilter->GetId() ] = theFilter;
 }
 
+/*!Checks: is filter present (with id \a theId)
+ *\param theId - filter id.
+ */
 bool  VTKViewer_InteractorStyle::IsFilterPresent( const int theId )
 {
   return myFilters.find( theId ) != myFilters.end();
 }
 
+/*!Remove filter with id \a theId.
+ *\param theId - filter id.
+ */
 void  VTKViewer_InteractorStyle::RemoveFilter( const int theId )
 {
   if ( IsFilterPresent( theId ) )
     myFilters.erase( theId );
 }
 
-
+/*!Checks: is valid cell(node) with id \a theId in actor \a theActor.
+ *\param theActor - VTKViewer_Actor pointer.
+ *\param theId    - cell id.
+ *\param theIsNode - boolean flag, if \c true - node, else - cell.
+ */
 bool VTKViewer_InteractorStyle::IsValid( VTKViewer_Actor* theActor,
                                                const int     theId,
                                                const bool    theIsNode )
@@ -1421,21 +1499,33 @@ bool VTKViewer_InteractorStyle::IsValid( VTKViewer_Actor* theActor,
   return true;
 }
 
+/*!Gets filter handle by filter id \a theId.*/
 Handle(VTKViewer_Filter) VTKViewer_InteractorStyle::GetFilter( const int theId )
 {
   return IsFilterPresent( theId ) ? myFilters[ theId ] : Handle(VTKViewer_Filter)();
 }
 
+/*!Increment pan.
+ *\param incrX - X coordinate increment.
+ *\param incrY - Y coordinate increment.
+ */
 void VTKViewer_InteractorStyle::IncrementalPan( const int incrX, const int incrY )
 {
   this->PanXY( incrX, incrY, 0, 0 );
 }
 
+/*!Increment zoom.
+ *\param incr - zoom increment.
+ */
 void VTKViewer_InteractorStyle::IncrementalZoom( const int incr )
 {
   this->DollyXY( incr, incr );
 }
 
+/*!Increment rotate.
+ *\param incrX - X coordinate increment.
+ *\param incrY - Y coordinate increment.
+ */
 void VTKViewer_InteractorStyle::IncrementalRotate( const int incrX, const int incrY )
 {
   this->RotateXY( incrX, -incrY );