Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_DocumentSelectionModel.hxx
1 // Copyright (C) 2009-2012  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
25 #include <LightApp_SelectionMgr.h>
26
27 #include <SVTK_ViewWindow.h>
28 #include <SVTK_Selector.h>
29
30 // #include <SOCC_ViewModel.h>
31 // #include <SOCC_ViewWindow.h>
32 // #include <OCCViewer_ViewWindow.h>
33
34 #include "MyGEOMBase_Helper.hxx"
35
36 #include "klinkitemselectionmodel.hxx"
37 #include "HEXABLOCKGUI_DocumentModel.hxx"
38
39
40 class OCCViewer_ViewWindow;
41
42 namespace HEXABLOCK
43 {
44   namespace GUI
45   {
46
47     class PatternBuilderSelectionModel: public KLinkItemSelectionModel
48     {
49       public:
50         PatternBuilderSelectionModel( QAbstractItemModel *model, 
51                                       QItemSelectionModel *proxySelector, QObject *parent = 0 ):
52         KLinkItemSelectionModel( model, proxySelector, parent )
53         {
54         }
55     };
56
57     class PatternDataSelectionModel : public QItemSelectionModel,
58                                       public MyGEOMBase_Helper
59     {
60       Q_OBJECT
61
62       public:
63         PatternDataSelectionModel( QAbstractItemModel * model );
64         virtual ~PatternDataSelectionModel();
65
66         void setVertexSelection();
67         void setEdgeSelection();
68         void setQuadSelection();
69         void setHexaSelection();
70         void setAllSelection();
71         void highlightVTKElts( const QModelIndexList& elts );
72
73         // 
74         QModelIndex  indexBy( int role, const QString&  value );
75         QModelIndex  indexBy( int role, const QVariant& var );
76
77         //Salome
78         void setSalomeSelectionMgr( LightApp_SelectionMgr* mgr );
79         void SetSelectionMode( Selection_Mode theMode );
80
81       protected slots:
82         void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
83         void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
84         void salomeSelectionChanged(); // Salome to Qt
85
86       private:
87         SVTK_ViewWindow*       _getVTKViewWindow();
88         OCCViewer_ViewWindow*  _getOCCViewWindow();
89
90         QModelIndex _indexOf( const QString& anIOEntry, int role );
91         void _setVTKSelectionMode( const QModelIndex& eltIndex, SVTK_ViewWindow* vtkViewWindow );
92         void _highlightGEOM( const QMultiMap<QString, int>&  entrySubIDs );
93         void _highlightGEOM( const QModelIndex & index );
94         void _selectVTK( const QModelIndex & index );
95
96         QModelIndex _geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
97         QModelIndex _vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
98
99         LightApp_SelectionMgr* _salomeSelectionMgr;
100         int                    _selectionFilter;
101
102         bool _theModelSelectionChanged;
103         bool _theVtkSelectionChanged;
104         bool _theGeomSelectionChanged;
105
106     };
107
108
109
110     class GroupsSelectionModel : public QItemSelectionModel
111     {
112       Q_OBJECT
113
114       public:
115         GroupsSelectionModel( QAbstractItemModel * model );
116         virtual ~GroupsSelectionModel();
117
118         QModelIndex  indexBy( int role, const QVariant& var );
119
120       protected slots:
121 //         void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
122         void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
123
124       private:
125         SVTK_ViewWindow* _getVTKViewWindow();
126         void _highlightGroups( const QModelIndex& eltIndex );
127
128     };
129
130
131
132
133     class MeshSelectionModel : public QItemSelectionModel
134     {
135       Q_OBJECT
136
137       public:
138         MeshSelectionModel( QAbstractItemModel * model );
139         virtual ~MeshSelectionModel();
140
141         QModelIndex  indexBy( int role, const QVariant& var );
142
143       protected slots:
144 //         void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
145         void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
146
147       private:
148         SVTK_ViewWindow* _getVTKViewWindow();
149         void _highlightPropagation( const QModelIndex& eltIndex );
150
151     };
152
153
154   }
155 }
156
157 #endif
158
159