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 = 0);
55  vtkQtTableModelAdapter(vtkTable* table, QObject *parent = 0);
57 
59 
62  virtual void SetVTKDataObject(vtkDataObject *data);
63  virtual vtkDataObject* GetVTKDataObject() const;
65 
67 
71  const QModelIndexList qmil) const;
72  virtual QItemSelection VTKIndexSelectionToQItemSelection(
73  vtkSelection *vtksel) const;
75 
76  virtual void SetKeyColumnName(const char* name);
77  virtual void SetColorColumnName(const char* name);
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;
115  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
116  Qt::ItemFlags flags(const QModelIndex &index) const;
117  QVariant headerData(int section, Qt::Orientation orientation,
118  int role = Qt::DisplayRole) const;
119  QModelIndex index(int row, int column,
120  const QModelIndex &parent = QModelIndex()) const;
121  QModelIndex parent(const QModelIndex &index) const;
122  int rowCount(const QModelIndex &parent = QModelIndex()) const;
123  int columnCount(const QModelIndex &parent = QModelIndex()) const;
125 
126  virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) ;
127  virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
128  virtual QStringList mimeTypes () const ;
129  Qt::DropActions supportedDropActions() const;
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 
158  vtkQtTableModelAdapter(const vtkQtTableModelAdapter &) VTK_DELETE_FUNCTION;
159  void operator=(const vtkQtTableModelAdapter&) VTK_DELETE_FUNCTION;
160 };
161 
162 #endif
Adapts a table to a Qt item model.
A node in a selection tree.
Definition: vtkSelection.h:43
A atomic type representing the union of many types.
Definition: vtkVariant.h:75
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