Back to index

salome-gui  6.5.0
LightApp_SelectionMgr.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 #ifndef LIGHTAPP_SELECTIONMGR_H
00024 #define LIGHTAPP_SELECTIONMGR_H
00025 
00026 #include "LightApp.h"
00027 
00028 #include <SUIT_SelectionMgr.h>
00029 
00030 #include <QtCore/QTime>
00031 
00032 #ifndef DISABLE_SALOMEOBJECT
00033   #include <SALOME_InteractiveObject.hxx>
00034   #include <QMap>
00035   #include <NCollection_DataMap.hxx>
00036 
00037   class SALOME_ListIO;
00038   class TColStd_IndexedMapOfInteger;
00039   class TColStd_MapOfInteger;
00040   class TCollection_AsciiString;
00041 #else
00042 #include <QStringList>
00043 #endif
00044 
00045 class LightApp_Application;
00046 
00051 class LIGHTAPP_EXPORT LightApp_SelectionMgr : public SUIT_SelectionMgr
00052 {
00053   Q_OBJECT
00054 
00055 public:
00056   LightApp_SelectionMgr( LightApp_Application*, const bool = true );
00057   virtual ~LightApp_SelectionMgr();
00058 
00059   LightApp_Application* application() const;
00060 
00061   virtual void           setSelected( const SUIT_DataOwnerPtrList&, const bool = false );
00062 
00063 #ifndef DISABLE_SALOMEOBJECT
00064   typedef NCollection_DataMap< Handle(SALOME_InteractiveObject), TColStd_IndexedMapOfInteger > MapIOOfMapOfInteger;
00065   typedef NCollection_DataMap< TCollection_AsciiString, TColStd_IndexedMapOfInteger > MapEntryOfMapOfInteger;
00066 
00067   void                   selectedObjects( SALOME_ListIO&, const QString& = QString(), const bool = true ) const;
00068   void                   setSelectedObjects( const SALOME_ListIO&, const bool = false );
00069 
00070   void                   GetIndexes( const Handle(SALOME_InteractiveObject)& IObject, 
00071                                      TColStd_IndexedMapOfInteger& theIndex );
00072   void                   GetIndexes( const QString& theEntry, 
00073                                      TColStd_IndexedMapOfInteger& theIndex );
00074 
00075   //bool                   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, 
00076   void                   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, 
00077                                            const TColStd_MapOfInteger& theIndices, 
00078                                            bool modeShift );
00079 
00080   void                   selectObjects( const Handle(SALOME_InteractiveObject)& IObject, 
00081                                         TColStd_IndexedMapOfInteger theIndex, bool append );
00082   void                   selectObjects( MapIOOfMapOfInteger theMapIO, bool append );
00083 
00084   void                   selectedSubOwners( MapEntryOfMapOfInteger& theMap );
00085 #else
00086   void                   selectedObjects( QStringList&, const QString& = QString(), const bool = true ) const;
00087 #endif
00088 
00089   void                   clearSelectionCache();
00090   bool                   isSelectionCacheEnabled() const;
00091   void                   setSelectionCacheEnabled( bool );
00092 
00093 signals:
00094   void                   currentSelectionChanged();
00095 
00096 private:
00097   virtual void           selectionChanged( SUIT_Selector* );
00098 
00099 #ifndef DISABLE_SALOMEOBJECT
00100   QList<Handle_SALOME_InteractiveObject> selectionCache( const QString& = QString() ) const;
00101 #else
00102   QStringList                            selectionCache( const QString& = QString() ) const;
00103 #endif
00104   bool                   isActualSelectionCache( const QString& = QString() ) const;
00105 
00106   QStringList            selectorTypes() const;
00107 
00108 private:
00109 #ifndef DISABLE_SALOMEOBJECT
00110   typedef Handle_SALOME_InteractiveObject SelObject;
00111 #else
00112   typedef QString                         SelObject;
00113 #endif
00114   typedef QList<SelObject>             SelList;
00115   typedef QMap<QString, QTime>         TimeMap;
00116   typedef QMap<QString, SelList>       CacheMap;
00117 
00118 private:
00119   LightApp_Application* myApp;
00120 
00121   QTime                 myTimeStamp;
00122 
00123   bool                  myCacheState;
00124   TimeMap               myCacheTimes;
00125   CacheMap              myCacheSelection;
00126 };
00127 
00128 #endif