]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To improve SALOME_Actor interface
authorapo <apo@opencascade.com>
Mon, 19 Sep 2005 11:46:44 +0000 (11:46 +0000)
committerapo <apo@opencascade.com>
Mon, 19 Sep 2005 11:46:44 +0000 (11:46 +0000)
12 files changed:
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_SelectionEvent.h
src/SVTK/SVTK_Selector.cxx
src/SVTK/SVTK_Selector.h
src/SVTK/SVTK_SelectorDef.h
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_View.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h

index 2c427b5c898404b795d4f071ce28f9b076a7578a..67f033ed1f704bd00e27a7b4a2d13fff78a37ce2 100644 (file)
@@ -73,6 +73,35 @@ using namespace std;
 #endif
 
 int SALOME_POINT_SIZE = 3;
+int SALOME_LINE_WIDTH = 2;
+
+//----------------------------------------------------------------------------
+namespace
+{
+  int
+  GetEdgeId(SALOME_Actor* theActor,
+           vtkPicker* thePicker, 
+           int theObjId)
+  {
+    int anEdgeId = -1;
+    if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
+      float aPickPosition[3];
+      thePicker->GetPickPosition(aPickPosition);
+      float aMinDist = 1000000.0, aDist = 0;
+      for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
+       if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
+         int subId;  float pcoords[3], closestPoint[3], weights[3];
+         aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
+         if (aDist < aMinDist) {
+           aMinDist = aDist;
+           anEdgeId = i;
+         }
+       }
+      }
+    }
+    return anEdgeId;
+  }
+}
 
 
 //----------------------------------------------------------------------------
@@ -103,45 +132,51 @@ SALOME_Actor
   for(int i = 0; i < 6; i++)
     myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
 
-  // from VISU
   myPointPicker = vtkPointPicker::New();
+  myPointPicker->Delete();
+
   myCellPicker = vtkCellPicker::New();
-  myCellRectPicker = VTKViewer_CellRectPicker::New();
+  myCellPicker->Delete();
 
-  myPreHighlightActor = SVTK_Actor::New(); 
-  myPreHighlightActor->GetProperty()->SetColor(0,1,1);
-  myPreHighlightActor->GetProperty()->SetPointSize(5);
-  myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
+  myCellRectPicker = VTKViewer_CellRectPicker::New();
+  myCellRectPicker->Delete();
 
-  myPointProperty = vtkProperty::New();
-  myPointProperty->SetColor(1,1,0);
-  myPointProperty->SetPointSize(5);
-  myPointProperty->SetRepresentationToPoints();
+  myPreHighlightProperty = vtkProperty::New();
+  myPreHighlightProperty->Delete();
+  myPreHighlightProperty->SetColor(0,1,1);
+  myPreHighlightProperty->SetPointSize(SALOME_POINT_SIZE);
+  myPreHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH);
+  myPreHighlightProperty->SetRepresentationToPoints();
 
-  myCellProperty = vtkProperty::New();
-  myCellProperty->SetColor(1,1,0);
-  myCellProperty->SetPointSize(5);
-  myCellProperty->SetRepresentationToSurface();
+  myPreHighlightActor = SVTK_Actor::New(); 
+  myPreHighlightActor->Delete();
+  myPreHighlightActor->SetProperty(myPreHighlightProperty.GetPointer());
+  myPreHighlightActor->SetVisibility( false );
 
-  myEdgeProperty = vtkProperty::New();
-  myEdgeProperty->SetColor(1,0,0);
-  myEdgeProperty->SetPointSize(5);
-  myEdgeProperty->SetRepresentationToWireframe();
+  myHighlightProperty = vtkProperty::New();
+  myHighlightProperty->Delete();
+  myHighlightProperty->SetColor(1,1,0);
+  myHighlightProperty->SetPointSize(SALOME_POINT_SIZE);
+  myHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH);
+  myHighlightProperty->SetRepresentationToPoints();
 
   myHighlightActor = SVTK_Actor::New(); 
   myHighlightActor->PickableOff();
-  myHighlightActor->SetProperty( myPointProperty );
-
+  myHighlightActor->SetProperty(myHighlightProperty.GetPointer());
+  myHighlightActor->SetVisibility( false );
 
   myOutline = vtkOutlineSource::New();
+  myOutline->Delete();
 
   myOutlineMapper = vtkPolyDataMapper::New();
-  myOutlineMapper->SetInput( myOutline->GetOutput() );
+  myOutlineMapper->Delete();
+  myOutlineMapper->SetInput(myOutline->GetOutput());
 
   myOutlineActor = vtkActor::New();
+  myOutlineActor->Delete();
   myOutlineActor->PickableOff();
   myOutlineActor->DragableOff();
-  myOutlineActor->SetMapper( myOutlineMapper );
+  myOutlineActor->SetMapper( myOutlineMapper.GetPointer() );
   myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0);
   myOutlineActor->GetProperty()->SetAmbient(1.0);
   myOutlineActor->GetProperty()->SetDiffuse(0.0);
@@ -169,16 +204,75 @@ SALOME_Actor
   }
 
   myProperty->Delete();
+}
 
-  // from VISU
-  myPointPicker->Delete();
-  myCellPicker->Delete();
-  myCellRectPicker->Delete();
-  myHighlightActor->Delete();
 
-  myOutline->Delete();
-  myOutlineMapper->Delete();
-  myOutlineActor->Delete();
+//----------------------------------------------------------------------------
+Standard_Boolean 
+SALOME_Actor
+::hasIO() 
+{ 
+  return !myIO.IsNull(); 
+}
+
+const Handle(SALOME_InteractiveObject)& 
+SALOME_Actor
+::getIO()
+{ 
+  return myIO; 
+}
+
+void
+SALOME_Actor
+::setIO(const Handle(SALOME_InteractiveObject)& theIO) 
+{ 
+  myIO = theIO; 
+}
+
+const char* 
+SALOME_Actor
+::getName() 
+{ 
+  return myName.c_str(); 
+}
+
+void
+SALOME_Actor
+::setName(const char* theName)
+{
+  if(hasIO())  
+    myIO->setName(theName);
+  myName = theName;
+}
+
+
+//----------------------------------------------------------------------------
+bool
+SALOME_Actor
+::hasHighlight() 
+{ 
+  return false; 
+} 
+
+void
+SALOME_Actor
+::highlight(bool theHighlight) 
+{ 
+  highlight(theHighlight,ActorSelection); 
+}  
+
+bool
+SALOME_Actor
+::isHighlighted() 
+{ 
+  return myIsHighlighted; 
+}
+
+void
+SALOME_Actor
+::SetPreSelected(bool thePreselect) 
+{ 
+  myIsPreselected = thePreselect;
 }
 
 
@@ -191,9 +285,9 @@ SALOME_Actor
 
   theRenderer->AddActor(this);
 
-  theRenderer->AddActor( myPreHighlightActor );
-  theRenderer->AddActor( myHighlightActor );
-  theRenderer->AddActor( myOutlineActor );
+  theRenderer->AddActor( myPreHighlightActor.GetPointer() );
+  theRenderer->AddActor( myHighlightActor.GetPointer() );
+  theRenderer->AddActor( myOutlineActor.GetPointer() );
 }
 
 void 
@@ -202,9 +296,9 @@ SALOME_Actor
 {
   theRenderer->RemoveActor(this);
 
-  theRenderer->RemoveActor( myPreHighlightActor );
-  theRenderer->RemoveActor( myHighlightActor );
-  theRenderer->RemoveActor( myOutlineActor );
+  theRenderer->RemoveActor( myPreHighlightActor.GetPointer() );
+  theRenderer->RemoveActor( myHighlightActor.GetPointer() );
+  theRenderer->RemoveActor( myOutlineActor.GetPointer() );
 }
 
 vtkRenderer*
@@ -214,6 +308,11 @@ SALOME_Actor
   return myRenderer;
 }
 
+void
+SALOME_Actor
+::GetChildActors(vtkActorCollection*) 
+{}
+
 
 //----------------------------------------------------------------------------
 void
@@ -321,13 +420,47 @@ SALOME_Actor
 }
 
 void
-SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units)
+SALOME_Actor
+::GetPolygonOffsetParameters(float& factor, float& units)
 {
   factor = myPolygonOffsetFactor;
   units = myPolygonOffsetUnits;
 }
 
 
+//----------------------------------------------------------------------------
+float
+SALOME_Actor
+::GetShrinkFactor() 
+{ 
+  return 1.0;
+}
+
+bool
+SALOME_Actor
+::IsShrunkable() 
+{ 
+  return false;
+}
+
+bool
+SALOME_Actor
+::IsShrunk() 
+{ 
+  return false;
+}
+
+void
+SALOME_Actor
+::SetShrink() 
+{} 
+
+void
+SALOME_Actor
+::UnShrink() 
+{}
+
+
 //----------------------------------------------------------------------------
 vtkDataSet* 
 SALOME_Actor
@@ -395,6 +528,20 @@ SALOME_Actor
 
 
 //----------------------------------------------------------------------------
+int 
+SALOME_Actor
+::GetNodeObjId(int theVtkID)
+{ 
+  return theVtkID;
+}
+
+float* 
+SALOME_Actor
+::GetNodeCoord(int theObjID)
+{
+  return GetInput()->GetPoint(theObjID);
+}
+
 vtkCell* 
 SALOME_Actor
 ::GetElemCell(int theObjID)
@@ -402,11 +549,11 @@ SALOME_Actor
   return GetInput()->GetCell(theObjID);
 }
 
-
-float* 
-SALOME_Actor::GetNodeCoord(int theObjID)
-{
-  return GetInput()->GetPoint(theObjID);
+int
+SALOME_Actor
+::GetElemObjId(int theVtkID) 
+{ 
+  return theVtkID;
 }
 
 
@@ -466,6 +613,33 @@ SALOME_Actor
 }
 
 
+//----------------------------------------------------------------------------
+bool
+SALOME_Actor
+::IsSetCamera() const 
+{ 
+  return false; 
+}
+
+bool
+SALOME_Actor
+::IsResizable() const 
+{ 
+  return false; 
+}
+
+void
+SALOME_Actor
+::SetSize( const float ) 
+{}
+
+
+void 
+SALOME_Actor
+::SetCamera( vtkCamera* ) 
+{}
+
+//----------------------------------------------------------------------------
 void
 SALOME_Actor
 ::SetOpacity(float theOpacity)
@@ -489,6 +663,13 @@ SALOME_Actor
   GetProperty()->SetColor(r,g,b);
 }
 
+void
+SALOME_Actor
+::SetColor(const float theRGB[3])
+{ 
+  SetColor(theRGB[0],theRGB[1],theRGB[2]);
+}
+
 void
 SALOME_Actor
 ::GetColor(float& r,float& g,float& b)
@@ -501,6 +682,7 @@ SALOME_Actor
 }
 
 
+//----------------------------------------------------------------------------
 int
 SALOME_Actor
 ::getDisplayMode()
@@ -519,7 +701,8 @@ SALOME_Actor::setDisplayMode(int theMode)
 //----------------------------------------------------------------
 void
 SALOME_Actor
-::highlight( bool theHighlight, int theSelectionMode )
+::highlight(bool theHighlight, 
+           Selection_Mode theSelectionMode)
 {
   myIsHighlighted = theHighlight; 
 
@@ -545,40 +728,15 @@ SALOME_Actor
 }
 
 
-//----------------------------------------------------------------
-int
-SALOME_Actor
-::GetEdgeId( vtkPicker* thePicker, int theObjId )
-{
-  int anEdgeId = -1;
-  if (vtkCell* aPickedCell = GetElemCell(theObjId)) {
-    float aPickPosition[3];
-    thePicker->GetPickPosition(aPickPosition);
-    float aMinDist = 1000000.0, aDist = 0;
-    for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
-      if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
-       int subId;  float pcoords[3], closestPoint[3], weights[3];
-       aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
-       if (aDist < aMinDist) {
-         aMinDist = aDist;
-         anEdgeId = i;
-       }
-      }
-    }
-  }
-  return anEdgeId;
-}
-
 //----------------------------------------------------------------
 bool
 SALOME_Actor
-::PreHighlight( SVTK_Selector* theSelector,
-               //vtkRenderer* theRenderer,
-               vtkInteractorStyle *theIS, 
-               SVTK_SelectionEvent theSelectionEvent,
-               bool theIsHighlight )
+::PreHighlight(SVTK_Selector* theSelector,
+              vtkInteractorStyle *theInteractorStyle, 
+              const SVTK_SelectionEvent& theSelectionEvent,
+              bool theIsHighlight)
 {
-  vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
+  vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
   //
   myPreHighlightActor->SetVisibility( false );
     
@@ -655,7 +813,7 @@ SALOME_Actor
       if ( aVtkId >= 0 && theSelector->IsValid( this, aVtkId ) && hasIO() )
       {
        int anObjId = GetElemObjId( aVtkId );
-       int anEdgeId = GetEdgeId( myCellPicker, anObjId );
+       int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
        TColStd_IndexedMapOfInteger aMapIndex;
        aMapIndex.Add( anObjId );
        aMapIndex.Add( anEdgeId );
@@ -692,16 +850,17 @@ SALOME_Actor
 
   return anIsChanged;
 }
+
+
 //----------------------------------------------------------------
 bool
 SALOME_Actor
-::Highlight( SVTK_Selector* theSelector,
-            vtkInteractorStyle* theIS,
-            SVTK_SelectionEvent theSelectionEvent,
-            bool theIsHighlight )
+::Highlight(SVTK_Selector* theSelector,
+           vtkInteractorStyle *theInteractorStyle, 
+           const SVTK_SelectionEvent& theSelectionEvent,
+           bool theIsHighlight)
 {
-  vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
-  
+  vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
   //
   int aSelectionMode = theSelectionEvent.mySelectionMode;
   float x1 = theSelectionEvent.myX;
@@ -779,7 +938,7 @@ SALOME_Actor
          {
            theSelector->ClearIObjects();
          }
-         int anEdgeId = GetEdgeId( myCellPicker, anObjId );
+         int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
          if( anEdgeId >= 0 )
          {
            theSelector->AddOrRemoveIndex( myIO, anObjId, false );
@@ -897,18 +1056,18 @@ SALOME_Actor
   switch( aSelectionMode )
   {
     case NodeSelection:
-      myHighlightActor->SetProperty( myPointProperty );
+      myHighlightProperty->SetRepresentationToPoints();
       myHighlightActor->MapPoints( this, aMapIndex );
       break;
     case EdgeOfCellSelection:
-      myHighlightActor->SetProperty( myEdgeProperty );
+      myHighlightProperty->SetRepresentationToWireframe();
       myHighlightActor->MapEdge( this, aMapIndex );
       break;
     case CellSelection:
     case EdgeSelection:
     case FaceSelection:
     case VolumeSelection:
-      myHighlightActor->SetProperty( myCellProperty );
+      myHighlightProperty->SetRepresentationToSurface();
       myHighlightActor->MapCells( this, aMapIndex );
       break;
     case ActorSelection:
@@ -920,3 +1079,38 @@ SALOME_Actor
   return true;
 }
 
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetSelectionProp(const double& theRed, 
+                  const double& theGreen, 
+                  const double& theBlue, 
+                  const int& theWidth) 
+{
+  myHighlightProperty->SetColor( theRed, theGreen, theBlue );
+  myHighlightProperty->SetLineWidth( theWidth );
+}
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetPreselectionProp(const double& theRed, 
+                     const double& theGreen, 
+                     const double& theBlue, 
+                     const int& theWidth) 
+{
+  myPreHighlightProperty->SetColor( theRed, theGreen, theBlue );
+  myPreHighlightProperty->SetLineWidth( theWidth );
+}
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetSelectionTolerance(const double& theTolNodes, 
+                       const double& theTolCell)
+{
+  myPointPicker->SetTolerance( theTolNodes );
+  myCellPicker->SetTolerance( theTolCell );
+  myCellRectPicker->SetTolerance( theTolCell );
+}
+
index 082c542c3a0ca1a56b11d0a790b3fb8bde41a899..b5f3443a556aae237491ebe98698f17c4b6b3a3c 100644 (file)
@@ -40,6 +40,8 @@
 #include <string>
 #include <vector>
 
+#include <vtkSmartPointer.h>
+
 class vtkCell;
 class vtkPicker;
 class vtkPointPicker;
@@ -64,6 +66,7 @@ class SVTK_Actor;
 class SVTK_InteractorStyle;
 
 extern int SALOME_POINT_SIZE;
+extern int SALOME_LINE_WIDTH;
 
 class SALOME_Actor;
 
@@ -74,69 +77,51 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   
   vtkTypeMacro(SALOME_Actor,vtkLODActor);
 
+  //----------------------------------------------------------------------------
   virtual
   Standard_Boolean 
-  hasIO() 
-  { 
-    return !myIO.IsNull(); 
-  }
+  hasIO();
 
   virtual 
   const Handle(SALOME_InteractiveObject)& 
-  getIO()
-  { 
-    return myIO; 
-  } 
+  getIO(); 
 
   virtual
   void
-  setIO(const Handle(SALOME_InteractiveObject)& theIO) 
-  { 
-    myIO = theIO; 
-  }
+  setIO(const Handle(SALOME_InteractiveObject)& theIO);
 
   virtual 
   const char* 
-  getName() 
-  { 
-    return myName.c_str(); 
-  }
+  getName();
 
   virtual
   void
-  setName(const char* theName)
-  {
-    if(hasIO())        
-      myIO->setName(theName);
-    myName = theName;
-  }
+  setName(const char* theName);
 
+  //----------------------------------------------------------------------------
   // To generate highlight automaticaly
   virtual
   bool
-  hasHighlight() 
-  { 
-    return false; 
-  } 
+  hasHighlight(); 
 
   virtual
   void
-  highlight( bool theHighlight, int theSelectionMode );
+  highlight(bool theHighlight, 
+           Selection_Mode theSelectionMode);
 
   virtual
   void
-  highlight(bool theHighlight) 
-  { 
-    highlight(theHighlight,ActorSelection); 
-  }  
+  highlight(bool theHighlight);  
 
   virtual
   bool
-  isHighlighted() 
-  { 
-    return myIsHighlighted; 
-  }
+  isHighlighted();
 
+  virtual
+  void
+  SetPreSelected(bool thePreselect = false);
+
+  //----------------------------------------------------------------------------
   virtual
   void
   SetOpacity(float theOpacity);
@@ -155,33 +140,13 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
 
   virtual
   void
-  SetColor(const float theRGB[3])
-  { 
-    SetColor(theRGB[0],theRGB[1],theRGB[2]);
-  }
-
-  vtkSetObjectMacro(PreviewProperty,vtkProperty);
+  SetColor(const float theRGB[3]);
 
-  virtual
-  void
-  SetPreSelected(bool thePreselect = false) 
-  { 
-    myIsPreselected = thePreselect;
-  }
-
-  // Used to obtain all dependent actors
-  virtual
-  void
-  GetChildActors(vtkActorCollection*) 
-  {};
-  
+  //----------------------------------------------------------------------------
   // For selection mapping purpose
   virtual
   int 
-  GetNodeObjId(int theVtkID)
-  { 
-    return theVtkID;
-  }
+  GetNodeObjId(int theVtkID);
 
   virtual
   float*
@@ -189,15 +154,13 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
 
   virtual 
   int
-  GetElemObjId(int theVtkID) 
-  { 
-    return theVtkID;
-  }
+  GetElemObjId(int theVtkID);
 
   virtual
   vtkCell* 
   GetElemCell(int theObjID);
 
+  //----------------------------------------------------------------------------
   virtual
   int
   GetObjDimension( const int theObjId );
@@ -218,6 +181,7 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   unsigned long int
   GetMTime();
 
+  //----------------------------------------------------------------------------
   virtual
   void
   SetRepresentation(int theMode);
@@ -234,6 +198,7 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   void
   setDisplayMode(int theMode);
 
+  //----------------------------------------------------------------------------
   // Infinitive means actor without size (point for example),
   // which is not taken into account in calculation of boundaries of the scene
   void
@@ -250,6 +215,24 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   void
   GetBounds(float bounds[6]);
 
+  //----------------------------------------------------------------------------
+  virtual
+  bool
+  IsSetCamera() const;
+
+  virtual
+  bool
+  IsResizable() const;
+
+  virtual
+  void
+  SetSize( const float );
+
+  virtual
+  void 
+  SetCamera( vtkCamera* );
+
+  //----------------------------------------------------------------------------
   void
   SetResolveCoincidentTopology(bool theIsResolve);
 
@@ -263,61 +246,28 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   void
   Render(vtkRenderer *, vtkMapper *);
 
+  //----------------------------------------------------------------------------
   virtual
   float
-  GetShrinkFactor() 
-  { 
-    return 1.0;
-  }
+  GetShrinkFactor();
 
   virtual
   bool
-  IsShrunkable() 
-  { 
-    return false;
-  }
+  IsShrunkable();
 
   virtual
   bool
-  IsShrunk() 
-  { 
-    return false;
-  }
+  IsShrunk();
 
   virtual
   void
-  SetShrink() 
-  {} 
+  SetShrink();
 
   virtual
   void
-  UnShrink() 
-  {}
-
-  virtual
-  bool
-  IsSetCamera() const 
-  { 
-    return false; 
-  }
-
-  virtual
-  bool
-  IsResizable() const 
-  { 
-    return false; 
-  }
-
-  virtual
-  void
-  SetSize( const float ) 
-  {}
-
-  virtual
-  void 
-  SetCamera( vtkCamera* ) 
-  {}
+  UnShrink();
 
+  //----------------------------------------------------------------------------
   virtual
   void
   SetVisibility( int );
@@ -334,6 +284,11 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   vtkRenderer*
   GetRenderer();
 
+  // Used to obtain all dependent actors
+  virtual
+  void
+  GetChildActors(vtkActorCollection*);
+  
   //----------------------------------------------------------------------------
   virtual
   void
@@ -346,55 +301,41 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   //----------------------------------------------------------------------------
   virtual
   bool
-  PreHighlight(        SVTK_Selector*
-               vtkInteractorStyle*
-               SVTK_SelectionEvent, 
-               bool );
+  PreHighlight(SVTK_Selector* theSelector
+              vtkInteractorStyle* theInteractorStyle
+              const SVTK_SelectionEvent& theSelectionEvent,
+              bool theIsHighlight);
 
   virtual 
   bool
-  Highlight( SVTK_Selector*, 
-            vtkInteractorStyle*,
-            SVTK_SelectionEvent, 
-            bool );
-
-  vtkProperty* 
-  getPointProperty()
-  { 
-    return myPointProperty; 
-  }
-
-  vtkProperty* 
-  getCellProperty()
-  { 
-    return myCellProperty; 
-  }
-
-  vtkProperty* 
-  getEdgeProperty()
-  { 
-    return myEdgeProperty; 
-  }
-
-  vtkPointPicker* 
-  getPointPicker() 
-  { 
-    return myPointPicker; 
-  }
-
-  vtkCellPicker* 
-  getCellPicker() 
-  { 
-    return myCellPicker; 
-  }
-
-  VTKViewer_CellRectPicker* 
-  getCellRectPicker() 
-  { 
-    return myCellRectPicker; 
-  }
+  Highlight(SVTK_Selector* theSelector, 
+           vtkInteractorStyle* theInteractorStyle, 
+           const SVTK_SelectionEvent& theSelectionEvent,
+           bool theIsHighlight);
+
+  virtual
+  void
+  SetSelectionProp(const double& theRed = 1, 
+                  const double& theGreen = 1,
+                  const double& theBlue = 0, 
+                  const int& theWidth = 5);
+
+  virtual
+  void
+  SetPreselectionProp(const double& theRed = 0, 
+                     const double& theGreen = 1,
+                     const double& theBlue = 1, 
+                     const int& theWidth = 5);
+
+  virtual
+  void
+  SetSelectionTolerance(const double& theTolNodes = 0.025, 
+                       const double& theTolCell = 0.001);
+
+  vtkSetObjectMacro(PreviewProperty,vtkProperty);
 
  protected:
+  //----------------------------------------------------------------------------
   vtkRenderWindowInteractor* myInteractor;
   vtkRenderer* myRenderer;
 
@@ -429,22 +370,21 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   ~SALOME_Actor();
 
  protected:
-  int GetEdgeId( vtkPicker*, int );
-
-  vtkProperty* myPointProperty;
-  vtkProperty* myCellProperty;
-  vtkProperty* myEdgeProperty;
+  //----------------------------------------------------------------------------
+  // Highlight/ Prehighlight devices
+  vtkSmartPointer<vtkPointPicker> myPointPicker;
+  vtkSmartPointer<vtkCellPicker> myCellPicker;
+  vtkSmartPointer<VTKViewer_CellRectPicker> myCellRectPicker;
 
-  vtkPointPicker* myPointPicker;
-  vtkCellPicker* myCellPicker;
-  VTKViewer_CellRectPicker* myCellRectPicker;
+  vtkSmartPointer<vtkProperty> myPreHighlightProperty;
+  vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
 
-  SVTK_Actor* myPreHighlightActor;
-  SVTK_Actor* myHighlightActor;
+  vtkSmartPointer<vtkProperty> myHighlightProperty;
+  vtkSmartPointer<SVTK_Actor> myHighlightActor;
 
-  vtkActor* myOutlineActor;
-  vtkOutlineSource* myOutline;
-  vtkPolyDataMapper* myOutlineMapper;
+  vtkSmartPointer<vtkActor> myOutlineActor;
+  vtkSmartPointer<vtkOutlineSource> myOutline;
+  vtkSmartPointer<vtkPolyDataMapper> myOutlineMapper;
 };
 
 #endif // SALOME_ACTOR_H
index 8a1b758f6934c7f6c5759258eb52ff7ed909db57..4f7762d01ee8ada2e504dee6a5f5008d679fe4d0 100644 (file)
@@ -874,7 +874,7 @@ SVTK_InteractorStyle
   // VSV: LOD actor activisation
   //  rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
 
-  int aSelectionMode = GetSelector()->SelectionMode();
+  Selection_Mode aSelectionMode = GetSelector()->SelectionMode();
 
   switch (State) {
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
index f371c025d5fec5f8988ad685fc1f0d790441343d..e004c782add0390ce3149b1598a809b45bf1cf06 100644 (file)
@@ -551,14 +551,14 @@ SVTK_RenderWindowInteractor
 //----------------------------------------------------------------
 void
 SVTK_RenderWindowInteractor
-::SetSelectionMode(int theMode)
+::SetSelectionMode(Selection_Mode theMode)
 {
   mySelector->SetSelectionMode(theMode);
 }
 
 
 //----------------------------------------------------------------
-int
+Selection_Mode
 SVTK_RenderWindowInteractor
 ::SelectionMode() const
 {
index 6a349d06243a676f83bb29c7bd78fdcf4dd6a315..5843597cbbbc08ce1a66ddc2f8e90abc2d58085c 100644 (file)
@@ -33,7 +33,7 @@
 
 struct SVTK_SelectionEvent
 {
-  int mySelectionMode;
+  Selection_Mode mySelectionMode;
   int myX;
   int myY;
   int myLastX;
index c4c85fcb2dac0d6942e47e767f718ff929e93e6b..54a3ae6542821deb8d5ef7015f17d2e1c2b6921e 100644 (file)
@@ -76,7 +76,7 @@ SVTK_SelectorDef
 //----------------------------------------------------------------------------
 void 
 SVTK_SelectorDef
-::SetSelectionMode(int theMode)
+::SetSelectionMode(Selection_Mode theMode)
 {
   mySelectionMode = theMode;
 }
index af580474a4c0859aa5cfeacd009c1ab0034c927b..8f29b3c94852bbbbb81bd3fd739ce10923984320 100644 (file)
@@ -50,10 +50,10 @@ public:
 
   virtual
   void 
-  SetSelectionMode( int theMode ) = 0;
+  SetSelectionMode(Selection_Mode theMode) = 0;
 
   virtual
-  int
+  Selection_Mode
   SelectionMode() const = 0;
 
   virtual
index 9150a652a472ce689fcedbf83a1264f7411c35e4..050a6838a3fd15d48c442c9b2b494778e1482e3a 100644 (file)
@@ -51,10 +51,10 @@ public:
 
   virtual
   void 
-  SetSelectionMode( int theMode );
+  SetSelectionMode(Selection_Mode theMode);
 
   virtual
-  int
+  Selection_Mode
   SelectionMode() const { return mySelectionMode; }
 
   virtual
index 014ff3834c2eaaa8727ae7f031d3aa6bb93c5632..7e4d6a48b527272de5db47a4a1d5d1c88d78d86d 100644 (file)
@@ -881,19 +881,25 @@ SVTK_View
 {
   vtkActorCollection* anActors = getRenderer()->GetActors();
   anActors->InitTraversal();
-  while( vtkActor* anActor = anActors->GetNextActor() )
-  {
-    if( SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ) )
-    {
-      aSActor->getPointProperty()->SetColor( theRed, theGreen, theBlue );
-      aSActor->getPointProperty()->SetLineWidth( theWidth );
-
-      aSActor->getCellProperty()->SetColor( theRed, theGreen, theBlue );
-      aSActor->getCellProperty()->SetLineWidth( theWidth );
+  while(vtkActor* anActor = anActors->GetNextActor()){
+    if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor))
+      aSActor->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
+  }
+}
 
-      aSActor->getEdgeProperty()->SetColor( theRed, theGreen, theBlue );
-      aSActor->getEdgeProperty()->SetLineWidth( theWidth );
-    }
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::SetPreselectionProp(const double& theRed, 
+                     const double& theGreen, 
+                     const double& theBlue, 
+                     const int& theWidth) 
+{
+  vtkActorCollection* anActors = getRenderer()->GetActors();
+  anActors->InitTraversal();
+  while(vtkActor* anActor = anActors->GetNextActor()){
+    if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor))
+      aSActor->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
   }
 }
 
@@ -901,18 +907,13 @@ SVTK_View
 void
 SVTK_View
 ::SetSelectionTolerance(const double& theTolNodes, 
-                       const double& theTolItems)
+                       const double& theTolCell)
 {
   vtkActorCollection* anActors = getRenderer()->GetActors();
   anActors->InitTraversal();
-  while( vtkActor* anActor = anActors->GetNextActor() )
-  {
-    if( SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ) )
-    {
-      aSActor->getPointPicker()->SetTolerance( theTolNodes );
-      aSActor->getCellPicker()->SetTolerance( theTolItems );
-      aSActor->getCellRectPicker()->SetTolerance( theTolItems );
-    }
+  while(vtkActor* anActor = anActors->GetNextActor()){
+    if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor))
+      aSActor->SetSelectionTolerance(theTolNodes,theTolCell);
   }
 }
 
index e992830179b44e74c54f8c283cebd8e0ab261e64..caa7fae7b1eba8f4abb0143503dc5c77e8d04bed 100644 (file)
@@ -295,6 +295,7 @@ public:
   rename(const Handle(SALOME_InteractiveObject)& IObject, 
         const QString& newName);
   
+  //----------------------------------------------------------------------------
   // Displaymode management
   int 
   GetDisplayMode();
@@ -335,6 +336,7 @@ public:
   QColor
   GetColor(const Handle(SALOME_InteractiveObject)& theIObject);
 
+  //----------------------------------------------------------------------------
   // Erase Display functions
   void
   EraseAll();
@@ -371,12 +373,19 @@ public:
   Remove(SALOME_Actor* SActor, 
         bool updateViewer = true);
 
+  //----------------------------------------------------------------------------
   void
   SetSelectionProp(const double& theRed = 1, 
                   const double& theGreen = 1,
                   const double& theBlue = 0, 
                   const int& theWidth = 5);
 
+  void
+  SetPreselectionProp(const double& theRed = 0, 
+                     const double& theGreen = 1,
+                     const double& theBlue = 1, 
+                     const int& theWidth = 5);
+
   void
   SetSelectionTolerance(const double& theTolNodes = 0.025, 
                        const double& theTolCell = 0.001);
index 180a53a66c02f241b2f6f7279ef44e446612e509..e34229ade6a86bb13cf9215b06a1e6850ca8e380 100755 (executable)
@@ -494,6 +494,17 @@ SVTK_ViewWindow
   myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
 }
 
+//----------------------------------------------------------------------------
+void
+SVTK_ViewWindow
+::SetPreselectionProp(const double& theRed, 
+                     const double& theGreen, 
+                     const double& theBlue, 
+                     const int& theWidth) 
+{
+  myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
+}
+
 //----------------------------------------------------------------------------
 void
 SVTK_ViewWindow
index 0cc14a104b9c853ff60fdfda3797f7b6d551c157..17e00f6b3b2ffc12f7550b20053726c0050ab580 100755 (executable)
@@ -177,6 +177,12 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
 
   virtual
   void
+  SetPreselectionProp(const double& theRed = 0, 
+                     const double& theGreen = 1,
+                     const double& theBlue = 1, 
+                     const int& theWidth = 5);
+  virtual
+  void
   SetSelectionTolerance(const double& theTolNodes = 0.025, 
                        const double& theTolCell = 0.001);