VTK  9.2.6
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 -------------------------------------------------------------------------*/
35 #ifndef vtkQtTreeModelAdapter_h
36 #define vtkQtTreeModelAdapter_h
37 
38 #include "vtkGUISupportQtModule.h" // For export macro
39 
41 #include "vtkType.h" // Needed for vtkIdType
42 #include <QHash> // Needed for the decoration map
43 #include <QVector> // Needed for the index map
44 
45 class vtkSelection;
46 class vtkTree;
48 
49 class QMimeData;
50 
51 class VTKGUISUPPORTQT_EXPORT vtkQtTreeModelAdapter : public vtkQtAbstractModelAdapter
52 {
53  Q_OBJECT
54 
55 public:
56  vtkQtTreeModelAdapter(QObject* parent = nullptr, vtkTree* tree = nullptr);
57  ~vtkQtTreeModelAdapter() override;
58 
60 
63  void SetVTKDataObject(vtkDataObject* data) override;
64  vtkDataObject* GetVTKDataObject() const override;
66 
75  vtkMTimeType GetVTKDataObjectMTime() const;
76 
78 
81  vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const override;
82  QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const override;
84 
85  void SetKeyColumnName(const char* name) override;
86 
87  void SetColorColumnName(const char* name) override;
88 
92  void setTree(vtkTree* t);
93  vtkTree* tree() const { return this->Tree; }
94 
95  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
96  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
97  Qt::ItemFlags flags(const QModelIndex& index) const override;
98  QVariant headerData(
99  int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
100  QModelIndex index(int row, int column, 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
132 // VTK-HeaderTest-Exclude: vtkQtTreeModelAdapter.h
QHash< QModelIndex, QVariant > IndexToDecoration
vtkAdjacentVertexIterator * ChildIterator
Adapts a tree to a Qt item model.
QVector< QModelIndex > VTKIndexToQtModelIndex
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
Iterates through adjacent vertices in a graph.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:59
int vtkIdType
Definition: vtkType.h:332
virtual void SetColorColumnName(const char *name)=0
virtual vtkDataObject * GetVTKDataObject() const =0
Set/Get the VTK data object as input to this adapter.
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.
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const =0
Selection conversion from VTK land to Qt land.
A rooted tree data structure.
Definition: vtkTree.h:60
general representation of visualization data
Definition: vtkDataObject.h:65
virtual vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const =0
Selection conversion from VTK land to Qt land.