Public Types | Public Slots | Signals | Public Member Functions | Private Member Functions | Private Attributes

Matrix Class Reference

Matrix worksheet class. More...

#include <Matrix.h>

Inheritance diagram for Matrix:
MdiSubWindow scripted

List of all members.

Public Types

enum  ColorMapType { Default, GrayScale, Rainbow, Custom }
enum  HeaderViewType { ColumnRow, XY }
enum  ImportMode { NewColumns, NewRows, Overwrite }
enum  Operation {
  Transpose, Invert, FlipHorizontally, FlipVertically,
  RotateClockwise, RotateCounterClockwise, FFT, Clear,
  Calculate, MuParserCalculate, SetImage, ImportAscii
}
enum  ViewType { TableView, ImageView }

Public Slots

static double ** allocateMatrixData (int rows, int columns)
 Allocate memory for a matrix buffer.
QwtDoubleRect boundingRect ()
 Returns the bounding rect of the matrix coordinates.
bool canCalculate (bool useMuParser=true)
double cell (int row, int col)
 Return the value of the cell as a double.
void clearSelection ()
 Clear cells.
int columnsWidth ()
 Return the width of all columns.
void copy (Matrix *m)
void copySelection ()
 Standard copy operation.
void cutSelection ()
 Standard cut operation.
void deleteSelectedColumns ()
 Delte the selected columns.
void deleteSelectedRows ()
 Delete the selected rows.
double dx ()
 Returns the step of the X axis.
double dy ()
 Returns the step of the Y axis.
void exportPDF (const QString &fileName)
QString formula ()
 Return the matrix formula.
static void freeMatrixData (double **data, int rows)
 Free memory used for a matrix buffer.
void freeWorkspace ()
void goToColumn (int col)
 Scroll to column (column starts with 1).
void goToRow (int row)
 Scroll to row (row starts with 1).
double * initWorkspace (int size)
 Tries to allocate memory for the workspace. Returns a NULL pointer if failure.
void insertColumn ()
 Insert a column before the current cell.
void insertRow ()
 Insert a row before the current cell.
bool isEmpty ()
 Returns true if no data values were set for this matrix.
void notifyModifiedData ()
int numSelectedColumns ()
 Return the number of selected columns.
int numSelectedRows ()
 Return the number of selected rows.
void pasteSelection ()
 Standard paste operation.
int precision ()
 Return the number precision digits.
void print (const QString &fileName)
 Print the Matrix to fileName.
void print (QPrinter *)
void print ()
 Print the Matrix.
void range (double *min, double *max)
 Min and max values of the matrix.
void restore (const QStringList &l)
 Load the matrix from a string list (i.e. lines from a project file).
void save (const QString &, const QString &, bool saveAsTemplate=false)
void setCell (int row, int col, double value)
 Set the value of the cell.
void setColumnsWidth (int width)
 Set the width of all columns.
void setCoordinates (double xs, double xe, double ys, double ye)
 Set the X and Y coordinate intervals.
void setDimensions (int rows, int cols)
 Set the Matrix size.
void setFormula (const QString &s)
 Set the matrix forumla.
void setNumericFormat (const QChar &f, int prec)
void setNumericPrecision (int prec)
 Set the number of significant digits.
void setText (int row, int col, const QString &new_text)
 Set the content of the cell as a string.
void setTextFormat (const QChar &format, int precision)
 Set the number format for the cells.
QString text (int row, int col)
 Return the content of the cell as a string.
QChar textFormat ()
 Return the text format code ('e', 'f', ...).
int verticalHeaderWidth ()
double xEnd ()
 Returns the X value corresponding to the last column.
double xStart ()
 Returns the X value corresponding to column 1.
double yEnd ()
 Returns the Y value corresponding to the last row.
double yStart ()
 Returns the Y value corresponding to row 1.

Signals

void modifiedData (Matrix *)

Public Member Functions

bool calculate (int startRow=0, int endRow=-1, int startCol=0, int endCol=-1, bool forceMuParser=false)
 Calculate matrix values using the formula_str.
QwtLinearColorMap colorMap ()
QwtLinearColorMap * colorMapPointer ()
ColorMapType colorMapType ()
void customEvent (QEvent *e)
 Custom event handler.
double determinant ()
 Calculate the determinant of the matrix.
void displayImage (const QImage &image)
bool exportASCII (const QString &fname, const QString &separator, bool exportSelection)
bool exportODF (const QString &fname, bool exportSelection)
void exportRasterImage (const QString &fileName, int quality=100, int dpi=0)
void exportSVG (const QString &fileName)
void exportToFile (const QString &fileName)
void exportVector (const QString &fileName, int res=0, bool color=true)
void fft (bool inverse=false)
void flipHorizontally ()
void flipVertically ()
HeaderViewType headerViewType ()
QImage image ()
void importASCII (const QString &fname, const QString &sep, int ignoredLines, bool stripSpaces, bool simplifySpaces, const QString &commentString, ImportMode importAs=Overwrite, const QLocale &l=QLocale(), int endLineChar=0, int maxRows=-1)
void importImage (const QString &fn)
void importImage (const QImage &image)
double integrate ()
 Calculate the volume integral.
void invert ()
 Invert the matrix.
 Matrix (ScriptingEnv *env, const QImage &image, const QString &label, ApplicationWindow *parent, const QString &name=QString(), Qt::WFlags f=0)
 Matrix (ScriptingEnv *env, int r, int c, const QString &label, ApplicationWindow *parent, const QString &name=QString(), Qt::WFlags f=0)
 Constructor.
MatrixModelmatrixModel ()
void moveCell (const QModelIndex &index)
bool muParserCalculate (int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
 Calculate matrix values using the formula_str (optimization for muParser).
int numCols ()
 Return the number of columns.
int numRows ()
 Return the number of rows.
void resetView ()
void rotate90 (bool clockwise=true)
QItemSelectionModel * selectionModel ()
void setColorMap (const QwtLinearColorMap &map)
void setColorMap (const QStringList &lst)
 Used when restoring from project files.
void setColorMapType (ColorMapType mapType)
void setDefaultColorMap ()
 Resets the color map to the one defined by the user in the Preferences dialog (3D plots tab).
void setGrayScale ()
void setHeaderViewType (HeaderViewType type)
void setNumCols (int cols)
void setNumRows (int rows)
void setRainbowColorMap ()
void setViewType (ViewType, bool renderImage=true)
virtual QString sizeToString ()
void transpose ()
 Transpose the matrix.
QUndoStack * undoStack ()
ViewType viewType ()
 ~Matrix ()

Private Member Functions

bool eventFilter (QObject *, QEvent *)
bool ignoreUndo ()
void initGlobals ()
void initImage (const QImage &image)
void initImageView ()
void initTable (int rows, int cols)
 Initialize the matrix.
void initTableView ()

Private Attributes

QwtLinearColorMap d_color_map
 The color map used to display images.
ColorMapType d_color_map_type
 The color map type.
int d_column_width
 Column width in pixels;.
HeaderViewType d_header_view_type
 Keeps track of the header view type;.
MatrixModeld_matrix_model
QShortcut * d_select_all_shortcut
QStackedWidget * d_stack
QTableView * d_table_view
 Pointer to the table view.
QUndoStack * d_undo_stack
 Undo/Redo commands stack.
ViewType d_view_type
 Keeps track of the view type;.
double * d_workspace
 Pointer to a data buffer used for matrix operations.
QString formula_str
 Last formula used to calculate cell values.
QLabel * imageLabel
 Used to display the image view.
int num_precision
 Number of significant digits.
QChar txt_format
 Format code for displaying numbers.
double x_end
 X value corresponding to the last column.
double x_start
 X value corresponding to column 1.
double y_end
 Y value corresponding to the last row.
double y_start
 Y value corresponding to row 1.

Detailed Description

Matrix worksheet class.


Member Enumeration Documentation

Enumerator:
Default 
GrayScale 
Rainbow 
Custom 
Enumerator:
ColumnRow 
XY 
Enumerator:
NewColumns 

add file as new columns to the current matrix

NewRows 

add file as new rows to the current matrix

Overwrite 

replace content of current matrix with the imported file

Enumerator:
Transpose 
Invert 
FlipHorizontally 
FlipVertically 
RotateClockwise 
RotateCounterClockwise 
FFT 
Clear 
Calculate 
MuParserCalculate 
SetImage 
ImportAscii 
Enumerator:
TableView 
ImageView 

Constructor & Destructor Documentation

Matrix::Matrix ( ScriptingEnv env,
int  r,
int  c,
const QString &  label,
ApplicationWindow parent,
const QString &  name = QString(),
Qt::WFlags  f = 0 
)

Constructor.

Parameters:
env scripting interpreter
r initial number of rows
c initial number of columns
label window label
parent parent object
name 
name window name
f window flags

References initTable().

Matrix::Matrix ( ScriptingEnv env,
const QImage &  image,
const QString &  label,
ApplicationWindow parent,
const QString &  name = QString(),
Qt::WFlags  f = 0 
)

References initImage().

Matrix::~Matrix (  ) 

References d_matrix_model, and d_undo_stack.


Member Function Documentation

double ** Matrix::allocateMatrixData ( int  rows,
int  columns 
) [static, slot]
QwtDoubleRect Matrix::boundingRect (  )  [slot]

Returns the bounding rect of the matrix coordinates.

References dx(), dy(), numCols(), numRows(), x_end, x_start, y_end, and y_start.

Referenced by Spectrogram::boundingRect().

bool Matrix::calculate ( int  startRow = 0,
int  endRow = -1,
int  startCol = 0,
int  endCol = -1,
bool  forceMuParser = false 
)
QwtLinearColorMap* Matrix::colorMapPointer (  )  [inline]

References d_color_map.

int Matrix::columnsWidth (  )  [inline, slot]

Return the width of all columns.

References d_column_width.

Referenced by MatrixDialog::apply(), copy(), and MatrixDialog::setMatrix().

void Matrix::copySelection (  )  [slot]
void Matrix::customEvent ( QEvent *  e  ) 

Custom event handler.

Currently handles SCRIPTING_CHANGE_EVENT only.

References scripted::scriptingChangeEvent().

void Matrix::cutSelection (  )  [slot]

Standard cut operation.

References clearSelection(), and copySelection().

void Matrix::deleteSelectedColumns (  )  [slot]
void Matrix::deleteSelectedRows (  )  [slot]
double Matrix::determinant (  ) 
void Matrix::displayImage ( const QImage &  image  ) 
bool Matrix::eventFilter ( QObject *  object,
QEvent *  e 
) [private]

References imageLabel.

bool Matrix::exportASCII ( const QString &  fname,
const QString &  separator,
bool  exportSelection 
)
bool Matrix::exportODF ( const QString &  fname,
bool  exportSelection 
)
void Matrix::exportPDF ( const QString &  fileName  )  [slot]

References print().

void Matrix::exportRasterImage ( const QString &  fileName,
int  quality = 100,
int  dpi = 0 
)
void Matrix::exportSVG ( const QString &  fileName  ) 
void Matrix::exportToFile ( const QString &  fileName  ) 
void Matrix::exportVector ( const QString &  fileName,
int  res = 0,
bool  color = true 
)
void Matrix::freeMatrixData ( double **  data,
int  rows 
) [static, slot]
void Matrix::freeWorkspace (  )  [inline, slot]
void Matrix::goToColumn ( int  col  )  [slot]

Scroll to column (column starts with 1).

References d_matrix_model, d_table_view, d_undo_stack, d_view_type, ImageView, numCols(), and TableView.

void Matrix::goToRow ( int  row  )  [slot]

Scroll to row (row starts with 1).

References d_matrix_model, d_table_view, d_undo_stack, d_view_type, ImageView, numRows(), and TableView.

QImage Matrix::image (  ) 
void Matrix::importASCII ( const QString &  fname,
const QString &  sep,
int  ignoredLines,
bool  stripSpaces,
bool  simplifySpaces,
const QString &  commentString,
ImportMode  importAs = Overwrite,
const QLocale &  l = QLocale(),
int  endLineChar = 0,
int  maxRows = -1 
)
void Matrix::initImage ( const QImage &  image  )  [private]
void Matrix::initImageView (  )  [private]

References d_stack, and imageLabel.

Referenced by copy(), initImage(), restore(), and setViewType().

void Matrix::initTable ( int  rows,
int  cols 
) [private]
void Matrix::initTableView (  )  [private]
double * Matrix::initWorkspace ( int  size  )  [slot]
void Matrix::insertColumn (  )  [slot]
void Matrix::insertRow (  )  [slot]
double Matrix::integrate (  ) 

Calculate the volume integral.

References MatrixModel::cell(), d_matrix_model, dx(), dy(), numCols(), and numRows().

bool Matrix::isEmpty (  )  [slot]

Returns true if no data values were set for this matrix.

References range().

Referenced by Graph3D::addMatrixData(), and Graph3D::updateMatrixData().

void Matrix::moveCell ( const QModelIndex &  index  ) 

References d_matrix_model, and d_table_view.

Referenced by MatrixModel::setData().

bool Matrix::muParserCalculate ( int  startRow = 0,
int  endRow = -1,
int  startCol = 0,
int  endCol = -1 
)
void Matrix::notifyModifiedData (  )  [inline, slot]

References modifiedData().

Referenced by MatrixModel::setData().

int Matrix::numSelectedColumns (  )  [slot]

Return the number of selected columns.

References d_table_view, and numCols().

Referenced by ApplicationWindow::showWindowContextMenu().

int Matrix::numSelectedRows (  )  [slot]

Return the number of selected rows.

References d_table_view, and numRows().

Referenced by ApplicationWindow::showWindowContextMenu().

void Matrix::print (  )  [slot]

Print the Matrix.

Referenced by canCalculate(), exportPDF(), and print().

void Matrix::print ( const QString &  fileName  )  [slot]

Print the Matrix to fileName.

References MdiSubWindow::applicationWindow(), and print().

void Matrix::print ( QPrinter *  printer  )  [slot]
void Matrix::range ( double *  min,
double *  max 
) [slot]
void Matrix::restore ( const QStringList &  l  )  [slot]
void Matrix::save ( const QString &  fn,
const QString &  info,
bool  saveAsTemplate = false 
) [slot]
QItemSelectionModel* Matrix::selectionModel (  )  [inline]

References d_table_view.

Referenced by MatrixValuesDialog::setMatrix().

void Matrix::setColorMap ( const QStringList &  lst  ) 

Used when restoring from project files.

References d_color_map, and d_color_map_type.

void Matrix::setColorMapType ( ColorMapType  mapType  ) 
void Matrix::setFormula ( const QString &  s  )  [inline, slot]
void Matrix::setNumCols ( int  cols  )  [inline]
void Matrix::setNumericFormat ( const QChar &  f,
int  prec 
) [slot]
void Matrix::setNumericPrecision ( int  prec  )  [slot]
void Matrix::setNumRows ( int  rows  )  [inline]
void Matrix::setText ( int  row,
int  col,
const QString &  new_text 
) [slot]

Set the content of the cell as a string.

References d_matrix_model, and MatrixModel::setText().

Referenced by ApplicationWindow::openMatrix().

void Matrix::setTextFormat ( const QChar &  format,
int  precision 
) [slot]

Set the number format for the cells.

This method should only be called before any user interaction was done. Use setTextFormat() if you want to change it from a dialog.

See also:
setTextFormat()

References num_precision, and txt_format.

Referenced by ApplicationWindow::openMatrix(), and restore().

QString Matrix::sizeToString (  )  [virtual]
QString Matrix::text ( int  row,
int  col 
) [slot]

Return the content of the cell as a string.

References d_matrix_model, and MatrixModel::text().

Referenced by muParserScript::cell(), copySelection(), pasteSelection(), and print().

QChar Matrix::textFormat (  )  [inline, slot]
void Matrix::transpose (  ) 
int Matrix::verticalHeaderWidth (  )  [inline, slot]

Member Data Documentation

QwtLinearColorMap Matrix::d_color_map [private]
int Matrix::d_column_width [private]

Column width in pixels;.

Referenced by columnsWidth(), initGlobals(), initTableView(), resetView(), save(), and setColumnsWidth().

Keeps track of the header view type;.

Referenced by copy(), headerViewType(), initGlobals(), restore(), save(), and setHeaderViewType().

QShortcut* Matrix::d_select_all_shortcut [private]
QStackedWidget* Matrix::d_stack [private]
double* Matrix::d_workspace [private]

Pointer to a data buffer used for matrix operations.

Referenced by flipHorizontally(), flipVertically(), freeWorkspace(), initGlobals(), initWorkspace(), rotate90(), and transpose().

QString Matrix::formula_str [private]

Last formula used to calculate cell values.

Referenced by canCalculate(), copy(), formula(), initGlobals(), restore(), save(), and setFormula().

QLabel* Matrix::imageLabel [private]

Used to display the image view.

Referenced by copy(), displayImage(), eventFilter(), initGlobals(), initImage(), initImageView(), restore(), and setViewType().

int Matrix::num_precision [private]

Number of significant digits.

Referenced by copy(), initGlobals(), precision(), save(), setNumericFormat(), setNumericPrecision(), and setTextFormat().

QChar Matrix::txt_format [private]

Format code for displaying numbers.

Referenced by copy(), initGlobals(), save(), setNumericFormat(), setTextFormat(), and textFormat().

double Matrix::x_end [private]

X value corresponding to the last column.

Referenced by boundingRect(), copy(), dx(), importImage(), initGlobals(), initImage(), restore(), save(), setCoordinates(), and xEnd().

double Matrix::x_start [private]

X value corresponding to column 1.

Referenced by boundingRect(), copy(), dx(), importImage(), initGlobals(), initImage(), restore(), save(), setCoordinates(), and xStart().

double Matrix::y_end [private]

Y value corresponding to the last row.

Referenced by boundingRect(), copy(), dy(), importImage(), initGlobals(), initImage(), restore(), save(), setCoordinates(), and yEnd().

double Matrix::y_start [private]

Y value corresponding to row 1.

Referenced by boundingRect(), copy(), dy(), importImage(), initGlobals(), initImage(), restore(), save(), setCoordinates(), and yStart().


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