VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkQtTreeModelAdapter.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00034 #ifndef __vtkQtTreeModelAdapter_h 00035 #define __vtkQtTreeModelAdapter_h 00036 00037 #include "vtkGUISupportQtModule.h" // For export macro 00038 #include "QVTKWin32Header.h" 00039 #include "vtkType.h" 00040 #include "vtkSelection.h" 00041 00042 #include "vtkQtAbstractModelAdapter.h" 00043 #include <QHash> 00044 #include <QMimeData> 00045 #include <QVector> 00046 00047 class vtkTree; 00048 class vtkAdjacentVertexIterator; 00049 00050 class VTKGUISUPPORTQT_EXPORT vtkQtTreeModelAdapter : public vtkQtAbstractModelAdapter 00051 { 00052 Q_OBJECT 00053 00054 public: 00055 vtkQtTreeModelAdapter(QObject *parent = 0, vtkTree* tree = 0); 00056 ~vtkQtTreeModelAdapter(); 00057 00059 00060 virtual void SetVTKDataObject(vtkDataObject *data); 00061 virtual vtkDataObject* GetVTKDataObject() const; 00063 00070 unsigned long GetVTKDataObjectMTime() const; 00071 00073 00074 virtual vtkSelection* QModelIndexListToVTKIndexSelection( 00075 const QModelIndexList qmil) const; 00076 virtual QItemSelection VTKIndexSelectionToQItemSelection( 00077 vtkSelection *vtksel) const; 00079 00080 virtual void SetKeyColumnName(const char* name); 00081 00082 virtual void SetColorColumnName(const char* name); 00083 00085 00086 void setTree(vtkTree* t); 00087 vtkTree* tree() const { return this->Tree; } 00089 00090 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00091 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); 00092 Qt::ItemFlags flags(const QModelIndex &index) const; 00093 QVariant headerData(int section, Qt::Orientation orientation, 00094 int role = Qt::DisplayRole) const; 00095 QModelIndex index(int row, int column, 00096 const QModelIndex &parent = QModelIndex()) const; 00097 QModelIndex parent(const QModelIndex &index) const; 00098 int rowCount(const QModelIndex &parent = QModelIndex()) const; 00099 int columnCount(const QModelIndex &parent = QModelIndex()) const; 00100 00102 00105 Qt::DropActions supportedDragActions() const; 00106 virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const; 00107 virtual QStringList mimeTypes () const ; 00109 00110 protected: 00111 void treeModified(); 00112 void GenerateVTKIndexToQtModelIndex(vtkIdType vtk_index, QModelIndex qmodel_index); 00113 00114 vtkTree* Tree; 00115 vtkAdjacentVertexIterator* ChildIterator; 00116 unsigned long TreeMTime; 00117 QVector<QModelIndex> VTKIndexToQtModelIndex; 00118 QHash<QModelIndex, QVariant> IndexToDecoration; 00119 00120 private: 00121 vtkQtTreeModelAdapter(const vtkQtTreeModelAdapter &); // Not implemented 00122 void operator=(const vtkQtTreeModelAdapter&); // Not implemented. 00123 }; 00124 00125 #endif