]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
1. Move SALOME_Actor to SVTK package
authorapo <apo@opencascade.com>
Tue, 2 Aug 2005 06:59:45 +0000 (06:59 +0000)
committerapo <apo@opencascade.com>
Tue, 2 Aug 2005 06:59:45 +0000 (06:59 +0000)
2. Move Highlight/Prehighlight functionality from InteractorStyle to SALOME_Actor

src/SVTK/Makefile.in
src/SVTK/SALOME_Actor.cxx [new file with mode: 0644]
src/SVTK/SALOME_Actor.h [new file with mode: 0644]
src/SVTK/SVTK_Actor.h
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h

index e41cfb610c370449e5c687ba14a8b6c5e53934d1..a9a26f4f0c3d263c1d70542274f26d4adae2bf95 100755 (executable)
@@ -15,6 +15,7 @@ VPATH=.:@srcdir@
 EXPORT_HEADERS= SVTK.h \
                SVTK_Prs.h \
                SVTK_Actor.h \
+               SALOME_Actor.h \
                SVTK_CubeAxesActor2D.h \
                SVTK_Functor.h \
                SVTK_ViewManager.h \
@@ -31,6 +32,7 @@ LIB = libSVTK.la
 
 LIB_SRC=       SVTK_Prs.cxx \
                SVTK_Actor.cxx \
+               SALOME_Actor.cxx \
                SVTK_CubeAxesActor2D.cxx \
                SVTK_Trihedron.cxx \
                SVTK_ViewManager.cxx \
diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx
new file mode 100644 (file)
index 0000000..b5caa8e
--- /dev/null
@@ -0,0 +1,586 @@
+//  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : SALOME_Actor.cxx
+//  Author : Nicolas REJNERI
+//  Module : SALOME
+//  $Header$
+
+/*!
+  \class SALOME_Actor SALOME_Actor.h
+  \brief Abstract class of SALOME Objects in VTK.
+*/
+
+
+#include "SALOME_Actor.h"
+
+#include "VTKViewer_Transform.h"
+#include "VTKViewer_TransformFilter.h"
+#include "VTKViewer_PassThroughFilter.h"
+#include "VTKViewer_GeometryFilter.h"
+#include "SVTK_Actor.h"
+#include "SVTK_InteractorStyle.h"
+
+// SALOME Includes
+//#include "utilities.h"
+
+// VTK Includes
+#include <vtkCell.h>
+#include <vtkPicker.h>
+#include <vtkPointPicker.h>
+#include <vtkCellPicker.h>
+#include <vtkRenderer.h>
+#include <vtkPolyData.h>
+#include <vtkObjectFactory.h>
+#include <vtkDataSetMapper.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
+
+//using namespace std;
+
+
+#if defined __GNUC__
+  #if __GNUC__ == 2
+    #define __GNUC_2__
+  #endif
+#endif
+
+int SALOME_POINT_SIZE = 3;
+
+
+vtkStandardNewMacro(SALOME_Actor);
+
+
+SALOME_Actor::SALOME_Actor(){
+  myIsHighlighted = myIsPreselected = false;
+
+  myRepresentation = 1;
+  myDisplayMode = myRepresentation - 1;
+
+  myProperty = vtkProperty::New();
+  PreviewProperty = NULL;
+
+  myIsInfinite = false;
+
+  myIsResolveCoincidentTopology = true;
+
+  vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
+                                                                myPolygonOffsetUnits);
+  myStoreMapping = false;
+  myGeomFilter = VTKViewer_GeometryFilter::New();
+
+  myTransformFilter = VTKViewer_TransformFilter::New();
+
+  for(int i = 0; i < 6; i++)
+    myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
+
+  // from VISU
+  myPreHighlightActor = SVTK_Actor::New(); 
+  myPreHighlightActor->GetProperty()->SetColor(0,1,0);
+  myPreHighlightActor->GetProperty()->SetPointSize(15);
+  myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
+
+  myPointProperty = vtkProperty::New();
+  myPointProperty->SetColor(1,0,1);
+  myPointProperty->SetPointSize(15);
+  myPointProperty->SetRepresentationToPoints();
+
+  myCellProperty = vtkProperty::New();
+  myCellProperty->SetColor(1,1,0);
+  myCellProperty->SetPointSize(5);
+  myCellProperty->SetRepresentationToSurface();
+
+  myEdgeProperty = vtkProperty::New();
+  myEdgeProperty->SetColor(1,0,0);
+  myEdgeProperty->SetPointSize(5);
+  myEdgeProperty->SetRepresentationToWireframe();
+
+  myHighlightActor = SVTK_Actor::New(); 
+  myHighlightActor->PickableOff();
+  myHighlightActor->SetProperty( myPointProperty );
+}
+
+
+SALOME_Actor::~SALOME_Actor(){
+  SetPreviewProperty(NULL);
+
+  myGeomFilter->UnRegisterAllOutputs(); 
+  myGeomFilter->Delete();
+
+  myTransformFilter->UnRegisterAllOutputs();
+  myTransformFilter->Delete();
+
+  for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
+    if(myPassFilter[i]){
+      myPassFilter[i]->UnRegisterAllOutputs(); 
+      myPassFilter[i]->Delete();
+    }
+  }
+
+  myProperty->Delete();
+
+  // from VISU
+  myHighlightActor->SetProperty( NULL );
+}
+
+
+void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){
+  theRenderer->AddActor(this);
+
+  // from VISU
+  theRenderer->AddActor( myPreHighlightActor );
+  theRenderer->AddActor( myHighlightActor );
+}
+
+void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){
+  theRenderer->RemoveActor(this);
+
+  // from VISU
+  theRenderer->RemoveActor( myPreHighlightActor );
+  theRenderer->RemoveActor( myHighlightActor );
+}
+
+
+void SALOME_Actor::SetTransform(VTKViewer_Transform* theTransform){
+  myTransformFilter->SetTransform(theTransform);
+}
+
+
+void SALOME_Actor::SetMapper(vtkMapper* theMapper){
+  InitPipeLine(theMapper);
+}
+
+void SALOME_Actor::InitPipeLine(vtkMapper* theMapper){
+  if(theMapper){
+    int anId = 0;
+    myPassFilter[ anId ]->SetInput( theMapper->GetInput() );
+    myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
+    
+    anId++; // 1
+    myGeomFilter->SetStoreMapping( myStoreMapping );
+    myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
+
+    anId++; // 2
+    myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() ); 
+    myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
+
+    anId++; // 3
+    myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
+
+    anId++; // 4
+    myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
+    myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
+
+    anId++; // 5
+    if(vtkDataSetMapper* aMapper = dynamic_cast<vtkDataSetMapper*>(theMapper)){
+      aMapper->SetInput(myPassFilter[anId]->GetOutput());
+    }else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(theMapper)){
+      aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput());
+    }
+  }
+  vtkLODActor::SetMapper(theMapper);
+}
+
+
+void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper* m){
+  if(myIsResolveCoincidentTopology){
+    int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
+    float aFactor, aUnit; 
+    vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
+    
+    vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
+    vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
+                                                                  myPolygonOffsetUnits);
+    vtkLODActor::Render(ren,m);
+    
+    vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
+    vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
+  }else{
+    vtkLODActor::Render(ren,m);
+  }
+}
+
+
+void SALOME_Actor::SetResolveCoincidentTopology(bool theIsResolve) {
+  myIsResolveCoincidentTopology = theIsResolve;
+}
+
+void SALOME_Actor::SetPolygonOffsetParameters(float factor, float units){
+  myPolygonOffsetFactor = factor;
+  myPolygonOffsetUnits = units;
+}
+
+void SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units){
+  factor = myPolygonOffsetFactor;
+  units = myPolygonOffsetUnits;
+}
+
+
+vtkDataSet* SALOME_Actor::GetInput(){
+  return myPassFilter.front()->GetOutput();
+}
+
+
+unsigned long int SALOME_Actor::GetMTime(){
+  unsigned long mTime = this->Superclass::GetMTime();
+  unsigned long time = myTransformFilter->GetMTime();
+  mTime = ( time > mTime ? time : mTime );
+  if(vtkDataSet *aDataSet = myPassFilter[0]->GetInput()){
+    time = aDataSet->GetMTime();
+    mTime = ( time > mTime ? time : mTime );
+  }
+  return mTime;
+}
+
+
+void SALOME_Actor::SetRepresentation(int theMode) { 
+  switch(myRepresentation){
+  case VTK_POINTS : 
+  case VTK_SURFACE : 
+    myProperty->DeepCopy(GetProperty());
+  }    
+  switch(theMode){
+  case VTK_POINTS : 
+  case VTK_SURFACE : 
+    GetProperty()->DeepCopy(myProperty);
+    break;
+  default:
+    GetProperty()->SetAmbient(1.0);
+    GetProperty()->SetDiffuse(0.0);
+    GetProperty()->SetSpecular(0.0);
+  }
+  switch(theMode){
+  case 3 : 
+    myGeomFilter->SetInside(true);
+    GetProperty()->SetRepresentation(1);
+    break;
+  case VTK_POINTS : 
+    GetProperty()->SetPointSize(SALOME_POINT_SIZE);  
+  default :
+    GetProperty()->SetRepresentation(theMode);
+    myGeomFilter->SetInside(false);
+  }
+  myRepresentation = theMode;
+}
+
+int SALOME_Actor::GetRepresentation(){ 
+  return myRepresentation;
+}
+
+
+vtkCell* SALOME_Actor::GetElemCell(int theObjID){
+  return GetInput()->GetCell(theObjID);
+}
+
+
+float* SALOME_Actor::GetNodeCoord(int theObjID){
+  return GetInput()->GetPoint(theObjID);
+}
+
+
+//=================================================================================
+// function : GetObjDimension
+// purpose  : Return object dimension.
+//            Virtual method shoulb be redifined by derived classes
+//=================================================================================
+int SALOME_Actor::GetObjDimension( const int theObjId )
+{
+  if ( vtkCell* aCell = GetElemCell(theObjId) )
+    return aCell->GetCellDimension();
+  return 0;
+}
+
+
+bool SALOME_Actor::IsInfinitive(){ 
+  return myIsInfinite; 
+}
+
+
+void SALOME_Actor::SetOpacity(float theOpacity){ 
+  myOpacity = theOpacity;
+  GetProperty()->SetOpacity(theOpacity);
+}
+
+float SALOME_Actor::GetOpacity(){
+  return myOpacity;
+}
+
+
+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){
+  float aColor[3];
+  GetProperty()->GetColor(aColor);
+  r = aColor[0];
+  g = aColor[1];
+  b = aColor[2];
+}
+
+
+int SALOME_Actor::getDisplayMode(){ 
+  return myDisplayMode; 
+}
+
+void SALOME_Actor::setDisplayMode(int theMode){ 
+  SetRepresentation(theMode+1); 
+  myDisplayMode = GetRepresentation() - 1;
+}
+
+// from VISU
+
+//----------------------------------------------------------------
+void SALOME_Actor::highlight( bool theHighlight )
+{
+  //cout << "SALOME_Actor::highlight " << ( theHighlight ? "on" : "off" ) << endl;
+
+  myHighlightActor->SetVisibility( theHighlight );
+}
+
+//----------------------------------------------------------------
+void SALOME_Actor::SetVisibility( int theVisibility )
+{
+  vtkProp::SetVisibility( theVisibility );
+
+  myHighlightActor->SetVisibility( theVisibility && isHighlighted() );
+}
+
+//----------------------------------------------------------------
+bool SALOME_Actor::PreHighlight( SVTK_InteractorStyle* theInteractorStyle,
+                                const int& theIndex )
+{
+  //cout << "SALOME_Actor::PreHighlight : " << theIndex << endl;
+
+  if( theIndex == -1 )
+  {
+    myPreHighlightActor->SetVisibility( false );
+  }
+  else
+  {
+    TColStd_IndexedMapOfInteger aMapIndex;
+    aMapIndex.Add( theIndex );
+
+    myPreHighlightActor->SetVisibility( true );
+    myPreHighlightActor->MapPoints( this, aMapIndex );
+  }
+
+  return false;
+}
+
+//----------------------------------------------------------------
+bool SALOME_Actor::Highlight( SVTK_InteractorStyle* theInteractorStyle,
+                             SVTK_Selector* theSelector,
+                             vtkRenderer* theRenderer,
+                             SVTK_SelectionEvent theSelectionEvent,
+                             bool theIsHighlight,
+                             bool theIsUpdate )
+{
+  Selection_Mode aSelectionMode = theSelectionEvent.SelectionMode;
+  float x = theSelectionEvent.X;
+  float y = theSelectionEvent.Y;
+  float z = 0.0;
+  bool isShift = theSelectionEvent.IsShift;
+
+  if( aSelectionMode == NodeSelection )
+  {
+    //vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
+    vtkPointPicker* aPicker = vtkPointPicker::New();
+
+    aPicker->Pick( x, y, z, theRenderer );
+
+    int aVtkId = aPicker->GetPointId();
+    if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId, true ) )
+    {
+      int anObjId = GetNodeObjId( aVtkId );
+      if( anObjId >= 0 )
+      {
+       if( theSelector->IsSelected( myIO ) )
+       {
+         // This IO is already in the selection
+         theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+       }
+       else
+       {
+         if( !isShift )
+         {
+           theInteractorStyle->HighlightProp( NULL );
+           theSelector->ClearIObjects();
+         }
+         theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+         theSelector->AddIObject( this );
+       }
+      }
+    }
+    aPicker->Delete();
+  }
+  else if( aSelectionMode == CellSelection )
+  {
+    vtkCellPicker* aPicker = vtkCellPicker::New();
+
+    aPicker->Pick( x, y, z, theRenderer );
+    
+    int aVtkId = aPicker->GetCellId();
+    if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId ) )
+    {
+      int anObjId = GetElemObjId( aVtkId );
+      if( anObjId >= 0 )
+      {
+       //if( theInteractorStyle->CheckDimensionId( aSelectionMode, this, anObjId ) )
+       {
+         if( theSelector->IsSelected( myIO ) )
+         {
+           // This IO is already in the selection
+           theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+         }
+         else
+         {
+           if( !isShift )
+           {
+             theInteractorStyle->HighlightProp( NULL );
+             theSelector->ClearIObjects();
+           }
+           theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+           theSelector->AddIObject( this );
+         }
+       }
+      }
+    }
+    aPicker->Delete();
+  }
+  else if( aSelectionMode == EdgeOfCellSelection )
+  {
+    vtkCellPicker* aPicker = vtkCellPicker::New();
+
+    aPicker->Pick( x, y, z, theRenderer );
+    
+    int aVtkId = aPicker->GetCellId();
+    if( aVtkId >= 0 && hasIO() && theInteractorStyle->IsValid( this, aVtkId ) )
+    {
+      int anObjId = GetElemObjId( aVtkId );
+      if( anObjId >= 0 )
+      {
+       if( !isShift )
+       {
+         theInteractorStyle->HighlightProp( NULL );
+         theSelector->ClearIObjects();
+       }
+       int anEdgeId = 0;//theInteractorStyle->GetEdgeId( aPicker, this, anObjId );
+       if( anEdgeId >= 0 )
+       {
+         theSelector->AddOrRemoveIndex( myIO, anObjId, false );
+         theSelector->AddOrRemoveIndex( myIO, -anEdgeId-1, true );
+         theSelector->AddIObject( this );
+       } 
+      }
+    }
+    aPicker->Delete();
+  }
+  else if( aSelectionMode == ActorSelection )
+  {
+    if ( hasIO() )
+    {
+      //theInteractorStyle->PropPicked++;
+      if( theSelector->IsSelected( myIO ) )
+      {
+       // This IO is already in the selection
+       if( isShift )
+         theSelector->RemoveIObject( this );
+      }
+      else
+      {
+       if( !isShift )
+       {
+         theInteractorStyle->HighlightProp( NULL );
+         theSelector->ClearIObjects();
+       }
+       theSelector->AddIObject( this );
+      }
+    }
+  }
+
+  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 << "IsHighlight : " << ( theIsHighlight ? "true" : "false" ) << endl;
+  cout << "IsUpdate : " << ( theIsUpdate ? "true" : "false" ) << endl;
+  */
+
+  if( GetVisibility() && theIsHighlight )
+    theInteractorStyle->HighlightProp( this );
+  else if( !theIsHighlight )
+    theInteractorStyle->HighlightProp( NULL );
+
+  //if( aSelectionMode != ActorSelection && !hasHighlight() )
+  //  return false;
+
+  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:
+    case FaceSelection:
+    case VolumeSelection:
+      myHighlightActor->SetProperty( myCellProperty );
+      myHighlightActor->MapCells( this, aMapIndex );
+      highlight( theIsHighlight );
+      break;
+    case ActorSelection:
+      highlight( false );
+      break;
+  }
+
+  return false;
+}
+
+//----------------------------------------------------------------
+bool SALOME_Actor::Unhighlight( SVTK_InteractorStyle* theInteractorStyle,
+                                SVTK_Selector* theSelector,
+                                bool theIsUpdate )
+{
+
+  theInteractorStyle->HighlightProp( NULL );
+  theSelector->ClearIObjects();
+}
diff --git a/src/SVTK/SALOME_Actor.h b/src/SVTK/SALOME_Actor.h
new file mode 100644 (file)
index 0000000..a9b6bcc
--- /dev/null
@@ -0,0 +1,220 @@
+//  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+//  File   : SALOME_Actor.h
+//  Author : Nicolas REJNERI
+//  Module : SALOME
+//  $Header$
+
+#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 <vtkLODActor.h> // INCLUDES "stdio.h"
+#include <vtkProperty.h> 
+
+// to overcome the conflict between std::ostream and io::ostream 
+// the following variable must be defined:
+// VTK_USE_ANSI_STDLIB
+
+#include <vector>
+
+class vtkCell;
+class vtkDataSet;
+class vtkPolyData;
+class vtkCamera;
+class vtkProperty;
+
+class VTKViewer_Transform;
+class VTKViewer_GeometryFilter;
+class VTKViewer_TransformFilter;
+class VTKViewer_PassThroughFilter;
+
+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 <TColStd_IndexedMapOfInteger.hxx>
+
+#include <string>
+
+class vtkRenderer;
+
+class SVTK_Actor;
+class SVTK_InteractorStyle;
+
+class SALOME_OBJECT_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 const char* getName() { return myName.c_str(); }
+  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 void SetOpacity(float theOpacity);
+  virtual float GetOpacity();
+
+  virtual void SetColor(float r,float g,float b);
+  virtual void GetColor(float& r,float& g,float& b);
+  void SetColor(const float theRGB[3]){ 
+    SetColor(theRGB[0],theRGB[1],theRGB[2]);
+  }
+
+  vtkSetObjectMacro(PreviewProperty,vtkProperty);
+
+  virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
+
+  // Used to obtain all dependent actors
+  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);
+
+  virtual int GetElemObjId(int theVtkID) { return theVtkID;}
+  virtual vtkCell* GetElemCell(int theObjID);
+
+  virtual int GetObjDimension( const int theObjId );
+
+  virtual void SetMapper(vtkMapper* theMapper); 
+  virtual vtkDataSet* GetInput(); 
+
+
+  virtual void SetTransform(VTKViewer_Transform* theTransform); 
+  virtual unsigned long int GetMTime();
+
+  virtual void SetRepresentation(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 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 bool IsResizable() const { return false; }
+  virtual void SetSize( const float ) {}
+  virtual void SetCamera( vtkCamera* ) {}
+
+ protected:
+  bool myIsResolveCoincidentTopology;
+  float myPolygonOffsetFactor;
+  float myPolygonOffsetUnits;
+
+  Handle(SALOME_InteractiveObject) myIO;
+  std::string myName;
+
+  vtkProperty *PreviewProperty;
+  bool myIsPreselected;
+
+  float myOpacity;
+  bool myIsHighlighted;
+  int myDisplayMode;
+  bool myIsInfinite;
+
+  bool myStoreMapping;
+  VTKViewer_GeometryFilter *myGeomFilter;
+  VTKViewer_TransformFilter *myTransformFilter;
+  std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
+
+  int myRepresentation;
+  vtkProperty *myProperty;
+
+  void InitPipeLine(vtkMapper* theMapper); 
+
+  SALOME_Actor();
+  ~SALOME_Actor();
+
+  // From VISU
+ public:
+  virtual void highlight( bool );
+
+  virtual void SetVisibility( int );
+
+  virtual void AddToRender( vtkRenderer* ); 
+  virtual void RemoveFromRender( vtkRenderer* );
+
+  virtual bool PreHighlight( SVTK_InteractorStyle*, const int& );
+
+  virtual bool Highlight( SVTK_InteractorStyle*, SVTK_Selector*, vtkRenderer*, SVTK_SelectionEvent, bool, bool );
+  virtual bool Unhighlight( SVTK_InteractorStyle*, SVTK_Selector*, bool );
+
+ protected:
+  vtkProperty* myPointProperty;
+  vtkProperty* myCellProperty;
+  vtkProperty* myEdgeProperty;
+
+  SVTK_Actor* myPreHighlightActor;
+  SVTK_Actor* myHighlightActor;
+};
+
+
+#endif // SALOME_ACTOR_H
+
index 7a9b4a641f03b0a0a73415ab2806193f03e1f60b..517edbd38301ec947f6d2a0adce294da2863d900 100644 (file)
@@ -30,14 +30,14 @@ class vtkUnstructuredGrid;
 #include "SVTK.h"
 #include "SALOME_Actor.h"
 
-class SVTK_EXPORT SVTK_Actor : public SALOME_Actor
+class SVTK_EXPORT SVTK_Actor : public VTKViewer_Actor
 {
 public:
   virtual ~SVTK_Actor();
 
   static SVTK_Actor* New();
 
-  vtkTypeMacro(SVTK_Actor,SALOME_Actor);
+  vtkTypeMacro(SVTK_Actor,VTKViewer_Actor);
 
   void  SetShrinkFactor(float value);
   virtual void SetShrink(); 
index c4d585b75ca7b939ea28343753b65f2309b4a16e..6627d9fb3afd78040ac8e3f339a9f332f74f71e1 100644 (file)
@@ -38,6 +38,7 @@
 #include "SVTK_RenderWindowInteractor.h"
 #include "SVTK_RenderWindow.h"
 #include "SVTK_ViewWindow.h"
+#include "SVTK_Selection.h"
 
 #include "SALOME_Actor.h"
 #include "SVTK_Actor.h"
@@ -888,6 +889,7 @@ SVTK_InteractorStyle
         fitRect(x1, y1, x2, y2);
       }
       else {
+       myViewWindow->unHighlightAll();
         if (myPoint == myOtherPoint) {
          // process point selection
           int w, h, x, y;
@@ -903,94 +905,17 @@ SVTK_InteractorStyle
     
          SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
 
-          if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
-           int aVtkId = picker->GetCellId();
-           if ( aVtkId >= 0 && aSActor && aSActor->hasIO() && IsValid( aSActor, aVtkId ) ) {
-             int anObjId = aSActor->GetElemObjId(aVtkId);
-             if(anObjId >= 0){
-               Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
-               if(aSelectionMode != EdgeOfCellSelection) {
-                 if(CheckDimensionId(aSelectionMode,aSActor,anObjId)){
-                   if(MYDEBUG) INFOS(" CellId : "<<anObjId);
-                   if (GetSelector()->IsSelected(anIO)) {
-                     // This IO is already in the selection
-                     GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
-                   } else {
-                     if (!myShiftState) {
-                       this->HighlightProp( NULL );
-                       GetSelector()->ClearIObjects();
-                     }
-                     GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
-                     GetSelector()->AddIObject(aSActor);
-                   }
-                 }
-               }else{
-                 if (!myShiftState) {
-                   this->HighlightProp( NULL );
-                   GetSelector()->ClearIObjects();
-                 }
-                 int anEdgeId = GetEdgeId(picker,aSActor,anObjId);
-                 if (anEdgeId >= 0) {
-                   if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
-                   GetSelector()->AddOrRemoveIndex(anIO,anObjId,false);
-                   GetSelector()->AddOrRemoveIndex(anIO,-anEdgeId-1,true);
-                   GetSelector()->AddIObject(aSActor);
-                 } 
-               }
-             }
-           } else {
-             this->HighlightProp( NULL );
-             GetSelector()->ClearIObjects();
-           }
-          } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
-           int aVtkId = picker->GetPointId();
-           if ( aVtkId >= 0 && IsValid( aSActor, aVtkId, true ) ) {
-             if ( aSActor && aSActor->hasIO() ) {
-               int anObjId = aSActor->GetNodeObjId(aVtkId);
-               if(anObjId >= 0){
-                 Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
-                 if(GetSelector()->IsSelected(anIO)) {
-                   // This IO is already in the selection
-                   GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
-                 } else {
-                   if(!myShiftState) {
-                     this->HighlightProp( NULL );
-                     GetSelector()->ClearIObjects();
-                   }
-                   if(MYDEBUG) INFOS(" PointId : "<<anObjId);
-                   GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
-                   GetSelector()->AddIObject(aSActor);
-                 }
-               }
-             }
-           } else {
-             this->HighlightProp( NULL );
-             GetSelector()->ClearIObjects();
-           } 
-         } else {
-           if ( aSActor && aSActor->hasIO() ) {
-             this->PropPicked++;
-             Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
-             if(GetSelector()->IsSelected(anIO)) {
-               // This IO is already in the selection
-               if(myShiftState) {
-                 GetSelector()->RemoveIObject(aSActor);
-               }
-             }
-             else {
-               if(!myShiftState) {
-                 this->HighlightProp( NULL );
-                 GetSelector()->ClearIObjects();
-               }
-               GetSelector()->AddIObject(aSActor);
-             }
-           }else{
-             // No selection clear all
-             this->PropPicked = 0;
-             this->HighlightProp( NULL );
-             GetSelector()->ClearIObjects();
-           }
+         SVTK_SelectionEvent aSelectionEvent = myInteractor->GetSelectionEvent();
+         aSelectionEvent.SelectionMode = aSelectionMode;
+
+         if( aSActor )
+           aSActor->Highlight( this, GetSelector(), this->CurrentRenderer, aSelectionEvent, true, true );
+         else
+         {
+           this->HighlightProp( NULL );
+           GetSelector()->ClearIObjects();
          }
+
          myInteractor->EndPickCallback();
         } else {
           //processing rectangle selection
@@ -1132,7 +1057,7 @@ SVTK_InteractorStyle
          } //end switch
          myInteractor->EndPickCallback();
        }
-       myViewWindow->onSelectionChanged();
+       //myViewWindow->onSelectionChanged();
       } 
     } 
     break;
@@ -1250,15 +1175,16 @@ SVTK_InteractorStyle
   myPreSelectionActor->SetVisibility(false);
 
   vtkPicker* aPicker = vtkPicker::SafeDownCast(myInteractor->GetPicker());
-  aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
 
   SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
+  if( aSActor )
+    aSActor->PreHighlight( this, -1 );
+  //cout << "onCursorMove : " << ( aSActor ? "1" : "0" ) << " ";
 
-  if (aSActor && myPreSelectionActor){
-    float aPos[3];
-    aSActor->GetPosition(aPos);
-    myPreSelectionActor->SetPosition(aPos);
-  }
+  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)) {
     int aVtkId = picker->GetCellId();
@@ -1274,7 +1200,7 @@ SVTK_InteractorStyle
              mySelectedActor = aSActor;
              myElemId = anObjId;
              if(MYDEBUG) INFOS(" CellId : "<<anObjId);
-             myInteractor->setCellData(anObjId,aSActor,myPreSelectionActor);
+             //myInteractor->setCellData(anObjId,aSActor,myPreSelectionActor);
            }
          }
        }
@@ -1289,7 +1215,7 @@ SVTK_InteractorStyle
              myEdgeId = anEdgeId;
              myElemId = anObjId;
              if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
-             myInteractor->setEdgeData(anObjId,aSActor,-anEdgeId-1,myPreSelectionActor);
+             //myInteractor->setEdgeData(anObjId,aSActor,-anEdgeId-1,myPreSelectionActor);
            } 
          }
        }
@@ -1302,18 +1228,25 @@ SVTK_InteractorStyle
   }
   else if (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
     int aVtkId = picker->GetPointId();
+    //cout << "vtkPointPicker" << endl;
+    //cout << aSActor << endl;
+    //cout << aVtkId << endl;
     if ( aVtkId >= 0 && IsValid( aSActor, aVtkId, true ) ) {
       if ( aSActor && aSActor->hasIO() ) {
        int anObjId = aSActor->GetNodeObjId(aVtkId);
+       aSActor->PreHighlight( this, anObjId );
+       /*
        bool anIsSameObjId = (mySelectedActor == aSActor && myNodeId == anObjId);
        if(!anIsSameObjId) {
          mySelectedActor = aSActor;
          myNodeId = anObjId;
          if(MYDEBUG) INFOS(" PointId : "<<anObjId);
          myInteractor->setPointData(anObjId,aSActor,myPreSelectionActor);
+         aSActor->PreHighlight( this, anObjId );
        }
        myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
        myPreSelectionActor->SetVisibility(true);
+       */
       }
     }
   }
index a80733492639df46b8de5244c69ff91eb1a4bfe7..9eb6b667cb574f962286fd11077079bb642f93be 100644 (file)
 
 #include "SVTK_InteractorStyle.h"
 #include "SVTK_RenderWindow.h"
-#include "SVTK_ViewWindow.h"
+#include "SVTK_Selection.h"
 
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"
-#include "SVTK_Actor.h"
+#include "SALOME_Actor.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -82,30 +82,10 @@ SVTK_RenderWindowInteractor
   this->Enabled = 0 ;
   this->mTimer = new QTimer( this ) ;
   myDisplayMode = 0;
-  myGUIWindow = 0;
 
   myBasicPicker = vtkPicker::New();
   myCellPicker = vtkCellPicker::New();
   myPointPicker = vtkPointPicker::New();
-
-  myCellActor = SVTK_Actor::New(); 
-  myCellActor->PickableOff();
-  myCellActor->GetProperty()->SetColor(1,1,0);
-  myCellActor->GetProperty()->SetLineWidth(5);
-  myCellActor->GetProperty()->SetRepresentationToSurface();
-
-  myEdgeActor = SVTK_Actor::New(); 
-  myEdgeActor->PickableOff();
-  myEdgeActor->GetProperty()->SetColor(1,0,0);
-  myEdgeActor->GetProperty()->SetLineWidth(5);
-  myEdgeActor->GetProperty()->SetRepresentationToWireframe();
-
-  myPointActor = SVTK_Actor::New(); 
-  myPointActor->PickableOff();
-  myPointActor->GetProperty()->SetColor(1,1,0);
-  myPointActor->GetProperty()->SetPointSize(5);
-  myPointActor->GetProperty()->SetRepresentationToPoints();
-
   connect(mTimer, SIGNAL(timeout()), this, SLOT(TimerFunc())) ;
 }
 
@@ -117,14 +97,6 @@ SVTK_RenderWindowInteractor
 
   delete mTimer ;
 
-  myViewWindow->RemoveActor(myCellActor);
-  myViewWindow->RemoveActor(myEdgeActor);
-  myViewWindow->RemoveActor(myPointActor);
-
-  myCellActor->Delete();
-  myEdgeActor->Delete();
-  myPointActor->Delete();
-
   myBasicPicker->Delete();
   myCellPicker->Delete();
   myPointPicker->Delete();
@@ -168,8 +140,9 @@ SVTK_RenderWindowInteractor
   this->Size[1] = ((aSize[1] > 0) ? aSize[1] : 300);
 
   this->SetPicker(myBasicPicker);
+  //this->SetPicker(vtkPicker::New());
 
-  SetSelectionTolerance();
+  //SetSelectionTolerance();
 
   //
   // Enable the interactor. 
@@ -189,37 +162,6 @@ SVTK_RenderWindowInteractor
   return ;
 }
 
-
-//----------------------------------------------------------------------------
-void
-SVTK_RenderWindowInteractor
-::setGUIWindow(QWidget* theWindow)
-{
-  myGUIWindow = theWindow;
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_RenderWindowInteractor
-::setViewWindow(SVTK_ViewWindow* theViewWindow)
-{
-  myViewWindow = theViewWindow;
-
-  myViewWindow->InsertActor(myCellActor);
-  myViewWindow->InsertActor(myEdgeActor);
-  myViewWindow->InsertActor(myPointActor);
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_RenderWindowInteractor
-::MoveInternalActors()
-{
-  myViewWindow->MoveActor(myCellActor);
-  myViewWindow->MoveActor(myEdgeActor);
-  myViewWindow->MoveActor(myPointActor);
-}
-
 //----------------------------------------------------------------------------
 void
 SVTK_RenderWindowInteractor
@@ -234,10 +176,6 @@ void
 SVTK_RenderWindowInteractor
 ::SetSelectionMode(Selection_Mode theMode)
 {
-  myCellActor->SetVisibility(false);
-  myEdgeActor->SetVisibility(false);
-  myPointActor->SetVisibility(false);
-
   switch(theMode){
   case ActorSelection:
     this->SetPicker(myBasicPicker);
@@ -256,7 +194,7 @@ SVTK_RenderWindowInteractor
 
   myInteractorStyle->OnSelectionModeChanged();
 }
-
+/*
 void
 SVTK_RenderWindowInteractor
 ::SetSelectionProp(const double& theRed, 
@@ -284,7 +222,7 @@ SVTK_RenderWindowInteractor
   myPointPicker->SetTolerance(myTolNodes);
 
 }
-
+*/
 // ================================== 
 void
 SVTK_RenderWindowInteractor
@@ -384,6 +322,10 @@ SVTK_RenderWindowInteractor
   if( ! this->Enabled ) {
     return ;
   }
+  this->SetEventInformationFlipY( event->x(), event->y(),
+                                 ( event->state() & ControlButton ),
+                                 ( event->state() & ShiftButton ) );
+
   myInteractorStyle->OnLeftButtonUp( (event->state() & ControlButton), 
                                     (event->state() & ShiftButton), 
                                     event->x(), event->y() ) ;
@@ -720,47 +662,6 @@ SVTK_RenderWindowInteractor
 ::KeyPressed(QKeyEvent *event)
 {}
 
-
-struct THighlightAction{
-  bool myIsHighlight;
-  SVTK_InteractorStyle* myInteractorStyle;
-  THighlightAction(SVTK_InteractorStyle* theInteractorStyle,
-                  bool theIsHighlight): 
-    myInteractorStyle(theInteractorStyle),
-    myIsHighlight(theIsHighlight)
-  {}
-  void operator()(SALOME_Actor* theActor){
-    if(theActor->GetMapper()){
-      if(theActor->hasHighlight())
-       theActor->highlight(myIsHighlight);
-      else{
-       if(theActor->GetVisibility() && myIsHighlight)
-         myInteractorStyle->HighlightProp(theActor);
-       else if(!myIsHighlight)
-         myInteractorStyle->HighlightProp(NULL);
-      }
-    }
-  }
-};
-
-bool
-SVTK_RenderWindowInteractor
-::highlight( const Handle(SALOME_InteractiveObject)& theIObject, 
-            bool hilight, 
-            bool update)
-{
-  using namespace VTK;
-  ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
-                         TIsSameIObject<SALOME_Actor>(theIObject),
-                         THighlightAction(myInteractorStyle,hilight));
-
-  if(update)
-    emit RenderWindowModified();
-
-  return false;
-}
-
-
 struct TUpdateAction{
   void operator()(vtkActor* theActor){
     theActor->ApplyProperties();
@@ -781,32 +682,6 @@ SVTK_RenderWindowInteractor
   emit RenderWindowModified();  
 }
 
-
-void
-SVTK_RenderWindowInteractor
-::unHighlightSubSelection()
-{
-  myPointActor->SetVisibility(false);
-  myEdgeActor->SetVisibility(false);
-  myCellActor->SetVisibility(false);
-}
-
-
-bool
-SVTK_RenderWindowInteractor
-::unHighlightAll()
-{
-  unHighlightSubSelection();
-
-  using namespace VTK;
-  ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
-                       THighlightAction(myInteractorStyle,false));
-
-  emit RenderWindowModified() ;
-
-  return false;
-}
-
 //-----------------
 // Color methods
 //-----------------
@@ -876,136 +751,19 @@ SVTK_RenderWindowInteractor
                          (&SALOME_Actor::setName,theName.latin1()));
 }
 
-
-//----------------------------------------------------------------------------
-bool
-SVTK_RenderWindowInteractor
-::highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
-           SALOME_Actor* theMapActor, 
-           SVTK_Actor* theActor,
-           TUpdateActor theFun, 
-           bool hilight, 
-           bool update)
-{
-  if(theMapIndex.Extent() == 0) return false;
-  
-  if (hilight) {
-    setActorData(theMapIndex,theMapActor,theActor,theFun);
-    theActor->SetVisibility(true);
-  }
-  else {
-    theActor->SetVisibility(false);
-  }
-
-  if(update){
-    this->RenderWindow->Render();  
-    emit RenderWindowModified() ;
-  }
-
-  return false;
-}
-  
-void
-SVTK_RenderWindowInteractor
-::setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
-              SALOME_Actor* theMapActor,
-              SVTK_Actor *theActor,
-              TUpdateActor theFun)
-{
-  (*theFun)(theMapIndex,theMapActor,theActor);
-  float aPos[3];
-  theMapActor->GetPosition(aPos);
-  theActor->SetPosition(aPos);
-}
-
-
-//----------------------------------------------------------------------------
-static void CellsUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
-                            SALOME_Actor* theMapActor, 
-                            SVTK_Actor* theActor)
-{
-  theActor->MapCells(theMapActor,theMapIndex);
-}
-  
-bool
-SVTK_RenderWindowInteractor
-::highlightCell(const TColStd_IndexedMapOfInteger& theMapIndex,
-               SALOME_Actor* theMapActor, 
-               bool hilight, 
-               bool update)
-{
-  return highlight(theMapIndex,theMapActor,myCellActor,&CellsUpdateActor,hilight,update);
-}
-  
-void 
+SVTK_SelectionEvent
 SVTK_RenderWindowInteractor
-::setCellData(const int& theIndex, 
-             SALOME_Actor* theMapActor,
-             SVTK_Actor* theActor)
+::GetSelectionEvent()
 {
-  TColStd_IndexedMapOfInteger MapIndex; 
-  MapIndex.Add(theIndex);
-  theActor->MapCells(theMapActor,MapIndex);
-}
+  SVTK_SelectionEvent aSelectionEvent;
 
+  int x, y;
+  this->GetEventPosition( x, y );
 
-//----------------------------------------------------------------------------
-static void PointsUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
-                             SALOME_Actor* theMapActor, 
-                             SVTK_Actor* theActor)
-{
-  theActor->MapPoints(theMapActor,theMapIndex);
-}
-  
-bool
-SVTK_RenderWindowInteractor
-::highlightPoint(const TColStd_IndexedMapOfInteger& theMapIndex,
-                SALOME_Actor* theMapActor, 
-                bool hilight, 
-                bool update)
-{
-  return highlight(theMapIndex,theMapActor,myPointActor,&PointsUpdateActor,hilight,update);
-}
-  
-void
-SVTK_RenderWindowInteractor
-::setPointData(const int& theIndex, 
-              SALOME_Actor* theMapActor,
-              SVTK_Actor* theActor)
-{
-  TColStd_IndexedMapOfInteger MapIndex; 
-  MapIndex.Add(theIndex);
-  theActor->MapPoints(theMapActor,MapIndex);
-}
+  aSelectionEvent.X = x;
+  aSelectionEvent.Y = y;
+  aSelectionEvent.IsCtrl = this->GetControlKey();
+  aSelectionEvent.IsShift = this->GetShiftKey();
 
-  
-//----------------------------------------------------------------------------
-static void EdgesUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
-                            SALOME_Actor* theMapActor, 
-                            SVTK_Actor* theActor)
-{
-  theActor->MapEdge(theMapActor,theMapIndex);
-}
-  
-bool
-SVTK_RenderWindowInteractor
-::highlightEdge(const TColStd_IndexedMapOfInteger& theMapIndex,
-               SALOME_Actor* theMapActor, 
-               bool hilight, 
-               bool update)
-{
-  return highlight(theMapIndex,theMapActor,myEdgeActor,&EdgesUpdateActor,hilight,update);
-}
-  
-void 
-SVTK_RenderWindowInteractor
-::setEdgeData(const int& theCellIndex, 
-             SALOME_Actor* theMapActor,
-             const int& theEdgeIndex, 
-             SVTK_Actor* theActor )
-{
-  TColStd_IndexedMapOfInteger MapIndex; 
-  MapIndex.Add(theCellIndex); 
-  MapIndex.Add(theEdgeIndex);
-  theActor->MapEdge(theMapActor,MapIndex);
+  return aSelectionEvent;
 }
index 55b07e806c6478c915a4227817c4b528d3e175a0..d37b1c6cac5ddcc5ea471e12e01865c9bf439d6d 100644 (file)
@@ -30,8 +30,8 @@
 #define SVTK_RenderWindowInteractor_h
 
 #include "SVTK.h"
+#include "SVTK_SelectionEvent.h"
 
-#include "SVTK_Selection.h"
 #include "SALOME_InteractiveObject.hxx"
 
 // QT Includes
@@ -53,7 +53,6 @@ class vtkPointPicker;
 class vtkActorCollection;
 
 class SALOME_Actor;
-class SVTK_Actor;
 
 class SVTK_ViewWindow;
 class SVTK_RenderWindow;
@@ -106,36 +105,19 @@ public:
   virtual int DestroyTimer() ; 
   
   /* Selection Management */
-  bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex, 
-                    SALOME_Actor* theMapActor, 
-                    bool hilight, 
-                    bool update = true );
-  bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex, 
-                    SALOME_Actor* theMapActor, 
-                    bool hilight, 
-                    bool update = true );
-  bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex, 
-                     SALOME_Actor* theMapActor, 
-                     bool hilight, 
-                     bool update = true );
-  bool highlight(const Handle(SALOME_InteractiveObject)& IObject, 
-                bool hiligth, 
-                bool immediatly = true );
-  void unHighlightSubSelection();
-  bool unHighlightAll();
-
   bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject);
   bool isVisible( const Handle(SALOME_InteractiveObject)& IObject);
   void rename(const Handle(SALOME_InteractiveObject)& IObject, QString newName);
 
   void SetSelectionMode(Selection_Mode mode);
+  /*
   void SetSelectionProp(const double& theRed = 1, 
                        const double& theGreen = 1,
                        const double& theBlue = 0, 
                        const int& theWidth = 5);
   void SetSelectionTolerance(const double& theTolNodes = 0.025, 
                             const double& theTolCell = 0.001);
-
+  */
   // Displaymode management
   int GetDisplayMode();
   void SetDisplayMode(int);
@@ -183,54 +165,20 @@ public:
 
   vtkRenderer* GetRenderer();
 
-  void setGUIWindow(QWidget* theWindow);
+  SVTK_SelectionEvent GetSelectionEvent();
 
-  void setViewWindow(SVTK_ViewWindow* theViewWindow);
-  
-  void setCellData(const int& theIndex, 
-                  SALOME_Actor* theMapActor,
-                  SVTK_Actor* theActor);
-  void setEdgeData(const int& theCellIndex, 
-                  SALOME_Actor* theMapActor,
-                  const int& theEdgeIndex, 
-                  SVTK_Actor* theActor ); //NB
-  void setPointData(const int& theIndex, 
-                   SALOME_Actor* theMapActor,
-                   SVTK_Actor* theActor);
-
-  typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
-                              SALOME_Actor* theMapActor, 
-                              SVTK_Actor* theActor);
  protected:
 
   SVTK_RenderWindowInteractor();
   ~SVTK_RenderWindowInteractor();
 
   SVTK_InteractorStyle* myInteractorStyle;
-
-  bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex, 
-                SALOME_Actor* theMapActor, 
-                SVTK_Actor* theActor,
-                TUpdateActor theFun, 
-                bool hilight, 
-                bool update);
-  void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
-                   SALOME_Actor* theMapActor,
-                   SVTK_Actor *theActor,
-                   TUpdateActor theFun);
   
   // Timer used during various mouse events to figure 
   // out mouse movements. 
   QTimer *mTimer ;
 
   int myDisplayMode;
-
-  //NRI: Selection mode
-  SVTK_Actor* myPointActor;
-  SVTK_Actor* myEdgeActor;
-  SVTK_Actor* myCellActor;
-  void MoveInternalActors();
-
   vtkPicker* myBasicPicker;
   vtkCellPicker* myCellPicker;
   vtkPointPicker* myPointPicker;
@@ -262,8 +210,6 @@ public:
   void contextMenuRequested( QContextMenuEvent *e );
 
  private:
-  SVTK_ViewWindow* myViewWindow;  
-  QWidget* myGUIWindow;  
   double myTolNodes;
   double myTolItems;
 };
index 5260b9732e43ad1e00fbf062bc8fa5c00cfd9e32..69eda9c15482fab8110c7267c158a91573897ccd 100755 (executable)
@@ -78,7 +78,7 @@ SVTK_ViewWindow
   // Create an interactor.
   myRWInteractor = SVTK_RenderWindowInteractor::New();
   myRWInteractor->SetRenderWindow( myRenderWindow->getRenderWindow() );
-  myRWInteractor->setViewWindow( this );
+  //myRWInteractor->setViewWindow( this );
 
   SVTK_InteractorStyle* RWS = SVTK_InteractorStyle::New();
   RWS->setGUIWindow( myRenderWindow );
@@ -488,6 +488,17 @@ SVTK_ViewWindow
   Repaint();
 }
 
+//----------------------------------------------------------------
+struct THighlightAction{
+  bool myIsHighlight;
+  THighlightAction( bool theIsHighlight ): myIsHighlight(theIsHighlight) {}
+  void operator()( SALOME_Actor* theActor) {
+    if(theActor->GetMapper()){
+      theActor->highlight( myIsHighlight );
+    }
+  }
+};
+
 //----------------------------------------------------------------
 void
 SVTK_ViewWindow
@@ -510,6 +521,7 @@ SVTK_ViewWindow
 ::SetSelectionMode(Selection_Mode theMode)
 {
   mySelector->SetSelectionMode(theMode);
+
   myRWInteractor->SetSelectionMode(theMode);
 }
 
@@ -526,7 +538,14 @@ void
 SVTK_ViewWindow
 ::unHighlightAll() 
 {
-  myRWInteractor->unHighlightAll();
+  //cout << "--------------------------------------------------" << endl;
+  //cout << "SVTK_ViewWindow::unHighlightAll" << endl;
+
+  using namespace VTK;
+  ForEach<SALOME_Actor>( myRenderer->GetActors(),
+                        THighlightAction( false ) );
+
+  //myRenderWindow->update();
 }
 
 //----------------------------------------------------------------
@@ -536,33 +555,12 @@ SVTK_ViewWindow
             bool theIsHighlight, 
             bool theIsUpdate ) 
 {
-  myRWInteractor->highlight(theIO, theIsHighlight, theIsUpdate);
-
-  if(mySelector->HasIndex(theIO) && theIO->hasEntry()){
-    TColStd_IndexedMapOfInteger aMapIndex;
-    mySelector->GetIndex(theIO,aMapIndex);
-    using namespace VTK;
-    const char* anEntry = theIO->getEntry();
-    vtkActorCollection* aCollection = myRenderer->GetActors();
-    if(SALOME_Actor* anActor = Find<SALOME_Actor>(aCollection,TIsSameEntry<SALOME_Actor>(anEntry))){
-      switch (mySelector->SelectionMode()) {
-      case NodeSelection:
-       myRWInteractor->highlightPoint(aMapIndex,anActor,theIsHighlight,theIsUpdate);
-       break;
-      case EdgeOfCellSelection:
-       myRWInteractor->highlightEdge(aMapIndex,anActor,theIsHighlight,theIsUpdate);
-       break;
-      case CellSelection:
-      case EdgeSelection:
-      case FaceSelection:
-      case VolumeSelection:
-       myRWInteractor->highlightCell(aMapIndex,anActor,theIsHighlight,theIsUpdate);
-       break;
-      }
-    }
-  }else{
-    myRWInteractor->unHighlightSubSelection();
-  }
+  using namespace VTK;
+  ForEachIf<SALOME_Actor>(myRenderer->GetActors(),
+                         TIsSameIObject<SALOME_Actor>(theIO),
+                         THighlightAction(theIsHighlight));
+
+  //myRenderWindow->update();
 }
 
 //----------------------------------------------------------------
@@ -758,7 +756,7 @@ SVTK_ViewWindow
     if(aCDisplayed) myCubeAxes->VisibilityOff();
 
     SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-    QString aSetting = aResMgr->stringValue("Viewer", "TrihedronSize", "105");
+    QString aSetting = aResMgr->stringValue("Viewer:TrihedronSize", "105");
     static float aSizeInPercents = aSetting.toFloat();
 
     //bool isComputeTrihedronSize =
@@ -985,18 +983,20 @@ SVTK_ViewWindow
 //----------------------------------------------------------------------------
 void
 SVTK_ViewWindow
-::InsertActor( SALOME_Actor* theActor, bool theMoveInternalActors )
+::InsertActor( VTKViewer_Actor* theActor, bool theMoveInternalActors )
 {
+  //cout << "SVTK_ViewWindow::InsertActor" << endl;
   theActor->AddToRender(myRenderer);
+
   theActor->SetTransform(myTransform);
-  if(theMoveInternalActors) 
-    myRWInteractor->MoveInternalActors();
+  //if(theMoveInternalActors) 
+  //  myRWInteractor->MoveInternalActors();
 }
 
 //----------------------------------------------------------------------------
 void
 SVTK_ViewWindow
-::AddActor( SALOME_Actor* theActor, bool theUpdate /*=false*/ )
+::AddActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ )
 {
   InsertActor(theActor);
   if(theUpdate) 
@@ -1006,8 +1006,11 @@ SVTK_ViewWindow
 //----------------------------------------------------------------------------
 void
 SVTK_ViewWindow
-::RemoveActor( SALOME_Actor* theActor, bool theUpdate /*=false*/ )
+::RemoveActor( VTKViewer_Actor* theActor, bool theUpdate /*=false*/ )
 {
+  //cout << "SVTK_ViewWindow::RemoveActor" << endl;
+  theActor->RemoveFromRender(myRenderer);
+
   theActor->RemoveFromRender(myRenderer);
   if(theUpdate) 
     Repaint();
@@ -1016,7 +1019,7 @@ SVTK_ViewWindow
 //----------------------------------------------------------------------------
 void
 SVTK_ViewWindow
-::MoveActor( SALOME_Actor* theActor)
+::MoveActor( VTKViewer_Actor* theActor)
 {
   RemoveActor(theActor);
   InsertActor(theActor,true);
index 2edda288e5291ed7a71103d03c8654db38a1a694..18a9dc76865547f0be7f791f873c06515292e48a 100755 (executable)
@@ -19,7 +19,7 @@ class SUIT_Desktop;
 class VTKViewer_Trihedron;
 class VTKViewer_Transform;
 
-class SALOME_Actor;
+class VTKViewer_Actor;
 
 class SVTK_Viewer;
 class SVTK_Selector;
@@ -76,8 +76,8 @@ public:
   //apply existing transformation on adding SALOME_Actor
   void SetScale( double theScale[3] );
   void GetScale( double theScale[3] );
-  void AddActor( SALOME_Actor*, bool update = false );
-  void RemoveActor(SALOME_Actor*, bool update = false);
+  void AddActor( VTKViewer_Actor*, bool update = false );
+  void RemoveActor(VTKViewer_Actor*, bool update = false);
 
   void AdjustTrihedrons( const bool forced );
   //merge with V2_2_0_VISU_improvements:bool ComputeTrihedronSize( double& theNewSize,
@@ -142,9 +142,9 @@ protected slots:
 
 private:
   void InitialSetup();
-  void InsertActor( SALOME_Actor* theActor,
+  void InsertActor( VTKViewer_Actor* theActor,
                     bool theMoveInternalActors = false );
-  void MoveActor( SALOME_Actor* theActor );
+  void MoveActor( VTKViewer_Actor* theActor );
 
 private:  
   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,