VTK  9.0.1
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 -------------------------------------------------------------------------*/
32 #ifndef vtkQtTableModelAdapter_h
33 #define vtkQtTableModelAdapter_h
34 
35 #include "vtkConfigure.h"
36 #include "vtkGUISupportQtModule.h" // For export macro
38 #include <QImage> // Needed for icon support
39 
40 class vtkSelection;
41 class vtkTable;
42 class vtkVariant;
43 
44 class QMimeData;
45 
46 class VTKGUISUPPORTQT_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
47 {
48  Q_OBJECT
49 
50 public:
51  vtkQtTableModelAdapter(QObject* parent = nullptr);
52  vtkQtTableModelAdapter(vtkTable* table, QObject* parent = nullptr);
54 
56 
60  vtkDataObject* GetVTKDataObject() const override;
62 
64 
67  vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const override;
68  QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const override;
70 
71  void SetKeyColumnName(const char* name) override;
72  void SetColorColumnName(const char* name) override;
73  void SetIconIndexColumnName(const char* name);
74 
75  enum
76  {
77  HEADER = 0,
78  ITEM = 1
79  };
80 
81  enum
82  {
83  COLORS = 0,
84  ICONS = 1,
85  NONE = 2
86  };
87 
92  void SetDecorationLocation(int s);
93 
98  void SetDecorationStrategy(int s);
99 
102 
104 
107  void setTable(vtkTable* table);
108  vtkTable* table() const { return this->Table; }
109  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
110  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
111  Qt::ItemFlags flags(const QModelIndex& index) const override;
112  QVariant headerData(
113  int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
114  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
115  QModelIndex parent(const QModelIndex& index) const override;
116  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
117  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
119 
120  bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
121  const QModelIndex& parent) override;
122  QMimeData* mimeData(const QModelIndexList& indexes) const override;
123  QStringList mimeTypes() const override;
124  Qt::DropActions supportedDropActions() const override;
125 
126  void SetIconSheet(QImage sheet);
127  void SetIconSize(int w, int h);
128  void SetIconSheetSize(int w, int h);
129 
130 signals:
132 
133 private:
134  void getValue(int row, int column, vtkVariant& retVal) const;
135  bool noTableCheck() const;
136  void updateModelColumnHashTables();
137  QVariant getColorIcon(int row) const;
138  QVariant getIcon(int row) const;
139 
140  bool SplitMultiComponentColumns;
141  vtkTable* Table;
142  int DecorationLocation;
143  int DecorationStrategy;
144  QImage IconSheet;
145  int IconSize[2];
146  int IconSheetSize[2];
147  int IconIndexColumn;
148 
149  class vtkInternal;
150  vtkInternal* Internal;
151 
153  void operator=(const vtkQtTableModelAdapter&) = delete;
154 };
155 
156 #endif
157 // VTK-HeaderTest-Exclude: vtkQtTableModelAdapter.h
general representation of visualization data
Definition: vtkDataObject.h:60
vtkFrustumSelector is a vtkSelector that selects elements based on whether they are inside or interse...
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.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
vtkDataObject * GetVTKDataObject() const override
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
bool GetSplitMultiComponentColumns() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
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
QModelIndex parent(const QModelIndex &index) const override
Qt::DropActions supportedDropActions() const override
vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const override
Selection conversion from VTK land to Qt land.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
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)
void SetColorColumnName(const char *name) override
vtkQtTableModelAdapter(QObject *parent=nullptr)
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:58
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:63
A atomic type representing the union of many types.
Definition: vtkVariant.h:66
@ orientation
Definition: vtkX3D.h:268
@ value
Definition: vtkX3D.h:226
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
@ data
Definition: vtkX3D.h:321