VTK  9.2.6
vtkQtAbstractModelAdapter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtAbstractModelAdapter.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
35 #ifndef vtkQtAbstractModelAdapter_h
36 #define vtkQtAbstractModelAdapter_h
37 
38 #include "vtkGUISupportQtModule.h" // For export macro
39 #include <QAbstractItemModel>
40 #include <QItemSelection> // Needed for selection methods
41 
42 class vtkDataObject;
43 class vtkSelection;
44 
45 class VTKGUISUPPORTQT_EXPORT vtkQtAbstractModelAdapter : public QAbstractItemModel
46 {
47  Q_OBJECT
48 
49 public:
50  // The view types.
51  enum
52  {
54  DATA_VIEW
55  };
56 
58  : QAbstractItemModel(p)
59  , ViewType(FULL_VIEW)
60  , KeyColumn(-1)
61  , ColorColumn(-1)
62  , DataStartColumn(-1)
63  , DataEndColumn(-1)
64  {
65  }
66 
68 
71  virtual void SetVTKDataObject(vtkDataObject* data) = 0;
72  virtual vtkDataObject* GetVTKDataObject() const = 0;
74 
76 
79  virtual vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const = 0;
80  virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const = 0;
82 
89  virtual void SetViewType(int type) { this->ViewType = type; }
90  virtual int GetViewType() { return this->ViewType; }
91 
99  virtual void SetKeyColumn(int col) { this->KeyColumn = col; }
100  virtual int GetKeyColumn() { return this->KeyColumn; }
101  virtual void SetKeyColumnName(const char* name) = 0;
102 
110  virtual void SetColorColumn(int col) { this->ColorColumn = col; }
111  virtual int GetColorColumn() { return this->ColorColumn; }
112  virtual void SetColorColumnName(const char* name) = 0;
113 
119  virtual void SetDataColumnRange(int c1, int c2)
120  {
121  this->DataStartColumn = c1;
122  this->DataEndColumn = c2;
123  }
124 
125  // We make the reset() method public because it isn't always possible for
126  // an adapter to know when its input has changed, so it must be callable
127  // by an outside entity.
130  void reset()
131  {
132  QAbstractItemModel::beginResetModel();
133  QAbstractItemModel::endResetModel();
134  }
135 
136  // We make the beginResetModel() and endResetModel() methods public because it
137  // isn't always possible for an adapter to know when its input has changed,
138  // so it must be callable by an outside entity.
139  void beginResetModel() { QAbstractItemModel::beginResetModel(); }
140  void endResetModel() { QAbstractItemModel::endResetModel(); }
141 
142 Q_SIGNALS:
143  void modelChanged();
144 
145 protected:
151  virtual int ModelColumnToFieldDataColumn(int col) const;
152 
153  int ViewType;
158 };
159 
160 #endif
161 // VTK-HeaderTest-Exclude: vtkQtAbstractModelAdapter.h
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:59
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:65
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.