VTK  9.2.6
vtkQtTableModelAdapter.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkQtTableModelAdapter.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 vtkQtTableModelAdapter_h
36#define vtkQtTableModelAdapter_h
37
38#include "vtkGUISupportQtModule.h" // For export macro
40#include <QImage> // Needed for icon support
41
42class vtkSelection;
43class vtkTable;
44class vtkVariant;
45
46class QMimeData;
47
48class VTKGUISUPPORTQT_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
49{
50 Q_OBJECT
51
52public:
53 vtkQtTableModelAdapter(QObject* parent = nullptr);
54 vtkQtTableModelAdapter(vtkTable* table, QObject* parent = nullptr);
56
58
61 void SetVTKDataObject(vtkDataObject* data) override;
64
66
69 vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const override;
70 QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const override;
72
73 void SetKeyColumnName(const char* name) override;
74 void SetColorColumnName(const char* name) override;
75 void SetIconIndexColumnName(const char* name);
76
77 enum
78 {
79 HEADER = 0,
80 ITEM = 1
81 };
82
83 enum
84 {
85 COLORS = 0,
86 ICONS = 1,
87 NONE = 2
88 };
89
95
101
104
106
109 void setTable(vtkTable* table);
110 vtkTable* table() const { return this->Table; }
111 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
112 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
113 Qt::ItemFlags flags(const QModelIndex& index) const override;
114 QVariant headerData(
115 int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
116 QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
117 QModelIndex parent(const QModelIndex& index) const override;
118 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
119 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
121
122 bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
123 const QModelIndex& parent) override;
124 QMimeData* mimeData(const QModelIndexList& indexes) const override;
125 QStringList mimeTypes() const override;
126 Qt::DropActions supportedDropActions() const override;
127
128 void SetIconSheet(QImage sheet);
129 void SetIconSize(int w, int h);
130 void SetIconSheetSize(int w, int h);
131
132Q_SIGNALS:
134
135private:
136 void getValue(int row, int column, vtkVariant& retVal) const;
137 bool noTableCheck() const;
138 void updateModelColumnHashTables();
139 QVariant getColorIcon(int row) const;
140 QVariant getIcon(int row) const;
141
142 bool SplitMultiComponentColumns;
143 vtkTable* Table;
144 int DecorationLocation;
145 int DecorationStrategy;
146 QImage IconSheet;
147 int IconSize[2];
148 int IconSheetSize[2];
149 int IconIndexColumn;
150
151 class vtkInternal;
152 vtkInternal* Internal;
153
155 void operator=(const vtkQtTableModelAdapter&) = delete;
156};
157
158#endif
159// VTK-HeaderTest-Exclude: vtkQtTableModelAdapter.h
general representation of visualization data
Superclass for Qt model adapters.
Adapts a table to a Qt item model.
void setTable(vtkTable *table)
Set up the model based on the current table.
vtkDataObject * GetVTKDataObject() const override
Set/Get the VTK data object as input to this adapter.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Set up the model based on the current table.
void SetIconIndexColumnName(const char *name)
~vtkQtTableModelAdapter() override
void selectionDropped(vtkSelection *)
void SetSplitMultiComponentColumns(bool value)
void SetDecorationLocation(int s)
Specify how to color rows if colors are provided by SetColorColumnName().
Qt::ItemFlags flags(const QModelIndex &index) const override
Set up the model based on the current table.
bool GetSplitMultiComponentColumns() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Set up the model based on the current table.
vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const override
Selection conversion from VTK land to Qt land.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Set up the model based on the current table.
QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const override
Selection conversion from VTK land to Qt land.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Set up the model based on the current table.
void SetIconSheetSize(int w, int h)
void SetDecorationStrategy(int s)
Specify how to color rows if colors are provided by SetColorColumnName().
void SetVTKDataObject(vtkDataObject *data) override
Set/Get the VTK data object as input to this adapter.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
void SetKeyColumnName(const char *name) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Set up the model based on the current table.
QModelIndex parent(const QModelIndex &index) const override
Set up the model based on the current table.
Qt::DropActions supportedDropActions() const override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Set up the model based on the current table.
vtkQtTableModelAdapter(vtkTable *table, QObject *parent=nullptr)
QStringList mimeTypes() const override
void SetIconSheet(QImage sheet)
QMimeData * mimeData(const QModelIndexList &indexes) const override
void SetIconSize(int w, int h)
vtkTable * table() const
Set up the model based on the current table.
void SetColorColumnName(const char *name) override
vtkQtTableModelAdapter(QObject *parent=nullptr)
data object that represents a "selection" in VTK.
Computes the portion of a dataset which is inside a selection.
A table, which contains similar-typed columns of data.
Definition vtkTable.h:74
A atomic type representing the union of many types.
Definition vtkVariant.h:70