MatrixModel.h
Go to the documentation of this file.
/***************************************************************************
File : MatrixModel.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2007 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : QtiPlot's matrix model
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef MATRIXMODEL_H
#define MATRIXMODEL_H
#include <QAbstractTableModel>
#include <QVector>
#include <QLocale>
#include <QSize>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_permutation.h>
class Matrix;
class MatrixModel : public QAbstractTableModel
{
Q_OBJECT
public:
MatrixModel(int rows = 32, int cols = 32, QObject *parent = 0);
MatrixModel(const QImage& image, QObject *parent);
~MatrixModel(){free(d_data);};
Matrix *matrix(){return d_matrix;};
Qt::ItemFlags flags( const QModelIndex & index ) const;
bool canResize(int rows, int cols);
void setDimensions(int rows, int cols);
void resample(int rows, int cols, int method = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
void setRowCount(int rows);
int columnCount(const QModelIndex &parent = QModelIndex()) const;
void setColumnCount(int cols);
bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
bool removeColumns(int column, int count, const QModelIndex & parent = QModelIndex());
bool insertColumns(int column, int count, const QModelIndex & parent = QModelIndex());
double x(int col) const;
double y(int row) const;
double cell(int row, int col);
void setCell(int row, int col, double val);
QString text(int row, int col);
void setText(int row, int col, const QString&);
QImage renderImage();
double data(int row, int col) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex & index, const QVariant & value, int role);
double* dataVector(){return d_data;};
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void setImage(const QImage& image);
bool importASCII(const QString &fname, const QString &sep, int ignoredLines, bool stripSpaces,
bool simplifySpaces, const QString& commentString, int importAs,
const QLocale& locale, int endLineChar = 0, int maxRows = -1);
void setLocale(const QLocale& locale){d_locale = locale;};
void setNumericFormat(char f, int prec);
bool initWorkspace();
void invert();
void transpose();
void flipVertically();
void flipHorizontally();
void rotate90(bool clockwise);
void fft(bool inverse);
void clear(int startRow = 0, int endRow = -1, int startCol = 0, int endCol = -1);
bool calculate(int startRow = 0, int endRow = -1, int startCol = 0, int endCol = -1);
bool muParserCalculate(int startRow = 0, int endRow = -1, int startCol = 0, int endCol = -1);
double* dataCopy(int startRow = 0, int endRow = -1, int startCol = 0, int endCol = -1);
void pasteData(double *clipboardBuffer, int topRow, int leftCol, int rows, int cols);
private:
void init();
int d_rows, d_cols;
double *d_data;
Matrix *d_matrix;
char d_txt_format;
int d_num_precision;
QLocale d_locale;
gsl_matrix *d_direct_matrix, *d_inv_matrix;
gsl_permutation *d_inv_perm;
QSize d_data_block_size;
};
#endif
MatrixModel::clear
void clear(int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
Definition: MatrixModel.cpp:756
MatrixModel
Definition: MatrixModel.h:43
MatrixModel::matrix
Matrix * matrix()
Definition: MatrixModel.h:52
MatrixModel::flipVertically
void flipVertically()
Definition: MatrixModel.cpp:628
MatrixModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: MatrixModel.cpp:118
MatrixModel::insertRows
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
Definition: MatrixModel.cpp:425
MatrixModel::setLocale
void setLocale(const QLocale &locale)
Definition: MatrixModel.h:96
MatrixModel::MatrixModel
MatrixModel(int rows=32, int cols=32, QObject *parent=0)
Definition: MatrixModel.cpp:51
MatrixModel::d_direct_matrix
gsl_matrix * d_direct_matrix
Pointers to GSL matrices used during inversion operations.
Definition: MatrixModel.h:125
MatrixModel::fft
void fft(bool inverse)
Definition: MatrixModel.cpp:941
MatrixModel::~MatrixModel
~MatrixModel()
Definition: MatrixModel.h:50
MatrixModel::rotate90
void rotate90(bool clockwise)
Definition: MatrixModel.cpp:670
MatrixModel::d_txt_format
char d_txt_format
Format code for displaying numbers.
Definition: MatrixModel.h:118
MatrixModel::flipHorizontally
void flipHorizontally()
Definition: MatrixModel.cpp:649
MatrixModel::init
void init()
Definition: MatrixModel.cpp:81
MatrixModel::transpose
void transpose()
Definition: MatrixModel.cpp:605
MatrixModel::setCell
void setCell(int row, int col, double val)
Definition: MatrixModel.cpp:183
MatrixModel::cell
double cell(int row, int col)
Definition: MatrixModel.cpp:174
MatrixModel::initWorkspace
bool initWorkspace()
Definition: MatrixModel.cpp:705
MatrixModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const
Definition: MatrixModel.cpp:110
MatrixModel::importASCII
bool importASCII(const QString &fname, const QString &sep, int ignoredLines, bool stripSpaces, bool simplifySpaces, const QString &commentString, int importAs, const QLocale &locale, int endLineChar=0, int maxRows=-1)
Definition: MatrixModel.cpp:486
MatrixModel::d_inv_perm
gsl_permutation * d_inv_perm
Pointer to a GSL permutation used during inversion operations.
Definition: MatrixModel.h:127
MatrixModel::d_cols
int d_cols
Definition: MatrixModel.h:114
MatrixModel::data
double data(int row, int col) const
Definition: MatrixModel.cpp:222
MatrixModel::insertColumns
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Definition: MatrixModel.cpp:399
MatrixModel::d_data
double * d_data
Definition: MatrixModel.h:115
MatrixModel::d_locale
QLocale d_locale
Locale used to display data.
Definition: MatrixModel.h:122
MatrixModel::calculate
bool calculate(int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
Definition: MatrixModel.cpp:880
MatrixModel::pasteData
void pasteData(double *clipboardBuffer, int topRow, int leftCol, int rows, int cols)
Definition: MatrixModel.cpp:1004
MatrixModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role)
Definition: MatrixModel.cpp:316
MatrixModel::d_data_block_size
QSize d_data_block_size
Definition: MatrixModel.h:128
MatrixModel::d_matrix
Matrix * d_matrix
Definition: MatrixModel.h:116
MatrixModel::d_num_precision
int d_num_precision
Number of significant digits.
Definition: MatrixModel.h:120
Matrix
Matrix worksheet class.
Definition: Matrix.h:57
MatrixModel::setText
void setText(int row, int col, const QString &)
Definition: MatrixModel.cpp:206
MatrixModel::text
QString text(int row, int col)
Definition: MatrixModel.cpp:192
MatrixModel::canResize
bool canResize(int rows, int cols)
Definition: MatrixModel.cpp:354
MatrixModel::renderImage
QImage renderImage()
Definition: MatrixModel.cpp:464
MatrixModel::muParserCalculate
bool muParserCalculate(int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
Definition: MatrixModel.cpp:798
MatrixModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: MatrixModel.cpp:123
MatrixModel::removeRows
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Definition: MatrixModel.cpp:446
MatrixModel::setImage
void setImage(const QImage &image)
Definition: MatrixModel.cpp:96
MatrixModel::d_inv_matrix
gsl_matrix * d_inv_matrix
Definition: MatrixModel.h:125
MatrixModel::setRowCount
void setRowCount(int rows)
Definition: MatrixModel.cpp:128
MatrixModel::invert
void invert()
Definition: MatrixModel.cpp:724
MatrixModel::x
double x(int col) const
Definition: MatrixModel.cpp:231
MatrixModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: MatrixModel.cpp:261
MatrixModel::dataCopy
double * dataCopy(int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
Definition: MatrixModel.cpp:773
MatrixModel::setNumericFormat
void setNumericFormat(char f, int prec)
Definition: MatrixModel.cpp:596
MatrixModel::removeColumns
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Definition: MatrixModel.cpp:380
MatrixModel::d_rows
int d_rows
Definition: MatrixModel.h:114
MatrixModel::setColumnCount
void setColumnCount(int cols)
Definition: MatrixModel.cpp:143
MatrixModel::setDimensions
void setDimensions(int rows, int cols)
Definition: MatrixModel.cpp:158
MatrixModel::dataVector
double * dataVector()
Definition: MatrixModel.h:87
MatrixModel::y
double y(int row) const
Definition: MatrixModel.cpp:246
MatrixModel::resample
void resample(int rows, int cols, int method=0)
Definition: MatrixModel.cpp:1024