Salome HOME
PR: Merge V1_2c etape 1
[modules/kernel.git] / src / SALOMEGUI / SALOME_Selection.h
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_Selection.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef SALOME_SELECTION_H
30 #define SALOME_SELECTION_H
31
32 #include "SALOME_Filter.hxx"
33 #include "SALOME_ListIO.hxx"
34 #include "SALOME_ListOfFilter.hxx"
35 #include "SALOME_InteractiveObject.hxx"
36 #include "SALOME_DataMapOfIOMapOfInteger.hxx"
37
38 // Qt Includes
39 #include <qlist.h>
40 #include <qstring.h>
41 #include <qobject.h>
42
43 // Open CASCADE Include
44 #include <TColStd_MapOfInteger.hxx>
45
46 class SALOME_Selection : public QObject
47 {
48   Q_OBJECT
49     
50 public:
51         SALOME_Selection(const QString& aName);
52         ~SALOME_Selection();
53
54         static bool                CreateSelection(const QString& aName) ;
55         static SALOME_Selection*   Selection      (const QString& aName) ;
56         static bool                RemoveSelection(const QString& aName) ;
57         static bool                FindSelection  (const QString& aName) ;
58
59         void Clear () ;
60
61         void ClearIObjects () ;
62         int  AddIObject    ( const Handle(SALOME_InteractiveObject)& anObject, bool update = true) ;
63         int  RemoveIObject ( const Handle(SALOME_InteractiveObject)& anObject, bool update = true) ;
64
65         const SALOME_ListIO&             StoredIObjects() ;
66         int                              IObjectCount() ;
67
68         Handle(SALOME_InteractiveObject) firstIObject() ;
69         Handle(SALOME_InteractiveObject) lastIObject() ;
70
71         void                       AddFilter(const Handle(SALOME_Filter)& aFilter,
72                                              bool updateSelection = true ) ;
73         bool                       RemoveFilter(const Handle(SALOME_Filter)& aFilter) ;
74         void                       ClearFilters();
75         const SALOME_ListOfFilter& StoredFilters();
76         bool                       FindFilter(const Handle(SALOME_Filter)& aFilter);
77
78         bool                       IsOk( const Handle(SALOME_InteractiveObject)& IObject ) ;
79
80
81         void                       SetSelectionMode(int mode, bool activeCompOnly = false);
82         int                        SelectionMode();
83         bool                       IsSelectActiveCompOnly() const;
84         
85         bool                        HasIndex( const Handle(SALOME_InteractiveObject)& IObject );
86         void                       GetIndex( const Handle(SALOME_InteractiveObject)& IObject, 
87                                              TColStd_MapOfInteger& theIndex );
88         
89         bool                        AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index, bool modeShift, bool update=true );
90         void                        RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index );
91         bool                        IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index);
92
93 signals:
94         void                        currentSelectionChanged();
95
96 private:
97         QString               myName;
98         SALOME_ListOfFilter   myFilters;
99         SALOME_ListIO         myIObjects;
100
101         SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex;
102
103         int                   mySelectionMode;
104         bool                  mySelActiveCompOnly;
105 };
106
107 #endif
108