VTK
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 
51  // The view types.
52  enum {
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 
67 
70  virtual void SetVTKDataObject(vtkDataObject *data) = 0;
71  virtual vtkDataObject* GetVTKDataObject() const = 0;
73 
75 
78  virtual vtkSelection* QModelIndexListToVTKIndexSelection(
79  const QModelIndexList qmil) const = 0;
80  virtual QItemSelection VTKIndexSelectionToQItemSelection(
81  vtkSelection *vtksel) const = 0;
83 
90  virtual void SetViewType(int type) { this->ViewType = type; }
91  virtual int GetViewType() { return this->ViewType; }
92 
100  virtual void SetKeyColumn(int col) { this->KeyColumn = col; }
101  virtual int GetKeyColumn() { return this->KeyColumn; }
102  virtual void SetKeyColumnName(const char* name) = 0;
103 
111  virtual void SetColorColumn(int col) { this->ColorColumn = col; }
112  virtual int GetColorColumn() { return this->ColorColumn; }
113  virtual void SetColorColumnName(const char* name) = 0;
114 
120  virtual void SetDataColumnRange(int c1, int c2)
121  { this->DataStartColumn = c1; this->DataEndColumn = c2; }
122 
123  // We make the reset() method public because it isn't always possible for
124  // an adapter to know when its input has changed, so it must be callable
125  // by an outside entity.
128  void reset() { QAbstractItemModel::beginResetModel(); QAbstractItemModel::endResetModel();}
129 
130  // We make the beginResetModel() and endResetModel() methods public because it
131  // isn't always possible for an adapter to know when its input has changed,
132  // so it must be callable by an outside entity.
133  void beginResetModel() { QAbstractItemModel::beginResetModel(); }
134  void endResetModel() { QAbstractItemModel::endResetModel(); }
135 
136 
137 signals:
138  void modelChanged();
139 
140 protected:
141 
147  virtual int ModelColumnToFieldDataColumn(int col) const;
148 
149  int ViewType;
154 };
155 
156 #endif
A node in a selection tree.
Definition: vtkSelection.h:43
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:64
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.