1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _HEXABLOCKGUI_DOCUMENTSELECTIONMODEL_HXX_
21 #define _HEXABLOCKGUI_DOCUMENTSELECTIONMODEL_HXX_
23 #include <QItemSelectionModel>
24 #include <LightApp_SelectionMgr.h>
26 #include <SVTK_ViewWindow.h>
27 #include <SVTK_Selector.h>
29 #include "klinkitemselectionmodel.hxx"
31 class OCCViewer_ViewWindow;
39 class SelectionModel: public QItemSelectionModel
45 SelectionModel( QAbstractItemModel * model );
46 virtual ~SelectionModel();
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 );
53 virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
54 virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
56 void clearHighlightedItems() { currentHighlightedItems.clear(); }
60 virtual void onCurrentChanged( const QModelIndex & current,
61 const QModelIndex & previous ) {}
63 virtual void onSelectionChanged( const QItemSelection & selected,
64 const QItemSelection & deselected ) {}
66 void salomeSelectionChanged(); // Salome to Qt
69 QModelIndexList getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject);
71 QModelIndexList currentHighlightedItems;
74 class PatternBuilderSelectionModel: public KLinkItemSelectionModel
77 PatternBuilderSelectionModel( QAbstractItemModel *model,
78 QItemSelectionModel *proxySelector, QObject *parent = 0 ):
79 KLinkItemSelectionModel( model, proxySelector, parent )
84 class PatternDataSelectionModel : public SelectionModel
89 PatternDataSelectionModel( QAbstractItemModel * model );
90 virtual ~PatternDataSelectionModel();
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);
99 virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
100 virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
103 virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
104 virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
108 class PatternGeomSelectionModel : public SelectionModel
113 PatternGeomSelectionModel( QAbstractItemModel * model );
114 virtual ~PatternGeomSelectionModel();
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);
123 virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
124 virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
129 class GroupsSelectionModel : public SelectionModel
134 GroupsSelectionModel( QAbstractItemModel * model );
135 virtual ~GroupsSelectionModel();
138 virtual void onSelectionChanged( const QItemSelection & selected,
139 const QItemSelection & deselected );
144 class MeshSelectionModel : public SelectionModel
149 MeshSelectionModel( QAbstractItemModel * model );
150 virtual ~MeshSelectionModel();
153 virtual void onSelectionChanged( const QItemSelection & selected,
154 const QItemSelection & deselected );