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 "HEXABLOCKGUI_Export.hxx"
25 #include <QItemSelectionModel>
26 #include <LightApp_SelectionMgr.h>
28 #include <SVTK_ViewWindow.h>
29 #include <SVTK_Selector.h>
31 #include "klinkitemselectionmodel.hxx"
33 class OCCViewer_ViewWindow;
41 class HEXABLOCK_EXPORT SelectionModel: public QItemSelectionModel
47 SelectionModel( QAbstractItemModel * model );
48 virtual ~SelectionModel();
50 QModelIndex indexBy( int role, const QString& value );
51 QModelIndex indexBy( int role, const QVariant& var );
52 QModelIndex indexOf( const QString& anIOEntry, int role );
53 QModelIndexList indexListOf( const QString& anEntry, int role );
55 virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
56 virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) {}
58 void clearHighlightedItems() { currentHighlightedItems.clear(); }
62 virtual void onCurrentChanged( const QModelIndex & current,
63 const QModelIndex & previous ) {}
65 virtual void onSelectionChanged( const QItemSelection & selected,
66 const QItemSelection & deselected ) {}
68 void salomeSelectionChanged(); // Salome to Qt
71 QModelIndexList getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject);
73 QModelIndexList currentHighlightedItems;
76 class PatternBuilderSelectionModel: public KLinkItemSelectionModel
79 PatternBuilderSelectionModel( QAbstractItemModel *model,
80 QItemSelectionModel *proxySelector, QObject *parent = 0 ):
81 KLinkItemSelectionModel( model, proxySelector, parent )
86 class PatternDataSelectionModel : public SelectionModel
91 PatternDataSelectionModel( QAbstractItemModel * model );
92 virtual ~PatternDataSelectionModel();
94 void highlightTreeItems(QModelIndexList& indexes,
95 Qt::GlobalColor bgColor = Qt::darkGreen,
96 Qt::GlobalColor fgColor = Qt::white, bool only=true);
97 void unhighlightTreeItems(bool clearSelected=true);
98 QModelIndexList getGeomAssociations(const QModelIndex& dataIndex);
101 virtual void geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
102 virtual void vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject );
105 virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
106 virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
110 class PatternGeomSelectionModel : public SelectionModel
115 PatternGeomSelectionModel( QAbstractItemModel * model );
116 virtual ~PatternGeomSelectionModel();
118 QModelIndex getModelIndex(const Handle(SALOME_InteractiveObject)& anIObject);
119 void highlightTreeItems(QModelIndexList& indexes,
120 Qt::GlobalColor bgColor = Qt::darkGreen,
121 Qt::GlobalColor fgColor = Qt::white, bool only=true);
122 void unhighlightTreeItems(bool clearSelected=true);
125 virtual void onCurrentChanged( const QModelIndex & current, const QModelIndex & previous );
126 virtual void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
131 class GroupsSelectionModel : public SelectionModel
136 GroupsSelectionModel( QAbstractItemModel * model );
137 virtual ~GroupsSelectionModel();
140 virtual void onSelectionChanged( const QItemSelection & selected,
141 const QItemSelection & deselected );
146 class MeshSelectionModel : public SelectionModel
151 MeshSelectionModel( QAbstractItemModel * model );
152 virtual ~MeshSelectionModel();
155 virtual void onSelectionChanged( const QItemSelection & selected,
156 const QItemSelection & deselected );