Salome HOME
0058a1984c816667574ee9778300b7781adb58f9
[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 #include <vector>
47
48 enum Selection_Mode { 
49  NodeSelection, 
50  CellSelection,
51  EdgeOfCellSelection,
52  EdgeSelection, 
53  FaceSelection, 
54  VolumeSelection, 
55  ActorSelection };
56
57 class SALOME_Selection : public QObject
58 {
59   Q_OBJECT
60     
61 public:
62
63         SALOME_Selection(const QString& aName);
64         ~SALOME_Selection();
65
66         static bool                CreateSelection(const QString& aName) ;
67         static SALOME_Selection*   Selection      (const QString& aName) ;
68         static bool                RemoveSelection(const QString& aName) ;
69         static bool                FindSelection  (const QString& aName) ;
70
71         void Clear () ;
72
73         void ClearIObjects () ;
74         int  AddIObject    ( const Handle(SALOME_InteractiveObject)& anObject, bool update = true) ;
75         int  RemoveIObject ( const Handle(SALOME_InteractiveObject)& anObject, bool update = true) ;
76
77         const SALOME_ListIO&             StoredIObjects() ;
78         int                              IObjectCount() ;
79
80         Handle(SALOME_InteractiveObject) firstIObject() ;
81         Handle(SALOME_InteractiveObject) lastIObject() ;
82
83         void                       AddFilter(const Handle(SALOME_Filter)& aFilter,
84                                              bool updateSelection = true ) ;
85         bool                       RemoveFilter(const Handle(SALOME_Filter)& aFilter) ;
86         void                       ClearFilters();
87         const SALOME_ListOfFilter& StoredFilters();
88         bool                       FindFilter(const Handle(SALOME_Filter)& aFilter);
89
90         bool                       IsOk( const Handle(SALOME_InteractiveObject)& IObject ) ;
91
92
93         void                       SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false);
94         Selection_Mode             SelectionMode();
95         bool                       IsSelectActiveCompOnly() const;
96         
97         bool                        HasIndex( const Handle(SALOME_InteractiveObject)& IObject );
98         void                       GetIndex( const Handle(SALOME_InteractiveObject)& IObject, 
99                                              TColStd_MapOfInteger& theIndex );
100         
101         bool                        AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index, bool modeShift, bool update=true );
102         bool                        AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const TColStd_MapOfInteger& theIndices, bool modeShift, bool update=true );
103         bool                        AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const std::vector<int>& theIndices, bool modeShift, bool update=true );
104         void                        RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index );
105         bool                        IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index);
106
107 signals:
108         void                        currentSelectionChanged();
109
110 private:
111         QString               myName;
112         SALOME_ListOfFilter   myFilters;
113         SALOME_ListIO         myIObjects;
114
115         SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex;
116
117         Selection_Mode        mySelectionMode;
118         bool                  mySelActiveCompOnly;
119 };
120
121 #endif
122