Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / SVTK / SALOME_Actor.cxx
index 9b1b7937d02b90b562884b45d15d114651c3b99c..bb100848c0419ce776ee924bc3a165533b25739c 100644 (file)
@@ -73,7 +73,6 @@ using namespace std;
 int SALOME_POINT_SIZE = 5;
 int SALOME_LINE_WIDTH = 3;
 
-//----------------------------------------------------------------------------
 namespace
 {
   int
@@ -83,12 +82,13 @@ namespace
   {
     int anEdgeId = 0;
     if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
-      float aPickPosition[3];
+      vtkFloatingPointType aPickPosition[3];
       thePicker->GetPickPosition(aPickPosition);
-      float aMinDist = 1000000.0, aDist = 0;
+      vtkFloatingPointType 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];
+         int subId;  
+         vtkFloatingPointType pcoords[3], closestPoint[3], weights[3];
          aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
          if (aDist < aMinDist) {
            aMinDist = aDist;
@@ -122,11 +122,11 @@ namespace
 }
 
 
-//----------------------------------------------------------------------------
 vtkStandardNewMacro(SALOME_Actor);
 
-
-//----------------------------------------------------------------------------
+/*!
+  Constructor
+*/
 SALOME_Actor
 ::SALOME_Actor():
   myRenderer(NULL),
@@ -164,14 +164,17 @@ SALOME_Actor
   myOutlineActor->SetVisibility( false );
 }
 
-
-//----------------------------------------------------------------------------
+/*!
+  Destructor
+*/
 SALOME_Actor
 ::~SALOME_Actor()
 {}
 
 
-//----------------------------------------------------------------------------
+/*!
+  \return true if the SALOME_Actor has a reference to SALOME_InteractiveObject
+*/
 Standard_Boolean 
 SALOME_Actor
 ::hasIO() 
@@ -179,6 +182,9 @@ SALOME_Actor
   return !myIO.IsNull(); 
 }
 
+/*!
+  \return correspoinding reference to SALOME_InteractiveObject
+*/
 const Handle(SALOME_InteractiveObject)& 
 SALOME_Actor
 ::getIO()
@@ -186,6 +192,10 @@ SALOME_Actor
   return myIO; 
 }
 
+/*!
+  Sets reference to SALOME_InteractiveObject
+  \param theIO - new SALOME_InteractiveObject
+*/
 void
 SALOME_Actor
 ::setIO(const Handle(SALOME_InteractiveObject)& theIO) 
@@ -193,6 +203,10 @@ SALOME_Actor
   myIO = theIO; 
 }
 
+/*!
+  Sets name the SALOME_Actor
+  \param theName - new name
+*/
 void
 SALOME_Actor
 ::setName(const char* theName)
@@ -203,7 +217,9 @@ SALOME_Actor
 }
 
 
-//----------------------------------------------------------------------------
+/*!
+  Publishes the actor in all its internal devices
+*/
 void
 SALOME_Actor
 ::AddToRender(vtkRenderer* theRenderer)
@@ -217,6 +233,9 @@ SALOME_Actor
   theRenderer->AddActor( myOutlineActor.GetPointer() );
 }
 
+/*!
+  Removes the actor from all its internal devices
+*/
 void 
 SALOME_Actor
 ::RemoveFromRender(vtkRenderer* theRenderer)
@@ -228,6 +247,9 @@ SALOME_Actor
   theRenderer->RemoveActor( myOutlineActor.GetPointer() );
 }
 
+/*!
+  \return reference on renderer where it is published
+*/
 vtkRenderer*
 SALOME_Actor
 ::GetRenderer()
@@ -235,8 +257,10 @@ SALOME_Actor
   return myRenderer;
 }
 
-
-//----------------------------------------------------------------------------
+/*!
+  Sets interactor in order to use vtkInteractorObserver devices
+  \param theInteractor - new interactor
+*/
 void
 SALOME_Actor
 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
@@ -244,6 +268,9 @@ SALOME_Actor
   myInteractor = theInteractor;
 }
 
+/*!
+  Put a request to redraw the view 
+*/
 void
 SALOME_Actor
 ::Update()
@@ -251,8 +278,10 @@ SALOME_Actor
   myInteractor->CreateTimer(VTKI_TIMER_UPDATE);    
 }
 
-
-//----------------------------------------------------------------------------
+/*!
+  Apply view transformation
+  \param theTransform - transformation
+*/
 void
 SALOME_Actor
 ::SetTransform(VTKViewer_Transform* theTransform)
@@ -264,10 +293,14 @@ SALOME_Actor
   myOutlineActor->SetTransform(theTransform);
 }
 
-
+/*!
+  Apply additional position
+*/
 void
 SALOME_Actor
-::SetPosition(float _arg1, float _arg2, float _arg3)
+::SetPosition(vtkFloatingPointType _arg1, 
+             vtkFloatingPointType _arg2, 
+             vtkFloatingPointType _arg3)
 {
   Superclass::SetPosition(_arg1,_arg2,_arg3);
 
@@ -276,16 +309,20 @@ SALOME_Actor
   myOutlineActor->SetPosition(_arg1,_arg2,_arg3);
 }
 
-
+/*!
+  Apply additional position
+*/
 void
 SALOME_Actor
-::SetPosition(float _arg[3])
+::SetPosition(vtkFloatingPointType _arg[3])
 {
   SetPosition(_arg[0],_arg[1],_arg[2]);
 }
 
-
-//----------------------------------------------------------------
+/*!
+  Shows/hides actor
+  \param theVisibility - new visibility state
+*/
 void
 SALOME_Actor
 ::SetVisibility( int theVisibility )
@@ -304,8 +341,10 @@ SALOME_Actor
   }
 }
 
-
-//----------------------------------------------------------------
+/*!
+  Set selector in order to the actor at any time can restore current selection
+  \param theSelector - new selector
+*/
 void
 SALOME_Actor
 ::SetSelector(SVTK_Selector* theSelector)
@@ -313,6 +352,9 @@ SALOME_Actor
   mySelector = theSelector;
 }
 
+/*!
+  To map current selection to VTK representation
+*/
 void
 SALOME_Actor
 ::Highlight(bool theIsHighlight)
@@ -349,11 +391,14 @@ SALOME_Actor
   highlight(theIsHighlight);
 }
 
+/*!
+  Updates visibility of the highlight devices  
+*/
 void
 SALOME_Actor
 ::highlight(bool theIsHighlight)
 {
-  float aBounds[6];
+  vtkFloatingPointType aBounds[6];
   GetInput()->GetBounds(aBounds);
   myOutline->SetBounds(aBounds);
   myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight );
@@ -362,13 +407,18 @@ SALOME_Actor
 }
 
 
-//----------------------------------------------------------------
+/*!
+  To process prehighlight (called from SVTK_InteractorStyle)
+*/
 bool
 SALOME_Actor
 ::PreHighlight(vtkInteractorStyle *theInteractorStyle, 
               SVTK_SelectionEvent* theSelectionEvent,
               bool theIsHighlight)
 {
+  if ( !GetPickable() )
+    return false;
+
   vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
   //
   myPreHighlightActor->SetVisibility( false );
@@ -377,9 +427,9 @@ SALOME_Actor
   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
   bool anIsChanged = (mySelectionMode != aSelectionMode);
 
-  float x = theSelectionEvent->myX;
-  float y = theSelectionEvent->myY;
-  float z = 0.0;
+  vtkFloatingPointType x = theSelectionEvent->myX;
+  vtkFloatingPointType y = theSelectionEvent->myY;
+  vtkFloatingPointType z = 0.0;
 
   if( !theIsHighlight ) {
     SetPreSelected( false );
@@ -500,14 +550,18 @@ SALOME_Actor
   return anIsChanged;
 }
 
-
-//----------------------------------------------------------------
+/*!
+  To process highlight (called from SVTK_InteractorStyle)
+*/
 bool
 SALOME_Actor
 ::Highlight(vtkInteractorStyle *theInteractorStyle, 
            SVTK_SelectionEvent* theSelectionEvent,
            bool theIsHighlight)
 {
+  if ( !GetPickable() )
+    return false;
+
   myOutlineActor->SetVisibility( false );
   myHighlightActor->SetVisibility( false );
 
@@ -515,13 +569,16 @@ SALOME_Actor
   //
   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
   bool anIsShift = theSelectionEvent->myIsShift;
-  if( !anIsShift ) {
+  if( !anIsShift || !theIsHighlight ) {
     mySelector->RemoveIObject( this );
   }
 
-  float x = theSelectionEvent->myX;
-  float y = theSelectionEvent->myY;
-  float z = 0.0;
+  if ( !theIsHighlight )
+    return true;
+
+  vtkFloatingPointType x = theSelectionEvent->myX;
+  vtkFloatingPointType y = theSelectionEvent->myY;
+  vtkFloatingPointType z = 0.0;
 
   if( !theSelectionEvent->myIsRectangle ) {
     switch(aSelectionMode){
@@ -588,16 +645,16 @@ SALOME_Actor
       break;
     }
   }else{
-    float xLast = theSelectionEvent->myLastX;
-    float yLast = theSelectionEvent->myLastY;
-    float zLast = 0.0;
+    vtkFloatingPointType xLast = theSelectionEvent->myLastX;
+    vtkFloatingPointType yLast = theSelectionEvent->myLastY;
+    vtkFloatingPointType zLast = 0.0;
 
-    float x1 = x < xLast ? x : xLast;
-    float y1 = y < yLast ? y : yLast;
-    float z1 = z < zLast ? z : zLast;
-    float x2 = x > xLast ? x : xLast;
-    float y2 = y > yLast ? y : yLast;
-    float z2 = z > zLast ? z : zLast;
+    vtkFloatingPointType x1 = x < xLast ? x : xLast;
+    vtkFloatingPointType y1 = y < yLast ? y : yLast;
+    vtkFloatingPointType z1 = z < zLast ? z : zLast;
+    vtkFloatingPointType x2 = x > xLast ? x : xLast;
+    vtkFloatingPointType y2 = y > yLast ? y : yLast;
+    vtkFloatingPointType z2 = z > zLast ? z : zLast;
 
     switch(aSelectionMode){
     case NodeSelection: {
@@ -611,7 +668,6 @@ SALOME_Actor
       if(aMapIter != aVectorIdsMap.end()){
        const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
        vtkIdType anEnd = aVectorIds.size();
-       SVTK_RectPicker::TVectorIds::const_iterator anIdIter = aVectorIds.begin();
        for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
          int aPointId = aVectorIds[anId];
          if( aPointId >= 0 && mySelector->IsValid( this, aPointId, true ) ) {
@@ -633,8 +689,8 @@ SALOME_Actor
     }
     case ActorSelection :
     {
-      float aPnt[3];
-      float* aBounds = GetBounds();
+      vtkFloatingPointType aPnt[3];
+      vtkFloatingPointType* aBounds = GetBounds();
 
       bool anIsPicked = true;
       for( int i = 0; i <= 1; i++ ) {
@@ -672,7 +728,6 @@ SALOME_Actor
       if(aMapIter != aVectorIdsMap.end()){
        const SVTK_RectPicker::TVectorIds& aVectorIds = aMapIter->second;
        vtkIdType anEnd = aVectorIds.size();
-       SVTK_RectPicker::TVectorIds::const_iterator anIdIter = aVectorIds.begin();
        for(vtkIdType anId = 0; anId < anEnd; anId++ ) {
          int aCellId = aVectorIds[anId];
          if ( !mySelector->IsValid( this, aCellId ) )
@@ -698,7 +753,10 @@ SALOME_Actor
   return true;
 }
 
-//----------------------------------------------------------------------------
+/*!
+  To set up a picker for nodal selection (initialized by SVTK_Renderer::AddActor)
+  \param thePointPicker - new picker
+*/
 void
 SALOME_Actor
 ::SetPointPicker(vtkPointPicker* thePointPicker) 
@@ -706,6 +764,10 @@ SALOME_Actor
   myPointPicker = thePointPicker;
 }
 
+/*!
+  To set up a picker for cell selection (initialized by SVTK_Renderer::AddActor)
+  \param theCellPicker - new picker
+*/
 void
 SALOME_Actor
 ::SetCellPicker(vtkCellPicker* theCellPicker) 
@@ -713,6 +775,10 @@ SALOME_Actor
   myCellPicker = theCellPicker;
 }
 
+/*!
+  To set up a picker for point rectangle selection (initialized by SVTK_Renderer::AddActor)
+  \param theRectPicker - new picker
+*/
 void
 SALOME_Actor
 ::SetPointRectPicker(SVTK_RectPicker* theRectPicker) 
@@ -720,6 +786,10 @@ SALOME_Actor
   myPointRectPicker = theRectPicker;
 }
 
+/*!
+  To set up a picker for cell rectangle selection (initialized by SVTK_Renderer::AddActor)
+  \param theRectPicker - new picker
+*/
 void
 SALOME_Actor
 ::SetCellRectPicker(SVTK_RectPicker* theRectPicker) 
@@ -727,7 +797,9 @@ SALOME_Actor
   myCellRectPicker = theRectPicker;
 }
 
-//----------------------------------------------------------------------------
+/*!
+  To set up a prehighlight property (initialized by SVTK_Renderer::AddActor)
+*/
 void
 SALOME_Actor
 ::SetPreHighlightProperty(vtkProperty* theProperty) 
@@ -735,6 +807,9 @@ SALOME_Actor
   myPreHighlightActor->SetProperty(theProperty);
 }
 
+/*!
+  To set up a highlight property (initialized by SVTK_Renderer::AddActor)
+*/
 void
 SALOME_Actor
 ::SetHighlightProperty(vtkProperty* theProperty)