};
return false;
}
+}
- class TPickLimiter
+namespace SVTK
+{
+ /*!
+ Make picker work with this actor only
+ */
+ TPickLimiter::TPickLimiter(vtkAbstractPicker* picker, SALOME_Actor* actor):myPicker(picker)
{
- vtkAbstractPicker* myPicker;
- public:
- /*!
- Make picker work with this actor only
- */
- TPickLimiter(vtkAbstractPicker* picker, SALOME_Actor* actor):myPicker(picker)
- {
- myPicker->InitializePickList();
- myPicker->AddPickList( actor );
- myPicker->SetPickFromList( true );
- }
- /*!
- Unlimit picking
- */
- ~TPickLimiter()
- {
- myPicker->SetPickFromList( false );
- myPicker->InitializePickList();
- }
- };
+ myPicker->InitializePickList();
+ myPicker->AddPickList( actor );
+ myPicker->SetPickFromList( true );
+ }
+ /*!
+ Unlimit picking
+ */
+ TPickLimiter::~TPickLimiter()
+ {
+ myPicker->SetPickFromList( false );
+ myPicker->InitializePickList();
+ }
}
switch(aSelectionMode) {
case NodeSelection:
{
- TPickLimiter( myPointPicker, this );
+ SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
myPointPicker->Pick( x, y, z, aRenderer );
int aVtkId = myPointPicker->GetPointId();
case FaceSelection:
case VolumeSelection:
{
- TPickLimiter( myCellPicker, this );
+ SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
myCellPicker->Pick( x, y, z, aRenderer );
int aVtkId = myCellPicker->GetCellId();
}
case EdgeOfCellSelection:
{
- TPickLimiter( myCellPicker, this );
+ SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
myCellPicker->Pick( x, y, z, aRenderer );
int aVtkId = myCellPicker->GetCellId();
if( !theSelectionEvent->myIsRectangle ) {
switch(aSelectionMode){
case NodeSelection: {
- TPickLimiter( myPointPicker, this );
+ SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
myPointPicker->Pick( x, y, z, aRenderer );
int aVtkId = myPointPicker->GetPointId();
case FaceSelection:
case VolumeSelection:
{
- TPickLimiter( myCellPicker, this );
+ SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
myCellPicker->Pick( x, y, z, aRenderer );
int aVtkId = myCellPicker->GetCellId();
}
case EdgeOfCellSelection:
{
- TPickLimiter( myCellPicker, this );
+ SVTK::TPickLimiter aPickLimiter( myCellPicker, this );
myCellPicker->Pick( x, y, z, aRenderer );
int aVtkId = myCellPicker->GetCellId();
switch(aSelectionMode){
case NodeSelection: {
- TPickLimiter( myPointRectPicker, this );
+ SVTK::TPickLimiter aPickLimiter( myPointRectPicker, this );
myPointRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myPointRectPicker->GetPointIdsMap();
case FaceSelection:
case VolumeSelection:
{
- TPickLimiter( myCellRectPicker, this );
+ SVTK::TPickLimiter aPickLimiter( myCellRectPicker, this );
myCellRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
const SVTK_RectPicker::TVectorIdsMap& aVectorIdsMap = myCellRectPicker->GetCellIdsMap();
{
SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY();
- SALOME_Actor* anActor = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
+ bool isPicked = false;
+ vtkActorCollection* anActorCollection = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
- if ( anActor )
+ if( anActorCollection )
{
- myPointPicker->Pick( aSelectionEvent->myX,
- aSelectionEvent->myY,
- 0.0,
- GetCurrentRenderer() );
- int aVtkId = myPointPicker->GetPointId();
- if ( aVtkId >= 0 )
+ anActorCollection->InitTraversal();
+ while( vtkActor* aVTKActor = anActorCollection->GetNextActor() )
{
- int anObjId = anActor->GetNodeObjId( aVtkId );
- vtkFloatingPointType* aCoords = anActor->GetNodeCoord(anObjId);
-
- if (myCurrRotationPointType == SVTK::StartPointSelection) {
- myCurrRotationPointType = SVTK::SetRotateSelected;
-
- // invoke event for update coordinates in SVTK_SetRotationPointDlg
- InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords);
- }
- else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) {
- myCurrFocalPointType = SVTK::SetFocalPointSelected;
-
- // invoke event for update coordinates in SVTK_ViewParameterDlg
- InvokeEvent(SVTK::FocalPointChanged,(void*)aCoords);
- }
- }
- else
- {
- if (myCurrRotationPointType == SVTK::StartPointSelection) {
- // invoke event with no data (for SVTK_SetRotationPointDlg)
- InvokeEvent(SVTK::RotationPointChanged,0);
- myCurrRotationPointType = myPrevRotationPointType;
- }
- else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) {
- // invoke event with no data (for SVTK_ViewParameterDlg)
- InvokeEvent(SVTK::FocalPointChanged,0);
- myCurrFocalPointType = myPrevFocalPointType;
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( aVTKActor ) )
+ {
+ SVTK::TPickLimiter aPickLimiter( myPointPicker, anActor );
+ myPointPicker->Pick( aSelectionEvent->myX,
+ aSelectionEvent->myY,
+ 0.0,
+ GetCurrentRenderer() );
+ int aVtkId = myPointPicker->GetPointId();
+ if ( aVtkId >= 0 )
+ {
+ int anObjId = anActor->GetNodeObjId( aVtkId );
+ vtkFloatingPointType* aCoords = anActor->GetNodeCoord(anObjId);
+
+ if (myCurrRotationPointType == SVTK::StartPointSelection) {
+ myCurrRotationPointType = SVTK::SetRotateSelected;
+
+ // invoke event for update coordinates in SVTK_SetRotationPointDlg
+ InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords);
+ }
+ else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) {
+ myCurrFocalPointType = SVTK::SetFocalPointSelected;
+
+ // invoke event for update coordinates in SVTK_ViewParameterDlg
+ InvokeEvent(SVTK::FocalPointChanged,(void*)aCoords);
+ }
+
+ isPicked = true;
+ break;
+ }
}
}
}
- else
+
+ if( !isPicked )
{
if (myCurrRotationPointType == SVTK::StartPointSelection) {
// invoke event with no data (for SVTK_SetRotationPointDlg)
this->FindPokedRenderer(aSelectionEvent->myX, aSelectionEvent->myY);
Interactor->StartPickCallback();
- SALOME_Actor* anActor = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
+ SALOME_Actor* aHighlightedActor = NULL;
+ vtkActorCollection* anActorCollection = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
aSelectionEvent->myIsRectangle = false;
if(!myShiftState)
GetSelector()->ClearIObjects();
- if(anActor)
+ if( anActorCollection )
+ {
+ anActorCollection->InitTraversal();
+ while( vtkActor* aVTKActor = anActorCollection->GetNextActor() )
{
- anActor->Highlight( this, aSelectionEvent, true );
- }
- else
- {
- if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != anActor)
- myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( aVTKActor ) )
+ {
+ if( anActor->Highlight( this, aSelectionEvent, true ) &&
+ anActor->isHighlighted() )
+ {
+ aHighlightedActor = anActor;
+ break;
+ }
+ }
}
- myLastHighlitedActor = anActor;
+ }
+
+ if( !aHighlightedActor )
+ {
+ if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != aHighlightedActor)
+ myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
+ }
+ myLastHighlitedActor = aHighlightedActor;
}
else
{
bool anIsChanged = false;
- SALOME_Actor *anActor = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
+ SALOME_Actor* aPreHighlightedActor = NULL;
+ vtkActorCollection* anActorCollection = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
if ( myCurrRotationPointType == SVTK::StartPointSelection ||
myCurrFocalPointType == SVTK::StartFocalPointSelection )
{
myHighlightSelectionPointActor->SetVisibility( false );
- if ( anActor )
+ if( anActorCollection )
{
- myPointPicker->Pick( aSelectionEvent->myX, aSelectionEvent->myY, 0.0, GetCurrentRenderer() );
- int aVtkId = myPointPicker->GetPointId();
- if ( aVtkId >= 0 ) {
- int anObjId = anActor->GetNodeObjId( aVtkId );
-
- TColStd_IndexedMapOfInteger aMapIndex;
- aMapIndex.Add( anObjId );
- myHighlightSelectionPointActor->MapPoints( anActor, aMapIndex );
-
- myHighlightSelectionPointActor->SetVisibility( true );
- anIsChanged = true;
+ anActorCollection->InitTraversal();
+ while( vtkActor* aVTKActor = anActorCollection->GetNextActor() )
+ {
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( aVTKActor ) )
+ {
+ SVTK::TPickLimiter aPickLimiter( myPointPicker, anActor );
+ myPointPicker->Pick( aSelectionEvent->myX, aSelectionEvent->myY, 0.0, GetCurrentRenderer() );
+ int aVtkId = myPointPicker->GetPointId();
+ if ( aVtkId >= 0 ) {
+ int anObjId = anActor->GetNodeObjId( aVtkId );
+
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
+ myHighlightSelectionPointActor->MapPoints( anActor, aMapIndex );
+
+ myHighlightSelectionPointActor->SetVisibility( true );
+ anIsChanged = true;
+ break;
+ }
+ }
}
}
}
else {
- if (anActor){
- anIsChanged |= anActor->PreHighlight( this, aSelectionEvent, true );
+ if( anActorCollection )
+ {
+ anActorCollection->InitTraversal();
+ while( vtkActor* aVTKActor = anActorCollection->GetNextActor() )
+ {
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( aVTKActor ) )
+ {
+ anIsChanged = anActor->PreHighlight( this, aSelectionEvent, true );
+ if( anActor->isPreselected() )
+ {
+ aPreHighlightedActor = anActor;
+ break;
+ }
+ }
+ }
}
- if(myLastPreHighlitedActor.GetPointer() && myLastPreHighlitedActor.GetPointer() != anActor)
+ if(myLastPreHighlitedActor.GetPointer() && myLastPreHighlitedActor.GetPointer() != aPreHighlightedActor)
anIsChanged |= myLastPreHighlitedActor->PreHighlight( this, aSelectionEvent, false );
}
- myLastPreHighlitedActor = anActor;
+ myLastPreHighlitedActor = aPreHighlightedActor;
if(anIsChanged)
this->Render();