pqSILModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqSILModel.h
5 
6  Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqSILModel_h
33 #define pqSILModel_h
34 
35 #include <QAbstractItemModel>
36 #include <QSet>
37 #include <QVector>
38 #include <set>
39 
40 #include "pqComponentsModule.h"
41 #include "vtkObject.h"
42 #include "vtkSmartPointer.h"
43 
44 class vtkGraph;
45 class vtkSMSILDomain;
46 class vtkSMSILModel;
61 class PQCOMPONENTS_EXPORT pqSILModel : public QAbstractItemModel
62 {
63  Q_OBJECT
64  typedef QAbstractItemModel Superclass;
65 
66 public:
67  pqSILModel(QObject* parent = 0);
68  ~pqSILModel() override;
69 
81  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
82 
90  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
91 
99  bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;
100 
110  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
111 
119  QModelIndex parent(const QModelIndex& index) const override;
120 
129  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
130 
141  Qt::ItemFlags flags(const QModelIndex& index) const override;
142 
148  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
150 
156  QModelIndex hierarchyIndex(const QString& hierarchyName) const;
157 
158  QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override
159  {
160  if (role == Qt::DisplayRole)
161  {
162  return "Selections";
163  }
164  return QVariant();
165  }
166 
170  QList<QVariant> status(const QString& hierarchyName) const;
171  void setStatus(const QString& hierarchyName, const QList<QVariant>& values);
172 
173  void setSILDomain(vtkSMSILDomain* domain);
174 
175  void domainModified();
176 
180  QModelIndex makeIndex(vtkIdType vertexid) const;
181 
186  vtkIdType findVertex(const char* name) const;
187 
188 Q_SIGNALS:
189  void checkStatusChanged();
190 
191 public Q_SLOTS:
195  void update();
196 
197 protected:
202  void checkStateUpdated(vtkObject* caller, unsigned long eventid, void* calldata);
203 
207  bool isLeaf(vtkIdType vertexid) const;
208 
213  vtkIdType parent(vtkIdType vertexid) const;
214 
218  int childrenCount(vtkIdType vertexid) const;
219 
224  void collectLeaves(vtkIdType vertexid, std::set<vtkIdType>& list);
225 
227 
231  QMap<vtkIdType, QModelIndex>* ModelIndexCache;
232 
233  QMap<QString, QModelIndex> Hierarchies;
234 
239  QMap<QString, std::set<vtkIdType> > HierarchyVertexIds;
241  unsigned long SILDomainObserverId;
242 
243 private:
244  Q_DISABLE_COPY(pqSILModel)
245 };
246 
247 #endif
data
vtkSMSILModel * SILModel
Definition: pqSILModel.h:226
#define PQCOMPONENTS_EXPORT
QMap< vtkIdType, QModelIndex > * ModelIndexCache
Cache used by makeIndex() to avoid iterating over the edges each time.
Definition: pqSILModel.h:231
is a specialization for vtkSMArraySelectionDomain with access to the SIL.
int vtkIdType
is a helper for to work with SILs.
Definition: vtkSMSILModel.h:55
name
QMap< QString, std::set< vtkIdType > > HierarchyVertexIds
This map keeps a list of vertex ids that refer to the leaves in the hierarchy.
Definition: pqSILModel.h:239
QAbstractItemModel for legacy SIL (vtkGraph-based SIL)
Definition: pqSILModel.h:61
value
index
QVariant headerData(int, Qt::Orientation, int role=Qt::DisplayRole) const override
Definition: pqSILModel.h:158
unsigned long SILDomainObserverId
Definition: pqSILModel.h:241
QMap< QString, QModelIndex > Hierarchies
Definition: pqSILModel.h:233
vtkSmartPointer< vtkSMSILDomain > SILDomain
Definition: pqSILModel.h:240