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:
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;
}
if(myPointPicker->GetActor() != this) {
mySelector->ClearIObjects();
+
+ ChangeZoom(myPickingSettings,
+ theInteractorStyle,
+ anInitialHasIndex,
+ mySelector.GetPointer(),
+ anIO);
+
return true;
}
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;
}