+
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetShrink()
+{
+ if(!myIsShrinkable)
+ return;
+ if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
+ myShrinkFilter->SetInput(aDataSet);
+ myPassFilter[1]->SetInput(myShrinkFilter->GetOutput());
+ myIsShrunk = true;
+ }
+}
+
+void
+VISU_Actor
+::UnShrink()
+{
+ if(!myIsShrunk)
+ return;
+ if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
+ myPassFilter[1]->SetInput(aDataSet);
+ myPassFilter[1]->Modified();
+ myIsShrunk = false;
+ Modified();
+ }
+}
+
+bool
+VISU_Actor
+::IsShrunk()
+{
+ return myIsShrunk;
+}
+
+void
+VISU_Actor
+::SetShrinkable(bool theIsShrinkable)
+{
+ myIsShrinkable = theIsShrinkable;
+}
+
+bool
+VISU_Actor
+::IsShrunkable()
+{
+ return myIsShrinkable;
+}
+
+void
+VISU_Actor
+::SetShrinkFactor(vtkFloatingPointType theValue)
+{
+ myShrinkFilter->SetShrinkFactor(theValue);
+ Modified();
+}
+
+vtkFloatingPointType
+VISU_Actor
+::GetShrinkFactor()
+{
+ return myShrinkFilter->GetShrinkFactor();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetOpacity(vtkFloatingPointType theValue)
+{
+ GetProperty()->SetOpacity(theValue);
+}
+
+vtkFloatingPointType
+VISU_Actor
+::GetOpacity()
+{
+ return GetProperty()->GetOpacity();
+}
+
+void
+VISU_Actor
+::SetLineWidth(vtkFloatingPointType theLineWidth)
+{
+ GetProperty()->SetLineWidth(theLineWidth);
+}
+
+vtkFloatingPointType
+VISU_Actor
+::GetLineWidth()
+{
+ return GetProperty()->GetLineWidth();
+}
+
+//==================================================================
+// function: AddToRender
+// purpose :
+//==================================================================
+void
+VISU_Actor
+::AddToRender(vtkRenderer* theRenderer)
+{
+ Superclass::AddToRender(theRenderer);
+ theRenderer->AddActor(myAnnotationActor.GetPointer());
+}
+
+//==================================================================
+// function: RemoveFromRender
+// purpose :
+//==================================================================
+void
+VISU_Actor
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
+ theRenderer->RemoveActor(myAnnotationActor.GetPointer());
+ Superclass::RemoveFromRender(theRenderer);
+ myDestroySignal(this);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetVTKMapping(bool theIsVTKMapping)
+{
+ myIsVTKMapping = theIsVTKMapping;
+}
+
+bool
+VISU_Actor
+::IsVTKMapping() const
+{
+ return myIsVTKMapping;
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_Actor
+::GetInput()
+{
+ if(myIsVTKMapping)
+ return Superclass::GetInput();
+
+ return GetCurrentPL()->GetOutput();
+}
+
+//----------------------------------------------------------------------------
+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;
+ }
+ }
+
+ return aRet;
+}