VTK  9.3.1
vtkQtAbstractModelAdapter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
19 #ifndef vtkQtAbstractModelAdapter_h
20 #define vtkQtAbstractModelAdapter_h
21 
22 #include "vtkGUISupportQtModule.h" // For export macro
23 #include <QAbstractItemModel>
24 #include <QItemSelection> // Needed for selection methods
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkDataObject;
28 class vtkSelection;
29 
30 class VTKGUISUPPORTQT_EXPORT vtkQtAbstractModelAdapter : public QAbstractItemModel
31 {
32  Q_OBJECT
33 
34 public:
35  // The view types.
36  enum
37  {
39  DATA_VIEW
40  };
41 
43  : QAbstractItemModel(p)
44  , ViewType(FULL_VIEW)
45  , KeyColumn(-1)
46  , ColorColumn(-1)
47  , DataStartColumn(-1)
48  , DataEndColumn(-1)
49  {
50  }
51 
53 
56  virtual void SetVTKDataObject(vtkDataObject* data) = 0;
57  virtual vtkDataObject* GetVTKDataObject() const = 0;
59 
61 
64  virtual vtkSelection* QModelIndexListToVTKIndexSelection(QModelIndexList qmil) const = 0;
65  virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const = 0;
67 
74  virtual void SetViewType(int type) { this->ViewType = type; }
75  virtual int GetViewType() { return this->ViewType; }
76 
84  virtual void SetKeyColumn(int col) { this->KeyColumn = col; }
85  virtual int GetKeyColumn() { return this->KeyColumn; }
86  virtual void SetKeyColumnName(const char* name) = 0;
87 
95  virtual void SetColorColumn(int col) { this->ColorColumn = col; }
96  virtual int GetColorColumn() { return this->ColorColumn; }
97  virtual void SetColorColumnName(const char* name) = 0;
98 
104  virtual void SetDataColumnRange(int c1, int c2)
105  {
106  this->DataStartColumn = c1;
107  this->DataEndColumn = c2;
108  }
109 
110  // We make the reset() method public because it isn't always possible for
111  // an adapter to know when its input has changed, so it must be callable
112  // by an outside entity.
115  void reset()
116  {
117  QAbstractItemModel::beginResetModel();
118  QAbstractItemModel::endResetModel();
119  }
120 
121  // We make the beginResetModel() and endResetModel() methods public because it
122  // isn't always possible for an adapter to know when its input has changed,
123  // so it must be callable by an outside entity.
124  void beginResetModel() { QAbstractItemModel::beginResetModel(); }
125  void endResetModel() { QAbstractItemModel::endResetModel(); }
126 
127 Q_SIGNALS:
128  void modelChanged();
129 
130 protected:
136  virtual int ModelColumnToFieldDataColumn(int col) const;
137 
138  int ViewType;
143 };
144 
145 VTK_ABI_NAMESPACE_END
146 #endif
147 // VTK-HeaderTest-Exclude: vtkQtAbstractModelAdapter.h
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:49
virtual void SetKeyColumn(int col)
Set/Get the key column.
virtual void SetDataColumnRange(int c1, int c2)
Set the range of columns that specify the main data matrix.
Superclass for Qt model adapters.
general representation of visualization data
Definition: vtkDataObject.h:54
virtual void SetColorColumn(int col)
Set/Get the column storing the rgba color values for each row.
virtual void SetViewType(int type)
Set/Get the view type.