SALOME_Actor
::SALOME_Actor()
{
+ mySelectionMode = ActorSelection;
myIsHighlighted = myIsPreselected = false;
myRepresentation = 1;
//----------------------------------------------------------------
void
SALOME_Actor
-::highlight( bool theHighlight, Selection_Mode theMode )
+::highlight( bool theHighlight, int theSelectionMode )
{
myIsHighlighted = theHighlight;
myOutline->SetBounds( GetBounds() );
myOutlineActor->SetVisibility( theHighlight );
- myHighlightActor->SetVisibility( theHighlight && theMode != ActorSelection );
+ myHighlightActor->SetVisibility( theHighlight && theSelectionMode != ActorSelection );
}
//----------------------------------------------------------------
myOutlineActor->SetVisibility( theVisibility && isHighlighted() );
myHighlightActor->SetVisibility( theVisibility && isHighlighted() );
+ myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected );
}
SVTK_SelectionEvent theSelectionEvent,
bool theIsHighlight )
{
- Selection_Mode aSelectionMode = theSelectionEvent.SelectionMode;
- float x = theSelectionEvent.X;
- float y = theSelectionEvent.Y;
+ myPreHighlightActor->SetVisibility( false );
+
+ bool anIsSelectionModeChanged = (theSelectionEvent.mySelectionMode != mySelectionMode);
+ if(!anIsSelectionModeChanged && mySelectionMode == ActorSelection)
+ return false;
+
+ mySelectionMode = theSelectionEvent.mySelectionMode;
+
+ float x = theSelectionEvent.myX;
+ float y = theSelectionEvent.myY;
float z = 0.0;
+
+ bool anIsChanged = false;
if( !theIsHighlight )
{
- myPreHighlightActor->SetVisibility( false );
-
vtkActorCollection* theActors = theRenderer->GetActors();
theActors->InitTraversal();
while( vtkActor *ac = theActors->GetNextActor() )
if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
- anActor->SetPreSelected( false );
+ if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
+ anActor->SetPreSelected( false );
- return false;
- }
-
- if( aSelectionMode == NodeSelection )
- {
- myPointPicker->Pick( x, y, z, theRenderer );
-
- int aVtkId = myPointPicker->GetPointId();
- if( aVtkId >= 0 && theValidator->IsValid( this, aVtkId, true ) && hasIO() )
+ myIsPreselected = theIsHighlight;
+ anIsChanged = true;
+ }else{
+ switch(mySelectionMode){
+ case NodeSelection:
{
- int anObjId = GetNodeObjId( aVtkId );
- TColStd_IndexedMapOfInteger aMapIndex;
- aMapIndex.Add( anObjId );
-
- myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
- myPreHighlightActor->SetVisibility( true );
- myPreHighlightActor->MapPoints( this, aMapIndex );
+ myPointPicker->Pick( x, y, z, theRenderer );
+
+ int aVtkId = myPointPicker->GetPointId();
+ if( aVtkId >= 0 && theValidator->IsValid( this, aVtkId, true ) && hasIO() )
+ {
+ int anObjId = GetNodeObjId( aVtkId );
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
+
+ myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
+ myPreHighlightActor->SetVisibility( true );
+ myPreHighlightActor->MapPoints( this, aMapIndex );
+
+ myIsPreselected = theIsHighlight;
+ anIsChanged = true;
+ }
+ break;
}
- }
- else if( aSelectionMode == CellSelection )
- {
- myCellPicker->Pick( x, y, z, theRenderer );
-
- int aVtkId = myCellPicker->GetCellId();
- if ( aVtkId >= 0 && theValidator->IsValid( this, aVtkId ) && hasIO() )
+ case CellSelection:
{
- int anObjId = GetElemObjId (aVtkId );
- TColStd_IndexedMapOfInteger aMapIndex;
- aMapIndex.Add( anObjId );
+ myCellPicker->Pick( x, y, z, theRenderer );
+
+ int aVtkId = myCellPicker->GetCellId();
+ if ( aVtkId >= 0 && theValidator->IsValid( this, aVtkId ) && hasIO() )
+ {
+ int anObjId = GetElemObjId (aVtkId );
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
- myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
- myPreHighlightActor->SetVisibility( true );
- myPreHighlightActor->MapCells( this, aMapIndex );
- }
- }
- else if( aSelectionMode == EdgeOfCellSelection )
- {
- myCellPicker->Pick( x, y, z, theRenderer );
+ myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
+ myPreHighlightActor->SetVisibility( true );
+ myPreHighlightActor->MapCells( this, aMapIndex );
- int aVtkId = myCellPicker->GetCellId();
- if ( aVtkId >= 0 && theValidator->IsValid( this, aVtkId ) && hasIO() )
+ myIsPreselected = theIsHighlight;
+ anIsChanged = true;
+ }
+ break;
+ }
+ case EdgeOfCellSelection:
{
- int anObjId = GetElemObjId( aVtkId );
- int anEdgeId = GetEdgeId( myCellPicker, anObjId );
- TColStd_IndexedMapOfInteger aMapIndex;
- aMapIndex.Add( anObjId );
- aMapIndex.Add( anEdgeId );
-
- myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
- myPreHighlightActor->SetVisibility( true );
- myPreHighlightActor->MapEdge( this, aMapIndex );
+ myCellPicker->Pick( x, y, z, theRenderer );
+
+ int aVtkId = myCellPicker->GetCellId();
+ if ( aVtkId >= 0 && theValidator->IsValid( this, aVtkId ) && hasIO() )
+ {
+ int anObjId = GetElemObjId( aVtkId );
+ int anEdgeId = GetEdgeId( myCellPicker, anObjId );
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
+ aMapIndex.Add( anEdgeId );
+
+ myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
+ myPreHighlightActor->SetVisibility( true );
+ myPreHighlightActor->MapEdge( this, aMapIndex );
+
+ myIsPreselected = theIsHighlight;
+ anIsChanged = true;
+ }
+ break;
}
- }
- else
- {
- if( hasIO() && !theSelector->IsSelected( myIO ) )
+ default:
{
- vtkActorCollection* theActors = theRenderer->GetActors();
- theActors->InitTraversal();
- while( vtkActor *ac = theActors->GetNextActor() )
+ myPreHighlightActor->SetVisibility( true );
+
+ if( hasIO() && !theSelector->IsSelected( myIO ) )
{
- if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
- if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
- anActor->SetPreSelected( true );
+ vtkActorCollection* theActors = theRenderer->GetActors();
+ theActors->InitTraversal();
+ while( vtkActor *ac = theActors->GetNextActor() )
+ {
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
+ if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
+ anActor->SetPreSelected( true );
+ }
}
+ myIsPreselected = theIsHighlight;
+ anIsChanged = true;
+ }
}
}
- return true;
+ return anIsChanged;
}
SVTK_SelectionEvent theSelectionEvent,
bool theIsHighlight )
{
- Selection_Mode aSelectionMode = theSelectionEvent.SelectionMode;
- float x1 = theSelectionEvent.X;
- float y1 = theSelectionEvent.Y;
+ int aSelectionMode = theSelectionEvent.mySelectionMode;
+ float x1 = theSelectionEvent.myX;
+ float y1 = theSelectionEvent.myY;
float z1 = 0.0;
- float x2 = theSelectionEvent.LastX;
- float y2 = theSelectionEvent.LastY;
+ float x2 = theSelectionEvent.myLastX;
+ float y2 = theSelectionEvent.myLastY;
float z2 = 0.0;
- bool isShift = theSelectionEvent.IsShift;
- bool isRectangle = theSelectionEvent.IsRectangle;
+ bool isShift = theSelectionEvent.myIsShift;
+ bool isRectangle = theSelectionEvent.myIsRectangle;
if( !isRectangle )
{
Interactor->GetEventPosition( x, y );
Interactor->GetSize( w, h );
- aSelectionEvent.X = x;
- aSelectionEvent.Y = h - y - 1;
- aSelectionEvent.IsCtrl = Interactor->GetControlKey();
- aSelectionEvent.IsShift = Interactor->GetShiftKey();
+ aSelectionEvent.myX = x;
+ aSelectionEvent.myY = h - y - 1;
+ aSelectionEvent.myIsCtrl = Interactor->GetControlKey();
+ aSelectionEvent.myIsShift = Interactor->GetShiftKey();
return aSelectionEvent;
}
myPicker->Pick(x, y, 0.0, this->CurrentRenderer);
if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(myPicker->GetActor())){
SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
- aSelectionEvent.SelectionMode = aSelectionMode;
- aSelectionEvent.IsRectangle = false;
+ aSelectionEvent.mySelectionMode = aSelectionMode;
+ aSelectionEvent.myIsRectangle = false;
aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
}else{
GetSelector()->ClearIObjects();
myRectPicker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
- aSelectionEvent.SelectionMode = aSelectionMode;
- aSelectionEvent.IsRectangle = true;
- aSelectionEvent.LastX = x1;
- aSelectionEvent.LastY = y1;
+ aSelectionEvent.mySelectionMode = aSelectionMode;
+ aSelectionEvent.myIsRectangle = true;
+ aSelectionEvent.myLastX = x1;
+ aSelectionEvent.myLastY = y1;
vtkActorCollection* aListActors = myRectPicker->GetActors();
aListActors->InitTraversal();
Interactor->StartPickCallback();
SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
- aSelectionEvent.SelectionMode = myViewWindow->SelectionMode();
- aSelectionEvent.X = x;
- aSelectionEvent.Y = y;
+ aSelectionEvent.mySelectionMode = myViewWindow->SelectionMode();
+ aSelectionEvent.myX = x;
+ aSelectionEvent.myY = y;
- if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(myPicker->GetActor()))
- aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, false );
+ bool anIsChanged = false;
+ SALOME_Actor* aLastActor = SALOME_Actor::SafeDownCast(myPicker->GetActor());
myPicker->Pick(x, y, 0.0, this->CurrentRenderer);
- if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(myPicker->GetActor()))
- aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
+ if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(myPicker->GetActor())){
+ anIsChanged |= anActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
+ if(aLastActor && aLastActor != anActor)
+ aLastActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, false );
+ }
Interactor->EndPickCallback();
- //Interactor->Render();
- myGUIWindow->update();
+
+ if(anIsChanged)
+ Interactor->Render();
this->LastPos[0] = x;
this->LastPos[1] = y;