Salome HOME
Copyrights update 2015.
[modules/gui.git] / src / SVTK / SVTK_SelectorDef.h
index ec7ae91aa6beaa6446731d8a595c22c210356320..9093b3b3dc2d32c4f1890230dd78884239e12f0c 100644 (file)
@@ -1,37 +1,40 @@
-//  SALOME SALOMEGUI : implementation of desktop and GUI kernel
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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 
+// 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, or (at your option) any later version.
 //
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SALOME SALOMEGUI : implementation of desktop and GUI kernel
 //  File   : SALOME_Selection.h
 //  Author : Nicolas REJNERI
-//  Module : SALOME
-//  $Header$
 
 #ifndef SVTK_SELECTORDEF_H
 #define SVTK_SELECTORDEF_H
 
-#include <NCollection_DataMap.hxx>
-#include <vtkSmartPointer.h>
+#include <set>
+#include <map>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
 #include <TColStd_MapOfInteger.hxx>
+#include <vtkSmartPointer.h>
+
+#include "SALOME_InteractiveObject.hxx"
 
 #include "SVTK_Selector.h"
 
@@ -39,6 +42,8 @@ class SALOME_Actor;
 
 class SVTK_Viewer;
 class SVTK_ViewWindow;
+class vtkPicker;
+class vtkCellPicker;
 
 class SVTK_SelectorDef: public SVTK_Selector
 {
@@ -48,7 +53,7 @@ public:
 
   virtual
   void 
-  SetSelectionMode( Selection_Mode theMode );
+  SetSelectionMode(Selection_Mode theMode);
 
   virtual
   Selection_Mode
@@ -101,43 +106,148 @@ public:
   virtual
   void 
   GetIndex( const Handle(SALOME_InteractiveObject)& theIO, 
-           TColStd_IndexedMapOfInteger& theIndex );
-       
+            TColStd_IndexedMapOfInteger& theIndex );
+        
   virtual
   bool 
   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
-                   const TColStd_IndexedMapOfInteger& theIndices, 
-                   bool theIsModeShift);
+                    const TColStd_IndexedMapOfInteger& theIndices, 
+                    bool theIsModeShift);
   virtual
   bool 
   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
-                   const TColStd_MapOfInteger& theIndices, 
-                   bool theIsModeShift);
+                    const TColStd_MapOfInteger& theIndices, 
+                    bool theIsModeShift);
   virtual
   bool
   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
-                   int theIndex, 
-                   bool theIsModeShift);
+                    int theIndex, 
+                    bool theIsModeShift);
   virtual
   void 
   RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
-              int theIndex);
+               int theIndex);
   virtual
   bool 
   IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, 
-                 int theIndex) const;
+                  int theIndex) const;
   virtual
   void 
   ClearIndex();
 
+  //----------------------------------------------------------------------------
+  virtual
+  void 
+  SetFilter(const Handle(VTKViewer_Filter)& theFilter);
+
+  virtual
+  Handle(VTKViewer_Filter) 
+  GetFilter(const TFilterID theId) const;
+
+  virtual
+  bool
+  IsFilterPresent(const TFilterID theId) const;
+
+  virtual
+  void
+  RemoveFilter(const int theId);
+
+  virtual
+  bool
+  IsValid(SALOME_Actor* theActor,
+          const TFilterID theId,
+          const bool theIsNode = false) const;
+  
+  //----------------------------------------------------------------------------
+  virtual
+  void 
+  StartPickCallback();
+
+  virtual
+  void 
+  EndPickCallback();
+
+  //----------------------------------------------------------------------------
+  virtual
+  vtkActorCollection*
+  Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
+
+  virtual
+  void
+  SetTolerance(const double& theTolerance);
+
+  virtual
+  void
+  SetDynamicPreSelection( bool theIsDynPreselect );
+
+  virtual
+  bool
+  GetDynamicPreSelection() const;
+
+  virtual
+  void
+  SetPreSelectionEnabled( bool theEnabled );
+
+  virtual
+  bool
+  IsPreSelectionEnabled() const;
+
+  virtual
+  void
+  SetSelectionEnabled( bool theEnabled );
+
+  virtual
+  bool
+  IsSelectionEnabled() const;
+
 private:
-  typedef NCollection_DataMap<Handle(SALOME_InteractiveObject),
-                              vtkSmartPointer<SALOME_Actor> > TIO2Actors;
+  int mySelectionMode;
+
+  bool myDynamicPreselection;
+  bool myPreselectionEnabled;
+  bool mySelectionEnabled;
+
+  struct TIOLessThan
+  {
+    bool 
+    operator()(const Handle(SALOME_InteractiveObject)& theRightIO,
+               const Handle(SALOME_InteractiveObject)& theLeftIO) const
+    {
+      return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
+    }
+  };
+
+  struct TIndexedMapOfInteger
+  {
+    TColStd_IndexedMapOfInteger myMap;
+    TIndexedMapOfInteger()
+    {}
+    TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
+    {
+      myMap = theIndexedMapOfInteger.myMap;
+    }
+  };
+
+  mutable SALOME_ListIO myIObjectList;
+  typedef std::set<Handle(SALOME_InteractiveObject),
+                   TIOLessThan> TIObjects;
+  TIObjects myIObjects;
+
+  typedef std::map<Handle(SALOME_InteractiveObject),
+                   vtkSmartPointer<SALOME_Actor>,
+                   TIOLessThan> TIO2Actors;
   TIO2Actors myIO2Actors;
-  Selection_Mode mySelectionMode;
-  SALOME_ListIO myIObjects;
-  SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex;
-};
 
+  typedef std::map<Handle(SALOME_InteractiveObject),
+                   TIndexedMapOfInteger,
+                   TIOLessThan> TMapIOSubIndex;
+  TMapIOSubIndex myMapIOSubIndex;
+
+  typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
+  TFilters myFilters;
+
+  vtkSmartPointer<vtkPicker> myPicker;
+  vtkSmartPointer<vtkCellPicker> myCellPicker;
+};
 
 #endif