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 public:
52  pqSILModel(QObject* parent=0);
53  virtual ~pqSILModel();
54 
56 
57  virtual int rowCount(const QModelIndex &parent=QModelIndex()) const;
63 
69  virtual int columnCount(const QModelIndex &parent=QModelIndex()) const;
70 
76  virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const;
77 
85  virtual QModelIndex index(int row, int column,
86  const QModelIndex &parent=QModelIndex()) const;
87 
93  virtual QModelIndex parent(const QModelIndex &index) const;
94 
101  virtual QVariant data(const QModelIndex &index,
102  int role=Qt::DisplayRole) const;
103 
112  virtual Qt::ItemFlags flags(const QModelIndex &index) const;
113 
117  bool setData(const QModelIndex &index, const QVariant& value,
118  int role = Qt::EditRole);
120 
124  QModelIndex hierarchyIndex(const QString& hierarchyName) const;
125 
126  virtual QVariant headerData (int, Qt::Orientation, int role = Qt::DisplayRole ) const
127  {
128  if (role == Qt::DisplayRole)
129  {
130  return "Selections";
131  }
132  return QVariant();
133  }
134 
136  QList<QVariant> status(const QString& hierarchyName) const;
137  void setStatus(const QString& hierarchyName, const QList<QVariant>& values);
138 
140  QModelIndex makeIndex(vtkIdType vertexid) const;
141 
144  vtkIdType findVertex(const char* name) const;
145 
146 signals:
147  void checkStatusChanged();
148 
149 public slots:
151  void update(vtkGraph* sil);
152 
153 protected:
156  void checkStateUpdated(vtkObject* caller,
157  unsigned long eventid, void* calldata);
158 
160  bool isLeaf(vtkIdType vertexid) const;
161 
164  vtkIdType parent(vtkIdType vertexid) const;
165 
167  int childrenCount(vtkIdType vertexid) const;
168 
171  void collectLeaves(vtkIdType vertexid, std::set<vtkIdType>& list);
172 
173  vtkSMSILModel* SILModel;
174 
176  QMap<vtkIdType, QModelIndex> *ModelIndexCache;
177 
178  QMap<QString, QModelIndex> Hierarchies;
179 
182  QMap<QString, std::set<vtkIdType> > HierarchyVertexIds;
183  vtkSmartPointer<vtkGraph> SIL;
184 
185 private:
186  Q_DISABLE_COPY(pqSILModel)
187 };
188 
189 #endif
190 
191 
vtkSMSILModel * SILModel
Definition: pqSILModel.h:173
QMap< vtkIdType, QModelIndex > * ModelIndexCache
Cache used by makeIndex() to avoid iterating over the edges each time.
Definition: pqSILModel.h:176
vtkSmartPointer< vtkGraph > SIL
Definition: pqSILModel.h:183
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:182
QMap< QString, QModelIndex > Hierarchies
Definition: pqSILModel.h:178
virtual QVariant headerData(int, Qt::Orientation, int role=Qt::DisplayRole) const
Definition: pqSILModel.h:126