From: apo Date: Mon, 14 Nov 2005 13:11:46 +0000 (+0000) Subject: 1. To implement caching of highlight / prehighlight functionality X-Git-Tag: BR-D5-38-2003_D2005-24-11~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ce229d749bed2ab271e556dd712474667cfc9bf5;p=modules%2Fvisu.git 1. To implement caching of highlight / prehighlight functionality 2. To move "change camera zoom on picking" functionality from VVTK_InteractorStyle to VISU_GaussPtsAct --- diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index b17b622c..14b6921e 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -490,19 +490,19 @@ bool VISU_GaussPtsAct::PreHighlight(vtkInteractorStyle* theInteractorStyle, return false; } - if(theSelectionEvent->mySelectionMode == ActorSelection || !theIsHighlight) + if(!theIsHighlight) + myLastObjPointID = -1; + + Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; + + if(aSelectionMode == ActorSelection || !theIsHighlight) return Superclass::PreHighlight(theInteractorStyle, theSelectionEvent, theIsHighlight); - - - bool anIsSelectionModeChanged = (theSelectionEvent->mySelectionMode != mySelectionMode); - if(!anIsSelectionModeChanged && mySelectionMode == ActorSelection) - return false; - - mySelectionMode = theSelectionEvent->mySelectionMode; - - bool anIsChanged = false; + + bool anIsChanged = (mySelectionMode != aSelectionMode); + bool anIsPreselected = myIsPreselected; + if(theIsHighlight){ switch(mySelectionMode){ case NodeSelection: @@ -520,39 +520,83 @@ bool VISU_GaussPtsAct::PreHighlight(vtkInteractorStyle* theInteractorStyle, if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){ vtkIdType anObjId = GetNodeObjId( aVtkId ); - if(myLastObjPointID != anObjId){ - float* aNodeCoord = GetNodeCoord(anObjId); - vtkDataSet* aDataSet = GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - if(vtkDataArray *aScalarArray = aCellData->GetScalars()){ - float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray); - float aPyramidHeight = myPickingSettings->GetPyramidHeight(); - aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); - myCursorPyramid->Init(aPyramidHeight, - aRadius, - aNodeCoord, - myPreHighlightActor->GetProperty()->GetColor()); + myIsPreselected = (anObjId >= 0); + if(myIsPreselected){ + anIsChanged = (myLastObjPointID != anObjId); + if(anIsChanged){ + float* aNodeCoord = GetNodeCoord(anObjId); + vtkDataSet* aDataSet = GetInput(); + vtkCellData* aCellData = aDataSet->GetCellData(); + if(vtkDataArray *aScalarArray = aCellData->GetScalars()){ + float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray); + float aPyramidHeight = myPickingSettings->GetPyramidHeight(); + aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); + myCursorPyramid->Init(aPyramidHeight, + aRadius, + aNodeCoord, + myPreHighlightActor->GetProperty()->GetColor()); + } + myLastObjPointID = anObjId; } - myLastObjPointID = anObjId; + myCursorPyramid->SetVisibility(true); } - myCursorPyramid->SetVisibility(true); - myIsPreselected = theIsHighlight; - anIsChanged = true; } } break; } } + mySelectionMode = aSelectionMode; + anIsChanged |= (anIsPreselected != myIsPreselected); + return anIsChanged; } //---------------------------------------------------------------------------- +inline +void +ChangeZoom(VISU_PickingSettings *thePickingSettings, + vtkInteractorStyle* theInteractorStyle, + int theInitialHasIndex, + SVTK_Selector* theSelector, + const Handle(SALOME_InteractiveObject)& theIO) +{ + int aCurrentHasIndex = theSelector->HasIndex(theIO); + + if(theInitialHasIndex + aCurrentHasIndex == 1){ + vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); + vtkCamera *aCamera = aRenderer->GetActiveCamera(); + float aZoomFactor = thePickingSettings->GetZoomFactor(); + double aScale = aCamera->GetParallelScale(); + if (!theInitialHasIndex && aCurrentHasIndex) { + aCamera->SetParallelScale(aScale/aZoomFactor); + } + else { + aCamera->SetParallelScale(aScale*aZoomFactor); + } + } + +} + bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, SVTK_SelectionEvent* theSelectionEvent, bool theIsHighlight) { + Handle(SALOME_InteractiveObject) anIO = getIO(); + int anInitialHasIndex = mySelector->HasIndex(anIO); + if(!theIsHighlight){ + mySelector->RemoveIObject(anIO); + + ChangeZoom(myPickingSettings, + theInteractorStyle, + anInitialHasIndex, + mySelector.GetPointer(), + anIO); + + return true; + } + if (!myBarVisibility) { return false; } @@ -575,6 +619,13 @@ bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, if(myPointPicker->GetActor() != this) { mySelector->ClearIObjects(); + + ChangeZoom(myPickingSettings, + theInteractorStyle, + anInitialHasIndex, + mySelector.GetPointer(), + anIO); + return true; } @@ -609,11 +660,23 @@ bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, mySelectionMode = aSelectionMode; + ChangeZoom(myPickingSettings, + theInteractorStyle, + anInitialHasIndex, + mySelector.GetPointer(), + anIO); + return true; // }// if( anObjId >= 0 ) { }//if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) }//if(!theSelectionEvent->myIsRectangle){ + + ChangeZoom(myPickingSettings, + theInteractorStyle, + anInitialHasIndex, + mySelector.GetPointer(), + anIO); return false; }