]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
provides pass vtkInteractorStyle objrct to the methods Highlight(),Prehighlight(...
authorpkv <pkv@opencascade.com>
Tue, 6 Sep 2005 06:08:52 +0000 (06:08 +0000)
committerpkv <pkv@opencascade.com>
Tue, 6 Sep 2005 06:08:52 +0000 (06:08 +0000)
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK_InteractorStyle.cxx

index 764b2a0d45d1e318b1e44e47fcabdcc24e2a2087..c8ae5aba6ac9ab222275951135222534ce1f838c 100644 (file)
@@ -55,6 +55,7 @@
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
 #include <vtkOutlineSource.h>
+#include <vtkInteractorStyle.h>
 
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
@@ -546,15 +547,17 @@ SALOME_Actor
   return anEdgeId;
 }
 
-
 //----------------------------------------------------------------
 bool
 SALOME_Actor
 ::PreHighlight( SVTK_Selector* theSelector,
-               vtkRenderer* theRenderer,
+               //vtkRenderer* theRenderer,
+               vtkInteractorStyle *theIS, 
                SVTK_SelectionEvent theSelectionEvent,
                bool theIsHighlight )
 {
+  vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
+  //
   myPreHighlightActor->SetVisibility( false );
     
   bool anIsSelectionModeChanged = (theSelectionEvent.mySelectionMode != mySelectionMode);
@@ -571,7 +574,7 @@ SALOME_Actor
   bool anIsChanged = false;
   if( !theIsHighlight )
   {
-    vtkActorCollection* theActors = theRenderer->GetActors();
+    vtkActorCollection* theActors = aRenderer->GetActors();
     theActors->InitTraversal();
     while( vtkActor *ac = theActors->GetNextActor() )
       if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
@@ -584,7 +587,7 @@ SALOME_Actor
     switch(mySelectionMode){
     case NodeSelection: 
     {
-      myPointPicker->Pick( x, y, z, theRenderer );
+      myPointPicker->Pick( x, y, z, aRenderer );
       
       int aVtkId = myPointPicker->GetPointId();
       if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO() )
@@ -604,7 +607,7 @@ SALOME_Actor
     }
     case CellSelection:
     {
-      myCellPicker->Pick( x, y, z, theRenderer );
+      myCellPicker->Pick( x, y, z, aRenderer );
       
       int aVtkId = myCellPicker->GetCellId();
       if ( aVtkId >= 0 && theSelector->IsValid( this, aVtkId ) && hasIO() )
@@ -624,7 +627,7 @@ SALOME_Actor
     }
     case EdgeOfCellSelection:
     {
-      myCellPicker->Pick( x, y, z, theRenderer );
+      myCellPicker->Pick( x, y, z, aRenderer );
       
       int aVtkId = myCellPicker->GetCellId();
       if ( aVtkId >= 0 && theSelector->IsValid( this, aVtkId ) && hasIO() )
@@ -650,7 +653,7 @@ SALOME_Actor
 
       if( hasIO() && !theSelector->IsSelected( myIO ) )
       {
-       vtkActorCollection* theActors = theRenderer->GetActors();
+       vtkActorCollection* theActors = aRenderer->GetActors();
        theActors->InitTraversal();
        while( vtkActor *ac = theActors->GetNextActor() )
         {
@@ -667,16 +670,17 @@ SALOME_Actor
 
   return anIsChanged;
 }
-
-
 //----------------------------------------------------------------
 bool
 SALOME_Actor
 ::Highlight( SVTK_Selector* theSelector,
-            vtkRenderer* theRenderer,
+            vtkInteractorStyle* theIS,
             SVTK_SelectionEvent theSelectionEvent,
             bool theIsHighlight )
 {
+  vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
+  
+  //
   int aSelectionMode = theSelectionEvent.mySelectionMode;
   float x1 = theSelectionEvent.myX;
   float y1 = theSelectionEvent.myY;
@@ -691,7 +695,7 @@ SALOME_Actor
   {
     if( aSelectionMode == NodeSelection )
     {
-      myPointPicker->Pick( x1, y1, z1, theRenderer );
+      myPointPicker->Pick( x1, y1, z1, aRenderer );
 
       int aVtkId = myPointPicker->GetPointId();
       if( aVtkId >= 0 && hasIO() && theSelector->IsValid( this, aVtkId, true ) )
@@ -715,7 +719,7 @@ SALOME_Actor
     }
     else if( aSelectionMode == CellSelection )
     {
-      myCellPicker->Pick( x1, y1, z1, theRenderer );
+      myCellPicker->Pick( x1, y1, z1, aRenderer );
     
       int aVtkId = myCellPicker->GetCellId();
       if( aVtkId >= 0 && hasIO() && theSelector->IsValid( this, aVtkId ) )
@@ -741,7 +745,7 @@ SALOME_Actor
     }
     else if( aSelectionMode == EdgeOfCellSelection )
     {
-      myCellPicker->Pick( x1, y1, z1, theRenderer );
+      myCellPicker->Pick( x1, y1, z1, aRenderer );
     
       int aVtkId = myCellPicker->GetCellId();
       if( aVtkId >= 0 && hasIO() && theSelector->IsValid( this, aVtkId ) )
@@ -793,18 +797,18 @@ SALOME_Actor
          aDataSet->GetPoint( i, aPoint );
 
          float aPnt[3];
-         theRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
-         theRenderer->WorldToDisplay();
-         theRenderer->GetDisplayPoint( aPnt );
+         aRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
+         aRenderer->WorldToDisplay();
+         aRenderer->GetDisplayPoint( aPnt );
 
          if( aPnt[0] > x2 && aPnt[0] < x1 && aPnt[1] > y1 && aPnt[1] < y2 )
          {
            float aDisp[3];
-           theRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
-           theRenderer->WorldToDisplay();
-           theRenderer->GetDisplayPoint( aDisp );
+           aRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
+           aRenderer->WorldToDisplay();
+           aRenderer->GetDisplayPoint( aDisp );
 
-           if( myPointPicker->Pick( aDisp[0], aDisp[1], 0.0, theRenderer ) )
+           if( myPointPicker->Pick( aDisp[0], aDisp[1], 0.0, aRenderer ) )
            {
              if( vtkActorCollection* anActorCollection = myPointPicker->GetActors() )
              {
@@ -836,7 +840,7 @@ SALOME_Actor
     else if( aSelectionMode != ActorSelection && hasIO() )
     {
       myCellRectPicker->SetTolerance( 0.001 );
-      myCellRectPicker->Pick( x2, y2, z2, x1, y1, z1, theRenderer );
+      myCellRectPicker->Pick( x2, y2, z2, x1, y1, z1, aRenderer );
 
       VTKViewer_CellDataSet cellList = myCellRectPicker->GetCellData( this );
       TColStd_MapOfInteger anIndexes;
@@ -893,3 +897,4 @@ SALOME_Actor
 
   return true;
 }
+
index 12098a807686d633c38e8556975fb93dacd42d4b..06896be1bf583740985e64cfa1917e310a9a3759 100644 (file)
@@ -51,7 +51,7 @@ class vtkProperty;
 class vtkPolyDataMapper;
 class vtkOutlineSource;
 class vtkRenderer;
-
+class vtkInteractorStyle;
 class VTKViewer_Transform;
 class VTKViewer_GeometryFilter;
 class VTKViewer_TransformFilter;
@@ -328,16 +328,18 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   void
   RemoveFromRender( vtkRenderer* );
 
+  
   virtual
   bool
   PreHighlight(        SVTK_Selector*, 
-               vtkRenderer*, 
+               vtkInteractorStyle*, 
                SVTK_SelectionEvent, 
                bool );
+
   virtual 
   bool
   Highlight( SVTK_Selector*, 
-            vtkRenderer*, 
+            vtkInteractorStyle*,
             SVTK_SelectionEvent, 
             bool );
 
index d4ed7b4a9ddba34eecc0ea4ea22e1db5c277d167..4ab6048618322848afed495b4ed8589035bb840a 100644 (file)
@@ -944,11 +944,13 @@ SVTK_InteractorStyle
            SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
            aSelectionEvent.mySelectionMode = aSelectionMode;
            aSelectionEvent.myIsRectangle = false;
-           aSActor->Highlight( GetSelector(), GetCurrentRenderer(), aSelectionEvent, true );
-         }else{
+           aSActor->Highlight( GetSelector(), this, aSelectionEvent, true );
+         }
+         else{
            GetSelector()->ClearIObjects();
          }
-        } else {
+        } 
+       else {
           //processing rectangle selection
          Interactor->StartPickCallback();
          GetSelector()->StartPickCallback();
@@ -984,7 +986,7 @@ SVTK_InteractorStyle
          aListActors->InitTraversal();
          while(vtkActor* aActor = aListActors->GetNextActor()){
            if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)){
-             aSActor->Highlight( GetSelector(), GetCurrentRenderer(), aSelectionEvent, true );
+             aSActor->Highlight( GetSelector(), this, aSelectionEvent, true );
            }
          }
        }
@@ -1092,9 +1094,10 @@ SVTK_InteractorStyle
 
   myPicker->Pick(x, y, 0.0, GetCurrentRenderer());
   if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(myPicker->GetActor())){
-    anIsChanged |= anActor->PreHighlight( GetSelector(), GetCurrentRenderer(), aSelectionEvent, true );
-    if(aLastActor && aLastActor != anActor)
-      aLastActor->PreHighlight( GetSelector(), GetCurrentRenderer(), aSelectionEvent, false );
+    anIsChanged |= anActor->PreHighlight( GetSelector(), this, aSelectionEvent, true );
+    if(aLastActor && aLastActor != anActor) {
+      aLastActor->PreHighlight( GetSelector(), this, aSelectionEvent, false );
+    }
   }
   
   if(anIsChanged)