]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Selection mechanism corrected
authorouv <ouv@opencascade.com>
Mon, 15 Aug 2005 10:53:57 +0000 (10:53 +0000)
committerouv <ouv@opencascade.com>
Mon, 15 Aug 2005 10:53:57 +0000 (10:53 +0000)
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_ViewWindow.cxx

index 190d8e561ecaa8169086b9098778627910192ef6..c47bf0beadbd4151e9ebec0424bd0742ffc7a641 100644 (file)
@@ -58,6 +58,7 @@
 #include <vtkDataSetMapper.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
+#include "vtkOutlineSource.h"
 
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
@@ -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;
 }
 
index 0bb64057d55e82974e94421ae487f041f73326d2..31c4a44b7663922f0d0bc99c268d428eda568c17 100644 (file)
@@ -34,8 +34,8 @@
 #include "Handle_SALOME_InteractiveObject.hxx"
 #endif
 
-#include <vtkLODActor.h> // INCLUDES "stdio.h"
-#include <vtkProperty.h> 
+//#include <vtkLODActor.h> // INCLUDES "stdio.h"
+//#include <vtkProperty.h> 
 
 // 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 <string>
 
-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
index 0165f410415e88a9ec5fafdbfec3265151726891..444ec2db96809730fcb1749f76888f373e657648 100644 (file)
@@ -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<SALOME_Actor>( 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<SALOME_Actor>(getRenderer()->GetActors(),
-                         TIsSameIObject<SALOME_Actor>(theIO),
-                         THighlightAction(theIsHighlight));
+  ForEachIf<SALOME_Actor>( getRenderer()->GetActors(),
+                          TIsSameIObject<SALOME_Actor>( theIO ),
+                          THighlightAction( theIsHighlight, mySelector->SelectionMode() ) );
 
-  //myRenderWindow->update();
+  update();
 }
 
 #define INCREMENT_FOR_OP 10
index 520b467dc595ca0cbb70f8f433a3a190160a9f7c..34870b38d770a6c9ac7a75167cf5e055587ecafd 100755 (executable)
@@ -187,7 +187,8 @@ void
 SVTK_ViewWindow
 ::onSelectionChanged()
 {
-  //myView->onSelectionChanged();
+  //cout << "SVTK_ViewWindow::onSelectionChanged" << endl;
+  myView->onSelectionChanged();
   emit selectionChanged();
 }