Back to index

salome-gui  6.5.0
SVTK_SelectorDef.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
00024 //  File   : SALOME_Selection.h
00025 //  Author : Nicolas REJNERI
00026 
00027 #ifndef SVTK_SELECTORDEF_H
00028 #define SVTK_SELECTORDEF_H
00029 
00030 #include <set>
00031 #include <map>
00032 
00033 #include <TColStd_IndexedMapOfInteger.hxx>
00034 #include <TColStd_MapOfInteger.hxx>
00035 #include <vtkSmartPointer.h>
00036 
00037 #include "SALOME_InteractiveObject.hxx"
00038 
00039 #include "SVTK_Selector.h"
00040 
00041 class SALOME_Actor;
00042 
00043 class SVTK_Viewer;
00044 class SVTK_ViewWindow;
00045 class vtkPicker;
00046 class vtkCellPicker;
00047 
00048 class SVTK_SelectorDef: public SVTK_Selector
00049 {
00050 public:
00051   SVTK_SelectorDef();
00052   virtual ~SVTK_SelectorDef();
00053 
00054   virtual
00055   void 
00056   SetSelectionMode(Selection_Mode theMode);
00057 
00058   virtual
00059   Selection_Mode
00060   SelectionMode() const { return mySelectionMode; }
00061 
00062   virtual
00063   void
00064   ClearIObjects();
00065 
00066   virtual
00067   SALOME_Actor* 
00068   GetActor(const Handle(SALOME_InteractiveObject)& theIO) const;
00069 
00070   virtual
00071   bool
00072   IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const;
00073 
00074   virtual
00075   bool
00076   IsSelected(SALOME_Actor* theActor) const;
00077 
00078   virtual
00079   bool
00080   AddIObject(const Handle(SALOME_InteractiveObject)& theIO);
00081 
00082   virtual
00083   bool
00084   AddIObject(SALOME_Actor* theActor);
00085 
00086   virtual
00087   bool 
00088   RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO);
00089 
00090   virtual
00091   bool 
00092   RemoveIObject(SALOME_Actor* theActor);
00093 
00094   virtual
00095   const SALOME_ListIO& 
00096   StoredIObjects() const;
00097 
00098   virtual
00099   int 
00100   IObjectCount() const;
00101 
00102   virtual
00103   bool 
00104   HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const;
00105 
00106   virtual
00107   void 
00108   GetIndex( const Handle(SALOME_InteractiveObject)& theIO, 
00109             TColStd_IndexedMapOfInteger& theIndex );
00110         
00111   virtual
00112   bool 
00113   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
00114                     const TColStd_IndexedMapOfInteger& theIndices, 
00115                     bool theIsModeShift);
00116   virtual
00117   bool 
00118   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
00119                     const TColStd_MapOfInteger& theIndices, 
00120                     bool theIsModeShift);
00121   virtual
00122   bool
00123   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
00124                     int theIndex, 
00125                     bool theIsModeShift);
00126   virtual
00127   void 
00128   RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, 
00129                int theIndex);
00130   virtual
00131   bool 
00132   IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, 
00133                   int theIndex) const;
00134   virtual
00135   void 
00136   ClearIndex();
00137 
00138   //----------------------------------------------------------------------------
00139   virtual
00140   void 
00141   SetFilter(const Handle(VTKViewer_Filter)& theFilter);
00142 
00143   virtual
00144   Handle(VTKViewer_Filter) 
00145   GetFilter(const TFilterID theId) const;
00146 
00147   virtual
00148   bool
00149   IsFilterPresent(const TFilterID theId) const;
00150 
00151   virtual
00152   void
00153   RemoveFilter(const int theId);
00154 
00155   virtual
00156   bool
00157   IsValid(SALOME_Actor* theActor,
00158           const TFilterID theId,
00159           const bool theIsNode = false) const;
00160   
00161   //----------------------------------------------------------------------------
00162   virtual
00163   void 
00164   StartPickCallback();
00165 
00166   virtual
00167   void 
00168   EndPickCallback();
00169 
00170   //----------------------------------------------------------------------------
00171   virtual
00172   vtkActorCollection*
00173   Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
00174 
00175   virtual
00176   void
00177   SetTolerance(const double& theTolerance);
00178 
00179   virtual
00180   void
00181   SetDynamicPreSelection( bool theIsDynPreselect );
00182 
00183   virtual
00184   bool
00185   GetDynamicPreSelection() const;
00186 
00187 private:
00188   int mySelectionMode;
00189 
00190   bool myDynamicPreselection;
00191 
00192   struct TIOLessThan
00193   {
00194     bool 
00195     operator()(const Handle(SALOME_InteractiveObject)& theRightIO,
00196                const Handle(SALOME_InteractiveObject)& theLeftIO) const
00197     {
00198       return strcmp(theRightIO->getEntry(),theLeftIO->getEntry()) < 0;
00199     }
00200   };
00201 
00202   struct TIndexedMapOfInteger
00203   {
00204     TColStd_IndexedMapOfInteger myMap;
00205     TIndexedMapOfInteger()
00206     {}
00207     TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger)
00208     {
00209       myMap = theIndexedMapOfInteger.myMap;
00210     }
00211   };
00212 
00213   mutable SALOME_ListIO myIObjectList;
00214   typedef std::set<Handle(SALOME_InteractiveObject),
00215                    TIOLessThan> TIObjects;
00216   TIObjects myIObjects;
00217 
00218   typedef std::map<Handle(SALOME_InteractiveObject),
00219                    vtkSmartPointer<SALOME_Actor>,
00220                    TIOLessThan> TIO2Actors;
00221   TIO2Actors myIO2Actors;
00222 
00223   typedef std::map<Handle(SALOME_InteractiveObject),
00224                    TIndexedMapOfInteger,
00225                    TIOLessThan> TMapIOSubIndex;
00226   TMapIOSubIndex myMapIOSubIndex;
00227 
00228   typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
00229   TFilters myFilters;
00230 
00231   vtkSmartPointer<vtkPicker> myPicker;
00232   vtkSmartPointer<vtkCellPicker> myCellPicker;
00233 };
00234 
00235 #endif