From: apo Date: Wed, 14 Nov 2007 08:19:19 +0000 (+0000) Subject: Fix for Bug NPAL16809 X-Git-Tag: V3_2_9rc1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=914fc39fdd72f4d09675b5ef77bb70ffa7eb0f3e;p=modules%2Fvisu.git Fix for Bug NPAL16809 EDF 562 VISU Gauss Picking, having an alphanumeric selection (Context zooming and camera position modification is moved to the post highlight action) --- diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 1941fec3..fe142dcc 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -91,6 +91,31 @@ static int MYDEBUG2 = 0; #endif +namespace +{ + bool + CheckIsSameValue(vtkFloatingPointType theTarget, + vtkFloatingPointType theSource) + { + static vtkFloatingPointType TOL = 10.0 / VTK_LARGE_FLOAT; + return fabs(theTarget - theSource) < TOL; + } + + bool + CheckIsSameVector(vtkFloatingPointType* theTarget, + vtkFloatingPointType* theSource, + size_t theLength) + { + for ( size_t anId = 0; anId < theLength; anId++ ) { + if ( !CheckIsSameValue( theTarget[ anId ], theSource[ anId ] ) ) + return false; + } + + return true; + } + +} + //============================================================================ vtkStandardNewMacro(VISU_GaussPtsAct); @@ -102,7 +127,7 @@ VISU_GaussPtsAct myDeviceActor(VISU_GaussPtsDeviceActor::New()), myWidgetCtrl(NULL), myGaussPointsPL(NULL), - myLastObjPointID(-1), + myLastPreHighlightObjID(-1), myTextActor(VISU_FramedTextActor::New()), myCursorPyramid(VISU_CursorPyramid::New()), myCursorPyramidSelected(VISU_CursorPyramid::New()), @@ -651,7 +676,7 @@ VISU_GaussPtsAct if(!theIsHighlight) - myLastObjPointID = -1; + myLastPreHighlightObjID = -1; Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; @@ -679,7 +704,7 @@ VISU_GaussPtsAct vtkIdType anObjId = GetNodeObjId( aVtkId ); myIsPreselected = (anObjId >= 0); if(myIsPreselected){ - anIsChanged = (myLastObjPointID != anObjId); + anIsChanged = (myLastPreHighlightObjID != anObjId); if(anIsChanged){ vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); vtkDataSet* aDataSet = GetInput(); @@ -702,7 +727,7 @@ VISU_GaussPtsAct aNodeCoord, aColor); } - myLastObjPointID = anObjId; + myLastPreHighlightObjID = anObjId; } myCursorPyramid->SetVisibility(true); } @@ -720,21 +745,19 @@ VISU_GaussPtsAct inline void ChangeZoom(VISU_PickingSettings *thePickingSettings, - vtkInteractorStyle* theInteractorStyle, - int theInitialHasIndex, - int theCurrentHasIndex, - const Handle(SALOME_InteractiveObject)& theIO) + vtkRenderer *theRenderer, + vtkIdType theInitialHasIndex, + vtkIdType theCurrentHasIndex) { if(theInitialHasIndex + theCurrentHasIndex == 1){ - vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); - vtkCamera *aCamera = aRenderer->GetActiveCamera(); + vtkCamera *aCamera = theRenderer->GetActiveCamera(); vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor(); double aScale = aCamera->GetParallelScale(); - if (!theInitialHasIndex && theCurrentHasIndex) { - aCamera->SetParallelScale(aScale/aZoomFactor); + if ( !theInitialHasIndex && theCurrentHasIndex ) { + aCamera->SetParallelScale( aScale / aZoomFactor ); } else { - aCamera->SetParallelScale(aScale*aZoomFactor); + aCamera->SetParallelScale( aScale * aZoomFactor ); } } @@ -749,21 +772,11 @@ VISU_GaussPtsAct if ( !GetPickable() ) return false; - int anInitialHasIndex = myIsHighlighted && mySelectionMode == GaussPointSelection; Handle(SALOME_InteractiveObject) anIO = getIO(); - myIsHighlighted = false; - Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; if(!theIsHighlight && aSelectionMode == GaussPointSelection){ mySelector->RemoveIObject(anIO); - - ChangeZoom(myPickingSettings, - theInteractorStyle, - anInitialHasIndex, - false, - anIO); - return true; } @@ -786,13 +799,6 @@ VISU_GaussPtsAct if(myPointPicker->GetActor() != this) { mySelector->ClearIObjects(); - - ChangeZoom(myPickingSettings, - theInteractorStyle, - anInitialHasIndex, - false, - anIO); - return true; } @@ -800,7 +806,6 @@ VISU_GaussPtsAct if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) { vtkIdType anObjId = GetNodeObjId( aVtkId ); if(anObjId >= 0){ - myIsHighlighted = true; // Update the Selector if(mySelector->IsSelected(myIO)) mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift); @@ -812,42 +817,13 @@ VISU_GaussPtsAct mySelector->AddIObject(this); } // - vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); - // - // FlyTo - vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor(); - vtkFloatingPointType aDollyWas = anInteractor->GetDolly(); - int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames(); - - anInteractor->SetDolly(0.); - anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber()); - anInteractor->FlyTo(aRenderer, aNodeCoord); - aRenderer->ResetCameraClippingRange(); - anInteractor->SetDolly(aDollyWas); - anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas); - - anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord); - mySelectionMode = aSelectionMode; - ChangeZoom(myPickingSettings, - theInteractorStyle, - anInitialHasIndex, - true, - anIO); - return true; - // }// if( anObjId >= 0 ) { }//if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) }//if(!theSelectionEvent->myIsRectangle){ - ChangeZoom(myPickingSettings, - theInteractorStyle, - anInitialHasIndex, - false, - anIO); - return false; } @@ -862,34 +838,72 @@ VISU_GaussPtsAct if(!mySelector.GetPointer()) return; + Selection_Mode aSelectionMode = mySelector->SelectionMode(); + + bool anInitialHasIndex = isHighlighted() && mySelectionMode == GaussPointSelection; + + TColStd_IndexedMapOfInteger aMapIndex; + mySelector->GetIndex( getIO(), aMapIndex ); + bool aCurrentHasIndex = aMapIndex.Extent() == 1; + bool anIsVisible = GetVisibility() && aCurrentHasIndex && theIsHighlight; + myOutlineActor->SetVisibility(false); - myTextActor->SetVisibility(false); - myCursorPyramidSelected->SetVisibility(false); myCursorPyramid->SetVisibility(false); - myCellActor->SetVisibility(false); - GetScalarBarCtrl()->SetIsMarked(false); - GetScalarBarCtrl()->Update(); + + myTextActor->SetVisibility(anIsVisible); + myCellActor->SetVisibility(anIsVisible); + GetScalarBarCtrl()->SetIsMarked(anIsVisible); + myCursorPyramidSelected->SetVisibility(anIsVisible); + + myIsHighlighted = aCurrentHasIndex; + + // Zoom if necessary + ChangeZoom(myPickingSettings, + GetRenderer(), + anInitialHasIndex, + aCurrentHasIndex); if(!theIsHighlight) return; - bool anIsVisible = GetVisibility(); + if ( aSelectionMode == ActorSelection ) { + Superclass::highlight(theIsHighlight); + return; + } - Selection_Mode aSelectionMode = mySelector->SelectionMode(); + if ( aSelectionMode != GaussPointSelection ) + return; - if(aSelectionMode == ActorSelection) - Superclass::highlight(theIsHighlight); - else if(aSelectionMode != GaussPointSelection) + if ( !aCurrentHasIndex || !myBarVisibility ) return; - TColStd_IndexedMapOfInteger aMapIndex; - mySelector->GetIndex( getIO(), aMapIndex ); - if(aMapIndex.Extent() != 1 || !myBarVisibility) { + vtkRenderer *aRenderer = GetRenderer(); + vtkCamera* aCamera = aRenderer->GetActiveCamera(); + + int anObjId = aMapIndex(1); + vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId); + + vtkFloatingPointType aFocalPnt[3]; + aCamera->GetFocalPoint(aFocalPnt); + + if ( CheckIsSameVector( aNodeCoord, aFocalPnt, 3 ) ) return; - } - // + + // FlyTo + vtkRenderWindowInteractor* anInteractor = myInteractor; + vtkFloatingPointType aDollyWas = anInteractor->GetDolly(); + int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames(); + + anInteractor->SetDolly(0.0); + anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber()); + anInteractor->FlyTo(aRenderer, aNodeCoord); + aRenderer->ResetCameraClippingRange(); + anInteractor->SetDolly(aDollyWas); + anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas); + + anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord); + std::ostringstream aStr; - int anObjId = aMapIndex(1); aStr<<"Global ID: "<GetScalars()){ vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId); // - GetScalarBarCtrl()->SetIsMarked(true); GetScalarBarCtrl()->SetMarkValue(aVal); GetScalarBarCtrl()->Update(); // diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 2603a820..09680e30 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -297,7 +297,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor VISU_GaussPointsPL* myCurrentPL; vtkSmartPointer myGaussPointsPL; - vtkIdType myLastObjPointID; + vtkIdType myLastPreHighlightObjID; vtkSmartPointer myTextActor;