VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkQtAbstractModelAdapter.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 __vtkQtAbstractModelAdapter_h 00035 #define __vtkQtAbstractModelAdapter_h 00036 00037 #include "QVTKWin32Header.h" 00038 #include <QAbstractItemModel> 00039 #include <QItemSelection> 00040 00041 class vtkDataObject; 00042 class vtkSelection; 00043 class QItemSelection; 00044 class QVTK_EXPORT vtkQtAbstractModelAdapter : public QAbstractItemModel 00045 { 00046 Q_OBJECT 00047 00048 public: 00049 00050 // The view types. 00051 enum { 00052 FULL_VIEW, 00053 DATA_VIEW 00054 }; 00055 00056 vtkQtAbstractModelAdapter(QObject* p) : 00057 QAbstractItemModel(p), 00058 ViewType(FULL_VIEW), 00059 KeyColumn(-1), 00060 ColorColumn(-1), 00061 DataStartColumn(-1), 00062 DataEndColumn(-1) 00063 { } 00064 00066 00067 virtual void SetVTKDataObject(vtkDataObject *data) = 0; 00068 virtual vtkDataObject* GetVTKDataObject() const = 0; 00070 00072 00073 virtual vtkSelection* QModelIndexListToVTKIndexSelection( 00074 const QModelIndexList qmil) const = 0; 00075 virtual QItemSelection VTKIndexSelectionToQItemSelection( 00076 vtkSelection *vtksel) const = 0; 00078 00080 00083 virtual void SetViewType(int type) { this->ViewType = type; } 00084 virtual int GetViewType() { return this->ViewType; } 00086 00088 00091 virtual void SetKeyColumn(int col) { this->KeyColumn = col; } 00092 virtual int GetKeyColumn() { return this->KeyColumn; } 00093 virtual void SetKeyColumnName(const char* name) = 0; 00095 00097 00101 virtual void SetColorColumn(int col) { this->ColorColumn = col; } 00102 virtual int GetColorColumn() { return this->ColorColumn; } 00103 virtual void SetColorColumnName(const char* name) = 0; 00105 00107 00110 virtual void SetDataColumnRange(int c1, int c2) 00111 { this->DataStartColumn = c1; this->DataEndColumn = c2; } 00113 00114 // We make the reset() method public because it isn't always possible for 00115 // an adapter to know when its input has changed, so it must be callable 00116 // by an outside entity. 00117 void reset() { QAbstractItemModel::reset(); } 00118 00119 00120 signals: 00121 void modelChanged(); 00122 00123 protected: 00124 00128 virtual int ModelColumnToFieldDataColumn(int col) const; 00129 00130 int ViewType; 00131 int KeyColumn; 00132 int ColorColumn; 00133 int DataStartColumn; 00134 int DataEndColumn; 00135 }; 00136 00137 #endif