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 -------------------------------------------------------------------------*/
34 #ifndef vtkQtTreeModelAdapter_h
35 #define vtkQtTreeModelAdapter_h
36 
37 #include "vtkGUISupportQtModule.h" // For export macro
38 #include "QVTKWin32Header.h"
39 #include "vtkType.h"
40 #include "vtkSelection.h"
41 
43 #include <QHash>
44 #include <QMimeData>
45 #include <QVector>
46 
47 class vtkTree;
49 
50 class VTKGUISUPPORTQT_EXPORT vtkQtTreeModelAdapter : public vtkQtAbstractModelAdapter
51 {
52  Q_OBJECT
53 
54 public:
55  vtkQtTreeModelAdapter(QObject *parent = 0, vtkTree* tree = 0);
57 
59 
60  virtual void SetVTKDataObject(vtkDataObject *data);
61  virtual vtkDataObject* GetVTKDataObject() const;
63 
70  unsigned long GetVTKDataObjectMTime() const;
71 
73 
75  const QModelIndexList qmil) const;
76  virtual QItemSelection VTKIndexSelectionToQItemSelection(
77  vtkSelection *vtksel) const;
79 
80  virtual void SetKeyColumnName(const char* name);
81 
82  virtual void SetColorColumnName(const char* name);
83 
85 
86  void setTree(vtkTree* t);
87  vtkTree* tree() const { return this->Tree; }
89 
90  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
91  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
92  Qt::ItemFlags flags(const QModelIndex &index) const;
93  QVariant headerData(int section, Qt::Orientation orientation,
94  int role = Qt::DisplayRole) const;
95  QModelIndex index(int row, int column,
96  const QModelIndex &parent = QModelIndex()) const;
97  QModelIndex parent(const QModelIndex &index) const;
98  int rowCount(const QModelIndex &parent = QModelIndex()) const;
99  int columnCount(const QModelIndex &parent = QModelIndex()) const;
100 
102 
105  Qt::DropActions supportedDragActions() const;
106  virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
107  virtual QStringList mimeTypes () const ;
109 
110 protected:
111  void treeModified();
112  void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index);
113 
116  unsigned long TreeMTime;
117  QVector<QModelIndex> VTKIndexToQtModelIndex;
118  QHash<QModelIndex, QVariant> IndexToDecoration;
119 
120 private:
121  vtkQtTreeModelAdapter(const vtkQtTreeModelAdapter &); // Not implemented
122  void operator=(const vtkQtTreeModelAdapter&); // Not implemented.
123 };
124 
125 #endif
QHash< QModelIndex, QVariant > IndexToDecoration
vtkAdjacentVertexIterator * ChildIterator
Adapts a tree to a Qt item model.
QVector< QModelIndex > VTKIndexToQtModelIndex
Iterates through adjacent vertices in a graph.
A node in a selection tree. Used to store selection results.
Definition: vtkSelection.h:44
int vtkIdType
Definition: vtkType.h:275
virtual vtkSelection * QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const =0
virtual void SetColorColumnName(const char *name)=0
virtual vtkDataObject * GetVTKDataObject() const =0
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const =0
Superclass for Qt model adapters.
virtual void SetKeyColumnName(const char *name)=0
virtual void SetVTKDataObject(vtkDataObject *data)=0
A rooted tree data structure.
Definition: vtkTree.h:59
general representation of visualization data
Definition: vtkDataObject.h:64