MatrixModel.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : MatrixModel.h
00003     Project              : QtiPlot
00004 --------------------------------------------------------------------
00005     Copyright            : (C) 2007 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : QtiPlot's matrix model
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 
00030 #ifndef IMAGEMODEL_H
00031 #define IMAGEMODEL_H
00032 
00033 #include <QAbstractTableModel>
00034 #include <QVector>
00035 
00036 class Matrix;
00037 
00038 class MatrixModel : public QAbstractTableModel
00039 {
00040     Q_OBJECT
00041 
00042 public:
00043     MatrixModel(int rows = 32, int cols = 32, QObject *parent = 0);
00044     MatrixModel(const QImage& image, QObject *parent);
00045 
00046     Qt::ItemFlags flags( const QModelIndex & index ) const;
00047 
00048     int rowCount(const QModelIndex &parent = QModelIndex()) const;
00049     int columnCount(const QModelIndex &parent = QModelIndex()) const;
00050 
00051     bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
00052     bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
00053     bool removeColumns ( int column, int count, const QModelIndex & parent = QModelIndex());
00054     bool insertColumns ( int column, int count, const QModelIndex & parent = QModelIndex());
00055 
00056     double cell(int row, int col);
00057     void setCell(int row, int col, double val);
00058 
00059     QString text(int row, int col);
00060     void setText(int row, int col, const QString&);
00061 
00062     QString saveToString();
00063     QImage renderImage();
00064     
00065     double data(int row, int col) const;
00066     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00067     bool setData(const QModelIndex & index, const QVariant & value, int role);
00068 
00069     double* dataVector(){return d_data.data();};
00070     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00071     void setDataVector(const QVector<double>& data);
00072 
00073 private:
00074     int d_rows, d_cols;
00075     QVector<double> d_data;
00076     Matrix *d_matrix;
00077 };
00078 
00079 #endif

Generated on Thu Feb 7 13:59:27 2008 for QtiPlot by  doxygen 1.5.4