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);
63  ~pqSpreadSheetViewModel() override;
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 
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 override;
94 
98  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
99 
104  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
105 
119  QVariant headerData(
120  int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
121 
125  void sortSection(int section, Qt::SortOrder order);
126 
130  bool isSortable(int section);
131 
135  int getFieldType() const;
136 
137  // Returns the vtk indices for the view indices.
138  QSet<vtkIndex> getVTKIndices(const QModelIndexList& indexes);
139 
144  void resetCompositeDataSetIndex();
145 
149  void setDecimalPrecision(int);
150  int getDecimalPrecision();
151 
155  void setFixedRepresentation(bool);
156  bool getFixedRepresentation();
157 
164  void setActiveRegion(int row_top, int row_bottom);
165 
170  pqDataRepresentation* activeRepresentation() const;
171  vtkSMProxy* activeRepresentationProxy() const;
172 
176  Qt::ItemFlags flags(const QModelIndex& index) const override;
177  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
178 
179  enum
180  {
181  SectionInternal = Qt::UserRole + 1,
183  };
184 
189  QString GetRowsAsString() const;
190 
191 public Q_SLOTS:
195  void forceUpdate();
196 
201  void setActiveRepresentation(pqDataRepresentation*);
202 
208  void setActiveRepresentationProxy(vtkSMProxy*);
209 
210 Q_SIGNALS:
214  void selectionChanged(const QItemSelection& selection);
215 
216 private Q_SLOTS:
220  void delayedUpdate();
221 
222  void triggerSelectionChanged();
223 
228  void onDataFetched(vtkObject*, unsigned long, void*, void* call_data);
229 
233  void hiddenColumnsChanged();
234 
235 protected:
240  bool isDataValid(const QModelIndex& idx) const;
241 
242  vtkSpreadSheetView* GetView() const;
243 
244 private:
245  Q_DISABLE_COPY(pqSpreadSheetViewModel)
246 
247  class pqInternal;
248  pqInternal* Internal;
249 
250  vtkSMProxy* ViewProxy;
251 };
252 
253 #endif
data
pqDataRepresentation is the superclass for a display for a pqPipelineSource i.e.
order
bool operator==(const vtkIndex &other) const
vtkSpreadSheetView is a vtkPVView subclass for a view used to show any data as a spreadsheet.
int vtkIdType
vtkIndex(vtkIdType a, vtkIdType b, vtkIdType c)
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:152
value
orientation
index