VTK
vtkQtTreeModelAdapter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkQtTreeModelAdapter.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 vtkQtTreeModelAdapter_h
33 #define vtkQtTreeModelAdapter_h
34 
35 #include "vtkGUISupportQtModule.h" // For export macro
36 
38 #include <QHash> // Needed for the decoration map
39 #include <QVector> // Needed for the index map
40 #include "vtkType.h" // Needed for vtkIdType
41 
42 class vtkSelection;
43 class vtkTree;
45 
46 class QMimeData;
47 
48 class VTKGUISUPPORTQT_EXPORT vtkQtTreeModelAdapter : public vtkQtAbstractModelAdapter
49 {
50  Q_OBJECT
51 
52 public:
53  vtkQtTreeModelAdapter(QObject *parent = 0, vtkTree* tree = 0);
54  ~vtkQtTreeModelAdapter() VTK_OVERRIDE;
55 
57 
60  void SetVTKDataObject(vtkDataObject *data) VTK_OVERRIDE;
61  vtkDataObject* GetVTKDataObject() const VTK_OVERRIDE;
63 
72  vtkMTimeType GetVTKDataObjectMTime() const;
73 
75 
79  const QModelIndexList qmil) const VTK_OVERRIDE;
80  QItemSelection VTKIndexSelectionToQItemSelection(
81  vtkSelection *vtksel) const VTK_OVERRIDE;
83 
84  void SetKeyColumnName(const char* name) VTK_OVERRIDE;
85 
86  void SetColorColumnName(const char* name) VTK_OVERRIDE;
87 
91  void setTree(vtkTree* t);
92  vtkTree* tree() const { return this->Tree; }
93 
94  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const VTK_OVERRIDE;
95  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) VTK_OVERRIDE;
96  Qt::ItemFlags flags(const QModelIndex &index) const VTK_OVERRIDE;
97  QVariant headerData(int section, Qt::Orientation orientation,
98  int role = Qt::DisplayRole) const VTK_OVERRIDE;
99  QModelIndex index(int row, int column,
100  const QModelIndex &parent = QModelIndex()) const VTK_OVERRIDE;
101  QModelIndex parent(const QModelIndex &index) const VTK_OVERRIDE;
102  int rowCount(const QModelIndex &parent = QModelIndex()) const VTK_OVERRIDE;
103  int columnCount(const QModelIndex &parent = QModelIndex()) const VTK_OVERRIDE;
104 
106 
111 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
112  Qt::DropActions supportedDragActions() const VTK_OVERRIDE;
113 #else
114  Qt::DropActions supportedDragActions() const;
115 #endif
116  QMimeData * mimeData ( const QModelIndexList & indexes ) const VTK_OVERRIDE;
117  QStringList mimeTypes () const VTK_OVERRIDE;
119 
120 protected:
121  void treeModified();
122  void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index);
123 
124  vtkTree* Tree;
126  vtkMTimeType TreeMTime;
127  QVector<QModelIndex> VTKIndexToQtModelIndex;
128  QHash<QModelIndex, QVariant> IndexToDecoration;
129 
130 private:
131  vtkQtTreeModelAdapter(const vtkQtTreeModelAdapter &) VTK_DELETE_FUNCTION;
132  void operator=(const vtkQtTreeModelAdapter&) VTK_DELETE_FUNCTION;
133 };
134 
135 #endif
Adapts a tree to a Qt item model.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
Iterates through adjacent vertices in a graph.
A node in a selection tree.
Definition: vtkSelection.h:37
int vtkIdType
Definition: vtkType.h:345
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.
virtual void SetKeyColumnName(const char *name)=0
virtual void SetVTKDataObject(vtkDataObject *data)=0
Set/Get the VTK data object as input to this adapter.
A rooted tree data structure.
Definition: vtkTree.h:54
general representation of visualization data
Definition: vtkDataObject.h:58