Salome HOME
bb6d13b08e30eb9c2cce88701b2ba95133b4401a
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_DocumentSelectionModel.hxx
1 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _HEXABLOCKGUI_DOCUMENTSELECTIONMODEL_HXX_
21 #define _HEXABLOCKGUI_DOCUMENTSELECTIONMODEL_HXX_
22
23 #include "HEXABLOCKGUI_Export.hxx"
24
25 #include <QItemSelectionModel>
26 #include <LightApp_SelectionMgr.h>
27
28 #include <SVTK_ViewWindow.h>
29 #include <SVTK_Selector.h>
30
31 #include "klinkitemselectionmodel.hxx"
32
33 class OCCViewer_ViewWindow;
34
35
36 namespace HEXABLOCK
37 {
38   namespace GUI
39   {
40
41     class HEXABLOCK_EXPORT SelectionModel: public QItemSelectionModel
42     {
43         Q_OBJECT
44
45         public:
46
47             SelectionModel( QAbstractItemModel * model );
48             virtual ~SelectionModel();
49
50             QModelIndex     indexBy( int role, const QString&  value );
51             QModelIndex     indexBy( int role, const QVariant& var );
52             QModelIndex     indexOf( const QString& anIOEntry, int role );
53             QModelIndexList indexListOf( const QString& anEntry, int role );
54
55             virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
56             virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
57
58             void clearHighlightedItems() { currentHighlightedItems.clear(); }
59
60        protected slots:
61
62             virtual void onCurrentChanged( const QModelIndex & current,
63                     const QModelIndex & previous ) {}
64
65             virtual void onSelectionChanged( const QItemSelection & selected,
66                     const QItemSelection & deselected ) {}
67
68             void salomeSelectionChanged(); // Salome to Qt
69
70        protected:
71             QModelIndexList getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject);
72
73             QModelIndexList currentHighlightedItems;
74     };
75
76     class PatternBuilderSelectionModel: public KLinkItemSelectionModel
77     {
78       public:
79         PatternBuilderSelectionModel( QAbstractItemModel *model, 
80                                       QItemSelectionModel *proxySelector, QObject *parent = 0 ):
81         KLinkItemSelectionModel( model, proxySelector, parent )
82         {
83         }
84     };
85
86     class PatternDataSelectionModel : public SelectionModel
87     {
88       Q_OBJECT
89
90       public:
91         PatternDataSelectionModel( QAbstractItemModel * model );
92         virtual ~PatternDataSelectionModel();
93
94         void highlightTreeItems(QModelIndexList& indexes,
95                                 Qt::GlobalColor bgColor = Qt::darkGreen,
96                                 Qt::GlobalColor fgColor = Qt::white, bool only=true);
97         void unhighlightTreeItems(bool clearSelected=true);
98         QModelIndexList getGeomAssociations(const QModelIndex& dataIndex);
99
100         //Salome
101         virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
102         virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
103
104       protected slots:
105         virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
106         virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
107
108     };
109
110     class PatternGeomSelectionModel : public SelectionModel
111     {
112         Q_OBJECT
113
114     public:
115         PatternGeomSelectionModel( QAbstractItemModel * model );
116         virtual ~PatternGeomSelectionModel();
117
118         QModelIndex getModelIndex(const Handle(SALOME_InteractiveObject)& anIObject);
119         void highlightTreeItems(QModelIndexList& indexes,
120                                 Qt::GlobalColor bgColor = Qt::darkGreen,
121                                 Qt::GlobalColor fgColor = Qt::white, bool only=true);
122         void unhighlightTreeItems(bool clearSelected=true);
123
124     protected slots:
125         virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
126         virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
127
128     };
129
130
131     class GroupsSelectionModel : public SelectionModel
132     {
133       Q_OBJECT
134
135       public:
136         GroupsSelectionModel( QAbstractItemModel * model );
137         virtual ~GroupsSelectionModel();
138
139       protected slots:
140         virtual void onSelectionChanged( const QItemSelection & selected,
141                                             const QItemSelection & deselected );
142
143     };
144
145
146     class MeshSelectionModel : public SelectionModel
147     {
148       Q_OBJECT
149
150       public:
151         MeshSelectionModel( QAbstractItemModel * model );
152         virtual ~MeshSelectionModel();
153
154       protected slots:
155         virtual void onSelectionChanged( const QItemSelection & selected,
156                 const QItemSelection & deselected );
157
158     };
159
160
161   }
162 }
163
164 #endif
165
166