ParaView
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 vtkSMSILModel;
46 
47 class PQCOMPONENTS_EXPORT pqSILModel : public QAbstractItemModel
48 {
49  Q_OBJECT
50  typedef QAbstractItemModel Superclass;
51 
52 public:
53  pqSILModel(QObject* parent = 0);
54  virtual ~pqSILModel();
55 
67  virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
68 
76  virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
77 
85  virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const;
86 
96  virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
97 
105  virtual QModelIndex parent(const QModelIndex& index) const;
106 
115  virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
116 
127  virtual Qt::ItemFlags flags(const QModelIndex& index) const;
128 
134  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
136 
142  QModelIndex hierarchyIndex(const QString& hierarchyName) const;
143 
144  virtual QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const
145  {
146  if (role == Qt::DisplayRole)
147  {
148  return "Selections";
149  }
150  return QVariant();
151  }
152 
156  QList<QVariant> status(const QString& hierarchyName) const;
157  void setStatus(const QString& hierarchyName, const QList<QVariant>& values);
158 
162  QModelIndex makeIndex(vtkIdType vertexid) const;
163 
168  vtkIdType findVertex(const char* name) const;
169 
170 signals:
171  void checkStatusChanged();
172 
173 public slots:
177  void update(vtkGraph* sil);
178 
179 protected:
184  void checkStateUpdated(vtkObject* caller, unsigned long eventid, void* calldata);
185 
189  bool isLeaf(vtkIdType vertexid) const;
190 
195  vtkIdType parent(vtkIdType vertexid) const;
196 
200  int childrenCount(vtkIdType vertexid) const;
201 
206  void collectLeaves(vtkIdType vertexid, std::set<vtkIdType>& list);
207 
209 
213  QMap<vtkIdType, QModelIndex>* ModelIndexCache;
214 
215  QMap<QString, QModelIndex> Hierarchies;
216 
221  QMap<QString, std::set<vtkIdType> > HierarchyVertexIds;
222  vtkSmartPointer<vtkGraph> SIL;
223 
224 private:
225  Q_DISABLE_COPY(pqSILModel)
226 };
227 
228 #endif
vtkSMSILModel * SILModel
Definition: pqSILModel.h:208
QMap< vtkIdType, QModelIndex > * ModelIndexCache
Cache used by makeIndex() to avoid iterating over the edges each time.
Definition: pqSILModel.h:213
vtkSmartPointer< vtkGraph > SIL
Definition: pqSILModel.h:222
is a helper for to work with SILs.
Definition: vtkSMSILModel.h:47
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:221
QMap< QString, QModelIndex > Hierarchies
Definition: pqSILModel.h:215
virtual QVariant headerData(int, Qt::Orientation, int role=Qt::DisplayRole) const
Definition: pqSILModel.h:144