ParaView
pqSpreadSheetViewModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqSpreadSheetViewModel.h
5 
6  Copyright (c) 2005-2008 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 pqSpreadSheetViewModel_h
33 #define pqSpreadSheetViewModel_h
34 
35 #include "pqCoreModule.h"
36 #include "vtkType.h" // needed for vtkIdType.
37 #include <QAbstractTableModel>
38 #include <QPair>
39 #include <QSet>
40 
48 class QItemSelection;
49 class QItemSelectionModel;
50 class vtkObject;
51 class vtkSelection;
52 class vtkSelectionNode;
53 class vtkSMProxy;
54 class vtkSpreadSheetView;
55 
56 class PQCORE_EXPORT pqSpreadSheetViewModel : public QAbstractTableModel
57 {
58  Q_OBJECT
59  typedef QAbstractTableModel Superclass;
60 
61 public:
62  pqSpreadSheetViewModel(vtkSMProxy* viewProxy, QObject* parent = NULL);
64 
65  class vtkIndex
66  {
67  public:
68  vtkIdType Tuple[3];
70  {
71  this->Tuple[0] = 0;
72  this->Tuple[1] = 0;
73  this->Tuple[2] = 0;
74  }
75 
76  vtkIndex(vtkIdType a, vtkIdType b, vtkIdType c)
77  {
78  this->Tuple[0] = a;
79  this->Tuple[1] = b;
80  this->Tuple[2] = c;
81  }
82 
83  bool operator==(const vtkIndex& other) const
84  {
85  return (this->Tuple[0] == other.Tuple[0] && this->Tuple[1] == other.Tuple[1] &&
86  this->Tuple[2] == other.Tuple[2]);
87  }
88  };
89 
93  int rowCount(const QModelIndex& parent = QModelIndex()) const;
94 
98  int columnCount(const QModelIndex& parent = QModelIndex()) const;
99 
104  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
105 
110  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
111 
115  void sortSection(int section, Qt::SortOrder order);
116 
120  bool isSortable(int section);
121 
125  bool isVisible(int section);
126 
130  void setVisible(int section, bool visible);
131 
135  void clearVisible();
136 
140  int getFieldType() const;
141 
142  // Returns the vtk indices for the view indices.
143  QSet<vtkIndex> getVTKIndices(const QModelIndexList& indexes);
144 
149  void resetCompositeDataSetIndex();
150 
154  void setDecimalPrecision(int);
155  int getDecimalPrecision();
156 
163  void setActiveRegion(int row_top, int row_bottom);
164 
169  pqDataRepresentation* activeRepresentation() const;
170  vtkSMProxy* activeRepresentationProxy() const;
171 
175  virtual Qt::ItemFlags flags(const QModelIndex& index) const;
176  virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
177 public slots:
181  void forceUpdate();
182 
187  void setActiveRepresentation(pqDataRepresentation*);
188 
194  void setActiveRepresentationProxy(vtkSMProxy*);
195 
196 signals:
200  void selectionChanged(const QItemSelection& selection);
201 
202 private slots:
206  void delayedUpdate();
207 
208  void triggerSelectionChanged();
209 
214  void onDataFetched(vtkObject*, unsigned long, void*, void* call_data);
215 
216 protected:
221  bool isDataValid(const QModelIndex& idx) const;
222 
223  vtkSpreadSheetView* GetView() const;
224 
225 private:
226  Q_DISABLE_COPY(pqSpreadSheetViewModel)
227 
228  class pqInternal;
229  pqInternal* Internal;
230 
231  vtkSMProxy* ViewProxy;
232 };
233 
234 #endif
pqDataRepresentation is the superclass for a display for a pqPipelineSource i.e.
bool operator==(const vtkIndex &other) const
vtkSpreadSheetView is a vtkPVView subclass for a view used to show any data as a spreadsheet.
vtkIndex(vtkIdType a, vtkIdType b, vtkIdType c)
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:152