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