VTK
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 "vtkConfigure.h"
39 #include "vtkGUISupportQtModule.h" // For export macro
41 #include <QImage> // Needed for icon support
42 
43 class vtkSelection;
44 class vtkTable;
45 class vtkVariant;
46 
47 class QMimeData;
48 
49 class VTKGUISUPPORTQT_EXPORT vtkQtTableModelAdapter : public vtkQtAbstractModelAdapter
50 {
51  Q_OBJECT
52 
53 public:
54  vtkQtTableModelAdapter(QObject *parent = nullptr);
55  vtkQtTableModelAdapter(vtkTable* table, QObject *parent = nullptr);
56  ~vtkQtTableModelAdapter() override;
57 
59 
62  void SetVTKDataObject(vtkDataObject *data) override;
63  vtkDataObject* GetVTKDataObject() const override;
65 
67 
71  const QModelIndexList qmil) const override;
72  QItemSelection VTKIndexSelectionToQItemSelection(
73  vtkSelection *vtksel) const override;
75 
76  void SetKeyColumnName(const char* name) override;
77  void SetColorColumnName(const char* name) override;
78  void SetIconIndexColumnName(const char* name);
79 
80  enum
81  {
82  HEADER = 0,
83  ITEM = 1
84  };
85 
86  enum
87  {
88  COLORS = 0,
89  ICONS = 1,
90  NONE = 2
91  };
92 
97  void SetDecorationLocation(int s);
98 
103  void SetDecorationStrategy(int s);
104 
105  bool GetSplitMultiComponentColumns() const;
106  void SetSplitMultiComponentColumns(bool value);
107 
109 
112  void setTable(vtkTable* table);
113  vtkTable* table() const { return this->Table; }
114  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
115  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
116  Qt::ItemFlags flags(const QModelIndex &index) const override;
117  QVariant headerData(int section, Qt::Orientation orientation,
118  int role = Qt::DisplayRole) const override;
119  QModelIndex index(int row, int column,
120  const QModelIndex &parent = QModelIndex()) const override;
121  QModelIndex parent(const QModelIndex &index) const override;
122  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
123  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
125 
126  bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) override ;
127  QMimeData * mimeData ( const QModelIndexList & indexes ) const override;
128  QStringList mimeTypes () const override;
129  Qt::DropActions supportedDropActions() const override;
130 
131  void SetIconSheet(QImage sheet);
132  void SetIconSize(int w, int h);
133  void SetIconSheetSize(int w, int h);
134 
135 signals:
136  void selectionDropped(vtkSelection*);
137 
138 private:
139 
140  void getValue(int row, int column, vtkVariant& retVal) const;
141  bool noTableCheck() const;
142  void updateModelColumnHashTables();
143  QVariant getColorIcon(int row) const;
144  QVariant getIcon(int row) const;
145 
146  bool SplitMultiComponentColumns;
147  vtkTable* Table;
148  int DecorationLocation;
149  int DecorationStrategy;
150  QImage IconSheet;
151  int IconSize[2];
152  int IconSheetSize[2];
153  int IconIndexColumn;
154 
155  class vtkInternal;
156  vtkInternal* Internal;
157 
159  void operator=(const vtkQtTableModelAdapter&) = delete;
160 };
161 
162 #endif
Adapts a table to a Qt item model.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:63
A atomic type representing the union of many types.
Definition: vtkVariant.h:71
vtkTable * table() const
Set up the model based on the current table.
virtual vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const =0
Selection conversion from VTK land to Qt land.
virtual void SetColorColumnName(const char *name)=0
virtual vtkDataObject * GetVTKDataObject() const =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.
Superclass for Qt model adapters.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:68
virtual void SetKeyColumnName(const char *name)=0
virtual void SetVTKDataObject(vtkDataObject *data)=0
Set/Get the VTK data object as input to this adapter.
general representation of visualization data
Definition: vtkDataObject.h:64