From 19906ad7a8a9cb32ff663c64908b3b979764219d Mon Sep 17 00:00:00 2001 From: pkv Date: Tue, 6 Sep 2005 06:08:52 +0000 Subject: [PATCH] provides pass vtkInteractorStyle objrct to the methods Highlight(),Prehighlight() in order to be able to use the methods of the class vtkInteractorStyle --- src/SVTK/SALOME_Actor.cxx | 47 +++++++++++++++++-------------- src/SVTK/SALOME_Actor.h | 8 ++++-- src/SVTK/SVTK_InteractorStyle.cxx | 17 ++++++----- 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 764b2a0d4..c8ae5aba6 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -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; } + diff --git a/src/SVTK/SALOME_Actor.h b/src/SVTK/SALOME_Actor.h index 12098a807..06896be1b 100644 --- a/src/SVTK/SALOME_Actor.h +++ b/src/SVTK/SALOME_Actor.h @@ -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 ); diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index d4ed7b4a9..4ab604861 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -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) -- 2.39.2