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 -------------------------------------------------------------------------*/
35 #ifndef vtkQtTreeModelAdapter_h
36 #define vtkQtTreeModelAdapter_h
37 
38 #include "vtkGUISupportQtModule.h" // For export macro
39 
41 #include <QHash> // Needed for the decoration map
42 #include <QVector> // Needed for the index map
43 #include "vtkType.h" // Needed for vtkIdType
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 
82  const QModelIndexList qmil) const override;
83  QItemSelection VTKIndexSelectionToQItemSelection(
84  vtkSelection *vtksel) const override;
86 
87  void SetKeyColumnName(const char* name) override;
88 
89  void SetColorColumnName(const char* name) override;
90 
94  void setTree(vtkTree* t);
95  vtkTree* tree() const { return this->Tree; }
96 
97  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
98  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
99  Qt::ItemFlags flags(const QModelIndex &index) const override;
100  QVariant headerData(int section, Qt::Orientation orientation,
101  int role = Qt::DisplayRole) const override;
102  QModelIndex index(int row, int column,
103  const QModelIndex &parent = QModelIndex()) const override;
104  QModelIndex parent(const QModelIndex &index) const override;
105  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
106  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
107 
109 
114  Qt::DropActions supportedDragActions() const override;
115  QMimeData * mimeData ( const QModelIndexList & indexes ) const override;
116  QStringList mimeTypes () const override;
118 
119 protected:
120  void treeModified();
121  void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index);
122 
126  QVector<QModelIndex> VTKIndexToQtModelIndex;
127  QHash<QModelIndex, QVariant> IndexToDecoration;
128 
129 private:
131  void operator=(const vtkQtTreeModelAdapter&) = delete;
132 };
133 
134 #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:63
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:60
general representation of visualization data
Definition: vtkDataObject.h:64