MatrixModel Class Reference

`#include <MatrixModel.h>`

Inheritance diagram for MatrixModel:

## Public Member Functions

bool | calculate (int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
bool | canResize (int rows, int cols)
double | cell (int row, int col)
void | clear (int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
int | columnCount (const QModelIndex &parent=QModelIndex()) const
double | data (int row, int col) const
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const
double * | dataCopy (int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
double * | dataVector ()
void | fft (bool inverse)
Qt::ItemFlags | flags (const QModelIndex &index) const
void | flipHorizontally ()
void | flipVertically ()
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
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)
bool | initWorkspace ()
bool | insertColumns (int column, int count, const QModelIndex &parent=QModelIndex())
bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
void | invert ()
Matrix * | matrix ()
| MatrixModel (int rows=32, int cols=32, QObject *parent=0)
| MatrixModel (const QImage &image, QObject *parent)
bool | muParserCalculate (int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
void | pasteData (double *clipboardBuffer, int topRow, int leftCol, int rows, int cols)
bool | removeColumns (int column, int count, const QModelIndex &parent=QModelIndex())
bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
QImage | renderImage ()
void | resample (int rows, int cols, int method=0)
void | rotate90 (bool clockwise)
int | rowCount (const QModelIndex &parent=QModelIndex()) const
void | setCell (int row, int col, double val)
void | setColumnCount (int cols)
bool | setData (const QModelIndex &index, const QVariant &value, int role)
void | setDimensions (int rows, int cols)
void | setImage (const QImage &image)
void | setLocale (const QLocale &locale)
void | setNumericFormat (char f, int prec)
void | setRowCount (int rows)
void | setText (int row, int col, const QString &)
QString | text (int row, int col)
void | transpose ()
double | x (int col) const
double | y (int row) const
| ~MatrixModel ()

## Private Member Functions

void | init ()

## Private Attributes

int | d_cols
double * | d_data
QSize | d_data_block_size
gsl_matrix * | d_direct_matrix
| Pointers to GSL matrices used during inversion operations. More...
gsl_matrix * | d_inv_matrix
gsl_permutation * | d_inv_perm
| Pointer to a GSL permutation used during inversion operations. More...
QLocale | d_locale
| Locale used to display data. More...
Matrix * | d_matrix
int | d_num_precision
| Number of significant digits. More...
int | d_rows
char | d_txt_format
| Format code for displaying numbers. More...

## Constructor & Destructor Documentation

MatrixModel::MatrixModel | ( | int | rows = `32`,
|  | int | cols = `32`,
|  | QObject * | parent = `0`
| ) |  |

References canResize(), cell(), d_cols, d_data, d_locale, d_matrix, d_num_precision, d_rows, d_txt_format, init(), Matrix::precision(), and Matrix::textFormat().

MatrixModel::MatrixModel | ( | const QImage & | image,
|  | QObject * | parent
| ) |  |

References init(), and setImage().

MatrixModel::~MatrixModel | ( |  | ) |

inline

References d_data.

## Member Function Documentation

bool MatrixModel::calculate | ( | int | startRow = `0`,
|  | int | endRow = `-1`,
|  | int | startCol = `0`,
|  | int | endCol = `-1`
| ) |  |

References Script::compile(), d_cols, d_data, d_matrix, d_rows, Matrix::dx(), Matrix::dy(), Script::eval(), Matrix::formula(), ScriptingEnv::newScript(), scripted::scriptingEnv(), setColumnCount(), Script::setDouble(), setRowCount(), Matrix::xStart(), and Matrix::yStart().

Referenced by Matrix::calculate(), and MatrixUndoCommand::redo().

bool MatrixModel::canResize | ( | int | rows,
|  | int | cols
| ) |  |

References d_data, d_data_block_size, and d_matrix.

Referenced by Matrix::insertColumn(), insertColumns(), Matrix::insertRow(), insertRows(), MatrixModel(), MatrixSmoothCommand::redo(), Matrix::resample(), Matrix::setDimensions(), and setImage().

double MatrixModel::cell | ( | int | row,
|  | int | col
| ) |  |

References d_cols, d_data, and d_rows.

Referenced by Matrix::cell(), fft(), insertColumns(), Matrix::integrate(), MatrixModel(), ApplicationWindow::matrixToTable(), pasteData(), resample(), rotate90(), and setImage().

void MatrixModel::clear | ( | int | startRow = `0`,
|  | int | endRow = `-1`,
|  | int | startCol = `0`,
|  | int | endCol = `-1`
| ) |  |

References d_cols, d_data, and d_rows.

Referenced by PreviewMatrix::clear(), Matrix::clearSelection(), and MatrixUndoCommand::redo().

int MatrixModel::columnCount | ( | const QModelIndex & | parent = `QModelIndex()` | ) | const

References d_cols.

Referenced by Matrix::numCols(), PreviewMatrix::PreviewMatrix(), MatrixSmoothCommand::redo(), Matrix::sizeToString(), MatrixDeleteRowsCommand::undo(), MatrixDeleteColsCommand::undo(), MatrixSmoothCommand::undo(), MatrixUndoCommand::undo(), and MatrixPasteCommand::undo().

double MatrixModel::data | ( | int | row,
|  | int | col
| ) |  | const

References d_cols, d_data, and d_rows.

Referenced by flipHorizontally(), flipVertically(), rotate90(), and transpose().

QVariant MatrixModel::data | ( | const QModelIndex & | index,
|  | int | role = `Qt::DisplayRole`
| ) |  | const

References d_cols, d_data, d_locale, d_matrix, d_num_precision, d_txt_format, Matrix::precision(), and Matrix::textFormat().

double * MatrixModel::dataCopy | ( | int | startRow = `0`,
|  | int | endRow = `-1`,
|  | int | startCol = `0`,
|  | int | endCol = `-1`
| ) |  |

References d_cols, d_data, and d_rows.

Referenced by Matrix::calculate(), Matrix::clearSelection(), Matrix::deleteSelectedColumns(), Matrix::deleteSelectedRows(), Matrix::fft(), Matrix::importASCII(), Matrix::importImage(), Matrix::muParserCalculate(), Matrix::pasteSelection(), Matrix::resample(), Matrix::setDimensions(), and Matrix::smooth().

double* MatrixModel::dataVector | ( |  | ) |

inline

References d_data.

Referenced by Matrix::copy(), Matrix::determinant(), Matrix::isEmpty(), QwtHistogram::loadDataFromMatrix(), Matrix::save(), MatrixDeleteRowsCommand::undo(), MatrixDeleteColsCommand::undo(), MatrixSetSizeCommand::undo(), MatrixSmoothCommand::undo(), MatrixUndoCommand::undo(), and MatrixPasteCommand::undo().

void MatrixModel::fft | ( | bool | inverse | ) |

References Matrix::allocateMatrixData(), cell(), d_cols, d_data, d_matrix, d_rows, fft2d(), fft2d_inv(), Matrix::freeMatrixData(), and Matrix::resetView().

Referenced by Matrix::fft(), and MatrixFftCommand::redo().

Qt::ItemFlags MatrixModel::flags | ( | const QModelIndex & | index | ) | const

void MatrixModel::flipHorizontally | ( |  | ) |

References d_cols, d_data, d_matrix, d_rows, data(), Matrix::freeWorkspace(), and Matrix::initWorkspace().

Referenced by MatrixSymmetryOperation::redo(), and MatrixSymmetryOperation::undo().

void MatrixModel::flipVertically | ( |  | ) |

References d_cols, d_data, d_matrix, d_rows, data(), Matrix::freeWorkspace(), and Matrix::initWorkspace().

Referenced by MatrixSymmetryOperation::redo(), and MatrixSymmetryOperation::undo().

QVariant MatrixModel::headerData | ( | int | section,
|  | Qt::Orientation | orientation,
|  | int | role = `Qt::DisplayRole`
| ) |  | const

References Matrix::ColumnRow, d_locale, d_matrix, d_num_precision, d_txt_format, Matrix::dx(), Matrix::dy(), Matrix::headerViewType(), Matrix::precision(), Matrix::textFormat(), Matrix::xEnd(), Matrix::xStart(), Matrix::yEnd(), and Matrix::yStart().

Referenced by Matrix::print().

bool MatrixModel::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`
| ) |  |

References d_cols, d_locale, d_matrix, d_rows, Matrix::NewColumns, Matrix::NewRows, Matrix::Overwrite, MdiSubWindow::parseAsciiFile(), Matrix::resetView(), setCell(), setColumnCount(), setRowCount(), and setText().

Referenced by PreviewMatrix::importASCII(), Matrix::importASCII(), and MatrixImportAsciiCommand::redo().

void MatrixModel::init | ( |  | ) |

private

References d_cols, d_data, d_data_block_size, d_direct_matrix, d_inv_matrix, d_inv_perm, d_locale, d_num_precision, d_rows, and d_txt_format.

Referenced by MatrixModel().

bool MatrixModel::initWorkspace | ( |  | ) |

References d_cols, d_direct_matrix, d_inv_matrix, d_inv_perm, d_matrix, and d_rows.

Referenced by invert(), and Matrix::invert().

bool MatrixModel::insertColumns | ( | int | column,
|  | int | count,
|  | const QModelIndex & | parent = `QModelIndex()`
| ) |  |

References canResize(), cell(), d_cols, d_data, and d_rows.

Referenced by pasteData(), MatrixInsertColCommand::redo(), setColumnCount(), and MatrixDeleteColsCommand::undo().

bool MatrixModel::insertRows | ( | int | row,
|  | int | count,
|  | const QModelIndex & | parent = `QModelIndex()`
| ) |  |

References canResize(), d_cols, d_data, and d_rows.

Referenced by pasteData(), MatrixInsertRowCommand::redo(), setData(), setDimensions(), setRowCount(), and MatrixDeleteRowsCommand::undo().

void MatrixModel::invert | ( |  | ) |

References d_cols, d_data, d_direct_matrix, d_inv_matrix, d_inv_perm, d_rows, and initWorkspace().

Referenced by MatrixSymmetryOperation::redo(), and MatrixSymmetryOperation::undo().

Matrix* MatrixModel::matrix | ( |  | ) |

inline

References d_matrix.

Referenced by MatrixDeleteColsCommand::MatrixDeleteColsCommand(), MatrixDeleteRowsCommand::MatrixDeleteRowsCommand(), MatrixEditCellCommand::MatrixEditCellCommand(), MatrixInsertColCommand::MatrixInsertColCommand(), MatrixInsertRowCommand::MatrixInsertRowCommand(), MatrixPasteCommand::MatrixPasteCommand(), MatrixResampleCommand::MatrixResampleCommand(), MatrixSetSizeCommand::MatrixSetSizeCommand(), MatrixSmoothCommand::MatrixSmoothCommand(), MatrixSymmetryOperation::MatrixSymmetryOperation(), MatrixUndoCommand::MatrixUndoCommand(), muParserCalculate(), MatrixEditCellCommand::redo(), MatrixSetSizeCommand::redo(), MatrixUndoCommand::redo(), MatrixSetImageCommand::redo(), MatrixSymmetryOperation::redo(), MatrixPasteCommand::redo(), MatrixEditCellCommand::undo(), MatrixSetSizeCommand::undo(), MatrixSmoothCommand::undo(), MatrixUndoCommand::undo(), MatrixSetImageCommand::undo(), MatrixSymmetryOperation::undo(), and MatrixPasteCommand::undo().

bool MatrixModel::muParserCalculate | ( | int | startRow = `0`,
|  | int | endRow = `-1`,
|  | int | startCol = `0`,
|  | int | endCol = `-1`
| ) |  |

References muParserScript::codeLines(), muParserScript::compile(), d_cols, d_data, d_matrix, d_rows, muParserScript::defineVariable(), Matrix::dx(), Matrix::dy(), muParserScript::eval(), muParserScript::evalSingleLine(), Matrix::formula(), matrix(), scripted::scriptingEnv(), setColumnCount(), setRowCount(), x(), Matrix::xStart(), y(), and Matrix::yStart().

Referenced by Matrix::muParserCalculate(), and MatrixUndoCommand::redo().

void MatrixModel::pasteData | ( | double * | clipboardBuffer,
|  | int | topRow,
|  | int | leftCol,
|  | int | rows,
|  | int | cols
| ) |  |

References cell(), d_cols, d_data, d_rows, insertColumns(), and insertRows().

Referenced by Matrix::pasteSelection(), and MatrixPasteCommand::redo().

bool MatrixModel::removeColumns | ( | int | column,
|  | int | count,
|  | const QModelIndex & | parent = `QModelIndex()`
| ) |  |

References d_cols, d_data, d_data_block_size, and d_rows.

Referenced by Matrix::deleteSelectedColumns(), MatrixDeleteColsCommand::redo(), setColumnCount(), and MatrixInsertColCommand::undo().

bool MatrixModel::removeRows | ( | int | row,
|  | int | count,
|  | const QModelIndex & | parent = `QModelIndex()`
| ) |  |

References d_cols, d_data, d_data_block_size, and d_rows.

Referenced by Matrix::deleteSelectedRows(), MatrixDeleteRowsCommand::redo(), setDimensions(), setRowCount(), and MatrixInsertRowCommand::undo().

QImage MatrixModel::renderImage | ( |  | ) |

References Matrix::colorMap(), Matrix::colorRange(), d_cols, d_data, d_matrix, and d_rows.

Referenced by Matrix::eventFilter(), Matrix::exportRasterImage(), Matrix::exportSVG(), Matrix::exportToFile(), Matrix::exportVector(), Matrix::image(), Matrix::print(), Matrix::resetView(), Matrix::setColorMap(), Matrix::setDefaultColorMap(), Matrix::setGrayScale(), Matrix::setRainbowColorMap(), and Matrix::setViewType().

void MatrixModel::resample | ( | int | rows,
|  | int | cols,
|  | int | method = `0`
| ) |  |

References Matrix::Bilinear, cell(), d_cols, d_matrix, d_rows, Matrix::resetView(), setCell(), and setDimensions().

Referenced by MatrixSmoothCommand::redo(), and MatrixResampleCommand::redo().

void MatrixModel::rotate90 | ( | bool | clockwise | ) |

References cell(), d_cols, d_data, d_matrix, d_rows, data(), Matrix::freeWorkspace(), and Matrix::initWorkspace().

Referenced by MatrixSymmetryOperation::redo(), and MatrixSymmetryOperation::undo().

int MatrixModel::rowCount | ( | const QModelIndex & | parent = `QModelIndex()` | ) | const

References d_rows.

Referenced by Matrix::numRows(), MatrixSmoothCommand::redo(), Matrix::sizeToString(), MatrixDeleteColsCommand::undo(), MatrixSmoothCommand::undo(), and MatrixPasteCommand::undo().

void MatrixModel::setCell | ( | int | row,
|  | int | col,
|  | double | val
| ) |  |

References d_cols, d_data, and d_rows.

Referenced by importASCII(), MatrixEditCellCommand::redo(), resample(), Matrix::setCell(), and MatrixEditCellCommand::undo().

void MatrixModel::setColumnCount | ( | int | cols | ) |

References d_cols, insertColumns(), and removeColumns().

Referenced by calculate(), importASCII(), muParserCalculate(), setDimensions(), Matrix::setNumCols(), and MatrixPasteCommand::undo().

bool MatrixModel::setData | ( | const QModelIndex & | index,
|  | const QVariant & | value,
|  | int | role
| ) |  |

References d_cols, d_data, d_locale, d_matrix, d_rows, insertRows(), Matrix::moveCell(), MdiSubWindow::notifyChanges(), Matrix::notifyModifiedData(), Matrix::resetView(), and Matrix::undoStack().

void MatrixModel::setDimensions | ( | int | rows,
|  | int | cols
| ) |  |

References d_rows, insertRows(), removeRows(), and setColumnCount().

Referenced by MatrixSetSizeCommand::redo(), resample(), Matrix::setDimensions(), MatrixSetSizeCommand::undo(), and MatrixSetImageCommand::undo().

void MatrixModel::setImage | ( | const QImage & | image | ) |

References canResize(), cell(), d_cols, d_data, and d_rows.

Referenced by Matrix::importImage(), MatrixModel(), and MatrixSetImageCommand::redo().

void MatrixModel::setLocale | ( | const QLocale & | locale | ) |

inline

References d_locale.

Referenced by PreviewMatrix::PreviewMatrix().

void MatrixModel::setNumericFormat | ( | char | f,
|  | int | prec
| ) |  |

References d_num_precision, and d_txt_format.

Referenced by PreviewMatrix::PreviewMatrix().

void MatrixModel::setRowCount | ( | int | rows | ) |

References d_rows, insertRows(), and removeRows().

Referenced by calculate(), importASCII(), muParserCalculate(), Matrix::setNumRows(), and MatrixPasteCommand::undo().

void MatrixModel::setText | ( | int | row,
|  | int | col,
|  | const QString & | text
| ) |  |

References d_cols, d_data, d_locale, d_matrix, and d_rows.

Referenced by importASCII(), and Matrix::setText().

QString MatrixModel::text | ( | int | row,
|  | int | col
| ) |  |

References d_cols, d_data, d_locale, d_matrix, d_num_precision, d_rows, d_txt_format, Matrix::precision(), and Matrix::textFormat().

Referenced by Matrix::copySelection(), Matrix::exportASCII(), Matrix::exportODF(), and Matrix::text().

void MatrixModel::transpose | ( |  | ) |

References d_cols, d_data, d_matrix, d_rows, data(), Matrix::freeWorkspace(), and Matrix::initWorkspace().

Referenced by MatrixSymmetryOperation::redo(), and MatrixSymmetryOperation::undo().

double MatrixModel::x | ( | int | col | ) | const

References d_cols, d_matrix, Matrix::dx(), Matrix::xEnd(), and Matrix::xStart().

Referenced by ImageProfilesTool::ImageProfilesTool(), ApplicationWindow::matrixToTable(), ImageProfilesTool::modifiedMatrix(), and muParserCalculate().

double MatrixModel::y | ( | int | row | ) | const

References d_matrix, d_rows, Matrix::dy(), Matrix::yEnd(), and Matrix::yStart().

Referenced by ImageProfilesTool::ImageProfilesTool(), ApplicationWindow::matrixToTable(), ImageProfilesTool::modifiedMatrix(), and muParserCalculate().

## Member Data Documentation

int MatrixModel::d_cols

private

Referenced by calculate(), cell(), clear(), columnCount(), data(), dataCopy(), fft(), flipHorizontally(), flipVertically(), importASCII(), init(), initWorkspace(), insertColumns(), insertRows(), invert(), MatrixModel(), muParserCalculate(), pasteData(), removeColumns(), removeRows(), renderImage(), resample(), rotate90(), setCell(), setColumnCount(), setData(), setImage(), setText(), text(), transpose(), and x().

double* MatrixModel::d_data

private

Referenced by calculate(), canResize(), cell(), clear(), data(), dataCopy(), dataVector(), fft(), flipHorizontally(), flipVertically(), init(), insertColumns(), insertRows(), invert(), MatrixModel(), muParserCalculate(), pasteData(), removeColumns(), removeRows(), renderImage(), rotate90(), setCell(), setData(), setImage(), setText(), text(), transpose(), and ~MatrixModel().

QSize MatrixModel::d_data_block_size

private

Referenced by canResize(), init(), removeColumns(), and removeRows().

gsl_matrix* MatrixModel::d_direct_matrix

private

Pointers to GSL matrices used during inversion operations.

Referenced by init(), initWorkspace(), and invert().

gsl_matrix * MatrixModel::d_inv_matrix

private

Referenced by init(), initWorkspace(), and invert().

gsl_permutation* MatrixModel::d_inv_perm

private

Pointer to a GSL permutation used during inversion operations.

Referenced by init(), initWorkspace(), and invert().

QLocale MatrixModel::d_locale

private

Locale used to display data.

Referenced by data(), headerData(), importASCII(), init(), MatrixModel(), setData(), setLocale(), setText(), and text().

Matrix* MatrixModel::d_matrix

private

Referenced by calculate(), canResize(), data(), fft(), flipHorizontally(), flipVertically(), headerData(), importASCII(), initWorkspace(), matrix(), MatrixModel(), muParserCalculate(), renderImage(), resample(), rotate90(), setData(), setText(), text(), transpose(), x(), and y().

int MatrixModel::d_num_precision

private

Number of significant digits.

Referenced by data(), headerData(), init(), MatrixModel(), setNumericFormat(), and text().

int MatrixModel::d_rows

private

Referenced by calculate(), cell(), clear(), data(), dataCopy(), fft(), flipHorizontally(), flipVertically(), importASCII(), init(), initWorkspace(), insertColumns(), insertRows(), invert(), MatrixModel(), muParserCalculate(), pasteData(), removeColumns(), removeRows(), renderImage(), resample(), rotate90(), rowCount(), setCell(), setData(), setDimensions(), setImage(), setRowCount(), setText(), text(), transpose(), and y().

char MatrixModel::d_txt_format

private

Format code for displaying numbers.

Referenced by data(), headerData(), init(), MatrixModel(), setNumericFormat(), and text().

The documentation for this class was generated from the following files:

- qtiplot/src/matrix/MatrixModel.h
- qtiplot/src/matrix/MatrixModel.cpp