Matrix Class Reference

#include <Matrix.h>

Inheritance diagram for Matrix:

MyWidget scripted

List of all members.


Detailed Description

Matrix worksheet class.

Public Types

enum  ColorMapType { GrayScale, Rainbow, Custom }
enum  HeaderViewType { ColumnRow, XY }
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 calculate (int startRow=0, int endRow=-1, int startCol=0, int endCol=-1)
 Calculate matrix values using the formula_str.
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 determinant ()
 Calculate the determinant of the matrix.
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 goToRow (int row)
 Scroll to row (row starts with 1).
void insertColumn ()
 Insert a column before the current cell.
void insertRow ()
 Insert a row before the current cell.
void invert ()
 Invert the matrix.
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 ()
 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).
QString saveAsTemplate (const QString &info)
 Format the matrix format in a string to save it in a template file.
QString saveToString (const QString &info, bool saveAsTemplate=false)
 Return a string to save the matrix in a project file (<matrix> section).
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', ...).
void transpose ()
 Transpose the matrix.
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 showContextMenu ()
 Show the context menu.

Public Member Functions

QwtLinearColorMap colorMap ()
ColorMapType colorMapType ()
void contextMenuEvent (QContextMenuEvent *e)
 Context menu event handler.
void customEvent (QEvent *e)
 Custom event handler.
bool eventFilter (QObject *object, QEvent *e)
 Event filter.
void exportRasterImage (const QString &fileName, int quality=100)
void exportSVG (const QString &fileName)
void exportToFile (const QString &fileName)
void exportVector (const QString &fileName, int res=0, bool color=true, bool keepAspect=true, QPrinter::PageSize pageSize=QPrinter::Custom)
void flipHorizontally ()
void flipVertically ()
HeaderViewType headerViewType ()
QImage image ()
void importImage (const QString &fn)
 Matrix (ScriptingEnv *env, const QImage &image, const QString &label, QWidget *parent=0, const QString &name=QString(), Qt::WFlags f=0)
 Matrix (ScriptingEnv *env, int r, int c, const QString &label, QWidget *parent=0, const QString &name=QString(), Qt::WFlags f=0)
 Constructor.
MatrixModelmatrixModel ()
void moveCell (const QModelIndex &index)
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 QStringList &lst)
 Used when restoring from project files.
void setColorMap (const QwtLinearColorMap &map)
void setColorMapType (ColorMapType mapType)
void setGrayScale ()
void setHeaderViewType (HeaderViewType type)
void setImage (const QImage &image)
void setNumCols (int cols)
void setNumRows (int rows)
void setRainbowColorMap ()
void setViewType (ViewType)
ViewType viewType ()

Private Member Functions

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
ColorMapType d_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.
ViewType d_view_type
 Keeps track of the view type;.
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.

Member Enumeration Documentation

enum Matrix::ColorMapType

Enumerator:
GrayScale 
Rainbow 
Custom 

enum Matrix::HeaderViewType

Enumerator:
ColumnRow 
XY 

enum Matrix::ViewType

Enumerator:
TableView 
ImageView 


Constructor & Destructor Documentation

Matrix::Matrix ( ScriptingEnv env,
int  r,
int  c,
const QString &  label,
QWidget *  parent = 0,
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

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


Member Function Documentation

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

Allocate memory for a matrix buffer.

QwtDoubleRect Matrix::boundingRect (  )  [slot]

Returns the bounding rect of the matrix coordinates.

bool Matrix::calculate ( int  startRow = 0,
int  endRow = -1,
int  startCol = 0,
int  endCol = -1 
) [slot]

Calculate matrix values using the formula_str.

double Matrix::cell ( int  row,
int  col 
) [slot]

Return the value of the cell as a double.

void Matrix::clearSelection (  )  [slot]

Clear cells.

QwtLinearColorMap Matrix::colorMap (  )  [inline]

ColorMapType Matrix::colorMapType (  )  [inline]

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

Return the width of all columns.

void Matrix::contextMenuEvent ( QContextMenuEvent *  e  ) 

Context menu event handler.

void Matrix::copy ( Matrix m  )  [slot]

void Matrix::copySelection (  )  [slot]

Standard copy operation.

void Matrix::customEvent ( QEvent *  e  ) 

Custom event handler.

Currently handles SCRIPTING_CHANGE_EVENT only.

void Matrix::cutSelection (  )  [slot]

Standard cut operation.

void Matrix::deleteSelectedColumns (  )  [slot]

Delte the selected columns.

void Matrix::deleteSelectedRows (  )  [slot]

Delete the selected rows.

double Matrix::determinant (  )  [slot]

Calculate the determinant of the matrix.

double Matrix::dx (  )  [inline, slot]

Returns the step of the X axis.

double Matrix::dy (  )  [inline, slot]

Returns the step of the Y axis.

bool Matrix::eventFilter ( QObject *  object,
QEvent *  e 
)

Event filter.

Currently only reacts to events of the title bar.

Reimplemented from MyWidget.

void Matrix::exportPDF ( const QString &  fileName  )  [virtual, slot]

Reimplemented from MyWidget.

void Matrix::exportRasterImage ( const QString &  fileName,
int  quality = 100 
)

void Matrix::exportSVG ( const QString &  fileName  ) 

void Matrix::exportToFile ( const QString &  fileName  ) 

void Matrix::exportVector ( const QString &  fileName,
int  res = 0,
bool  color = true,
bool  keepAspect = true,
QPrinter::PageSize  pageSize = QPrinter::Custom 
)

void Matrix::flipHorizontally (  ) 

void Matrix::flipVertically (  ) 

QString Matrix::formula (  )  [inline, slot]

Return the matrix formula.

void Matrix::freeMatrixData ( double **  data,
int  rows 
) [static, slot]

Free memory used for a matrix buffer.

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

Scroll to row (row starts with 1).

HeaderViewType Matrix::headerViewType (  )  [inline]

QImage Matrix::image (  ) 

void Matrix::importImage ( const QString &  fn  ) 

void Matrix::initGlobals (  )  [private]

void Matrix::initImage ( const QImage &  image  )  [private]

void Matrix::initImageView (  )  [private]

void Matrix::initTable ( int  rows,
int  cols 
) [private]

Initialize the matrix.

void Matrix::initTableView (  )  [private]

void Matrix::insertColumn (  )  [slot]

Insert a column before the current cell.

void Matrix::insertRow (  )  [slot]

Insert a row before the current cell.

void Matrix::invert (  )  [slot]

Invert the matrix.

MatrixModel* Matrix::matrixModel (  )  [inline]

void Matrix::moveCell ( const QModelIndex &  index  ) 

int Matrix::numCols (  ) 

Return the number of columns.

int Matrix::numRows (  ) 

Return the number of rows.

int Matrix::numSelectedColumns (  )  [slot]

Return the number of selected columns.

int Matrix::numSelectedRows (  )  [slot]

Return the number of selected rows.

void Matrix::pasteSelection (  )  [slot]

Standard paste operation.

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

Return the number precision digits.

See arguments of setNumericFormat().

See also:
setNumericFormat(), setTextFormat()

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

Print the Matrix to fileName.

void Matrix::print (  )  [virtual, slot]

Print the Matrix.

Reimplemented from MyWidget.

void Matrix::range ( double *  min,
double *  max 
) [slot]

Min and max values of the matrix.

void Matrix::resetView (  ) 

void Matrix::restore ( const QStringList &  l  )  [virtual, slot]

Load the matrix from a string list (i.e. lines from a project file).

Reimplemented from MyWidget.

void Matrix::rotate90 ( bool  clockwise = true  ) 

QString Matrix::saveAsTemplate ( const QString &  info  )  [virtual, slot]

Format the matrix format in a string to save it in a template file.

Reimplemented from MyWidget.

QString Matrix::saveToString ( const QString &  info,
bool  saveAsTemplate = false 
) [virtual, slot]

Return a string to save the matrix in a project file (<matrix> section).

Reimplemented from MyWidget.

QItemSelectionModel* Matrix::selectionModel (  )  [inline]

void Matrix::setCell ( int  row,
int  col,
double  value 
) [slot]

Set the value of the cell.

void Matrix::setColorMap ( const QStringList &  lst  ) 

Used when restoring from project files.

void Matrix::setColorMap ( const QwtLinearColorMap &  map  ) 

void Matrix::setColorMapType ( ColorMapType  mapType  ) 

void Matrix::setColumnsWidth ( int  width  )  [slot]

Set the width of all columns.

void Matrix::setCoordinates ( double  xs,
double  xe,
double  ys,
double  ye 
) [slot]

Set the X and Y coordinate intervals.

void Matrix::setDimensions ( int  rows,
int  cols 
) [slot]

Set the Matrix size.

void Matrix::setFormula ( const QString &  s  )  [inline, slot]

Set the matrix forumla.

void Matrix::setGrayScale (  ) 

void Matrix::setHeaderViewType ( HeaderViewType  type  ) 

void Matrix::setImage ( const QImage &  image  ) 

void Matrix::setNumCols ( int  cols  ) 

void Matrix::setNumericFormat ( const QChar &  f,
int  prec 
) [slot]

void Matrix::setNumericPrecision ( int  prec  )  [inline, slot]

Set the number of significant digits.

See also:
precision(), setNumericFormat(), setTextFormat()

void Matrix::setNumRows ( int  rows  ) 

void Matrix::setRainbowColorMap (  ) 

void Matrix::setText ( int  row,
int  col,
const QString &  new_text 
) [slot]

Set the content of the cell as a string.

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()

void Matrix::setViewType ( ViewType  type  ) 

void Matrix::showContextMenu (  )  [signal]

Show the context menu.

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

Return the content of the cell as a string.

QChar Matrix::textFormat (  )  [inline, slot]

Return the text format code ('e', 'f', ...).

See also:
setNumerFormat(), setTextFormat()

void Matrix::transpose (  )  [slot]

Transpose the matrix.

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

ViewType Matrix::viewType (  )  [inline]

double Matrix::xEnd (  )  [inline, slot]

Returns the X value corresponding to the last column.

double Matrix::xStart (  )  [inline, slot]

Returns the X value corresponding to column 1.

double Matrix::yEnd (  )  [inline, slot]

Returns the Y value corresponding to the last row.

double Matrix::yStart (  )  [inline, slot]

Returns the Y value corresponding to row 1.


Member Data Documentation

QwtLinearColorMap Matrix::d_color_map [private]

ColorMapType Matrix::d_color_map_type [private]

int Matrix::d_column_width [private]

Column width in pixels;.

HeaderViewType Matrix::d_header_view_type [private]

Keeps track of the header view type;.

MatrixModel* Matrix::d_matrix_model [private]

QShortcut* Matrix::d_select_all_shortcut [private]

QStackedWidget* Matrix::d_stack [private]

QTableView* Matrix::d_table_view [private]

Pointer to the table view.

ViewType Matrix::d_view_type [private]

Keeps track of the view type;.

QString Matrix::formula_str [private]

Last formula used to calculate cell values.

QLabel* Matrix::imageLabel [private]

Used to display the image view.

int Matrix::num_precision [private]

Number of significant digits.

QChar Matrix::txt_format [private]

Format code for displaying numbers.

double Matrix::x_end [private]

X value corresponding to the last column.

double Matrix::x_start [private]

X value corresponding to column 1.

double Matrix::y_end [private]

Y value corresponding to the last row.

double Matrix::y_start [private]

Y value corresponding to row 1.


The documentation for this class was generated from the following files:
Generated on Thu Feb 7 13:59:28 2008 for QtiPlot by  doxygen 1.5.4