Salome HOME
updated copyright message
[modules/gui.git] / src / LightApp / LightApp_SelectionMgr.h
index d865cac156ba7b4feafd40b41d5b99a898e8f1d9..1411537d0868dc5f3b2e50777c43e7cedd0ef2cb 100644 (file)
@@ -1,21 +1,25 @@
-// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-// 
+// Copyright (C) 2007-2023  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
+//
 // 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 
+// 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 
+// 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
 //
+
 #ifndef LIGHTAPP_SELECTIONMGR_H
 #define LIGHTAPP_SELECTIONMGR_H
 
 
 #include <SUIT_SelectionMgr.h>
 
+#include <QtCore/QTime>
+
 #ifndef DISABLE_SALOMEOBJECT
   #include <SALOME_InteractiveObject.hxx>
-  #include <qmap.h>
+  #include <QMap>
+  #include <NCollection_DataMap.hxx>
+
+  #include <TColStd_IndexedMapOfInteger.hxx>
+  #include <TColStd_MapOfInteger.hxx>
 
   class SALOME_ListIO;
-  class TColStd_IndexedMapOfInteger;
-  class TColStd_MapOfInteger;
+  class TCollection_AsciiString;
 #else
-#include <qstringlist.h>
+#include <QStringList>
 #endif
 
 class LightApp_Application;
@@ -50,40 +59,73 @@ public:
 
   LightApp_Application* application() const;
 
+  virtual void           setSelected( const SUIT_DataOwnerPtrList&, const bool = false );
+
 #ifndef DISABLE_SALOMEOBJECT
-  typedef QMap< Handle(SALOME_InteractiveObject), TColStd_IndexedMapOfInteger > MapIOOfMapOfInteger;
-  typedef QMap< QString, TColStd_IndexedMapOfInteger > MapEntryOfMapOfInteger;
+  typedef NCollection_DataMap< Handle(SALOME_InteractiveObject), TColStd_IndexedMapOfInteger > MapIOOfMapOfInteger;
+  typedef NCollection_DataMap< TCollection_AsciiString, TColStd_IndexedMapOfInteger > MapEntryOfMapOfInteger;
 
-  void                   selectedObjects( SALOME_ListIO&, const QString& = QString::null, const bool = true ) const;
+  void                   selectedObjects( SALOME_ListIO&, const QString& = QString(), const bool = true, const bool sole=false ) const;
+  Handle(SALOME_InteractiveObject) soleSelectedObject( const QString& = QString(), const bool = true ) const;
   void                   setSelectedObjects( const SALOME_ListIO&, const bool = false );
 
   void                   GetIndexes( const Handle(SALOME_InteractiveObject)& IObject, 
-                                    TColStd_IndexedMapOfInteger& theIndex );
+                                     TColStd_IndexedMapOfInteger& theIndex );
   void                   GetIndexes( const QString& theEntry, 
-                                    TColStd_IndexedMapOfInteger& theIndex );
+                                     TColStd_IndexedMapOfInteger& theIndex );
 
   //bool                   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, 
   void                   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, 
-                                          const TColStd_MapOfInteger& theIndices, 
-                                          bool modeShift );
+                                           const TColStd_MapOfInteger& theIndices, 
+                                           bool modeShift );
 
   void                   selectObjects( const Handle(SALOME_InteractiveObject)& IObject, 
-                                       TColStd_IndexedMapOfInteger theIndex, bool append );
+                                        TColStd_IndexedMapOfInteger theIndex, bool append );
   void                   selectObjects( MapIOOfMapOfInteger theMapIO, bool append );
 
   void                   selectedSubOwners( MapEntryOfMapOfInteger& theMap );
 #else
-  void                   selectedObjects( QStringList&, const QString& = QString::null, const bool = true ) const;
+  void                   selectedObjects( QStringList&, const QString& = QString(), const bool = true ) const;
+  void                   setSelectedObjects( const QStringList&, const bool = false );
 #endif
 
+  void                   clearSelectionCache();
+  bool                   isSelectionCacheEnabled() const;
+  void                   setSelectionCacheEnabled( bool );
+
 signals:
   void                   currentSelectionChanged();
 
 private:
   virtual void           selectionChanged( SUIT_Selector* );
 
+#ifndef DISABLE_SALOMEOBJECT
+  QList<Handle(SALOME_InteractiveObject)> selectionCache( const QString& = QString() ) const;
+#else
+  QStringList                            selectionCache( const QString& = QString() ) const;
+#endif
+  bool                   isActualSelectionCache( const QString& = QString() ) const;
+
+  QStringList            selectorTypes() const;
+
+private:
+#ifndef DISABLE_SALOMEOBJECT
+  typedef Handle(SALOME_InteractiveObject) SelObject;
+#else
+  typedef QString                         SelObject;
+#endif
+  typedef QList<SelObject>             SelList;
+  typedef QMap<QString, QTime>         TimeMap;
+  typedef QMap<QString, SelList>       CacheMap;
+
 private:
   LightApp_Application* myApp;
+
+  QTime                 myTimeStamp;
+
+  bool                  myCacheState;
+  TimeMap               myCacheTimes;
+  CacheMap              myCacheSelection;
 };
 
 #endif