]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
1. To remove dependecies between SALOME_Actor and SVTK_InteractorStyle.
authorapo <apo@opencascade.com>
Thu, 18 Aug 2005 04:09:18 +0000 (04:09 +0000)
committerapo <apo@opencascade.com>
Thu, 18 Aug 2005 04:09:18 +0000 (04:09 +0000)
2. To make pickers member of SVTK_InteractorStyle, not to use vtkRenderWindowInteractor's ones

src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.h

index 35b269ae5ddd1bf8b2160755c3a640c322b97a8e..757f6e2afca81e85cbafd82dc4e6afbfc97c8a35 100644 (file)
 #include "VTKViewer_CellRectPicker.h"
 
 #include "SVTK_Actor.h"
-#include "SVTK_InteractorStyle.h"
-
-// SALOME Includes
-//#include "utilities.h"
 
 // VTK Includes
 #include <vtkCell.h>
 #include <vtkDataSetMapper.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
-#include "vtkOutlineSource.h"
+#include <vtkOutlineSource.h>
 
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
 
-//using namespace std;
+#include "utilities.h"
+
+using namespace std;
 
 #if defined __GNUC__
   #if __GNUC__ == 2
 int SALOME_POINT_SIZE = 3;
 
 
+//----------------------------------------------------------------------------
 vtkStandardNewMacro(SALOME_Actor);
 
 
-SALOME_Actor::SALOME_Actor(){
+//----------------------------------------------------------------------------
+SALOME_Actor
+::SALOME_Actor()
+{
   myIsHighlighted = myIsPreselected = false;
 
   myRepresentation = 1;
@@ -146,7 +148,10 @@ SALOME_Actor::SALOME_Actor(){
 }
 
 
-SALOME_Actor::~SALOME_Actor(){
+//----------------------------------------------------------------------------
+SALOME_Actor
+::~SALOME_Actor()
+{
   SetPreviewProperty(NULL);
 
   myGeomFilter->UnRegisterAllOutputs(); 
@@ -176,7 +181,11 @@ SALOME_Actor::~SALOME_Actor(){
 }
 
 
-void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::AddToRender(vtkRenderer* theRenderer)
+{
   theRenderer->AddActor(this);
 
   // from VISU
@@ -185,7 +194,10 @@ void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){
   theRenderer->AddActor( myOutlineActor );
 }
 
-void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){
+void 
+SALOME_Actor
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
   theRenderer->RemoveActor(this);
 
   // from VISU
@@ -195,16 +207,26 @@ void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){
 }
 
 
-void SALOME_Actor::SetTransform(VTKViewer_Transform* theTransform){
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetTransform(VTKViewer_Transform* theTransform)
+{
   myTransformFilter->SetTransform(theTransform);
 }
 
 
-void SALOME_Actor::SetMapper(vtkMapper* theMapper){
+void
+SALOME_Actor
+::SetMapper(vtkMapper* theMapper)
+{
   InitPipeLine(theMapper);
 }
 
-void SALOME_Actor::InitPipeLine(vtkMapper* theMapper){
+void
+SALOME_Actor
+::InitPipeLine(vtkMapper* theMapper)
+{
   if(theMapper){
     int anId = 0;
     myPassFilter[ anId ]->SetInput( theMapper->GetInput() );
@@ -236,7 +258,11 @@ void SALOME_Actor::InitPipeLine(vtkMapper* theMapper){
 }
 
 
-void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper* m){
+//----------------------------------------------------------------------------
+void
+ SALOME_Actor
+::Render(vtkRenderer *ren, vtkMapper* m)
+{
   if(myIsResolveCoincidentTopology){
     int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
     float aFactor, aUnit; 
@@ -255,27 +281,42 @@ void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper* m){
 }
 
 
-void SALOME_Actor::SetResolveCoincidentTopology(bool theIsResolve) {
+void
+SALOME_Actor
+::SetResolveCoincidentTopology(bool theIsResolve) 
+{
   myIsResolveCoincidentTopology = theIsResolve;
 }
 
-void SALOME_Actor::SetPolygonOffsetParameters(float factor, float units){
+void
+SALOME_Actor
+::SetPolygonOffsetParameters(float factor, float units)
+{
   myPolygonOffsetFactor = factor;
   myPolygonOffsetUnits = units;
 }
 
-void SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units){
+void
+SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units)
+{
   factor = myPolygonOffsetFactor;
   units = myPolygonOffsetUnits;
 }
 
 
-vtkDataSet* SALOME_Actor::GetInput(){
+//----------------------------------------------------------------------------
+vtkDataSet* 
+SALOME_Actor
+::GetInput()
+{
   return myPassFilter.front()->GetOutput();
 }
 
 
-unsigned long int SALOME_Actor::GetMTime(){
+unsigned long int
+SALOME_Actor
+::GetMTime()
+{
   unsigned long mTime = this->Superclass::GetMTime();
   unsigned long time = myTransformFilter->GetMTime();
   mTime = ( time > mTime ? time : mTime );
@@ -287,7 +328,11 @@ unsigned long int SALOME_Actor::GetMTime(){
 }
 
 
-void SALOME_Actor::SetRepresentation(int theMode) { 
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetRepresentation(int theMode) 
+{ 
   switch(myRepresentation){
   case VTK_POINTS : 
   case VTK_SURFACE : 
@@ -317,17 +362,26 @@ void SALOME_Actor::SetRepresentation(int theMode) {
   myRepresentation = theMode;
 }
 
-int SALOME_Actor::GetRepresentation(){ 
+int
+SALOME_Actor
+::GetRepresentation()
+{ 
   return myRepresentation;
 }
 
 
-vtkCell* SALOME_Actor::GetElemCell(int theObjID){
+//----------------------------------------------------------------------------
+vtkCell* 
+SALOME_Actor
+::GetElemCell(int theObjID)
+{
   return GetInput()->GetCell(theObjID);
 }
 
 
-float* SALOME_Actor::GetNodeCoord(int theObjID){
+float* 
+SALOME_Actor::GetNodeCoord(int theObjID)
+{
   return GetInput()->GetPoint(theObjID);
 }
 
@@ -337,7 +391,9 @@ float* SALOME_Actor::GetNodeCoord(int theObjID){
 // purpose  : Return object dimension.
 //            Virtual method shoulb be redifined by derived classes
 //=================================================================================
-int SALOME_Actor::GetObjDimension( const int theObjId )
+int
+SALOME_Actor
+::GetObjDimension( const int theObjId )
 {
   if ( vtkCell* aCell = GetElemCell(theObjId) )
     return aCell->GetCellDimension();
@@ -345,26 +401,41 @@ int SALOME_Actor::GetObjDimension( const int theObjId )
 }
 
 
-bool SALOME_Actor::IsInfinitive(){ 
+bool
+SALOME_Actor
+::IsInfinitive()
+{ 
   return myIsInfinite; 
 }
 
 
-void SALOME_Actor::SetOpacity(float theOpacity){ 
+void
+SALOME_Actor
+::SetOpacity(float theOpacity)
+{ 
   myOpacity = theOpacity;
   GetProperty()->SetOpacity(theOpacity);
 }
 
-float SALOME_Actor::GetOpacity(){
+float
+SALOME_Actor
+::GetOpacity()
+{
   return myOpacity;
 }
 
 
-void SALOME_Actor::SetColor(float r,float g,float b){
+void
+SALOME_Actor
+::SetColor(float r,float g,float b)
+{
   GetProperty()->SetColor(r,g,b);
 }
 
-void SALOME_Actor::GetColor(float& r,float& g,float& b){
+void
+SALOME_Actor
+::GetColor(float& r,float& g,float& b)
+{
   float aColor[3];
   GetProperty()->GetColor(aColor);
   r = aColor[0];
@@ -373,21 +444,27 @@ void SALOME_Actor::GetColor(float& r,float& g,float& b){
 }
 
 
-int SALOME_Actor::getDisplayMode(){ 
+int
+SALOME_Actor
+::getDisplayMode()
+{ 
   return myDisplayMode; 
 }
 
-void SALOME_Actor::setDisplayMode(int theMode){ 
+void
+SALOME_Actor::setDisplayMode(int theMode)
+{ 
   SetRepresentation(theMode+1); 
   myDisplayMode = GetRepresentation() - 1;
 }
 
-// from VISU
 
 //----------------------------------------------------------------
-void SALOME_Actor::highlight( bool theHighlight, Selection_Mode theMode )
+void
+SALOME_Actor
+::highlight( bool theHighlight, Selection_Mode theMode )
 {
-  //cout << "SALOME_Actor::highlight " << ( theHighlight ? "on" : "off" ) << endl;
+  myIsHighlighted = theHighlight; 
 
   if( !GetVisibility() )
     return;
@@ -399,17 +476,21 @@ void SALOME_Actor::highlight( bool theHighlight, Selection_Mode theMode )
 }
 
 //----------------------------------------------------------------
-void SALOME_Actor::SetVisibility( int theVisibility )
+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() );
 }
 
+
 //----------------------------------------------------------------
-int SALOME_Actor::GetEdgeId( vtkPicker* thePicker, int theObjId )
+int
+SALOME_Actor
+::GetEdgeId( vtkPicker* thePicker, int theObjId )
 {
   int anEdgeId = -1;
   if (vtkCell* aPickedCell = GetElemCell(theObjId)) {
@@ -430,29 +511,21 @@ int SALOME_Actor::GetEdgeId( vtkPicker* thePicker, int theObjId )
   return anEdgeId;
 }
 
+
 //----------------------------------------------------------------
-bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
-                                SVTK_Selector* theSelector,
-                                vtkRenderer* theRenderer,
-                                SVTK_SelectionEvent theSelectionEvent,
-                                bool theIsHighlight )
+bool
+SALOME_Actor
+::PreHighlight( VTK::TValidator* theValidator,
+               SVTK_Selector* theSelector,
+               vtkRenderer* theRenderer,
+               SVTK_SelectionEvent theSelectionEvent,
+               bool theIsHighlight )
 {
   Selection_Mode aSelectionMode = theSelectionEvent.SelectionMode;
   float x = theSelectionEvent.X;
   float y = theSelectionEvent.Y;
   float z = 0.0;
-  /*
-  cout << "SALOME_Actor::PreHighlight" << endl;
-  cout << "SelectionMode : ";
-  switch( aSelectionMode )
-  {
-    case NodeSelection: cout << "Nodes" << endl; break;
-    case CellSelection: cout << "Cells" << endl; break;
-    case ActorSelection: cout << "Actor" << endl; break;
-    default: cout << "Other" << endl; break;
-  }
-  cout << "IsHighlight : " << ( theIsHighlight ? "true" : "false" ) << endl;
-  */
+
   if( !theIsHighlight )
   {
     myPreHighlightActor->SetVisibility( false );
@@ -471,12 +544,11 @@ bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
     myPointPicker->Pick( x, y, z, theRenderer );
 
     int aVtkId = myPointPicker->GetPointId();
-    if( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId, true ) && hasIO() )
+    if( aVtkId >= 0 && theValidator->IsValid( this, aVtkId, true ) && hasIO() )
     {
       int anObjId = GetNodeObjId( aVtkId );
       TColStd_IndexedMapOfInteger aMapIndex;
       aMapIndex.Add( anObjId );
-      //cout << "Index : " << anObjId << endl;
 
       myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
       myPreHighlightActor->SetVisibility( true );
@@ -488,12 +560,11 @@ bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
     myCellPicker->Pick( x, y, z, theRenderer );
 
     int aVtkId = myCellPicker->GetCellId();
-    if ( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId ) && hasIO() )
+    if ( aVtkId >= 0 && theValidator->IsValid( this, aVtkId ) && hasIO() )
     {
       int anObjId = GetElemObjId (aVtkId );
       TColStd_IndexedMapOfInteger aMapIndex;
       aMapIndex.Add( anObjId );
-      //cout << "Index : " << anObjId << endl;
 
       myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
       myPreHighlightActor->SetVisibility( true );
@@ -505,14 +576,13 @@ bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
     myCellPicker->Pick( x, y, z, theRenderer );
 
     int aVtkId = myCellPicker->GetCellId();
-    if ( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId ) && hasIO() )
+    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 );
-      //cout << "Index : " << anObjId << " " << anEdgeId << endl;
 
       myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
       myPreHighlightActor->SetVisibility( true );
@@ -537,12 +607,15 @@ bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
   return true;
 }
 
+
 //----------------------------------------------------------------
-bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
-                             SVTK_Selector* theSelector,
-                             vtkRenderer* theRenderer,
-                             SVTK_SelectionEvent theSelectionEvent,
-                             bool theIsHighlight )
+bool
+SALOME_Actor
+::Highlight( VTK::TValidator* theValidator,
+            SVTK_Selector* theSelector,
+            vtkRenderer* theRenderer,
+            SVTK_SelectionEvent theSelectionEvent,
+            bool theIsHighlight )
 {
   Selection_Mode aSelectionMode = theSelectionEvent.SelectionMode;
   float x1 = theSelectionEvent.X;
@@ -561,7 +634,7 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
       myPointPicker->Pick( x1, y1, z1, theRenderer );
 
       int aVtkId = myPointPicker->GetPointId();
-      if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId, true ) )
+      if( aVtkId >= 0 && hasIO() && theValidator->IsValid( this, aVtkId, true ) )
       {
        int anObjId = GetNodeObjId( aVtkId );
        if( anObjId >= 0 )
@@ -572,7 +645,6 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
          {
            if( !isShift )
            {
-             theInteractorStyle->HighlightProp( NULL );
              theSelector->ClearIObjects();
            }
            theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
@@ -586,12 +658,11 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
       myCellPicker->Pick( x1, y1, z1, theRenderer );
     
       int aVtkId = myCellPicker->GetCellId();
-      if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId ) )
+      if( aVtkId >= 0 && hasIO() && theValidator->IsValid( this, aVtkId ) )
       {
        int anObjId = GetElemObjId( aVtkId );
        if( anObjId >= 0 )
        {
-         //if( theInteractorStyle->CheckDimensionId( aSelectionMode, this, anObjId ) )
          {
            if( theSelector->IsSelected( myIO ) )
              theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
@@ -599,7 +670,6 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
            {
              if( !isShift )
              {
-               theInteractorStyle->HighlightProp( NULL );
                theSelector->ClearIObjects();
              }
              theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
@@ -614,17 +684,16 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
       myCellPicker->Pick( x1, y1, z1, theRenderer );
     
       int aVtkId = myCellPicker->GetCellId();
-      if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId ) )
+      if( aVtkId >= 0 && hasIO() && theValidator->IsValid( this, aVtkId ) )
       {
        int anObjId = GetElemObjId( aVtkId );
        if( anObjId >= 0 )
         {
          if( !isShift )
          {
-           theInteractorStyle->HighlightProp( NULL );
            theSelector->ClearIObjects();
          }
-         int anEdgeId = 0;//theInteractorStyle->GetEdgeId( myCellPicker, this, anObjId );
+         int anEdgeId = GetEdgeId( myCellPicker, anObjId );
          if( anEdgeId >= 0 )
          {
            theSelector->AddOrRemoveIndex( myIO, anObjId, false );
@@ -638,14 +707,12 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
     {
       if ( hasIO() )
       {
-       //theInteractorStyle->PropPicked++;
        if( theSelector->IsSelected( myIO ) && isShift )
          theSelector->RemoveIObject( this );
        else
        {
          if( !isShift )
          {
-           theInteractorStyle->HighlightProp( NULL );
            theSelector->ClearIObjects();
          }
          theSelector->AddIObject( this );
@@ -671,10 +738,8 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
          theRenderer->GetDisplayPoint( aPnt );
 
          if( aPnt[0] > x2 && aPnt[0] < x1 && aPnt[1] > y1 && aPnt[1] < y2 )
-         //if( theInteractorStyle->IsInRect( aPoint, x2, y2, x1, y1 ) )
          {
            float aDisp[3];
-           //theInteractorStyle->ComputeWorldToDisplay( aPoint[0], aPoint[1] ,aPoint[2], aDisp );
            theRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
            theRenderer->WorldToDisplay();
            theRenderer->GetDisplayPoint( aDisp );
@@ -688,7 +753,7 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
                  float aPickedPoint[3];
                  myPointPicker->GetMapperPosition( aPickedPoint );
                  vtkIdType aVtkId = aDataSet->FindPoint( aPickedPoint );
-                 if( aVtkId >= 0 && theInteractorStyle->IsValid( this, aVtkId, true ) )
+                 if( aVtkId >= 0 && theValidator->IsValid( this, aVtkId, true ) )
                  {
                    int anObjId = GetNodeObjId( aVtkId );
                    anIndices.Add( anObjId );
@@ -721,13 +786,12 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
        for( it = cellList.begin(); it != cellList.end(); ++it )
        {
          int aCellId = (*it).cellId;
-         if ( !theInteractorStyle->IsValid( this, aCellId ) )
+         if ( !theValidator->IsValid( this, aCellId ) )
            continue;
 
          int anObjId = GetElemObjId( aCellId );
          if( anObjId != -1 )
          {
-           //if( CheckDimensionId( aSelectionMode, this ,anObjId ) )
            anIndexes.Add( anObjId );
          }
        }
@@ -743,22 +807,6 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
 
   TColStd_IndexedMapOfInteger aMapIndex;
   theSelector->GetIndex( getIO(), aMapIndex );
-  /*
-  cout << "SALOME_Actor::Highlight : ";
-  for( int i = 1, n = aMapIndex.Extent(); i <= n; i++ )
-    cout << aMapIndex(i) << " ";
-  cout << endl;
-  cout << "SelectionMode : ";
-  switch( aSelectionMode )
-  {
-    case NodeSelection: cout << "Nodes" << endl; break;
-    case CellSelection: cout << "Cells" << endl; break;
-    case ActorSelection: cout << "Actor" << endl; break;
-    default: cout << "Other" << endl; break;
-  }
-  cout << "IsRectangle : " << ( isRectangle ? "true" : "false" ) << endl;
-  cout << "IsHighlight : " << ( theIsHighlight ? "true" : "false" ) << endl;
-  */
 
   switch( aSelectionMode )
   {
@@ -785,69 +833,3 @@ bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
 
   return true;
 }
-
-/*
-/// Checks: is the given Actor within display coordinates?
-bool
-SVTK_InteractorStyle
-::IsInRect(vtkActor* theActor, 
-          const int left, const int top, 
-          const int right, const int bottom)
-{
-  float* aBounds = theActor->GetBounds();
-  float aMin[3], aMax[3];
-  ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
-  ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
-  if (aMin[0] > aMax[0]) {
-    float aBuf = aMin[0];
-    aMin[0] = aMax[0];
-    aMax[0] = aBuf;
-  }
-  if (aMin[1] > aMax[1]) {
-    float aBuf = aMin[1];
-    aMin[1] = aMax[1];
-    aMax[1] = aBuf;    
-  }
-
-  return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
-}
-
-
-/// Checks: is the given Cell within display coordinates?
-bool
-SVTK_InteractorStyle
-::IsInRect(vtkCell* theCell, 
-          const int left, const int top, 
-          const int right, const int bottom)
-{
-  float* aBounds = theCell->GetBounds();
-  float aMin[3], aMax[3];
-  ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
-  ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
-  if (aMin[0] > aMax[0]) {
-    float aBuf = aMin[0];
-    aMin[0] = aMax[0];
-    aMax[0] = aBuf;
-  }
-  if (aMin[1] > aMax[1]) {
-    float aBuf = aMin[1];
-    aMin[1] = aMax[1];
-    aMax[1] = aBuf;    
-  }
-
-  return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
-}
-
-
-bool
-SVTK_InteractorStyle
-::IsInRect(float* thePoint, 
-          const int left, const int top, 
-          const int right, const int bottom)
-{
-  float aPnt[3];
-  ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
-
-  return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
-}
-*/
index 31c4a44b7663922f0d0bc99c268d428eda568c17..06be74f5f64c7f5b68b0bc3c3c036b16f3ba093b 100644 (file)
 #ifndef SALOME_ACTOR_H
 #define SALOME_ACTOR_H
 
-#include "SALOME_InteractiveObject.hxx" // INCLUDES "using namespace std"
-#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include "Handle_SALOME_InteractiveObject.hxx"
-#endif
+#include "SVTK_SelectionEvent.h"
+#include "SVTK_Selector.h"
+#include "SVTK.h"
 
-//#include <vtkLODActor.h> // INCLUDES "stdio.h"
-//#include <vtkProperty.h> 
+#include "VTKViewer_Actor.h"
 
-// to overcome the conflict between std::ostream and io::ostream 
-// the following variable must be defined:
-// VTK_USE_ANSI_STDLIB
+#include "SALOME_InteractiveObject.hxx"
 
+#include <string>
 #include <vector>
 
 class vtkCell;
@@ -61,110 +58,334 @@ class VTKViewer_TransformFilter;
 class VTKViewer_PassThroughFilter;
 class VTKViewer_CellRectPicker;
 
-extern int SALOME_POINT_SIZE;
-
-#ifdef WNT
-#define SALOME_OBJECT_EXPORT __declspec (dllexport)
-#else
-#define SALOME_OBJECT_EXPORT
-#endif
-
-#include <VTKViewer_Actor.h>
-
-#include "SVTK_Selector.h"
-#include "SVTK_SelectionEvent.h"
-
-#include <string>
-
 class SVTK_Actor;
 class SVTK_InteractorStyle;
 
-class SALOME_OBJECT_EXPORT SALOME_Actor : public VTKViewer_Actor {
+extern int SALOME_POINT_SIZE;
+
+class SALOME_Actor;
+
+namespace VTK
+{
+  struct TValidator
+  {
+    virtual 
+    bool 
+    IsValid( SALOME_Actor* theActor,
+            const int theId,
+            const bool theIsNode = false ) = 0;
+  };
+}
+
+class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor 
+{
  public:
   static SALOME_Actor* New();
-
+  
   vtkTypeMacro(SALOME_Actor,vtkLODActor);
 
-  virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
-  virtual const Handle(SALOME_InteractiveObject)& getIO() { return myIO; } 
-  virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
+  virtual
+  Standard_Boolean 
+  hasIO() 
+  { 
+    return !myIO.IsNull(); 
+  }
+
+  virtual 
+  const Handle(SALOME_InteractiveObject)& 
+  getIO()
+  { 
+    return myIO; 
+  } 
+
+  virtual
+  void
+  setIO(const Handle(SALOME_InteractiveObject)& theIO) 
+  { 
+    myIO = theIO; 
+  }
+
+  virtual 
+  const char* 
+  getName() 
+  { 
+    return myName.c_str(); 
+  }
 
-  virtual const char* getName() { return myName.c_str(); }
-  virtual void setName(const char* theName){
-    if(hasIO())        myIO->setName(theName);
+  virtual
+  void
+  setName(const char* theName)
+  {
+    if(hasIO())        
+      myIO->setName(theName);
     myName = theName;
   }
 
   // To generate highlight automaticaly
-  virtual bool hasHighlight() { return false; } 
-  //virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }  
-  virtual bool isHighlighted() { return myIsHighlighted; }
+  virtual
+  bool
+  hasHighlight() 
+  { 
+    return false; 
+  } 
+
+  virtual
+  void
+  highlight( bool, Selection_Mode );
+
+  virtual
+  void
+  highlight(bool theHighlight) 
+  { 
+    highlight(theHighlight,ActorSelection); 
+  }  
+
+  virtual
+  bool
+  isHighlighted() 
+  { 
+    return myIsHighlighted; 
+  }
+
+  virtual
+  void
+  SetOpacity(float theOpacity);
+
+  virtual
+  float 
+  GetOpacity();
 
-  virtual void SetOpacity(float theOpacity);
-  virtual float GetOpacity();
+  virtual
+  void
+  SetColor(float r,float g,float b);
 
-  virtual void SetColor(float r,float g,float b);
-  virtual void GetColor(float& r,float& g,float& b);
-  void SetColor(const float theRGB[3]){ 
+  virtual
+  void
+  GetColor(float& r,float& g,float& b);
+
+  virtual
+  void
+  SetColor(const float theRGB[3])
+  { 
     SetColor(theRGB[0],theRGB[1],theRGB[2]);
   }
 
   vtkSetObjectMacro(PreviewProperty,vtkProperty);
 
-  virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
+  virtual
+  void
+  SetPreSelected(bool thePreselect = false) 
+  { 
+    myIsPreselected = thePreselect;
+  }
 
   // Used to obtain all dependent actors
-  virtual void GetChildActors(vtkActorCollection*) {};
+  virtual
+  void
+  GetChildActors(vtkActorCollection*) 
+  {};
   
-  //virtual void AddToRender(vtkRenderer* theRenderer); 
-  //virtual void RemoveFromRender(vtkRenderer* theRenderer);
+  // For selection mapping purpose
+  virtual
+  int 
+  GetNodeObjId(int theVtkID)
+  { 
+    return theVtkID;
+  }
 
+  virtual
+  float*
+  GetNodeCoord(int theObjID);
 
-  // For selection mapping purpose
-  virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
-  virtual float* GetNodeCoord(int theObjID);
+  virtual 
+  int
+  GetElemObjId(int theVtkID) 
+  { 
+    return theVtkID;
+  }
+
+  virtual
+  vtkCell* 
+  GetElemCell(int theObjID);
 
-  virtual int GetElemObjId(int theVtkID) { return theVtkID;}
-  virtual vtkCell* GetElemCell(int theObjID);
+  virtual
+  int
+  GetObjDimension( const int theObjId );
 
-  virtual int GetObjDimension( const int theObjId );
+  virtual
+  void
+  SetMapper(vtkMapper* theMapper); 
 
-  virtual void SetMapper(vtkMapper* theMapper); 
-  virtual vtkDataSet* GetInput(); 
+  virtual
+  vtkDataSet* 
+  GetInput(); 
 
+  virtual
+  void
+  SetTransform(VTKViewer_Transform* theTransform); 
 
-  virtual void SetTransform(VTKViewer_Transform* theTransform); 
-  virtual unsigned long int GetMTime();
+  virtual
+  unsigned long int
+  GetMTime();
 
-  virtual void SetRepresentation(int theMode);
-  virtual int GetRepresentation();
+  virtual
+  void
+  SetRepresentation(int theMode);
 
-  virtual int getDisplayMode();
-  virtual void setDisplayMode(int theMode);
+  virtual
+  int
+  GetRepresentation();
+
+  virtual
+  int
+  getDisplayMode();
+
+  virtual
+  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 SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
-  virtual bool IsInfinitive();
+  void
+  SetInfinitive(bool theIsInfinite)
+  { 
+    myIsInfinite = theIsInfinite; 
+  }
+
+  virtual
+  bool
+  IsInfinitive();
     
-  void SetResolveCoincidentTopology(bool theIsResolve);
-  void SetPolygonOffsetParameters(float factor, float units);
-  void GetPolygonOffsetParameters(float& factor, float& units);
+  void
+  SetResolveCoincidentTopology(bool theIsResolve);
+
+  void
+  SetPolygonOffsetParameters(float factor, float units);
+
+  void
+  GetPolygonOffsetParameters(float& factor, float& units);
+
+  virtual
+  void
+  Render(vtkRenderer *, vtkMapper *);
+
+  virtual
+  float
+  GetShrinkFactor() 
+  { 
+    return 1.0;
+  }
+
+  virtual
+  bool
+  IsShrunkable() 
+  { 
+    return false;
+  }
+
+  virtual
+  bool
+  IsShrunk() 
+  { 
+    return false;
+  }
+
+  virtual
+  void
+  SetShrink() 
+  {} 
+
+  virtual
+  void
+  UnShrink() 
+  {}
+
+  virtual
+  bool
+  IsSetCamera() const 
+  { 
+    return false; 
+  }
 
-  virtual void Render(vtkRenderer *, vtkMapper *);
+  virtual
+  bool
+  IsResizable() const 
+  { 
+    return false; 
+  }
+
+  virtual
+  void
+  SetSize( const float ) 
+  {}
+
+  virtual
+  void 
+  SetCamera( vtkCamera* ) 
+  {}
+
+  virtual
+  void
+  SetVisibility( int );
+
+  virtual
+  void
+  AddToRender( vtkRenderer* ); 
+
+  virtual
+  void
+  RemoveFromRender( vtkRenderer* );
+
+  virtual
+  bool
+  PreHighlight( VTK::TValidator*, 
+               SVTK_Selector*, 
+               vtkRenderer*, 
+               SVTK_SelectionEvent, 
+               bool );
+  virtual 
+  bool
+  Highlight( VTK::TValidator*, 
+            SVTK_Selector*, 
+            vtkRenderer*, 
+            SVTK_SelectionEvent, 
+            bool );
+
+  vtkProperty* 
+  getPointProperty()
+  { 
+    return myPointProperty; 
+  }
 
-  virtual float GetShrinkFactor() { return 1.0;}
+  vtkProperty* 
+  getCellProperty()
+  { 
+    return myCellProperty; 
+  }
 
-  virtual bool IsShrunkable() { return false;}
-  virtual bool IsShrunk() { return false;}
+  vtkProperty* 
+  getEdgeProperty()
+  { 
+    return myEdgeProperty; 
+  }
 
-  virtual void SetShrink() {} 
-  virtual void UnShrink() {}
+  vtkPointPicker* 
+  getPointPicker() 
+  { 
+    return myPointPicker; 
+  }
 
-  virtual bool IsSetCamera() const { return false; }
-  virtual bool IsResizable() const { return false; }
-  virtual void SetSize( const float ) {}
-  virtual void SetCamera( vtkCamera* ) {}
+  vtkCellPicker* 
+  getCellPicker() 
+  { 
+    return myCellPicker; 
+  }
+
+  VTKViewer_CellRectPicker* 
+  getCellRectPicker() 
+  { 
+    return myCellRectPicker; 
+  }
 
  protected:
   bool myIsResolveCoincidentTopology;
@@ -190,46 +411,18 @@ class SALOME_OBJECT_EXPORT SALOME_Actor : public VTKViewer_Actor {
   int myRepresentation;
   vtkProperty *myProperty;
 
-  void InitPipeLine(vtkMapper* theMapper); 
+  void
+  InitPipeLine(vtkMapper* theMapper); 
 
   SALOME_Actor();
   ~SALOME_Actor();
 
   // From VISU
  public:
-  virtual void highlight( bool, Selection_Mode );
-
-  virtual void SetVisibility( int );
-
-  virtual void AddToRender( vtkRenderer* ); 
-  virtual void RemoveFromRender( vtkRenderer* );
-
-  virtual bool PreHighlight( SVTK_InteractorStyle*, SVTK_Selector*, vtkRenderer*, SVTK_SelectionEvent, bool );
-  virtual bool    Highlight( SVTK_InteractorStyle*, SVTK_Selector*, vtkRenderer*, SVTK_SelectionEvent, bool );
-
-  vtkProperty* getPointProperty() const { return myPointProperty; }
-  vtkProperty* getCellProperty() const { return myCellProperty; }
-  vtkProperty* getEdgeProperty() const { return myEdgeProperty; }
-
-  vtkPointPicker* getPointPicker() const { return myPointPicker; }
-  vtkCellPicker* getCellPicker() const { return myCellPicker; }
-  VTKViewer_CellRectPicker* getCellRectPicker() const { return myCellRectPicker; }
 
  protected:
   int GetEdgeId( vtkPicker*, int );
 
-  /*
-  bool IsInRect(vtkActor* theActor, 
-               const int left, const int top, 
-               const int right, const int bottom);
-  bool IsInRect(vtkCell* theCell, 
-               const int left, const int top, 
-               const int right, const int bottom);
-  bool IsInRect(float* thePoint, 
-               const int left, const int top, 
-               const int right, const int bottom);
-  */
- protected:
   vtkProperty* myPointProperty;
   vtkProperty* myCellProperty;
   vtkProperty* myEdgeProperty;
index 25e0216a12e249fb56466627feb70171a9e8b6d2..351b3006289fc76bd3d28b07d607c10de02a0211 100644 (file)
@@ -29,9 +29,6 @@
 
 #include "SVTK_InteractorStyle.h"
 
-#include "utilities.h"
-
-#include "VTKViewer_CellRectPicker.h"
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_RectPicker.h"
 
 #include "SALOME_ListIteratorOfListIO.hxx"
 #include "SALOME_ListIO.hxx"
 
-#include "SUIT_Session.h"
-#include "CAM_Application.h"
-
 #include <vtkObjectFactory.h>
 #include <vtkMath.h>
 #include <vtkCommand.h>
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
 #include <vtkPicker.h>
-#include <vtkPointPicker.h>
-#include <vtkCellPicker.h>
-#include <vtkLine.h> 
-#include <vtkMapper.h>
-#include <vtkDataSet.h>
-#include <vtkSmartPointer.h>
 #include <vtkRenderWindow.h>
 #include <vtkRenderWindowInteractor.h>
 
@@ -71,8 +59,9 @@
 //VRV: porting on Qt 3.0.5
 #include <algorithm>
 
-using namespace std;
+#include "utilities.h"
 
+using namespace std;
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
@@ -111,7 +100,11 @@ SVTK_InteractorStyle
   this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
   loadCursors();
 
-  OnSelectionModeChanged();
+  myPicker = vtkPicker::New();
+  myPicker->Delete();
+
+  myRectPicker = VTKViewer_RectPicker::New();
+  myRectPicker->Delete();
 }
 
 //----------------------------------------------------------------------------
@@ -129,23 +122,6 @@ SVTK_InteractorStyle
   return myViewWindow->GetSelector();
 }
 
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::setPreselectionProp(const double& theRed, 
-                     const double& theGreen, 
-                     const double& theBlue, 
-                     const int& theWidth) 
-{
-  /*
-  if ( myPreSelectionActor->GetProperty() == 0 )
-    return;
-  myPreSelectionActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
-  myPreSelectionActor->GetProperty()->SetLineWidth(theWidth);
-  myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
-  */
-}
-
 //----------------------------------------------------------------------------
 int
 SVTK_InteractorStyle
@@ -288,8 +264,6 @@ void
 SVTK_InteractorStyle
 ::OnMouseMove() 
 {
-  //cout << "SVTK_InteractorStyle::OnMouseMove" << endl;
-
   int x, y;
   this->Interactor->GetEventPosition( x, y );
   this->OnMouseMove( this->Interactor->GetControlKey(),
@@ -303,8 +277,6 @@ void
 SVTK_InteractorStyle
 ::OnLeftButtonDown()
 {
-  //cout << "SVTK_InteractorStyle::OnLeftButtonDown" << endl;
-
   int x, y;
   this->Interactor->GetEventPosition( x, y );
   this->OnLeftButtonDown( this->Interactor->GetControlKey(),
@@ -318,8 +290,6 @@ void
 SVTK_InteractorStyle
 ::OnLeftButtonUp()
 {
-  //cout << "SVTK_InteractorStyle::OnLeftButtonUp" << endl;
-
   int x, y;
   this->Interactor->GetEventPosition( x, y );
   this->OnLeftButtonUp( this->Interactor->GetControlKey(),
@@ -333,8 +303,6 @@ void
 SVTK_InteractorStyle
 ::OnMiddleButtonDown() 
 {
-  //cout << "SVTK_InteractorStyle::OnMiddleButtonDown" << endl;
-
   int x, y;
   this->Interactor->GetEventPosition( x, y );
   this->OnMiddleButtonDown( this->Interactor->GetControlKey(),
@@ -348,8 +316,6 @@ void
 SVTK_InteractorStyle
 ::OnMiddleButtonUp()
 {
-  //cout << "SVTK_InteractorStyle::OnMiddleButtonUp" << endl;
-
   int x, y;
   this->Interactor->GetEventPosition( x, y );
   this->OnMiddleButtonUp( this->Interactor->GetControlKey(),
@@ -363,8 +329,6 @@ void
 SVTK_InteractorStyle
 ::OnRightButtonDown() 
 {
-  //cout << "SVTK_InteractorStyle::OnRightButtonDown" << endl;
-
   int x, y;
   this->Interactor->GetEventPosition( x, y );
   this->OnRightButtonDown( this->Interactor->GetControlKey(),
@@ -377,8 +341,6 @@ void
 SVTK_InteractorStyle
 ::OnRightButtonUp()
 {
-  //cout << "SVTK_InteractorStyle::OnRightButtonUp" << endl;
-
   int x, y;
   this->Interactor->GetEventPosition( x, y );
   this->OnRightButtonUp( this->Interactor->GetControlKey(),
@@ -944,14 +906,6 @@ SVTK_InteractorStyle
   //  rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
 
   Selection_Mode aSelectionMode = myViewWindow->SelectionMode();
-  bool aSelActiveCompOnly = false;
-
-  QString aComponentDataType;
-  if(SUIT_Session* aSession = SUIT_Session::session())
-    if(SUIT_Application* aSUITApp = aSession->activeApplication())
-      if(CAM_Application* aCAMApp = dynamic_cast<CAM_Application*>(aSUITApp))
-       if(CAM_Module* aModule = aCAMApp->activeModule())
-         aComponentDataType = aModule->name();
 
   switch (State) {
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
@@ -986,25 +940,17 @@ SVTK_InteractorStyle
           this->FindPokedRenderer(x, y);
          Interactor->StartPickCallback();
 
-         vtkPicker* aPicker = vtkPicker::SafeDownCast(Interactor->GetPicker());
-          aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
-    
-         SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
-
-         SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
-         aSelectionEvent.SelectionMode = aSelectionMode;
-         aSelectionEvent.IsRectangle = false;
-
-         if( aSActor )
+          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;
            aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
-         else
-         {
-           this->HighlightProp( NULL );
+         }else{
            GetSelector()->ClearIObjects();
          }
         } else {
           //processing rectangle selection
-         if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
          Interactor->StartPickCallback();
 
          if (!myShiftState) {
@@ -1025,17 +971,16 @@ SVTK_InteractorStyle
          x2 = rect.right(); 
          y2 = h - rect.bottom() - 1;
 
+         myRectPicker->SetTolerance(0.001);
+         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;
          
-         vtkSmartPointer<VTKViewer_RectPicker> aPicker = VTKViewer_RectPicker::New();
-         aPicker->SetTolerance(0.001);
-         aPicker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
-         vtkActorCollection* aListActors = aPicker->GetActors();
+         vtkActorCollection* aListActors = myRectPicker->GetActors();
          aListActors->InitTraversal();
          while(vtkActor* aActor = aListActors->GetNextActor()){
            if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)){
@@ -1133,16 +1078,6 @@ SVTK_InteractorStyle
   this->LastPos[1] = h - mousePos.y() - 1;
 }
 
-// called when selection mode changed (!put necessary initialization here!)
-void
-SVTK_InteractorStyle
-::OnSelectionModeChanged()
-{
-  
-  myElemId = myEdgeId = myNodeId = -1;
-  mySelectedActor = NULL;
-}
-
 // called when user moves mouse inside viewer window and there is no active viewer operation 
 // (!put necessary processing here!)
 void
@@ -1150,8 +1085,6 @@ SVTK_InteractorStyle
 ::onCursorMove(QPoint mousePos) 
 {
   // processing highlighting
-  Selection_Mode aSelectionMode = myViewWindow->SelectionMode();
-
   int w, h, x, y;
   Interactor->GetSize(w, h);
   x = mousePos.x(); y = h - mousePos.y() - 1;
@@ -1159,48 +1092,18 @@ SVTK_InteractorStyle
   this->FindPokedRenderer(x,y);
   Interactor->StartPickCallback();
 
-  vtkPicker* aPicker = vtkPicker::SafeDownCast(Interactor->GetPicker());
-
-  SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
-
   SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
+  aSelectionEvent.SelectionMode = myViewWindow->SelectionMode();
   aSelectionEvent.X = x;
   aSelectionEvent.Y = y;
-  aSelectionEvent.SelectionMode = aSelectionMode;
 
-  if( aSActor )
+  if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(myPicker->GetActor()))
     aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, false );
-  //cout << "onCursorMove : " << ( aSActor ? "1" : "0" ) << " ";
 
-  aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
-
-  aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
-  //cout << ( aSActor ? "1" : "0" ) << endl;
-
-  if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
-    if ( aSActor )
-      aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
-  }
-  else if (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
-    if ( aSActor )
-      aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
-  }
-  else if ( vtkPicker::SafeDownCast(aPicker) ) {
-    if( aSActor )
-      aSActor->PreHighlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true );
-    /*
-    else {
-      myPreViewActor = NULL;
-      vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
-      theActors->InitTraversal();
-      while( vtkActor *ac = theActors->GetNextActor() ) {
-        if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
-          anActor->SetPreSelected( false );
-        }
-      }
-    }
-    */
-  }
+  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 );
+  
   Interactor->EndPickCallback();
   //Interactor->Render();
   myGUIWindow->update();
index 9315ee233b0be2ba9ea8f0f9be48f4f3ee9855a5..dc362274d8d4af09bd35c662003500d565bffd63 100644 (file)
@@ -32,9 +32,7 @@
 #include "SVTK.h"
 
 #include <vtkInteractorStyle.h>
-
-class vtkCell;
-class vtkRenderWindowInteractor;
+#include <vtkSmartPointer.h>
 
 #include <qobject.h>
 #include <qcursor.h>
@@ -45,8 +43,10 @@ class vtkRenderWindowInteractor;
 #include "VTKViewer_Filter.h"
 
 #include "SVTK_SelectionEvent.h"
+#include "SALOME_Actor.h"
 
-class VTKViewer_Trihedron;
+class vtkPicker;
+class VTKViewer_RectPicker;
 
 class SALOME_Actor;
 class SVTK_Viewer;
@@ -62,10 +62,12 @@ class SVTK_ViewWindow;
 #define VTK_INTERACTOR_STYLE_CAMERA_SELECT     6
 #define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
 
-class SVTK_EXPORT SVTK_InteractorStyle : public QObject, 
+class SVTK_EXPORT SVTK_InteractorStyle : 
+  public QObject,
+  public VTK::TValidator,
   public vtkInteractorStyle
 {
-  Q_OBJECT
+  Q_OBJECT;
 
  public:
   // Description:
@@ -82,12 +84,6 @@ class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
 
   SVTK_SelectionEvent GetSelectionEvent();
 
-  //merge with V2_2_0_VISU_improvements:void setTriedron(VTKViewer_Trihedron* theTrihedron);
-  void setPreselectionProp(const double& theRed = 0, 
-                          const double& theGreen = 1,
-                          const double& theBlue = 1, 
-                          const int& theWidth = 5);
-
   // VTK events
   virtual void OnMouseMove();
   virtual void OnLeftButtonDown();
@@ -106,21 +102,31 @@ class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
   void OnRightButtonDown(int ctrl, int shift, int x, int y);
   void OnRightButtonUp  (int ctrl, int shift, int x, int y);
 
-  void OnSelectionModeChanged();
+  void 
+  SetFilter( const Handle(VTKViewer_Filter)& );
+
+  Handle(VTKViewer_Filter) 
+  GetFilter( const int );  
 
-  //merge with V2_2_0_VISU_improvements:void  ViewFitAll();
+  bool
+  IsFilterPresent( const int );
 
-  void                     SetFilter( const Handle(VTKViewer_Filter)& );
-  Handle(VTKViewer_Filter) GetFilter( const int );  
-  bool                     IsFilterPresent( const int );
-  void                     RemoveFilter( const int );
-  bool                     IsValid( SALOME_Actor* theActor,
-                                    const int     theId,
-                                    const bool    theIsNode = false );
+  void
+  RemoveFilter( const int );
+
+  bool
+  IsValid( SALOME_Actor* theActor,
+          const int theId,
+          const bool theIsNode = false );
   
-  void                     IncrementalPan   ( const int incrX, const int incrY );
-  void                     IncrementalZoom  ( const int incr );
-  void                     IncrementalRotate( const int incrX, const int incrY );
+  void
+  IncrementalPan( const int incrX, const int incrY );
+
+  void
+  IncrementalZoom( const int incr );
+
+  void
+  IncrementalRotate( const int incrX, const int incrY );
 
  protected:
   SVTK_InteractorStyle();
@@ -142,13 +148,6 @@ class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
   float RadianToDegree;                 // constant: for conv from deg to rad
   double myScale;
 
-  SALOME_Actor* myPreViewActor;
-
-  SALOME_Actor* mySelectedActor;
-  int myElemId;
-  int myEdgeId;
-  int myNodeId;
-
  public:
   bool eventFilter(QObject* object, QEvent* event);
   void startZoom();
@@ -170,7 +169,6 @@ class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
 
  signals:
   void RenderWindowModified() ;
-  void contextMenuRequested( QContextMenuEvent *e );
 
  protected:
   QCursor                   myDefCursor;
@@ -187,8 +185,10 @@ class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
   int                       ForcedState;
   
   SVTK_ViewWindow*          myViewWindow;
-  //merge with V2_2_0_VISU_improvements:VTKViewer_Trihedron*      myTrihedron;
   QWidget*                  myGUIWindow;
+
+  vtkSmartPointer<vtkPicker> myPicker;
+  vtkSmartPointer<VTKViewer_RectPicker> myRectPicker;
   
   std::map<int, Handle(VTKViewer_Filter)> myFilters;