Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / OBJECT / VISU_Actor.cxx
index 814ef8141d36e0435e8e1bc359326ac307b366d8..02eaeb3f3782f471a06b616e9c5d486d39a08553 100644 (file)
 //
 //
 //
-//  File   : VISU_Actor.cxx
-//  Author : Laurent CORNABE with help of Nicolas REJNERI
+//  File   : 
+//  Author : 
 //  Module : VISU
 //  $Header$
 
-using namespace std;
 #include "VISU_Actor.h"
-#include "VISU_LookupTable.hxx"
-#include "VISU_ScalarBarActor.hxx"
+#include "VISU_PipeLine.hxx"
+#include "VTKViewer_ShrinkFilter.h"
+#include "VTKViewer_GeometryFilter.h"
+#include "VTKViewer_PassThroughFilter.h"
  
+#include <stdexcept>
+#include <sstream>
+
 // VTK Includes
-#include <vtkActor.h>
 #include <vtkProperty.h>
+#include <vtkSmartPointer.h>
+#include <vtkTextMapper.h>
+#include <vtkTextActor.h>
+#include <vtkProperty2D.h>
+#include <vtkRenderer.h>
+#include <vtkCellPicker.h>
+#include <vtkCell.h>
+#include <vtkPointPicker.h>
+#include <vtkPoints.h>
+#include <vtkInteractorStyle.h>
+#include <vtkDataSet.h>
+#include <vtkPolyData.h>
+#include <vtkUnstructuredGrid.h>
+
+#include <vtkShrinkFilter.h>
 #include <vtkShrinkPolyData.h>
-#include <vtkFeatureEdges.h>
-#include <vtkObjectFactory.h>
-
-static int VISU_POINT_SIZE = 3;
 
-//=======================================================================
+#include <vtkDataSetMapper.h>
+#include <vtkGeometryFilter.h>
+#include <vtkObjectFactory.h>
 
-VISU_Actor* VISU_Actor::New(){
-  vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_Actor");
-  if(ret) return (VISU_Actor*)ret;
-  return new VISU_Actor;
-} 
+#include <boost/bind.hpp>
 
-VISU_Actor::VISU_Actor(){
-  myIsShrunk = false;
-  myIsShrinkable = false;
-  myParent = this;
-  myPrs3d = NULL;
+#include "utilities.h"
 
-  myIO = NULL;
-  myName = "";
+using namespace std;
 
-  ishighlighted = false;
-  IsHighlighting = true;
-  HighlightProperty = vtkProperty::New();
-  HighlightProperty->SetAmbient(0.5);
-  HighlightProperty->SetDiffuse(0.3);
-  HighlightProperty->SetSpecular(0.2);
-  HighlightProperty->SetRepresentationToSurface();
-  HighlightProperty->SetAmbientColor(1, 1, 1);
-  HighlightProperty->SetDiffuseColor(1, 1, 1);
-  HighlightProperty->SetSpecularColor(0.5, 0.5, 0.5);
-}
+static int MYVTKDEBUG = 0;
 
-VISU_Actor::~VISU_Actor(){
-  HighlightProperty->Delete();
-}
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
 
-void VISU_Actor::setIO(const Handle(SALOME_InteractiveObject)& theIO){
-  SALOME_Actor::setIO(theIO); 
-  myName = theIO->getName(); 
-}
+//#define ENABLE_ANNOTATION
 
-void VISU_Actor::setPrs3d(VISU::Prs3d_i* thePrs3d){ 
-  myPrs3d = thePrs3d;
-}
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VISU_Actor);
 
-void VISU_Actor::SetParent(VISU_Actor* theParent){ 
-  myParent = theParent;
-}
+//----------------------------------------------------------------------------
+VISU_Actor
+::VISU_Actor():
+  myIsVTKMapping(false),
+  myPrs3d(NULL),
+  myActorFactory(NULL),
+  myMapper(vtkDataSetMapper::New()),
+  myIsShrunk(false),
+  myIsShrinkable(false),
+  myShrinkFilter(VTKViewer_ShrinkFilter::New()),
+  myAnnotationMapper(vtkTextMapper::New()),
+  myAnnotationActor(vtkTextActor::New())
+{
+  if(MYDEBUG) MESSAGE("VISU_Actor::VISU_Actor - this = "<<this);
 
-void VISU_Actor::SetMapper(vtkMapper* theMapper){
-  SALOME_Actor::SetMapper(theMapper);
-}
+  myMapper->Delete();
+  myShrinkFilter->Delete();
 
-void VISU_Actor::SetShrinkable(bool theIsShrinkable){
-  myIsShrinkable = theIsShrinkable;
-}
+  myStoreMapping = true;
 
-void VISU_Actor::setShrink(float theFactor){
-  if(!myIsShrinkable || myIsShrunk) return;
-  vtkShrinkPolyData *aShrinkFilter = vtkShrinkPolyData::New();
-  aShrinkFilter->SetShrinkFactor(theFactor);
-  // use for post-filtering
-  aShrinkFilter->SetInput(myPassFilter[2]->GetPolyDataOutput());
-  myPassFilter[3]->SetInput(aShrinkFilter->GetOutput());
-  myPassFilter[3]->Modified();
-  aShrinkFilter->Delete();
-  myIsShrunk = true;
-}
+  myShrinkFilter->SetStoreMapping(true);
 
-void VISU_Actor::unShrink(){
-  if(!myIsShrunk) return;
-  myPassFilter[3]->SetInput(myPassFilter[2]->GetPolyDataOutput());
-  myPassFilter[3]->Modified();
-  myIsShrunk = false;
-}
+  myAnnotationMapper->Delete();
+  myAnnotationActor->SetMapper(myAnnotationMapper.GetPointer());
 
-void VISU_Actor::SetVisibility(int theMode){
-  SALOME_Actor::SetVisibility(theMode);
+  myAnnotationActor->Delete();
+  myAnnotationActor->SetVisibility(0);
 }
 
-int VISU_Actor::GetVisibility(){
-  return SALOME_Actor::GetVisibility();
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::ShallowCopy(vtkProp *prop)
+{
+  VISU_Actor *anActor = VISU_Actor::SafeDownCast(prop);
+  if(anActor != NULL){
+    setName(anActor->getName());
+    if(anActor->hasIO()) setIO(anActor->getIO());
+  }
+  Superclass::ShallowCopy(prop);
 }
 
-void VISU_Actor::SetProperty(vtkProperty* theProperty){
-  SALOME_Actor::SetProperty(theProperty);
-}
+void
+VISU_Actor
+::ShallowCopyPL(VISU_PipeLine* thePipeLine)
+{
+  myPipeLine->ShallowCopy(thePipeLine);
 
-vtkProperty* VISU_Actor::GetProperty(){
-  return SALOME_Actor::GetProperty();
-}
+  vtkDataSet* aDatsSet = myMapper->GetInput();
+  GetMapper()->ShallowCopy(thePipeLine->GetMapper());
 
-void VISU_Actor::SetLineWidth(float theLineWidth){
-  GetProperty()->SetLineWidth(theLineWidth);
+  // To restore mapper input from pipeline
+  myMapper->SetInput(aDatsSet);
 }
 
-float VISU_Actor::GetLineWidth(){
-  return GetProperty()->GetLineWidth();
+//----------------------------------------------------------------------------
+VISU_Actor
+::~VISU_Actor()
+{
+  if(MYDEBUG) MESSAGE("~VISU_Actor() - this = "<<this);
+  Superclass::SetProperty(NULL);
+  SetDebug(MYVTKDEBUG);
 }
 
-void VISU_Actor::SetRepresentation(int theMode) { 
-  GetProperty()->SetRepresentation(theMode);
-  if(theMode == 0) 
-    GetProperty()->SetPointSize(VISU_POINT_SIZE);
+//----------------------------------------------------------------------------
+void 
+VISU_Actor
+::setIO(const Handle(SALOME_InteractiveObject)& theIO)
+{
+  Superclass::setIO(theIO); 
+  myName = theIO->getName(); 
 }
 
-int VISU_Actor::GetRepresentation(){ 
-  return GetProperty()->GetRepresentation();
+//----------------------------------------------------------------------------
+void 
+VISU_Actor
+::SetPrs3d(VISU::Prs3d_i* thePrs3d)
+{ 
+  myPrs3d = thePrs3d;
 }
 
-void VISU_Actor::ShallowCopy(vtkProp *prop){
-  VISU_Actor *anActor = VISU_Actor::SafeDownCast(prop);
-  if(anActor != NULL){
-    setName(anActor->getName());
-    if(anActor->hasIO()) setIO(anActor->getIO());
+VISU::Prs3d_i* 
+VISU_Actor
+::GetPrs3d()
+{ 
+  return myPrs3d;
+}
+
+//----------------------------------------------------------------------------
+VISU::TActorFactory* 
+VISU_Actor
+::GetFactory()
+{ 
+  return myActorFactory;
+}
+
+void
+VISU_Actor
+::SetFactory(VISU::TActorFactory* theActorFactory)
+{ 
+  using namespace VISU;
+
+  if(myActorFactory == theActorFactory)
+    return;
+  
+  if(theActorFactory)
+    myDestroySignal.connect(boost::bind(&TActorFactory::RemoveActor,
+                                       theActorFactory,
+                                       _1));
+
+  myActorFactory = theActorFactory;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::UpdateFromFactory()
+{
+  myActorFactory->UpdateActor(this);
+  Update();
+}
+
+void
+VISU_Actor
+::RemoveFromRender()
+{
+  RemoveFromRender(GetRenderer());
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetMapperInput(vtkDataSet* theDataSet) 
+{
+  myMapper->SetInput(theDataSet);
+  SetMapper(myMapper.GetPointer());
+}
+
+void
+VISU_Actor
+::SetPipeLine(VISU_PipeLine* thePipeLine) 
+{
+  myPipeLine = thePipeLine;
+  if(thePipeLine){
+    if(vtkMapper *aMapper = myPipeLine->GetMapper()){
+      if(vtkDataSet *aDataSet = aMapper->GetInput()){
+       SetShrinkable(thePipeLine->IsShrinkable());
+
+       SetMapperInput(aDataSet);
+      }
+    }
   }
-  SALOME_Actor::ShallowCopy(prop);
+  this->Modified();
 }
 
-void VISU_Actor::highlight(Standard_Boolean highlight) {
-  if (this->IsHighlighting) {
-    if(highlight && !ishighlighted) {
-      ishighlighted=true;
-      this->SetProperty(HighlightProperty);
-    }else if (!highlight)
-      if(ishighlighted)        ishighlighted=false;
-  }
+VISU_PipeLine* 
+VISU_Actor
+::GetPipeLine() 
+{ 
+  return myPipeLine.GetPointer();
 }
 
-//=======================================================================
+VISU_PipeLine* 
+VISU_Actor
+::GetCurrentPL() 
+{ 
+  return GetPipeLine();
+}
 
-VISUScalarMap_Actor* VISUScalarMap_Actor::New(){
-  vtkObject* ret = vtkObjectFactory::CreateInstance("VISUScalarMap_Actor");
-  if(ret) return (VISUScalarMap_Actor*)ret;
-  return new VISUScalarMap_Actor;
-} 
 
-VISUScalarMap_Actor::VISUScalarMap_Actor(){
-  myScalarBar = VISU_ScalarBarActor::New();
-  GetProperty()->FrontfaceCullingOff();
-  GetProperty()->BackfaceCullingOff();
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetRepresentation(int theMode) 
+{ 
+  Superclass::SetRepresentation(theMode);
+  if(myRepresentation == VTK_POINTS)
+    UnShrink();
 }
 
-VISUScalarMap_Actor::~VISUScalarMap_Actor(){
-  myScalarBar->Delete();
-}
 
-void VISUScalarMap_Actor::AddToRender(vtkRenderer* theRenderer){
-  SALOME_Actor::AddToRender(theRenderer);
-  if(myScalarBar)
-    theRenderer->AddActor2D(myScalarBar);
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetShrink()
+{
+  if(!myIsShrinkable) 
+    return;
+  if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
+    myShrinkFilter->SetInput(aDataSet);
+    myPassFilter[1]->SetInput(myShrinkFilter->GetOutput());
+    myIsShrunk = true;
+  }
 }
 
-void VISUScalarMap_Actor::RemoveFromRender(vtkRenderer* theRenderer){
-  SALOME_Actor::RemoveFromRender(theRenderer);
-  if(myScalarBar)
-    theRenderer->RemoveActor(myScalarBar);
+void
+VISU_Actor
+::UnShrink()
+{
+  if(!myIsShrunk) 
+    return;
+  if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
+    myPassFilter[1]->SetInput(aDataSet);
+    myPassFilter[1]->Modified();
+    myIsShrunk = false;
+    Modified();
+  }
 }
 
-void VISUScalarMap_Actor::SetVisibility(int theMode){
-  SALOME_Actor::SetVisibility(theMode);
-  if(myScalarBar) myScalarBar->SetVisibility(*myBarVisibility && theMode);
+bool
+VISU_Actor
+::IsShrunk()
+{
+  return myIsShrunk;
 }
 
-int VISUScalarMap_Actor::GetVisibility(){
-  return SALOME_Actor::GetVisibility();
+void
+VISU_Actor
+::SetShrinkable(bool theIsShrinkable)
+{
+  myIsShrinkable = theIsShrinkable;
 }
 
-void VISUScalarMap_Actor::SetBarVisibility(const bool* theMode){
-  myBarVisibility = theMode;
-  if(myScalarBar) myScalarBar->SetVisibility(*myBarVisibility);
+bool
+VISU_Actor
+::IsShrunkable() 
+{ 
+  return myIsShrinkable;
 }
 
-//=======================================================================
-
-VISUMesh_Actor* VISUMesh_Actor::New(){
-  vtkObject* ret = vtkObjectFactory::CreateInstance("VISUMesh_Actor");
-  if(ret) return (VISUMesh_Actor*)ret;
-  return new VISUMesh_Actor;
-} 
-
-VISUMesh_Actor::VISUMesh_Actor(){
-  myEdgeMapper = vtkPolyDataMapper::New();
-  mySurfaceActor = VISU_Actor::New();
-  mySurfaceActor->SetParent(this);
-  mySurfaceActor->GetProperty()->SetPointSize(VISU_POINT_SIZE);
-  mySurfaceActor->GetProperty()->FrontfaceCullingOff();
-  mySurfaceActor->GetProperty()->BackfaceCullingOff();
-  mySurfaceActor->SetRepresentation(2);
-
-  myEdgeActor = VISU_Actor::New();
-  myEdgeActor->SetParent(this);
-  myEdgeActor->PickableOff();
-  myEdgeActor->GetProperty()->SetPointSize(VISU_POINT_SIZE);
-  myEdgeActor->GetProperty()->FrontfaceCullingOff();
-  myEdgeActor->GetProperty()->BackfaceCullingOff();
-  myEdgeActor->SetRepresentation(2);
-
-  myRepresentation = 2; //SURFACE
-  myVisibility = 1; //On
+void
+VISU_Actor
+::SetShrinkFactor(vtkFloatingPointType theValue)
+{
+  myShrinkFilter->SetShrinkFactor(theValue);
+  Modified();
 }
 
-VISUMesh_Actor::~VISUMesh_Actor(){
-  myEdgeMapper->Delete();
-  mySurfaceActor->Delete();
-  myEdgeActor->Delete();
+vtkFloatingPointType
+VISU_Actor
+::GetShrinkFactor()
+{
+  return myShrinkFilter->GetShrinkFactor();
 }
 
-void VISUMesh_Actor::setIO(const Handle(SALOME_InteractiveObject)& theIO){
-  mySurfaceActor->setIO(theIO);
-  myEdgeActor->setIO(theIO);
-}
 
-void VISUMesh_Actor::setPrs3d(VISU::Prs3d_i* thePrs3d){ 
-  if(thePrs3d){
-    VISU_Actor::setPrs3d(thePrs3d);
-    mySurfaceActor->setPrs3d(thePrs3d);
-    myEdgeActor->setPrs3d(thePrs3d);
-  }
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetOpacity(vtkFloatingPointType theValue)
+{
+  GetProperty()->SetOpacity(theValue);
 }
 
-void VISUMesh_Actor::AddToRender(vtkRenderer* theRenderer){
-  theRenderer->AddActor(mySurfaceActor);
-  theRenderer->AddActor(myEdgeActor);
+vtkFloatingPointType
+VISU_Actor
+::GetOpacity()
+{ 
+  return GetProperty()->GetOpacity();
 }
 
-void VISUMesh_Actor::RemoveFromRender(vtkRenderer* theRenderer){
-  theRenderer->RemoveActor(mySurfaceActor);
-  theRenderer->RemoveActor(myEdgeActor);
+void
+VISU_Actor
+::SetLineWidth(vtkFloatingPointType theLineWidth)
+{
+  GetProperty()->SetLineWidth(theLineWidth);
 }
 
-void VISUMesh_Actor::SetMapper(vtkMapper* theMapper){
-  VISU_Actor::SetMapper(theMapper);
-  SALOME_PassThroughFilter* aPassFilter = SALOME_PassThroughFilter::New();
-  aPassFilter->SetInput(theMapper->GetInput());
-  vtkFeatureEdges *aFeatureEdges = vtkFeatureEdges::New();
-  aFeatureEdges->SetInput(aPassFilter->GetPolyDataOutput());
-  aFeatureEdges->BoundaryEdgesOn();
-  aFeatureEdges->ManifoldEdgesOn();
-  myEdgeMapper->SetInput(aFeatureEdges->GetOutput());
-  aFeatureEdges->Delete();
-  myEdgeMapper->ScalarVisibilityOff();
-  myEdgeActor->SetMapper(myEdgeMapper);
-  mySurfaceActor->SetMapper(theMapper);
+vtkFloatingPointType
+VISU_Actor
+::GetLineWidth()
+{
+  return GetProperty()->GetLineWidth();
 }
 
-void VISUMesh_Actor::SetTransform(SALOME_Transform* theTransform){
-  mySurfaceActor->SetTransform(theTransform);
-  myEdgeActor->SetTransform(theTransform);
+//==================================================================
+// function: AddToRender
+// purpose :
+//==================================================================
+void
+VISU_Actor
+::AddToRender(vtkRenderer* theRenderer)
+{
+  Superclass::AddToRender(theRenderer);
+  theRenderer->AddActor(myAnnotationActor.GetPointer());
 }
 
-void VISUMesh_Actor::SetShrinkable(bool theIsShrinkable){
-  myIsShrinkable = theIsShrinkable;
-  myEdgeActor->SetShrinkable(myIsShrinkable);
-  mySurfaceActor->SetShrinkable(myIsShrinkable);
+//==================================================================
+// function: RemoveFromRender
+// purpose :
+//==================================================================
+void
+VISU_Actor
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
+  theRenderer->RemoveActor(myAnnotationActor.GetPointer());
+  Superclass::RemoveFromRender(theRenderer); 
+  myDestroySignal(this);
 }
 
-vtkProperty* VISUMesh_Actor::GetProperty(){ 
-  mySurfaceActor->GetProperty();
-} 
-
-void VISUMesh_Actor::SetProperty(vtkProperty* theProperty){ 
-  mySurfaceActor->SetProperty(theProperty);
+//----------------------------------------------------------------------------
+void 
+VISU_Actor
+::SetVTKMapping(bool theIsVTKMapping)
+{
+  myIsVTKMapping = theIsVTKMapping;
 }
 
-vtkProperty* VISUMesh_Actor::GetEdgeProperty(){ 
-  myEdgeActor->GetProperty();
-} 
-
-void VISUMesh_Actor::SetEdgeProperty(vtkProperty* theProperty){ 
-  myEdgeActor->SetProperty(theProperty);
+bool 
+VISU_Actor
+::IsVTKMapping() const
+{
+  return myIsVTKMapping;
 }
 
-void VISUMesh_Actor::SetLineWidth(float theLineWidth){
-  GetProperty()->SetLineWidth(theLineWidth);
-  GetEdgeProperty()->SetLineWidth(theLineWidth);
-}
+//----------------------------------------------------------------------------
+vtkDataSet* 
+VISU_Actor
+::GetInput()
+{
+  if(myIsVTKMapping)
+    return Superclass::GetInput();
 
-float VISUMesh_Actor::GetLineWidth(){
-  return GetProperty()->GetLineWidth();
+  return GetCurrentPL()->GetOutput();
 }
 
-void VISUMesh_Actor::setShrink(float theFactor){
-  if(!myIsShrinkable || myIsShrunk || myRepresentation == 0) return;
-  mySurfaceActor->setShrink(theFactor);
-  myIsShrunk = true;
-  SetRepresentation(myRepresentation);
-}
-
-void VISUMesh_Actor::unShrink(){
-  if(!myIsShrunk) return;
-  mySurfaceActor->unShrink();
-  myIsShrunk = false;
-  SetRepresentation(myRepresentation);
-}
-
-void VISUMesh_Actor::SetRepresentation(int theMode){
-  if(theMode < 0 || theMode >2) return;
-  myRepresentation = theMode;
-  myEdgeActor->SetRepresentation(2);
-  mySurfaceActor->SetRepresentation(myRepresentation);
-  switch(theMode){
-  case 0: //POINTS
-    myEdgeActor->VisibilityOff();
-    mySurfaceActor->VisibilityOn();
-    break;
-  case 1: //WIREFRAME
-    myEdgeActor->VisibilityOff();
-    mySurfaceActor->VisibilityOn();
-    break;
-  case 2: //SURFACE
-    myEdgeActor->SetVisibility(!myIsShrunk);
-    mySurfaceActor->VisibilityOn();
-    break;
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_Actor
+::GetNodeObjId(vtkIdType theID)
+{
+  if(myIsVTKMapping)
+    return Superclass::GetNodeObjId(theID);
+
+  vtkIdType anID = myGeomFilter->GetNodeObjId(theID);
+
+  if(myIsShrunk)
+   anID = myShrinkFilter->GetNodeObjId(anID);
+
+  return GetCurrentPL()->GetNodeObjID(anID);
+}
+
+vtkIdType
+VISU_Actor
+::GetNodeVTKID(vtkIdType theID)
+{
+  if(myIsVTKMapping)
+    return theID;
+
+  return GetCurrentPL()->GetNodeVTKID(theID);
+}
+
+vtkFloatingPointType*
+VISU_Actor
+::GetNodeCoord(int theObjID)
+{
+  if(myIsVTKMapping)
+    return Superclass::GetNodeCoord(theObjID);
+
+  return GetCurrentPL()->GetNodeCoord(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_Actor
+::GetElemObjId(vtkIdType theID)
+{
+  if(myIsVTKMapping)
+    return Superclass::GetElemObjId(theID);
+
+  vtkIdType anID = myGeomFilter->GetElemObjId(theID);
+
+  if(myIsShrunk)
+   anID = myShrinkFilter->GetElemObjId(anID);
+
+  return GetCurrentPL()->GetElemObjID(anID);
+}
+
+vtkIdType
+VISU_Actor
+::GetElemVTKID(vtkIdType theID)
+{
+  if(myIsVTKMapping)
+    return theID;
+
+  return GetCurrentPL()->GetElemVTKID(theID);
+}
+
+vtkCell* 
+VISU_Actor
+::GetElemCell(vtkIdType theObjID)
+{
+  if(myIsVTKMapping)
+    return Superclass::GetElemCell(theObjID);
+
+  return GetCurrentPL()->GetElemCell(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VISU_Actor
+::PreHighlight(vtkInteractorStyle* theInteractorStyle, 
+              SVTK_SelectionEvent* theSelectionEvent,
+              bool theIsHighlight)
+{
+  bool aRet = Superclass::PreHighlight(theInteractorStyle,
+                                      theSelectionEvent,
+                                      theIsHighlight);
+#ifndef ENABLE_ANNOTATION
+  return aRet;
+#endif   
+  //
+  myAnnotationActor->SetVisibility(0);
+  if(theIsHighlight){
+    switch(mySelectionMode){
+    case CellSelection:{ 
+      vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer();
+      myCellPicker->Pick(theSelectionEvent->myX, 
+                        theSelectionEvent->myY, 
+                        0.0, 
+                        aRenderer);
+
+      if(myCellPicker->GetActor() != this)
+       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;
+         }
+       }
+      }
+      break;
+    }
+    case NodeSelection:{ 
+      vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer();
+      myPointPicker->Pick(theSelectionEvent->myX, 
+                         theSelectionEvent->myY, 
+                         0.0, 
+                         aRenderer);
+      
+      if(myPointPicker->GetActor() != this)
+       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;
+       }
+      }
+      break;
+    }
+    case EdgeOfCellSelection:
+      break;
+    default:
+      break;
+    }
   }
-  myRepresentation = theMode;
-}
 
-void VISUMesh_Actor::SetVisibility(int theMode){
-  SetRepresentation(myRepresentation);
-  myEdgeActor->SetVisibility(theMode);
-  mySurfaceActor->SetVisibility(theMode);
-  myVisibility = theMode;
+  return aRet;
 }
-
-//=======================================================================
-