]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.hxx
Salome HOME
4f8fb566d99c93b275c923e3e0fc4cd910a9fe5a
[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 <QItemSelectionModel>
24 #include <LightApp_SelectionMgr.h>
25
26 #include <SVTK_ViewWindow.h>
27 #include <SVTK_Selector.h>
28
29 #include "klinkitemselectionmodel.hxx"
30
31 class OCCViewer_ViewWindow;
32
33
34 namespace HEXABLOCK
35 {
36   namespace GUI
37   {
38
39     class SelectionModel: public QItemSelectionModel
40     {
41         Q_OBJECT
42
43         public:
44
45             SelectionModel( QAbstractItemModel * model );
46             virtual ~SelectionModel();
47
48             QModelIndex     indexBy( int role, const QString&  value );
49             QModelIndex     indexBy( int role, const QVariant& var );
50             QModelIndex     indexOf( const QString& anIOEntry, int role );
51             QModelIndexList indexListOf( const QString& anEntry, int role );
52
53             virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
54             virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
55
56             void clearHighlightedItems() { currentHighlightedItems.clear(); }
57
58        protected slots:
59
60             virtual void onCurrentChanged( const QModelIndex & current,
61                     const QModelIndex & previous ) {}
62
63             virtual void onSelectionChanged( const QItemSelection & selected,
64                     const QItemSelection & deselected ) {}
65
66             void salomeSelectionChanged(); // Salome to Qt
67
68        protected:
69             QModelIndexList getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject);
70
71             QModelIndexList currentHighlightedItems;
72     };
73
74     class PatternBuilderSelectionModel: public KLinkItemSelectionModel
75     {
76       public:
77         PatternBuilderSelectionModel( QAbstractItemModel *model, 
78                                       QItemSelectionModel *proxySelector, QObject *parent = 0 ):
79         KLinkItemSelectionModel( model, proxySelector, parent )
80         {
81         }
82     };
83
84     class PatternDataSelectionModel : public SelectionModel
85     {
86       Q_OBJECT
87
88       public:
89         PatternDataSelectionModel( QAbstractItemModel * model );
90         virtual ~PatternDataSelectionModel();
91
92         void highlightTreeItems(QModelIndexList& indexes,
93                                 Qt::GlobalColor bgColor = Qt::darkGreen,
94                                 Qt::GlobalColor fgColor = Qt::white, bool only=true);
95         void unhighlightTreeItems(bool clearSelected=true);
96         QModelIndexList getGeomAssociations(const QModelIndex& dataIndex);
97
98         //Salome
99         virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
100         virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
101
102       protected slots:
103         virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
104         virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
105
106     };
107
108     class PatternGeomSelectionModel : public SelectionModel
109     {
110         Q_OBJECT
111
112     public:
113         PatternGeomSelectionModel( QAbstractItemModel * model );
114         virtual ~PatternGeomSelectionModel();
115
116         QModelIndex getModelIndex(const Handle(SALOME_InteractiveObject)& anIObject);
117         void highlightTreeItems(QModelIndexList& indexes,
118                                 Qt::GlobalColor bgColor = Qt::darkGreen,
119                                 Qt::GlobalColor fgColor = Qt::white, bool only=true);
120         void unhighlightTreeItems(bool clearSelected=true);
121
122     protected slots:
123         virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
124         virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
125
126     };
127
128
129     class GroupsSelectionModel : public SelectionModel
130     {
131       Q_OBJECT
132
133       public:
134         GroupsSelectionModel( QAbstractItemModel * model );
135         virtual ~GroupsSelectionModel();
136
137       protected slots:
138         virtual void onSelectionChanged( const QItemSelection & selected,
139                                             const QItemSelection & deselected );
140
141     };
142
143
144     class MeshSelectionModel : public SelectionModel
145     {
146       Q_OBJECT
147
148       public:
149         MeshSelectionModel( QAbstractItemModel * model );
150         virtual ~MeshSelectionModel();
151
152       protected slots:
153         virtual void onSelectionChanged( const QItemSelection & selected,
154                 const QItemSelection & deselected );
155
156     };
157
158
159   }
160 }
161
162 #endif
163
164