From: ouv Date: Mon, 15 Aug 2005 10:53:57 +0000 (+0000) Subject: Selection mechanism corrected X-Git-Tag: BR-D5-38-2003_D2005-12-09~55 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bfcf1a57fed5f97a70b882a77854f5a97f522f33;p=modules%2Fgui.git Selection mechanism corrected --- diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 190d8e561..c47bf0bea 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -58,6 +58,7 @@ #include #include #include +#include "vtkOutlineSource.h" #include #include @@ -127,6 +128,21 @@ SALOME_Actor::SALOME_Actor(){ myHighlightActor = SVTK_Actor::New(); myHighlightActor->PickableOff(); myHighlightActor->SetProperty( myPointProperty ); + + + myOutline = vtkOutlineSource::New(); + + myOutlineMapper = vtkPolyDataMapper::New(); + myOutlineMapper->SetInput( myOutline->GetOutput() ); + + myOutlineActor = vtkActor::New(); + myOutlineActor->PickableOff(); + myOutlineActor->DragableOff(); + myOutlineActor->SetMapper( myOutlineMapper ); + myOutlineActor->GetProperty()->SetColor(0.0,1.0,0.0); + myOutlineActor->GetProperty()->SetAmbient(1.0); + myOutlineActor->GetProperty()->SetDiffuse(0.0); + myOutlineActor->SetVisibility( false ); } @@ -152,7 +168,11 @@ SALOME_Actor::~SALOME_Actor(){ myPointPicker->Delete(); myCellPicker->Delete(); myCellRectPicker->Delete(); - myHighlightActor->SetProperty( NULL ); + myHighlightActor->Delete(); + + myOutline->Delete(); + myOutlineMapper->Delete(); + myOutlineActor->Delete(); } @@ -162,6 +182,7 @@ void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){ // from VISU theRenderer->AddActor( myPreHighlightActor ); theRenderer->AddActor( myHighlightActor ); + theRenderer->AddActor( myOutlineActor ); } void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){ @@ -170,6 +191,7 @@ void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){ // from VISU theRenderer->RemoveActor( myPreHighlightActor ); theRenderer->RemoveActor( myHighlightActor ); + theRenderer->RemoveActor( myOutlineActor ); } @@ -363,11 +385,17 @@ void SALOME_Actor::setDisplayMode(int theMode){ // from VISU //---------------------------------------------------------------- -void SALOME_Actor::highlight( bool theHighlight ) +void SALOME_Actor::highlight( bool theHighlight, Selection_Mode theMode ) { //cout << "SALOME_Actor::highlight " << ( theHighlight ? "on" : "off" ) << endl; - myHighlightActor->SetVisibility( theHighlight ); + if( !GetVisibility() ) + return; + + myOutline->SetBounds( GetBounds() ); + myOutlineActor->SetVisibility( theHighlight ); + + myHighlightActor->SetVisibility( theHighlight && theMode != ActorSelection ); } //---------------------------------------------------------------- @@ -376,6 +404,7 @@ void SALOME_Actor::SetVisibility( int theVisibility ) //cout << "SALOME_Actor::SetVisibility " << ( theVisibility ? "on" : "off" ) << endl; vtkProp::SetVisibility( theVisibility ); + myOutlineActor->SetVisibility( theVisibility && isHighlighted() ); myHighlightActor->SetVisibility( theVisibility && isHighlighted() ); } @@ -731,22 +760,15 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle, cout << "IsHighlight : " << ( theIsHighlight ? "true" : "false" ) << endl; */ - if( GetVisibility() && theIsHighlight ) - theInteractorStyle->HighlightProp( this ); - else if( !theIsHighlight ) - theInteractorStyle->HighlightProp( NULL ); - switch( aSelectionMode ) { case NodeSelection: myHighlightActor->SetProperty( myPointProperty ); myHighlightActor->MapPoints( this, aMapIndex ); - highlight( theIsHighlight ); break; case EdgeOfCellSelection: myHighlightActor->SetProperty( myEdgeProperty ); myHighlightActor->MapEdge( this, aMapIndex ); - highlight( theIsHighlight ); break; case CellSelection: case EdgeSelection: @@ -754,13 +776,13 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle, case VolumeSelection: myHighlightActor->SetProperty( myCellProperty ); myHighlightActor->MapCells( this, aMapIndex ); - highlight( theIsHighlight ); break; case ActorSelection: - highlight( false ); break; } + highlight( theIsHighlight, aSelectionMode ); + return true; } diff --git a/src/SVTK/SALOME_Actor.h b/src/SVTK/SALOME_Actor.h index 0bb64057d..31c4a44b7 100644 --- a/src/SVTK/SALOME_Actor.h +++ b/src/SVTK/SALOME_Actor.h @@ -34,8 +34,8 @@ #include "Handle_SALOME_InteractiveObject.hxx" #endif -#include // INCLUDES "stdio.h" -#include +//#include // INCLUDES "stdio.h" +//#include // to overcome the conflict between std::ostream and io::ostream // the following variable must be defined: @@ -51,6 +51,9 @@ class vtkDataSet; class vtkPolyData; class vtkCamera; class vtkProperty; +class vtkPolyDataMapper; +class vtkOutlineSource; +class vtkRenderer; class VTKViewer_Transform; class VTKViewer_GeometryFilter; @@ -73,8 +76,6 @@ extern int SALOME_POINT_SIZE; #include -class vtkRenderer; - class SVTK_Actor; class SVTK_InteractorStyle; @@ -196,7 +197,7 @@ class SALOME_OBJECT_EXPORT SALOME_Actor : public VTKViewer_Actor { // From VISU public: - virtual void highlight( bool ); + virtual void highlight( bool, Selection_Mode ); virtual void SetVisibility( int ); @@ -239,6 +240,10 @@ class SALOME_OBJECT_EXPORT SALOME_Actor : public VTKViewer_Actor { SVTK_Actor* myPreHighlightActor; SVTK_Actor* myHighlightActor; + + vtkActor* myOutlineActor; + vtkOutlineSource* myOutline; + vtkPolyDataMapper* myOutlineMapper; }; #endif // SALOME_ACTOR_H diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index 0165f4104..444ec2db9 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -98,10 +98,13 @@ SVTK_View //---------------------------------------------------------------- struct THighlightAction{ bool myIsHighlight; - THighlightAction( bool theIsHighlight ): myIsHighlight(theIsHighlight) {} + Selection_Mode myMode; + THighlightAction( bool theIsHighlight, Selection_Mode theMode = ActorSelection ) + : myIsHighlight( theIsHighlight ), + myMode( theMode ) {} void operator()( SALOME_Actor* theActor) { if(theActor->GetMapper()){ - theActor->highlight( myIsHighlight ); + theActor->highlight( myIsHighlight, myMode ); } } }; @@ -145,14 +148,13 @@ void SVTK_View ::unHighlightAll() { - //cout << "--------------------------------------------------" << endl; //cout << "SVTK_View::unHighlightAll" << endl; using namespace VTK; ForEach( getRenderer()->GetActors(), THighlightAction( false ) ); - //myRenderWindow->update(); + update(); } //---------------------------------------------------------------- @@ -162,12 +164,13 @@ SVTK_View bool theIsHighlight, bool theIsUpdate ) { + //cout << "SVTK_View::highlight" << endl; using namespace VTK; - ForEachIf(getRenderer()->GetActors(), - TIsSameIObject(theIO), - THighlightAction(theIsHighlight)); + ForEachIf( getRenderer()->GetActors(), + TIsSameIObject( theIO ), + THighlightAction( theIsHighlight, mySelector->SelectionMode() ) ); - //myRenderWindow->update(); + update(); } #define INCREMENT_FOR_OP 10 diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 520b467dc..34870b38d 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -187,7 +187,8 @@ void SVTK_ViewWindow ::onSelectionChanged() { - //myView->onSelectionChanged(); + //cout << "SVTK_ViewWindow::onSelectionChanged" << endl; + myView->onSelectionChanged(); emit selectionChanged(); }