00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00034 #ifndef __vtkQtTreeModelAdapter_h
00035 #define __vtkQtTreeModelAdapter_h
00036
00037 #include "QVTKWin32Header.h"
00038 #include "vtkType.h"
00039 #include "vtkSelection.h"
00040
00041 #include "vtkQtAbstractModelAdapter.h"
00042 #include <QHash>
00043
00044 class vtkTree;
00045 class vtkAdjacentVertexIterator;
00046
00047 class QVTK_EXPORT vtkQtTreeModelAdapter : public vtkQtAbstractModelAdapter
00048 {
00049 Q_OBJECT
00050
00051 public:
00052 vtkQtTreeModelAdapter(QObject *parent = 0, vtkTree* tree = 0);
00053 ~vtkQtTreeModelAdapter();
00054
00056
00057 virtual void SetVTKDataObject(vtkDataObject *data);
00058 virtual vtkDataObject* GetVTKDataObject() const;
00060
00061 vtkIdType IdToPedigree(vtkIdType id) const;
00062 vtkIdType PedigreeToId(vtkIdType pedigree) const;
00063 QModelIndex PedigreeToQModelIndex(vtkIdType id) const;
00064 vtkIdType QModelIndexToPedigree(QModelIndex index) const;
00065
00066 virtual void SetKeyColumnName(const char* name);
00067
00069
00070 void setTree(vtkTree* t);
00071 vtkTree* tree() const { return this->Tree; }
00073
00074 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00075 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00076 Qt::ItemFlags flags(const QModelIndex &index) const;
00077 QVariant headerData(int section, Qt::Orientation orientation,
00078 int role = Qt::DisplayRole) const;
00079 QModelIndex index(vtkIdType index) const;
00080 QModelIndex index(int row, int column,
00081 const QModelIndex &parent = QModelIndex()) const;
00082 QModelIndex parent(const QModelIndex &index) const;
00083 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00084 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00085
00086 protected:
00087 void treeModified();
00088 void GenerateHashMap(vtkIdType & row, vtkIdType id, QModelIndex index);
00089
00090 vtkTree* Tree;
00091 vtkAdjacentVertexIterator* ChildIterator;
00092 unsigned long TreeMTime;
00093 QHash<vtkIdType, vtkIdType> IdToPedigreeHash;
00094 QHash<vtkIdType, QModelIndex> PedigreeToIndexHash;
00095 QHash<QModelIndex, vtkIdType> IndexToIdHash;
00096 QHash<vtkIdType, vtkIdType> RowToPedigreeHash;
00097
00098 QHash<QModelIndex, QVariant> IndexToDecoration;
00099
00100 private:
00101 vtkQtTreeModelAdapter(const vtkQtTreeModelAdapter &);
00102 void operator=(const vtkQtTreeModelAdapter&);
00103 };
00104
00105 #endif