From 8a95f9bdc55143fcc2481583c84efa159d16bb61 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 17 Jan 2006 08:10:34 +0000 Subject: [PATCH] To improve selection in the shift mode --- src/SVTK/SALOME_Actor.cxx | 45 ++++++++++--------------------- src/SVTK/SVTK_InteractorStyle.cxx | 3 ++- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 692b350df..510d9a879 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -942,7 +942,10 @@ SALOME_Actor vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); // Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; - bool isShift = theSelectionEvent->myIsShift; + bool anIsShift = theSelectionEvent->myIsShift; + if( !anIsShift ) { + mySelector->RemoveIObject( this ); + } float x = theSelectionEvent->myX; float y = theSelectionEvent->myY; @@ -957,15 +960,8 @@ SALOME_Actor if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) { int anObjId = GetNodeObjId( aVtkId ); if( anObjId >= 0 ) { - if( mySelector->IsSelected( myIO ) ) - mySelector->AddOrRemoveIndex( myIO, anObjId, isShift ); - else { - if( !isShift ) { - mySelector->ClearIObjects(); - } - mySelector->AddOrRemoveIndex( myIO, anObjId, isShift ); - mySelector->AddIObject( this ); - } + mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift ); + mySelector->AddIObject( this ); } } break; @@ -982,15 +978,8 @@ SALOME_Actor int anObjId = GetElemObjId( aVtkId ); if( anObjId >= 0 ) { if ( CheckDimensionId(aSelectionMode,this,anObjId) ) { - if( mySelector->IsSelected( myIO ) ) - mySelector->AddOrRemoveIndex( myIO, anObjId, isShift ); - else { - if( !isShift ) { - mySelector->ClearIObjects(); - } - mySelector->AddOrRemoveIndex( myIO, anObjId, isShift ); - mySelector->AddIObject( this ); - } + mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift ); + mySelector->AddIObject( this ); } } } @@ -1004,9 +993,6 @@ SALOME_Actor if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) { int anObjId = GetElemObjId( aVtkId ); if( anObjId >= 0 ) { - if( !isShift ) { - mySelector->ClearIObjects(); - } int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId); if( anEdgeId < 0 ) { mySelector->AddOrRemoveIndex( myIO, anObjId, false ); @@ -1019,12 +1005,9 @@ SALOME_Actor } case ActorSelection : { - if( mySelector->IsSelected( myIO ) && isShift ) + if( mySelector->IsSelected( myIO ) && anIsShift ) mySelector->RemoveIObject( this ); else { - if( !isShift ) { - mySelector->ClearIObjects(); - } mySelector->AddIObject( this ); } break; @@ -1067,7 +1050,7 @@ SALOME_Actor } if( !anIndexes.IsEmpty() ) { - mySelector->AddOrRemoveIndex( myIO, anIndexes, true ); + mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift ); mySelector->AddIObject( this ); anIndexes.Clear(); } @@ -1081,7 +1064,7 @@ SALOME_Actor float aPnt[3]; float* aBounds = GetBounds(); - bool picked = true; + bool anIsPicked = true; for( int i = 0; i <= 1; i++ ) { for( int j = 2; j <= 3; j++ ) { for( int k = 4; k <= 5; k++ ) { @@ -1090,14 +1073,14 @@ SALOME_Actor aRenderer->GetDisplayPoint( aPnt ); if( aPnt[0] < x1 || aPnt[0] > x2 || aPnt[1] < y1 || aPnt[1] > y2 ) { - picked = false; + anIsPicked = false; break; } } } } - if( picked ) + if( anIsPicked ) mySelector->AddIObject(this); break; @@ -1130,7 +1113,7 @@ SALOME_Actor } } } - mySelector->AddOrRemoveIndex( myIO, anIndexes, true ); + mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift ); mySelector->AddIObject( this ); } default: diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 389c3a359..963aa1894 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -914,7 +914,8 @@ SVTK_InteractorStyle }else{ if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != anActor) myLastHighlitedActor->Highlight( this, aSelectionEvent, false ); - GetSelector()->ClearIObjects(); + if(!myShiftState) + GetSelector()->ClearIObjects(); } myLastHighlitedActor = anActor; } -- 2.39.2