• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/GUISupport/Qt/vtkQtAbstractModelAdapter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkQtAbstractModelAdapter.h,v $
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 "vtkType.h"
00039 #include "vtkSelection.h"
00040 class vtkDataObject;
00041 
00042 #include <QAbstractItemModel>
00043 
00044 class QModelIndex;
00045 
00046 class QVTK_EXPORT vtkQtAbstractModelAdapter : public QAbstractItemModel
00047 {
00048   Q_OBJECT
00049 
00050 public:
00051 
00052   // The view types.
00053   enum {
00054     FULL_VIEW,
00055     DATA_VIEW,
00056     METADATA_VIEW
00057   };
00058 
00059   vtkQtAbstractModelAdapter(QObject* p) : 
00060     QAbstractItemModel(p), 
00061     ViewType(FULL_VIEW),
00062     KeyColumn(-1),
00063     DataStartColumn(-1),
00064     DataEndColumn(-1),
00065     ViewRows(true)
00066     { }
00067 
00069 
00070   virtual void SetVTKDataObject(vtkDataObject *data) = 0;
00071   virtual vtkDataObject* GetVTKDataObject() const = 0;
00073   
00075 
00076   virtual vtkIdType IdToPedigree(vtkIdType id) const = 0;
00077   virtual vtkIdType PedigreeToId(vtkIdType pedigree) const = 0;
00078   virtual QModelIndex PedigreeToQModelIndex(vtkIdType id) const = 0;
00079   virtual vtkIdType QModelIndexToPedigree(QModelIndex index) const = 0;
00081 
00083 
00087   virtual void SetViewType(int type) { this->ViewType = type; }
00088   virtual int GetViewType() { return this->ViewType; }
00090 
00092 
00095   virtual void SetKeyColumn(int col) { this->KeyColumn = col; }
00096   virtual int GetKeyColumn() { return this->KeyColumn; }
00097   virtual void SetKeyColumnName(const char* name) = 0;
00099 
00101 
00104   virtual void SetDataColumnRange(int c1, int c2)
00105     { this->DataStartColumn = c1; this->DataEndColumn = c2; }
00107 
00108   virtual bool GetViewRows()
00109     { return this->ViewRows; }
00110 
00111   // We make the reset() method public because it isn't always possible for
00112   // an adapter to know when its input has changed, so it must be callable
00113   // by an outside entity.
00114   void reset() { QAbstractItemModel::reset(); }
00115 
00116 public slots:
00118 
00122   void SetViewRows(bool b)
00123     { this->ViewRows = b; this->reset(); emit this->modelChanged(); }
00125 
00126 signals:
00127   void modelChanged();
00128   
00129 protected:
00130   virtual int ModelColumnToFieldDataColumn(int col) const;
00131 
00132   int ViewType;
00133   int KeyColumn;
00134   int DataStartColumn;
00135   int DataEndColumn;
00136   bool ViewRows;
00137 };
00138 
00139 #endif

Generated by  doxygen 1.7.1