VTK  9.1.0
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 "vtkType.h" // Needed for vtkIdType
39#include <QHash> // Needed for the decoration map
40#include <QVector> // Needed for the index map
41
42class vtkSelection;
43class vtkTree;
45
46class QMimeData;
47
48class VTKGUISUPPORTQT_EXPORT vtkQtTreeModelAdapter : public vtkQtAbstractModelAdapter
49{
50 Q_OBJECT
51
52public:
53 vtkQtTreeModelAdapter(QObject* parent = nullptr, vtkTree* tree = nullptr);
55
57
60 void SetVTKDataObject(vtkDataObject* data) override;
63
73
75
78 vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const override;
79 QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection* vtksel) const override;
81
82 void SetKeyColumnName(const char* name) override;
83
84 void SetColorColumnName(const char* name) override;
85
89 void setTree(vtkTree* t);
90 vtkTree* tree() const { return this->Tree; }
91
92 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
93 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
94 Qt::ItemFlags flags(const QModelIndex& index) const override;
95 QVariant headerData(
96 int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
97 QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
98 QModelIndex parent(const QModelIndex& index) const override;
99 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
100 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
101
103
108 Qt::DropActions supportedDragActions() const override;
109 QMimeData* mimeData(const QModelIndexList& indexes) const override;
110 QStringList mimeTypes() const override;
112
113protected:
115 void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index);
116
120 QVector<QModelIndex> VTKIndexToQtModelIndex;
121 QHash<QModelIndex, QVariant> IndexToDecoration;
122
123private:
125 void operator=(const vtkQtTreeModelAdapter&) = delete;
126};
127
128#endif
129// VTK-HeaderTest-Exclude: vtkQtTreeModelAdapter.h
Iterates through adjacent vertices in a graph.
general representation of visualization data
Superclass for Qt model adapters.
Adapts a tree to a Qt item model.
void SetVTKDataObject(vtkDataObject *data) override
Set/Get the VTK data object as input to this adapter.
vtkAdjacentVertexIterator * ChildIterator
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void setTree(vtkTree *t)
Set up the model based on the current tree.
QHash< QModelIndex, QVariant > IndexToDecoration
int rowCount(const QModelIndex &parent=QModelIndex()) const override
vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const override
Selection conversion from VTK land to Qt land.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void SetColorColumnName(const char *name) override
Qt::DropActions supportedDragActions() const override
If drag/drop is enabled in the view, the model will package up the current pedigreeid vtkSelection in...
vtkMTimeType GetVTKDataObjectMTime() const
Get the stored VTK data object modification time of when the adaption to a Qt model was done.
vtkDataObject * GetVTKDataObject() const override
Set/Get the VTK data object as input to this adapter.
void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index)
QMimeData * mimeData(const QModelIndexList &indexes) const override
If drag/drop is enabled in the view, the model will package up the current pedigreeid vtkSelection in...
QModelIndex parent(const QModelIndex &index) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
QStringList mimeTypes() const override
If drag/drop is enabled in the view, the model will package up the current pedigreeid vtkSelection in...
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const override
Selection conversion from VTK land to Qt land.
QVector< QModelIndex > VTKIndexToQtModelIndex
vtkQtTreeModelAdapter(QObject *parent=nullptr, vtkTree *tree=nullptr)
void SetKeyColumnName(const char *name) override
~vtkQtTreeModelAdapter() override
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:163
A rooted tree data structure.
Definition: vtkTree.h:164
int vtkIdType
Definition: vtkType.h:332
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287