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 "vtkGUISupportQtModule.h" // For export macro 00038 #include "QVTKWin32Header.h" 00039 #include <QAbstractItemModel> 00040 #include <QItemSelection> 00041 00042 class vtkDataObject; 00043 class vtkSelection; 00044 class QItemSelection; 00045 class VTKGUISUPPORTQT_EXPORT vtkQtAbstractModelAdapter : public QAbstractItemModel 00046 { 00047 Q_OBJECT 00048 00049 public: 00050 00051 // The view types. 00052 enum { 00053 FULL_VIEW, 00054 DATA_VIEW 00055 }; 00056 00057 vtkQtAbstractModelAdapter(QObject* p) : 00058 QAbstractItemModel(p), 00059 ViewType(FULL_VIEW), 00060 KeyColumn(-1), 00061 ColorColumn(-1), 00062 DataStartColumn(-1), 00063 DataEndColumn(-1) 00064 { } 00065 00067 00068 virtual void SetVTKDataObject(vtkDataObject *data) = 0; 00069 virtual vtkDataObject* GetVTKDataObject() const = 0; 00071 00073 00074 virtual vtkSelection* QModelIndexListToVTKIndexSelection( 00075 const QModelIndexList qmil) const = 0; 00076 virtual QItemSelection VTKIndexSelectionToQItemSelection( 00077 vtkSelection *vtksel) const = 0; 00079 00081 00084 virtual void SetViewType(int type) { this->ViewType = type; } 00085 virtual int GetViewType() { return this->ViewType; } 00087 00089 00092 virtual void SetKeyColumn(int col) { this->KeyColumn = col; } 00093 virtual int GetKeyColumn() { return this->KeyColumn; } 00094 virtual void SetKeyColumnName(const char* name) = 0; 00096 00098 00102 virtual void SetColorColumn(int col) { this->ColorColumn = col; } 00103 virtual int GetColorColumn() { return this->ColorColumn; } 00104 virtual void SetColorColumnName(const char* name) = 0; 00106 00108 00111 virtual void SetDataColumnRange(int c1, int c2) 00112 { this->DataStartColumn = c1; this->DataEndColumn = c2; } 00114 00115 // We make the reset() method public because it isn't always possible for 00116 // an adapter to know when its input has changed, so it must be callable 00117 // by an outside entity. 00118 void reset() { QAbstractItemModel::reset(); } 00119 00120 00121 signals: 00122 void modelChanged(); 00123 00124 protected: 00125 00129 virtual int ModelColumnToFieldDataColumn(int col) const; 00130 00131 int ViewType; 00132 int KeyColumn; 00133 int ColorColumn; 00134 int DataStartColumn; 00135 int DataEndColumn; 00136 }; 00137 00138 #endif