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 -------------------------------------------------------------------------*/
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 = 0);
52  vtkQtTableModelAdapter(vtkTable* table, QObject *parent = 0);
53  ~vtkQtTableModelAdapter() VTK_OVERRIDE;
54 
56 
59  void SetVTKDataObject(vtkDataObject *data) VTK_OVERRIDE;
60  vtkDataObject* GetVTKDataObject() const VTK_OVERRIDE;
62 
64 
68  const QModelIndexList qmil) const VTK_OVERRIDE;
69  QItemSelection VTKIndexSelectionToQItemSelection(
70  vtkSelection *vtksel) const VTK_OVERRIDE;
72 
73  void SetKeyColumnName(const char* name) VTK_OVERRIDE;
74  void SetColorColumnName(const char* name) VTK_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 VTK_OVERRIDE;
112  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) VTK_OVERRIDE;
113  Qt::ItemFlags flags(const QModelIndex &index) const VTK_OVERRIDE;
114  QVariant headerData(int section, Qt::Orientation orientation,
115  int role = Qt::DisplayRole) const VTK_OVERRIDE;
116  QModelIndex index(int row, int column,
117  const QModelIndex &parent = QModelIndex()) const VTK_OVERRIDE;
118  QModelIndex parent(const QModelIndex &index) const VTK_OVERRIDE;
119  int rowCount(const QModelIndex &parent = QModelIndex()) const VTK_OVERRIDE;
120  int columnCount(const QModelIndex &parent = QModelIndex()) const VTK_OVERRIDE;
122 
123  bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) VTK_OVERRIDE ;
124  QMimeData * mimeData ( const QModelIndexList & indexes ) const VTK_OVERRIDE;
125  QStringList mimeTypes () const VTK_OVERRIDE;
126  Qt::DropActions supportedDropActions() const VTK_OVERRIDE;
127 
128  void SetIconSheet(QImage sheet);
129  void SetIconSize(int w, int h);
130  void SetIconSheetSize(int w, int h);
131 
132 signals:
133  void selectionDropped(vtkSelection*);
134 
135 private:
136 
137  void getValue(int row, int column, vtkVariant& retVal) const;
138  bool noTableCheck() const;
139  void updateModelColumnHashTables();
140  QVariant getColorIcon(int row) const;
141  QVariant getIcon(int row) const;
142 
143  bool SplitMultiComponentColumns;
144  vtkTable* Table;
145  int DecorationLocation;
146  int DecorationStrategy;
147  QImage IconSheet;
148  int IconSize[2];
149  int IconSheetSize[2];
150  int IconIndexColumn;
151 
152  class vtkInternal;
153  vtkInternal* Internal;
154 
155  vtkQtTableModelAdapter(const vtkQtTableModelAdapter &) VTK_DELETE_FUNCTION;
156  void operator=(const vtkQtTableModelAdapter&) VTK_DELETE_FUNCTION;
157 };
158 
159 #endif
Adapts a table to a Qt item model.
A node in a selection tree.
Definition: vtkSelection.h:37
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 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:62
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:58