Salome HOME
Update copyright information
[modules/visu.git] / src / OBJECT / VISU_Actor.cxx
index 431ffd681daa3ba48a99beb3543ccea4d415e868..53cdcb54ad2461be1431b4bdedb7e40bda15a8ea 100644 (file)
@@ -1,45 +1,56 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU OBJECT : interactive object for VISU entities implementation
-//  File   : 
-//  Author : 
+//  File   :
+//  Author :
 //  Module : VISU
-
+//
 #include "VISU_Actor.h"
 
+#include "VISU_ActorFactory.h"
 #include "VISU_PickingSettings.h"
 #include "VISU_GaussPtsDeviceActor.h"
+#include "VISU_SelectVisiblePoints.h"
 
 #include "VISU_PipeLine.hxx"
+#include "VISU_UsedPointsFilter.hxx"
 
+#include "SVTK_Actor.h"
 #include "SVTK_Event.h"
 
+#include "VTKViewer_CellCenters.h"
+#include "VTKViewer_FramedTextActor.h"
 #include "VTKViewer_ShrinkFilter.h"
 #include "VTKViewer_GeometryFilter.h"
-#include "VISU_ActorFactory.h"
+
 #include "SALOME_InteractiveObject.hxx"
+
+#include "SUIT_Session.h"
+#include "SUIT_ResourceMgr.h"
+
 #include <stdexcept>
 #include <sstream>
+#include <cmath> // to use std::abs( int )
 
 // VTK Includes
 #include <vtkProperty.h>
@@ -48,6 +59,7 @@
 #include <vtkTextActor.h>
 #include <vtkProperty2D.h>
 #include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
 #include <vtkCellPicker.h>
 #include <vtkCell.h>
 #include <vtkPointPicker.h>
@@ -61,7 +73,6 @@
 #include <vtkActor2D.h>
 #include <vtkMaskPoints.h>
 #include <vtkLabeledDataMapper.h>
-#include <vtkSelectVisiblePoints.h>
 #include <vtkTextProperty.h>
 #include <vtkProperty2D.h>
 
@@ -107,8 +118,12 @@ VISU_Actor
   myIsShrinkable(false),
   myShrinkFilter(VTKViewer_ShrinkFilter::New()),
   myAnnotationMapper(vtkTextMapper::New()),
+#if (VTK_XVERSION < 0x050100)
   myAnnotationActor(vtkTextActor::New()),
-  myTextActor(VISU_FramedTextActor::New()),
+#else
+  myAnnotationActor(vtkActor2D::New()),
+#endif
+  myTextActor(VTKViewer_FramedTextActor::New()),
   myIsFeatureEdgesAllowed(false),
   myIsFeatureEdgesEnabled(false),
   myFeatureEdges(vtkFeatureEdges::New()),
@@ -136,35 +151,49 @@ VISU_Actor
   myFeatureEdges->Delete();
 
   myEventCallbackCommand->Delete();
-  myEventCallbackCommand->SetClientData(this); 
+  myEventCallbackCommand->SetClientData(this);
   myEventCallbackCommand->SetCallback(VISU_Actor::ProcessEvents);
 
   if( VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get() )
-    aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, 
-                                 myEventCallbackCommand.GetPointer(), 
-                                 myPriority);
-                                 
+    aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent,
+                                  myEventCallbackCommand.GetPointer(),
+                                  myPriority);
+
   //Definition of values labeling pipeline
 
   myValLblDataSet = vtkUnstructuredGrid::New();
 
-  myValCellCenters = vtkCellCenters::New();
+  myValCellCenters = VTKViewer_CellCenters::New();
   myValCellCenters->SetInput(myValLblDataSet);
 
+  myValUsedPoints = VISU_UsedPointsFilter::New();
+  myValUsedPoints->SetInput(myValLblDataSet);
+
   myValMaskPoints = vtkMaskPoints::New();
   myValMaskPoints->SetInput(myValCellCenters->GetOutput());
   myValMaskPoints->SetOnRatio(1);
-    
-  myValSelectVisiblePoints = vtkSelectVisiblePoints::New();
+
+  myValSelectVisiblePoints = VISU_SelectVisiblePoints::New();
   myValSelectVisiblePoints->SetInput(myValMaskPoints->GetOutput());
   myValSelectVisiblePoints->SelectInvisibleOff();
   myValSelectVisiblePoints->SetTolerance(0.1);
-    
+
+  char aFormat[16] = "%g";
+  SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+  if (aResourceMgr) {
+    // san: precision can be negative - this is used by double spin boxes
+    int aFloatingPrec = std::abs( aResourceMgr->integerValue("VISU", "visual_data_precision", 6) );
+    sprintf(aFormat, "%%.%dg", aFloatingPrec);
+    //cout << "$$$ aFormat = " << aFormat << endl;
+  }
+
   myValLabeledDataMapper = vtkLabeledDataMapper::New();
   myValLabeledDataMapper->SetInput(myValSelectVisiblePoints->GetOutput());
-  myValLabeledDataMapper->SetLabelFormat("%g");
+  //myValLabeledDataMapper->SetLabelFormat("%g");
+  //myValLabeledDataMapper->SetLabelFormat("%.20g");
+  myValLabeledDataMapper->SetLabelFormat(aFormat);
   myValLabeledDataMapper->SetLabelModeToLabelScalars();
-    
+
   vtkTextProperty* aClsTextProp = vtkTextProperty::New();
   aClsTextProp->SetFontFamilyToTimes();
   static int aCellsFontSize = 12;
@@ -174,13 +203,18 @@ VISU_Actor
   aClsTextProp->SetShadow(0);
   myValLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
   aClsTextProp->Delete();
-    
+
   myIsValLabeled = false;
 
   myValLabels = vtkActor2D::New();
   myValLabels->SetMapper(myValLabeledDataMapper);
   myValLabels->GetProperty()->SetColor(0,1,0);
   myValLabels->SetVisibility( myIsValLabeled );
+
+  // to allow modification of the reference coordinate in redefined SetPosition() methods
+  vtkCoordinate* aValLabelsCoordinate = vtkCoordinate::New();
+  myValLabels->GetPositionCoordinate()->SetReferenceCoordinate( aValLabelsCoordinate );
+  aValLabelsCoordinate->Delete();
 }
 
 //----------------------------------------------------------------------------
@@ -230,6 +264,7 @@ VISU_Actor
   myValLabeledDataMapper->Delete();
   myValSelectVisiblePoints->Delete();
   myValMaskPoints->Delete();
+  myValUsedPoints->Delete();
   myValCellCenters->Delete();
   myValLabels->Delete();
 
@@ -239,58 +274,58 @@ VISU_Actor
 }
 
 //----------------------------------------------------------------------------
-void 
+void
 VISU_Actor
 ::setIO(const Handle(SALOME_InteractiveObject)& theIO)
 {
-  Superclass::setIO(theIO); 
-  myName = theIO->getName(); 
+  Superclass::setIO(theIO);
+  myName = theIO->getName();
 }
 
 //----------------------------------------------------------------------------
-void 
+void
 VISU_Actor
 ::SetPrs3d(VISU::Prs3d_i* thePrs3d)
-{ 
+{
   myPrs3d = thePrs3d;
 }
 
-VISU::Prs3d_i* 
+VISU::Prs3d_i*
 VISU_Actor
 ::GetPrs3d()
-{ 
+{
   return myPrs3d;
 }
 
 //----------------------------------------------------------------------------
 void
 VISU_Actor
-::SetPipeLine(VISU_PipeLine* thePipeLine) 
+::SetPipeLine(VISU_PipeLine* thePipeLine)
 {
   myPipeLine = thePipeLine;
   if(thePipeLine){
     if(vtkMapper *aMapper = myPipeLine->GetMapper()){
       if(vtkDataSet *aDataSet = aMapper->GetInput()){
-       SetShrinkable(thePipeLine->IsShrinkable());
-       SetFeatureEdgesAllowed(thePipeLine->IsFeatureEdgesAllowed());
-       SetMapperInput(aDataSet);
+        SetShrinkable(thePipeLine->IsShrinkable());
+        SetFeatureEdgesAllowed(thePipeLine->IsFeatureEdgesAllowed());
+        SetMapperInput(aDataSet);
       }
     }
   }
   this->Modified();
 }
 
-VISU_PipeLine* 
+VISU_PipeLine*
 VISU_Actor
-::GetPipeLine() 
-{ 
+::GetPipeLine()
+{
   return myPipeLine.GetPointer();
 }
 
-VISU_PipeLine* 
+VISU_PipeLine*
 VISU_Actor
-::GetCurrentPL() 
-{ 
+::GetCurrentPL()
+{
   return GetPipeLine();
 }
 
@@ -298,14 +333,14 @@ VISU_Actor
 //----------------------------------------------------------------------------
 void
 VISU_Actor
-::SetRepresentation(int theMode) 
-{ 
+::SetRepresentation(int theMode)
+{
   Superclass::SetRepresentation(theMode);
   if(myRepresentation == VTK_POINTS)
   {
     UnShrink();
   }
-  SetFeatureEdgesEnabled( theMode == SVTK::Representation::FeatureEdges );
+  SetFeatureEdgesEnabled( theMode == VTKViewer::Representation::FeatureEdges );
 }
 
 
@@ -314,7 +349,7 @@ void
 VISU_Actor
 ::SetShrink()
 {
-  if(!myIsShrinkable) 
+  if(!myIsShrinkable)
     return;
   if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
     myShrinkFilter->SetInput(aDataSet);
@@ -327,7 +362,7 @@ void
 VISU_Actor
 ::UnShrink()
 {
-  if(!myIsShrunk) 
+  if(!myIsShrunk)
     return;
   if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
     myPassFilter[1]->SetInput(aDataSet);
@@ -353,8 +388,8 @@ VISU_Actor
 
 bool
 VISU_Actor
-::IsShrunkable() 
-{ 
+::IsShrunkable()
+{
   return myIsShrinkable;
 }
 
@@ -377,8 +412,8 @@ VISU_Actor
 //----------------------------------------------------------------------------
 bool
 VISU_Actor
-::IsFeatureEdgesAllowed() 
-{ 
+::IsFeatureEdgesAllowed()
+{
   return myIsFeatureEdgesAllowed;
 }
 
@@ -400,7 +435,7 @@ void
 VISU_Actor
 ::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled)
 {
-  if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled ) 
+  if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled )
     return;
 
   if ( vtkPolyData* aPolyData = myPassFilter[ 2 ]->GetPolyDataOutput() )
@@ -440,9 +475,9 @@ VISU_Actor
 void
 VISU_Actor
 ::GetFeatureEdgesFlags(bool& theIsFeatureEdges,
-                      bool& theIsBoundaryEdges,
-                      bool& theIsManifoldEdges,
-                      bool& theIsNonManifoldEdges)
+                       bool& theIsBoundaryEdges,
+                       bool& theIsManifoldEdges,
+                       bool& theIsNonManifoldEdges)
 {
   theIsFeatureEdges = myFeatureEdges->GetFeatureEdges();
   theIsBoundaryEdges = myFeatureEdges->GetBoundaryEdges();
@@ -453,9 +488,9 @@ VISU_Actor
 void
 VISU_Actor
 ::SetFeatureEdgesFlags(bool theIsFeatureEdges,
-                      bool theIsBoundaryEdges,
-                      bool theIsManifoldEdges,
-                      bool theIsNonManifoldEdges)
+                       bool theIsBoundaryEdges,
+                       bool theIsManifoldEdges,
+                       bool theIsNonManifoldEdges)
 {
   myFeatureEdges->SetFeatureEdges(theIsFeatureEdges);
   myFeatureEdges->SetBoundaryEdges(theIsBoundaryEdges);
@@ -490,7 +525,7 @@ VISU_Actor
 vtkFloatingPointType
 VISU_Actor
 ::GetOpacity()
-{ 
+{
   return GetProperty()->GetOpacity();
 }
 
@@ -536,28 +571,61 @@ VISU_Actor
   theRenderer->RemoveActor(myAnnotationActor.GetPointer());
   theRenderer->RemoveActor(myTextActor.GetPointer());
   theRenderer->RemoveActor(myValLabels);
-  Superclass::RemoveFromRender(theRenderer); 
+  Superclass::RemoveFromRender(theRenderer);
   myDestroySignal(this);
 }
 
 //----------------------------------------------------------------------------
-void 
+void
 VISU_Actor
 ::SetVisibility(int theMode)
 {
   Superclass::SetVisibility( theMode );
   myValLabels->SetVisibility( myIsValLabeled && theMode );
+
+  // Moved from VISU_GaussPtsAct::SetVisibility() (due to IPAL21159)
+  Highlight(isHighlighted());
+}
+//----------------------------------------------------------------------------
+  //! Gets know whether the actor should be displayed or not
+bool
+VISU_Actor
+::ShouldBeDisplayed()
+{
+  return GetFactory()->GetActiveState();
 }
 
 //----------------------------------------------------------------------------
-void 
+void
+VISU_Actor
+::SetPosition( double thePosition[3] )
+{
+  Superclass::SetPosition( thePosition );
+  if( vtkCoordinate* aCoord = myValLabels->GetPositionCoordinate()->GetReferenceCoordinate() )
+    aCoord->SetValue( thePosition );
+  myValSelectVisiblePoints->SetOffset( thePosition );
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetPosition( double theX, double theY, double theZ )
+{
+  Superclass::SetPosition( theX, theY, theZ );
+  if( vtkCoordinate* aCoord = myValLabels->GetPositionCoordinate()->GetReferenceCoordinate() )
+    aCoord->SetValue( theX, theY, theZ );
+  myValSelectVisiblePoints->SetOffset( theX, theY, theZ );
+}
+
+//----------------------------------------------------------------------------
+void
 VISU_Actor
 ::SetVTKMapping(bool theIsVTKMapping)
 {
   myIsVTKMapping = theIsVTKMapping;
 }
 
-bool 
+bool
 VISU_Actor
 ::IsVTKMapping() const
 {
@@ -565,7 +633,7 @@ VISU_Actor
 }
 
 //----------------------------------------------------------------------------
-vtkDataSet* 
+vtkDataSet*
 VISU_Actor
 ::GetInput()
 {
@@ -653,7 +721,7 @@ VISU_Actor
   return VISU::GetElemVTKID(GetMapper()->GetInput(), theID);
 }
 
-vtkCell* 
+vtkCell*
 VISU_Actor
 ::GetElemCell(vtkIdType theObjID)
 {
@@ -667,9 +735,9 @@ VISU_Actor
 //----------------------------------------------------------------------------
 bool
 VISU_Actor
-::isSubElementsHighlighted() 
-{ 
-  return myIsSubElementsHighlighted; 
+::isSubElementsHighlighted()
+{
+  return myIsSubElementsHighlighted;
 }
 
 
@@ -677,9 +745,9 @@ VISU_Actor
 inline
 void
 ChangeZoom(vtkFloatingPointType theZoomFactor,
-          vtkRenderer* theRenderer,
-          vtkIdType theInitialHasIndex,
-          vtkIdType theCurrentHasIndex)
+           vtkRenderer* theRenderer,
+           vtkIdType theInitialHasIndex,
+           vtkIdType theCurrentHasIndex)
 {
   //printf( "VISU_Actor::ChangeZoom( %d, %d )", theInitialHasIndex, theCurrentHasIndex );
   if(theInitialHasIndex + theCurrentHasIndex == 1){
@@ -699,7 +767,7 @@ ChangeZoom(vtkFloatingPointType theZoomFactor,
 }
 
 /*!
-  Updates visibility of the highlight devices  
+  Updates visibility of the highlight devices
 */
 void
 VISU_Actor
@@ -712,12 +780,11 @@ VISU_Actor
   {
     if( mySelectionMode == ActorSelection )
       ResetTextActor();
-    else
-      aShowTextActor = false;
     myLastSelectionMode = mySelectionMode;
   }
 
-  myTextActor->SetVisibility( GetVisibility() && theIsHighlight && aShowTextActor );
+  myTextActor->SetVisibility( GetVisibility() && theIsHighlight && aShowTextActor &&
+                              ( mySelectionMode == ActorSelection || isSubElementsHighlighted() ) );
 
   bool anInitialHasIndex = isHighlighted();
   bool aCurrentHasIndex = theIsHighlight;
@@ -731,9 +798,9 @@ VISU_Actor
     {
       vtkFloatingPointType aZoomFactor = aPickingSettings->GetZoomFactor();
       ChangeZoom(aZoomFactor,
-                GetRenderer(),
-                anInitialHasIndex,
-                aCurrentHasIndex);
+                 GetRenderer(),
+                 anInitialHasIndex,
+                 aCurrentHasIndex);
     }
   }
 
@@ -745,95 +812,95 @@ VISU_Actor
 */
 bool
 VISU_Actor
-::PreHighlight(vtkInteractorStyle* theInteractorStyle, 
-              SVTK_SelectionEvent* theSelectionEvent,
-              bool theIsHighlight)
+::PreHighlight(vtkInteractorStyle* theInteractorStyle,
+               SVTK_SelectionEvent* theSelectionEvent,
+               bool theIsHighlight)
 {
   bool aRet = Superclass::PreHighlight(theInteractorStyle,
-                                      theSelectionEvent,
-                                      theIsHighlight);
+                                       theSelectionEvent,
+                                       theIsHighlight);
 #ifndef ENABLE_ANNOTATION
   return aRet;
-#endif   
+#endif
   //
   myAnnotationActor->SetVisibility(0);
   if(theIsHighlight){
     switch(mySelectionMode){
-    case CellSelection:{ 
+    case CellSelection:{
       vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer();
-      myCellPicker->Pick(theSelectionEvent->myX, 
-                        theSelectionEvent->myY, 
-                        0.0, 
-                        aRenderer);
+      myCellPicker->Pick(theSelectionEvent->myX,
+                         theSelectionEvent->myY,
+                         0.0,
+                         aRenderer);
 
       if(myCellPicker->GetActor() != this)
-       return false;
+        return false;
 
       vtkIdType aVTKId = myCellPicker->GetCellId();
       if(aVTKId >= 0  && mySelector->IsValid(this,aVTKId,true) && hasIO()){
-       vtkIdType anObjId = GetElemObjId(aVTKId);
-       if(vtkCell* aCell = GetElemCell(anObjId)){
-         vtkPoints* aPts = aCell->GetPoints();
-         if(int aNbPts = aCell->GetNumberOfPoints()){
-           vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0};
-           for(int i = 0; i < aNbPts; i++){
-             vtkFloatingPointType *aPntCoord = aPts->GetPoint(i); 
-             aCoord[0] += aPntCoord[0];
-             aCoord[1] += aPntCoord[1];
-             aCoord[2] += aPntCoord[2];
-           }
-           // Display coordinates
-           vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
-           aRenderer->SetWorldPoint(aWorldCoord);
-           aRenderer->WorldToDisplay();
-           vtkFloatingPointType aSelectionPoint[3];
-           aRenderer->GetDisplayPoint(aSelectionPoint);
-           myAnnotationActor->SetPosition(aSelectionPoint);
-           //
-           // To prepare the annotation text
-           std::ostringstream aStr;
-           aStr<<"Cell ID: "<< anObjId;
-           std::string aString = aStr.str();
-           myAnnotationMapper->SetInput(aString.c_str());
-           
-           myAnnotationActor->SetVisibility(1);
-           return true;
-         }
-       }
+        vtkIdType anObjId = GetElemObjId(aVTKId);
+        if(vtkCell* aCell = GetElemCell(anObjId)){
+          vtkPoints* aPts = aCell->GetPoints();
+          if(int aNbPts = aCell->GetNumberOfPoints()){
+            vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0};
+            for(int i = 0; i < aNbPts; i++){
+              vtkFloatingPointType *aPntCoord = aPts->GetPoint(i);
+              aCoord[0] += aPntCoord[0];
+              aCoord[1] += aPntCoord[1];
+              aCoord[2] += aPntCoord[2];
+            }
+            // Display coordinates
+            vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
+            aRenderer->SetWorldPoint(aWorldCoord);
+            aRenderer->WorldToDisplay();
+            vtkFloatingPointType aSelectionPoint[3];
+            aRenderer->GetDisplayPoint(aSelectionPoint);
+            myAnnotationActor->SetPosition(aSelectionPoint);
+            //
+            // To prepare the annotation text
+            std::ostringstream aStr;
+            aStr<<"Cell ID: "<< anObjId;
+            std::string aString = aStr.str();
+            myAnnotationMapper->SetInput(aString.c_str());
+
+            myAnnotationActor->SetVisibility(1);
+            return true;
+          }
+        }
       }
       break;
     }
-    case NodeSelection:{ 
+    case NodeSelection:{
       vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer();
-      myPointPicker->Pick(theSelectionEvent->myX, 
-                         theSelectionEvent->myY, 
-                         0.0, 
-                         aRenderer);
+      myPointPicker->Pick(theSelectionEvent->myX,
+                          theSelectionEvent->myY,
+                          0.0,
+                          aRenderer);
 
       if(myPointPicker->GetActor() != this)
-       return false;
+        return false;
 
       vtkIdType aVtkId = myPointPicker->GetPointId();
       if(aVtkId >= 0  && mySelector->IsValid(this,aVtkId,true) && hasIO()){
-       vtkIdType anObjId = GetNodeObjId( aVtkId );
-       if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){
-         // Display coordinates
-         vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
-         aRenderer->SetWorldPoint(aWorldCoord);
-         aRenderer->WorldToDisplay();
-         vtkFloatingPointType aSelectionPoint[3];
-         aRenderer->GetDisplayPoint(aSelectionPoint);
-         myAnnotationActor->SetPosition(aSelectionPoint);
-         //
-         // To prepare the annotation text
-         std::ostringstream aStr;
-         aStr<<"Node ID: "<< anObjId;
-         std::string aString = aStr.str();
-         myAnnotationMapper->SetInput(aString.c_str());
-         
-         myAnnotationActor->SetVisibility(1);
-         return true;
-       }
+        vtkIdType anObjId = GetNodeObjId( aVtkId );
+        if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){
+          // Display coordinates
+          vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
+          aRenderer->SetWorldPoint(aWorldCoord);
+          aRenderer->WorldToDisplay();
+          vtkFloatingPointType aSelectionPoint[3];
+          aRenderer->GetDisplayPoint(aSelectionPoint);
+          myAnnotationActor->SetPosition(aSelectionPoint);
+          //
+          // To prepare the annotation text
+          std::ostringstream aStr;
+          aStr<<"Node ID: "<< anObjId;
+          std::string aString = aStr.str();
+          myAnnotationMapper->SetInput(aString.c_str());
+
+          myAnnotationActor->SetVisibility(1);
+          return true;
+        }
       }
       break;
     }
@@ -897,13 +964,13 @@ template<class TData> std::string getVector(TData* theData, int theId)
 */
 bool
 VISU_Actor
-::Highlight(vtkInteractorStyle* theInteractorStyle, 
-           SVTK_SelectionEvent* theSelectionEvent,
-           bool theIsHighlight)
+::Highlight(vtkInteractorStyle* theInteractorStyle,
+            SVTK_SelectionEvent* theSelectionEvent,
+            bool theIsHighlight)
 {
   return Superclass::Highlight(theInteractorStyle,
-                              theSelectionEvent,
-                              theIsHighlight);
+                               theSelectionEvent,
+                               theIsHighlight);
 }
 
 //-------------------------------------------------------------------------
@@ -916,7 +983,7 @@ VISU_Actor
   VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
 
   bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode != ActorSelection;
-  
+
   TColStd_IndexedMapOfInteger aMapIndex;
   mySelector->GetIndex( getIO(), aMapIndex );
   bool aCurrentHasIndex = aMapIndex.Extent() == 1;
@@ -934,131 +1001,131 @@ VISU_Actor
     {
       case ActorSelection:
       {
-       ResetTextActor();
-       break;
+        ResetTextActor();
+        break;
       }
       case CellSelection:
       {
-       if( !aCurrentHasIndex )
-       {
-         myTextActor->SetVisibility(false);
-         break;
-       }
-
-       int anObjId = aMapIndex(1);
-       vtkCellData* aCellData = aDataSet->GetCellData();
-       if(vtkCell* aCell = GetElemCell(anObjId)){
-         vtkPoints* aPts = aCell->GetPoints();
-         if(int aNbPts = aCell->GetNumberOfPoints()){
-           vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0};
-           for(int i = 0; i < aNbPts; i++){
-             vtkFloatingPointType *aPntCoord = aPts->GetPoint(i); 
-             aCoord[0] += aPntCoord[0];
-             aCoord[1] += aPntCoord[1];
-             aCoord[2] += aPntCoord[2];
-           }
-
-           aFlyTo = true;
-           aFlyToCoord[0] = aCoord[0] / aNbPts;
-           aFlyToCoord[1] = aCoord[1] / aNbPts;
-           aFlyToCoord[2] = aCoord[2] / aNbPts;
-
-           vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
-           aRenderer->SetWorldPoint(aWorldCoord);
-           aRenderer->WorldToDisplay();
-           vtkFloatingPointType aSelectionPoint[3];
-           aRenderer->GetDisplayPoint(aSelectionPoint);
-           myTextActor->SetPosition(aSelectionPoint);
-           myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
-           myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
-           myTextActor->SetWorldPoint(aWorldCoord);
-
-           std::ostringstream aStr;
-           aStr << "Cell ID: " << anObjId;
-
-           vtkCell* aCell = GetElemCell(anObjId);
-           int aVTKID = GetElemVTKID(anObjId);
-           if (aCell) {
-             int aNbOfPoints = aCell->GetNumberOfPoints();
-             if ( aNbOfPoints > 0 ) {
-               aStr << getScalar(aCellData, aVTKID);
-               aStr << getVector(aCellData, aVTKID);
-             }
-           }
-
-           std::string aString = aStr.str();
-           myTextActor->SetText(aString.c_str());
-         }
-       }
-       break;
+        if( !aCurrentHasIndex )
+        {
+          myTextActor->SetVisibility(false);
+          break;
+        }
+
+        int anObjId = aMapIndex(1);
+        vtkCellData* aCellData = aDataSet->GetCellData();
+        if(vtkCell* aCell = GetElemCell(anObjId)){
+          vtkPoints* aPts = aCell->GetPoints();
+          if(int aNbPts = aCell->GetNumberOfPoints()){
+            vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0};
+            for(int i = 0; i < aNbPts; i++){
+              vtkFloatingPointType *aPntCoord = aPts->GetPoint(i);
+              aCoord[0] += aPntCoord[0];
+              aCoord[1] += aPntCoord[1];
+              aCoord[2] += aPntCoord[2];
+            }
+
+            aFlyTo = true;
+            aFlyToCoord[0] = aCoord[0] / aNbPts;
+            aFlyToCoord[1] = aCoord[1] / aNbPts;
+            aFlyToCoord[2] = aCoord[2] / aNbPts;
+
+            vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
+            aRenderer->SetWorldPoint(aWorldCoord);
+            aRenderer->WorldToDisplay();
+            vtkFloatingPointType aSelectionPoint[3];
+            aRenderer->GetDisplayPoint(aSelectionPoint);
+            myTextActor->SetPosition(aSelectionPoint);
+            myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
+            myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
+            myTextActor->SetWorldPoint(aWorldCoord);
+
+            std::ostringstream aStr;
+            aStr << "Cell ID: " << anObjId;
+
+            vtkCell* aCell = GetElemCell(anObjId);
+            int aVTKID = GetElemVTKID(anObjId);
+            if (aCell) {
+              int aNbOfPoints = aCell->GetNumberOfPoints();
+              if ( aNbOfPoints > 0 ) {
+                aStr << getScalar(aCellData, aVTKID);
+                aStr << getVector(aCellData, aVTKID);
+              }
+            }
+
+            std::string aString = aStr.str();
+            myTextActor->SetText(aString.c_str());
+          }
+        }
+        break;
       }
       case NodeSelection:
-      { 
-       if( !aCurrentHasIndex )
-       {
-         myTextActor->SetVisibility(false);
-         break;
-       }
-
-       int anObjId = aMapIndex(1);
-       vtkPointData* aPntData = aDataSet->GetPointData();
-       if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){
-         aFlyTo = true;
-         aFlyToCoord[0] = aCoord[0];
-         aFlyToCoord[1] = aCoord[1];
-         aFlyToCoord[2] = aCoord[2];
-
-         vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
-         aRenderer->SetWorldPoint(aWorldCoord);
-         aRenderer->WorldToDisplay();
-         vtkFloatingPointType aSelectionPoint[3];
-         aRenderer->GetDisplayPoint(aSelectionPoint);
-         myTextActor->SetPosition(aSelectionPoint);
-         myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
-         myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
-         myTextActor->SetWorldPoint(aWorldCoord);
-
-         std::ostringstream aStr;
-         aStr << "Point ID: " << anObjId;
-
-         int aVTKID = GetNodeVTKID(anObjId);
-         if(aVTKID >= 0) {
-           aStr << getScalar(aPntData, aVTKID);
-           aStr << getVector(aPntData, aVTKID);
-         }
-
-         const VISU::PIDMapper& aMapper = GetPipeLine()->GetIDMapper();
-         //VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anObjId);
-         VISU::TStructuredId aVec = aMapper->GetIndexesOfNode(anObjId);
-
-         aStr << "\nCoordinates: " << "[";
-         aStr << aCoord[0];
-         //if( aVec.size() > 0 )
-         if (aVec[0] != -1)
-           aStr << " (" << aVec[0] << ")";
-         aStr << "; ";
-
-         aStr << aCoord[1];
-         //if( aVec.size() > 1 )
-         if (aVec[1] != -1)
-           aStr << " (" << aVec[1] << ")";
-         aStr << "; ";
-
-         aStr << aCoord[2];
-         //if( aVec.size() > 2 )
-         if (aVec[2] != -1)
-           aStr << " (" << aVec[2] << ")";
-         aStr << "]";
-
-         std::string aString = aStr.str();
-         myTextActor->SetText(aString.c_str());
-       }
-       break;
+      {
+        if( !aCurrentHasIndex )
+        {
+          myTextActor->SetVisibility(false);
+          break;
+        }
+
+        int anObjId = aMapIndex(1);
+        vtkPointData* aPntData = aDataSet->GetPointData();
+        if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){
+          aFlyTo = true;
+          aFlyToCoord[0] = aCoord[0];
+          aFlyToCoord[1] = aCoord[1];
+          aFlyToCoord[2] = aCoord[2];
+
+          vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
+          aRenderer->SetWorldPoint(aWorldCoord);
+          aRenderer->WorldToDisplay();
+          vtkFloatingPointType aSelectionPoint[3];
+          aRenderer->GetDisplayPoint(aSelectionPoint);
+          myTextActor->SetPosition(aSelectionPoint);
+          myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
+          myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
+          myTextActor->SetWorldPoint(aWorldCoord);
+
+          std::ostringstream aStr;
+          aStr << "Point ID: " << anObjId;
+
+          int aVTKID = GetNodeVTKID(anObjId);
+          if(aVTKID >= 0) {
+            aStr << getScalar(aPntData, aVTKID);
+            aStr << getVector(aPntData, aVTKID);
+          }
+
+          const VISU::PIDMapper& aMapper = GetPipeLine()->GetIDMapper();
+          //VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anObjId);
+          VISU::TStructuredId aVec = aMapper->GetIndexesOfNode(anObjId);
+
+          aStr << "\nCoordinates: " << "[";
+          aStr << aCoord[0];
+          //if( aVec.size() > 0 )
+          if (aVec[0] != -1)
+            aStr << " (" << aVec[0] << ")";
+          aStr << "; ";
+
+          aStr << aCoord[1];
+          //if( aVec.size() > 1 )
+          if (aVec[1] != -1)
+            aStr << " (" << aVec[1] << ")";
+          aStr << "; ";
+
+          aStr << aCoord[2];
+          //if( aVec.size() > 2 )
+          if (aVec[2] != -1)
+            aStr << " (" << aVec[2] << ")";
+          aStr << "]";
+
+          std::string aString = aStr.str();
+          myTextActor->SetText(aString.c_str());
+        }
+        break;
       }
       case EdgeOfCellSelection:
-       break;
+        break;
       default:
-       break;
+        break;
     }
   }
 
@@ -1067,9 +1134,9 @@ VISU_Actor
   {
     vtkFloatingPointType aZoomFactor = aPickingSettings->GetZoomFactor();
     ChangeZoom(aZoomFactor,
-              GetRenderer(),
-              anInitialHasIndex,
-              aCurrentHasIndex);
+               GetRenderer(),
+               anInitialHasIndex,
+               aCurrentHasIndex);
   }
 
   // FlyTo
@@ -1078,7 +1145,12 @@ VISU_Actor
     vtkRenderWindowInteractor* anInteractor = myInteractor;
     vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
     int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
-  
+
+    double aPosition[3];
+    GetPosition( aPosition );
+    for( int i = 0; i < 3; i++ )
+      aFlyToCoord[i] += aPosition[i];
+
     anInteractor->SetDolly(0.0);
     anInteractor->SetNumberOfFlyFrames(aPickingSettings->GetStepNumber());
     anInteractor->FlyTo(aRenderer, aFlyToCoord);
@@ -1100,8 +1172,8 @@ VISU_Actor
   GetBounds(aCoord);
 
   vtkFloatingPointType aWorldCoord[4] = { ( aCoord[0] + aCoord[1] ) / 2,
-                                         ( aCoord[2] + aCoord[3] ) / 2,
-                                         ( aCoord[4] + aCoord[5] ) / 2, 1.0};
+                                          ( aCoord[2] + aCoord[3] ) / 2,
+                                          ( aCoord[4] + aCoord[5] ) / 2, 1.0};
   vtkRenderer* aRenderer = GetRenderer();
   aRenderer->SetWorldPoint(aWorldCoord);
   aRenderer->WorldToDisplay();
@@ -1128,17 +1200,17 @@ VISU_Actor
 }
 
 //-------------------------------------------------------------------------
-void 
+void
 VISU_Actor
-::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
-               unsigned long theEvent,
-               void* theClientData, 
-               void* vtkNotUsed(theCallData))
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+                unsigned long theEvent,
+                void* theClientData,
+                void* vtkNotUsed(theCallData))
 {
   if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
     if(VISU_Actor* self = dynamic_cast<VISU_Actor*>(anObject)) {
       if(theEvent == VISU::UpdatePickingSettingsEvent)
-       self->UpdatePickingSettings();
+        self->UpdatePickingSettings();
     }
 }
 
@@ -1167,7 +1239,7 @@ void VISU_Actor::SetValuesLabeled( const bool theIsValLabeled )
   vtkDataSet* aGrid = GetValLabelsInput();
   if ( !aGrid )
     return;
-  
+
   bool isOnPnt = VISU::IsDataOnPoints( aGrid );
   bool isOnCell = VISU::IsDataOnCells( aGrid );
   if ( !isOnPnt && !isOnCell )
@@ -1198,7 +1270,7 @@ void VISU_Actor::SetValuesLabeled( const bool theIsValLabeled )
       return;
     }
   }
-  
+
   myIsValLabeled = theIsValLabeled;
 
   if ( myIsValLabeled )
@@ -1211,13 +1283,16 @@ void VISU_Actor::SetValuesLabeled( const bool theIsValLabeled )
       myValMaskPoints->SetInput( myValCellCenters->GetOutput() );
     }
     else if ( isOnPnt )
-      myValMaskPoints->SetInput( aDataSet );
+    {
+      myValUsedPoints->SetInput( aDataSet );
+      myValMaskPoints->SetInput( myValUsedPoints->GetOutput() );
+    }
 
     myValLabels->SetVisibility( GetVisibility() );
   }
   else
     myValLabels->SetVisibility( false );
-  
+
   Modified();
 }
 
@@ -1232,7 +1307,7 @@ bool VISU_Actor::GetValuesLabeled() const
 
 vtkTextProperty* VISU_Actor::GetsValLabelsProps() const
 {
-  return myValLabeledDataMapper->GetLabelTextProperty();  
+  return myValLabeledDataMapper->GetLabelTextProperty();
 }
 
 //----------------------------------------------------------------------------
@@ -1248,3 +1323,29 @@ vtkDataSet* VISU_Actor::GetValLabelsInput()
   return aDataSet;
 }
 
+
+VISU_Actor::EQuadratic2DRepresentation
+VISU_Actor::GetQuadratic2DRepresentation() const
+{
+  if(Superclass::GetQuadraticArcMode()){
+    return VISU_Actor::eArcs;
+  }
+  else
+    return VISU_Actor::eLines;
+}
+
+void VISU_Actor::SetQuadratic2DRepresentation( EQuadratic2DRepresentation theMode )
+{
+  switch(theMode) {
+  case VISU_Actor::eArcs:
+    myPreHighlightActor->SetQuadraticArcMode(true);
+    myHighlightActor->SetQuadraticArcMode(true);
+    break;
+  case VISU_Actor::eLines:
+    myPreHighlightActor->SetQuadraticArcMode(false);
+    myHighlightActor->SetQuadraticArcMode(false);
+    break;
+  default:
+    break;
+  }
+}