Salome HOME
Updated copyright comment
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_DocumentSelectionModel.hxx
1 // Copyright (C) 2009-2024  CEA, EDF
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, or (at your option) any later version.
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 #include "HEXABLOCKGUI_DocumentModel.hxx"
34
35 class OCCViewer_ViewWindow;
36
37
38 namespace HEXABLOCK
39 {
40   namespace GUI
41   {
42
43     class HEXABLOCK_EXPORT SelectionModel: public QItemSelectionModel
44     {
45         Q_OBJECT
46
47         public:
48
49             SelectionModel( QAbstractItemModel * model );
50             virtual ~SelectionModel();
51
52             QModelIndex     indexBy( int role, const QString&  value );
53             QModelIndex     indexBy( int role, const QVariant& var );
54             QModelIndex     indexOf( const QString& anIOEntry, int role );
55             QModelIndexList indexListOf( const QString& anEntry, int role );
56             DocumentModel*  getDocModel() const;
57             void            showEltInfo(QModelIndex& elt);
58
59             virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
60             virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
61
62             void clearHighlightedItems() { currentHighlightedItems.clear(); }
63
64             void setInfoMode(bool isOn) { infoMode = isOn; }
65
66        protected slots:
67
68             virtual void onCurrentChanged( const QModelIndex & current,
69                     const QModelIndex & previous ) {}
70
71             virtual void onSelectionChanged( const QItemSelection & selected,
72                     const QItemSelection & deselected ) {}
73
74             void salomeSelectionChanged(); // Salome to Qt
75
76        protected:
77             QModelIndexList getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject);
78             QModelIndexList currentHighlightedItems;
79             static bool infoMode;
80     };
81
82 //    class PatternBuilderSelectionModel: public KLinkItemSelectionModel
83 //    {
84 //      public:
85 //        PatternBuilderSelectionModel( QAbstractItemModel *model,
86 //                                      QItemSelectionModel *proxySelector, QObject *parent = 0 ):
87 //        KLinkItemSelectionModel( model, proxySelector, parent )
88 //        {
89 //        }
90 //    };
91
92     class HEXABLOCK_EXPORT PatternDataSelectionModel : public SelectionModel
93     {
94       Q_OBJECT
95
96       public:
97         PatternDataSelectionModel( QAbstractItemModel * model );
98         virtual ~PatternDataSelectionModel();
99
100         void highlightTreeItems(QModelIndexList& indexes,
101                                 Qt::GlobalColor bgColor = Qt::darkGreen,
102                                 Qt::GlobalColor fgColor = Qt::white, bool only=true);
103         void unhighlightTreeItems(bool clearSelected=true);
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 HEXABLOCK_EXPORT 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         void highlightTreeItems(QModelIndexList& indexes,
126                                 Qt::GlobalColor bgColor = Qt::darkGreen,
127                                 Qt::GlobalColor fgColor = Qt::white, bool only=true);
128         void unhighlightTreeItems(bool clearSelected=true);
129
130     protected slots:
131         virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
132         virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
133
134     };
135
136
137     class HEXABLOCK_EXPORT GroupsSelectionModel : public SelectionModel
138     {
139       Q_OBJECT
140
141       public:
142         GroupsSelectionModel( QAbstractItemModel * model );
143         virtual ~GroupsSelectionModel();
144
145       protected slots:
146         virtual void onSelectionChanged( const QItemSelection & selected,
147                                             const QItemSelection & deselected );
148
149     };
150
151
152     class HEXABLOCK_EXPORT MeshSelectionModel : public SelectionModel
153     {
154       Q_OBJECT
155
156       public:
157         MeshSelectionModel( QAbstractItemModel * model );
158         virtual ~MeshSelectionModel();
159
160       protected slots:
161         virtual void onSelectionChanged( const QItemSelection & selected,
162                 const QItemSelection & deselected );
163
164     };
165
166
167   }
168 }
169
170 #endif
171
172