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 = nullptr, vtkTree* tree = nullptr);
54  ~vtkQtTreeModelAdapter() override;
55 
57 
60  void SetVTKDataObject(vtkDataObject *data) override;
61  vtkDataObject* GetVTKDataObject() const override;
63 
72  vtkMTimeType GetVTKDataObjectMTime() const;
73 
75 
79  const QModelIndexList qmil) const override;
80  QItemSelection VTKIndexSelectionToQItemSelection(
81  vtkSelection *vtksel) const override;
83 
84  void SetKeyColumnName(const char* name) override;
85 
86  void SetColorColumnName(const char* name) 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 override;
95  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
96  Qt::ItemFlags flags(const QModelIndex &index) const override;
97  QVariant headerData(int section, Qt::Orientation orientation,
98  int role = Qt::DisplayRole) const override;
99  QModelIndex index(int row, int column,
100  const QModelIndex &parent = QModelIndex()) const override;
101  QModelIndex parent(const QModelIndex &index) const override;
102  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
103  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
104 
106 
111  Qt::DropActions supportedDragActions() const override;
112  QMimeData * mimeData ( const QModelIndexList & indexes ) const override;
113  QStringList mimeTypes () const override;
115 
116 protected:
117  void treeModified();
118  void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index);
119 
123  QVector<QModelIndex> VTKIndexToQtModelIndex;
124  QHash<QModelIndex, QVariant> IndexToDecoration;
125 
126 private:
128  void operator=(const vtkQtTreeModelAdapter&) = delete;
129 };
130 
131 #endif
QHash< QModelIndex, QVariant > IndexToDecoration
vtkAdjacentVertexIterator * ChildIterator
Adapts a tree to a Qt item model.
QVector< QModelIndex > VTKIndexToQtModelIndex
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
Iterates through adjacent vertices in a graph.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:57
int vtkIdType
Definition: vtkType.h:347
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