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
00046 class QVTK_EXPORT vtkQtTreeModelAdapter : public vtkQtAbstractModelAdapter
00047 {
00048 Q_OBJECT
00049
00050 public:
00051 vtkQtTreeModelAdapter(QObject *parent = 0, vtkTree* tree = 0);
00052 ~vtkQtTreeModelAdapter();
00053
00055
00056 virtual void SetVTKDataObject(vtkDataObject *data);
00057 virtual vtkDataObject* GetVTKDataObject() const;
00059
00060 vtkIdType IdToPedigree(vtkIdType id) const;
00061 vtkIdType PedigreeToId(vtkIdType pedigree) const;
00062 QModelIndex PedigreeToQModelIndex(vtkIdType id) const;
00063 vtkIdType QModelIndexToPedigree(QModelIndex index) const;
00064
00065 virtual void SetKeyColumnName(const char* name);
00066
00068
00069 void setTree(vtkTree* t);
00070 vtkTree* tree() const { return this->Tree; }
00072
00073 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00074 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00075 Qt::ItemFlags flags(const QModelIndex &index) const;
00076 QVariant headerData(int section, Qt::Orientation orientation,
00077 int role = Qt::DisplayRole) const;
00078 QModelIndex index(vtkIdType index) const;
00079 QModelIndex index(int row, int column,
00080 const QModelIndex &parent = QModelIndex()) const;
00081 QModelIndex parent(const QModelIndex &index) const;
00082 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00083 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00084
00085 protected:
00086 void treeModified();
00087 void GenerateHashMap(vtkIdType & row, vtkIdType id, QModelIndex index);
00088
00089 vtkTree* Tree;
00090 unsigned long TreeMTime;
00091 QHash<vtkIdType, vtkIdType> IdToPedigreeHash;
00092 QHash<vtkIdType, QModelIndex> PedigreeToIndexHash;
00093 QHash<QModelIndex, vtkIdType> IndexToIdHash;
00094 QHash<vtkIdType, vtkIdType> RowToPedigreeHash;
00095
00096 QHash<QModelIndex, QVariant> IndexToDecoration;
00097
00098 private:
00099 vtkQtTreeModelAdapter(const vtkQtTreeModelAdapter &);
00100 void operator=(const vtkQtTreeModelAdapter&);
00101 };
00102
00103 #endif