#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);
myDeviceActor(VISU_GaussPtsDeviceActor::New()),
myWidgetCtrl(NULL),
myGaussPointsPL(NULL),
- myLastObjPointID(-1),
+ myLastPreHighlightObjID(-1),
myTextActor(VISU_FramedTextActor::New()),
myCursorPyramid(VISU_CursorPyramid::New()),
myCursorPyramidSelected(VISU_CursorPyramid::New()),
if(!theIsHighlight)
- myLastObjPointID = -1;
+ myLastPreHighlightObjID = -1;
Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
vtkIdType anObjId = GetNodeObjId( aVtkId );
myIsPreselected = (anObjId >= 0);
if(myIsPreselected){
- anIsChanged = (myLastObjPointID != anObjId);
+ anIsChanged = (myLastPreHighlightObjID != anObjId);
if(anIsChanged){
vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
vtkDataSet* aDataSet = GetInput();
aNodeCoord,
aColor);
}
- myLastObjPointID = anObjId;
+ myLastPreHighlightObjID = anObjId;
}
myCursorPyramid->SetVisibility(true);
}
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 );
}
}
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;
}
if(myPointPicker->GetActor() != this) {
mySelector->ClearIObjects();
-
- ChangeZoom(myPickingSettings,
- theInteractorStyle,
- anInitialHasIndex,
- false,
- anIO);
-
return true;
}
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);
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;
}
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: "<<anObjId;
//
vtkIdType aVtkId = GetNodeVTKID(anObjId);
if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
//
- GetScalarBarCtrl()->SetIsMarked(true);
GetScalarBarCtrl()->SetMarkValue(aVal);
GetScalarBarCtrl()->Update();
//