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 "QVTKWin32Header.h"
38 #include "vtkType.h"
39 #include "vtkSelection.h"
40 
42 #include <QHash>
43 #include <QMimeData>
44 #include <QVector>
45 
46 class vtkTree;
48 
50 {
51  Q_OBJECT
52 
53 public:
54  vtkQtTreeModelAdapter(QObject *parent = 0, vtkTree* tree = 0);
56 
58 
59  virtual void SetVTKDataObject(vtkDataObject *data);
60  virtual vtkDataObject* GetVTKDataObject() const;
62 
69  unsigned long GetVTKDataObjectMTime() const;
70 
72 
74  const QModelIndexList qmil) const;
75  virtual QItemSelection VTKIndexSelectionToQItemSelection(
76  vtkSelection *vtksel) const;
78 
79  virtual void SetKeyColumnName(const char* name);
80 
81  virtual void SetColorColumnName(const char* name);
82 
84 
85  void setTree(vtkTree* t);
86  vtkTree* tree() const { return this->Tree; }
88 
89  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
90  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
91  Qt::ItemFlags flags(const QModelIndex &index) const;
92  QVariant headerData(int section, Qt::Orientation orientation,
93  int role = Qt::DisplayRole) const;
94  QModelIndex index(int row, int column,
95  const QModelIndex &parent = QModelIndex()) const;
96  QModelIndex parent(const QModelIndex &index) const;
97  int rowCount(const QModelIndex &parent = QModelIndex()) const;
98  int columnCount(const QModelIndex &parent = QModelIndex()) const;
99 
101 
104  Qt::DropActions supportedDragActions() const;
105  virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
106  virtual QStringList mimeTypes () const ;
108 
109 protected:
110  void treeModified();
111  void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index);
112 
115  unsigned long TreeMTime;
116  QVector<QModelIndex> VTKIndexToQtModelIndex;
117  QHash<QModelIndex, QVariant> IndexToDecoration;
118 
119 private:
120  vtkQtTreeModelAdapter(const vtkQtTreeModelAdapter &); // Not implemented
121  void operator=(const vtkQtTreeModelAdapter&); // Not implemented.
122 };
123 
124 #endif