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 
42 class vtkSelection;
43 class vtkTable;
44 class vtkVariant;
45 
46 class QMimeData;
47 
48 class VTKGUISUPPORTQT_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
49 {
50  Q_OBJECT
51 
52 public:
53  vtkQtTableModelAdapter(QObject* parent = nullptr);
54  vtkQtTableModelAdapter(vtkTable* table, QObject* parent = nullptr);
55  ~vtkQtTableModelAdapter() override;
56 
58 
61  void SetVTKDataObject(vtkDataObject* data) override;
62  vtkDataObject* GetVTKDataObject() const 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 
94  void SetDecorationLocation(int s);
95 
100  void SetDecorationStrategy(int s);
101 
102  bool GetSplitMultiComponentColumns() const;
103  void SetSplitMultiComponentColumns(bool value);
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 
132 Q_SIGNALS:
133  void selectionDropped(vtkSelection*);
134 
135 private:
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
Adapts a table to a Qt item model.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:59
A atomic type representing the union of many types.
Definition: vtkVariant.h:69
vtkTable * table() const
Set up the model based on the current table.
virtual void SetColorColumnName(const char *name)=0
virtual vtkDataObject * GetVTKDataObject() const =0
Set/Get the VTK data object as input to this adapter.
Superclass for Qt model adapters.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:73
virtual void SetKeyColumnName(const char *name)=0
virtual void SetVTKDataObject(vtkDataObject *data)=0
Set/Get the VTK data object as input to this adapter.
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const =0
Selection conversion from VTK land to Qt land.
general representation of visualization data
Definition: vtkDataObject.h:65
virtual vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const =0
Selection conversion from VTK land to Qt land.