Salome HOME
57a4efbe79654d96932fe80f6171d543f9b44cab
[modules/gui.git] / src / LightApp / LightApp_SelectionMgr.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef LIGHTAPP_SELECTIONMGR_H
23 #define LIGHTAPP_SELECTIONMGR_H
24
25 #include "LightApp.h"
26
27 #include <SUIT_SelectionMgr.h>
28
29 #ifndef DISABLE_SALOMEOBJECT
30   #include <SALOME_InteractiveObject.hxx>
31   #include <QMap>
32   #include <NCollection_DataMap.hxx>
33
34   class SALOME_ListIO;
35   class TColStd_IndexedMapOfInteger;
36   class TColStd_MapOfInteger;
37   class TCollection_AsciiString;
38 #else
39 #include <QStringList>
40 #endif
41
42 class LightApp_Application;
43
44 /*!
45   Custom selection manager, allowing to work with object selection
46   (additionally to data owners) and to access to sub-selection of objects
47 */
48 class LIGHTAPP_EXPORT LightApp_SelectionMgr : public SUIT_SelectionMgr
49 {
50   Q_OBJECT
51
52 public:
53   LightApp_SelectionMgr( LightApp_Application*, const bool = true );
54   virtual ~LightApp_SelectionMgr();
55
56   LightApp_Application* application() const;
57
58 #ifndef DISABLE_SALOMEOBJECT
59   typedef NCollection_DataMap< Handle(SALOME_InteractiveObject), TColStd_IndexedMapOfInteger > MapIOOfMapOfInteger;
60   typedef NCollection_DataMap< TCollection_AsciiString, TColStd_IndexedMapOfInteger > MapEntryOfMapOfInteger;
61
62   void                   selectedObjects( SALOME_ListIO&, const QString& = QString(), const bool = true ) const;
63   void                   setSelectedObjects( const SALOME_ListIO&, const bool = false );
64
65   void                   GetIndexes( const Handle(SALOME_InteractiveObject)& IObject, 
66                                      TColStd_IndexedMapOfInteger& theIndex );
67   void                   GetIndexes( const QString& theEntry, 
68                                      TColStd_IndexedMapOfInteger& theIndex );
69
70   //bool                   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, 
71   void                   AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, 
72                                            const TColStd_MapOfInteger& theIndices, 
73                                            bool modeShift );
74
75   void                   selectObjects( const Handle(SALOME_InteractiveObject)& IObject, 
76                                         TColStd_IndexedMapOfInteger theIndex, bool append );
77   void                   selectObjects( MapIOOfMapOfInteger theMapIO, bool append );
78
79   void                   selectedSubOwners( MapEntryOfMapOfInteger& theMap );
80 #else
81   void                   selectedObjects( QStringList&, const QString& = QString(), const bool = true ) const;
82 #endif
83
84 signals:
85   void                   currentSelectionChanged();
86
87 private:
88   virtual void           selectionChanged( SUIT_Selector* );
89
90 private:
91   LightApp_Application* myApp;
92 };
93
94 #endif