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 
46 class QItemSelection;
47 class QItemSelectionModel;
48 class vtkObject;
49 class vtkSelection;
50 class vtkSelectionNode;
51 class vtkSMProxy;
52 class vtkSpreadSheetView;
53 
54 class PQCORE_EXPORT pqSpreadSheetViewModel : public QAbstractTableModel
55 {
56  Q_OBJECT
57  typedef QAbstractTableModel Superclass;
58 public:
59  pqSpreadSheetViewModel(vtkSMProxy* viewProxy, QObject* parent=NULL);
61 
62  class vtkIndex
63  {
64  public:
65  vtkIdType Tuple[3];
67  {
68  this->Tuple[0] = 0;
69  this->Tuple[1] = 0;
70  this->Tuple[2] = 0;
71  }
72 
73  vtkIndex(vtkIdType a, vtkIdType b, vtkIdType c)
74  {
75  this->Tuple[0] = a;
76  this->Tuple[1] = b;
77  this->Tuple[2] = c;
78  }
79 
80  bool operator==(const vtkIndex& other) const
81  {
82  return (this->Tuple[0] == other.Tuple[0] &&
83  this->Tuple[1] == other.Tuple[1] &&
84  this->Tuple[2] == other.Tuple[2]);
85  }
86  };
87 
89  int rowCount(const QModelIndex& parent=QModelIndex()) const;
90 
92  int columnCount(const QModelIndex& parent=QModelIndex()) const;
93 
96  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const;
97 
100  QVariant headerData (int section, Qt::Orientation orientation,
101  int role=Qt::DisplayRole) const;
102 
104  void sortSection (int section, Qt::SortOrder order);
105 
107  bool isSortable(int section);
108 
110  bool isVisible(int section);
111 
113  void setVisible(int section, bool visible);
114 
116  void clearVisible();
117 
119  int getFieldType() const;
120 
121  // Returns the vtk indices for the view indices.
122  QSet<vtkIndex> getVTKIndices(const QModelIndexList& indexes);
123 
126  void resetCompositeDataSetIndex();
127 
129  void setDecimalPrecision(int);
130  int getDecimalPrecision();
131 
136  void setActiveRegion(int row_top, int row_bottom);
137 
140  pqDataRepresentation* activeRepresentation() const;
141  vtkSMProxy* activeRepresentationProxy() const;
142 
144  virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
145  virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
146 public slots:
148  void forceUpdate();
149 
152  void setActiveRepresentation(pqDataRepresentation*);
153 
157  void setActiveRepresentationProxy(vtkSMProxy*);
158 
159 signals:
161  void selectionChanged(const QItemSelection& selection);
162 
163 private slots:
165  void delayedUpdate();
166 
167  void triggerSelectionChanged();
168 
171  void onDataFetched(vtkObject*, unsigned long, void*, void* call_data);
172 
173 protected:
176  bool isDataValid(const QModelIndex &idx) const;
177 
178  vtkSpreadSheetView* GetView() const;
179 private:
180  Q_DISABLE_COPY(pqSpreadSheetViewModel)
181 
182  class pqInternal;
183  pqInternal* Internal;
184 
185  vtkSMProxy* ViewProxy;
186 };
187 
188 #endif
189 
190 
pqDataRepresentation is the superclass for a display for a pqPipelineSource i.e.
bool operator==(const vtkIndex &other) const
vtkIndex(vtkIdType a, vtkIdType b, vtkIdType c)