#include <Matrix.h>
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 | cellEdited (int, int) |
Called if any cell value was changed. | |
void | clearSelection () |
Clear cells. | |
bool | columnsSelected () |
Return whether any columns are fully selected. | |
int | columnsWidth () |
Return the width of all columns. | |
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. | |
void | exportPDF (const QString &fileName) |
int | firstSelectedColumn () |
Return the first fully selected column or -1 if no column is fully selected. | |
void | forgetSavedCells () |
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. | |
bool | isColumnSelected (int col, bool full=false) |
Returns whether a column contains selected cells (full=false) or is fully selected (full=true). | |
bool | isRowSelected (int row, bool full=false) |
Returns whether a row contains selected cells (full=false) or is fully selected (full=true). | |
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). | |
bool | rowsSelected () |
Return whether any rows are fully selected. | |
QString | saveAsTemplate (const QString &info) |
Format the matrix format in a string to save it in a template file. | |
void | saveCellsToMemory () |
Temporally save the cell values to memory. | |
QString | saveText () |
Return a string conaining the data of the matrix (<data> section). | |
QString | saveToString (const QString &info) |
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 | setFormula (const QString &s) |
Set the matrix forumla. | |
void | setMatrixDimensions (int rows, int cols) |
Set the Matrix size. | |
void | setNumericFormat (const QChar &f, int prec) |
Set the number format for the cells. | |
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. | |
QTableWidget * | table () |
Return a pointer to the QTableWidget. | |
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 () |
Return the X value corresponding to the last column. | |
double | xStart () |
Return the X value corresponding to column 1. | |
double | yEnd () |
Return the Y value corresponding to the last row. | |
double | yStart () |
Return the Y value corresponding to row 1. | |
Signals | |
void | showContextMenu () |
Show the context menu. | |
Public Member Functions | |
void | contextMenuEvent (QContextMenuEvent *e) |
Context menu event handler. | |
void | customEvent (QEvent *e) |
Custom event handler. | |
bool | eventFilter (QObject *object, QEvent *e) |
Event filter. | |
bool | isEmptyRow (int row) |
Returns whether the row is empty or not. | |
Matrix (ScriptingEnv *env, int r, int c, const QString &label, QWidget *parent=0, const char *name=0, Qt::WFlags f=0) | |
Constructor. | |
int | numCols () |
Return the number of columns. | |
int | numRows () |
Return the number of rows. | |
~Matrix () | |
Private Member Functions | |
void | init (int rows, int cols) |
Initialize the matrix. | |
Private Attributes | |
bool | allow_modification_signals |
Toggle between allow/suppress the emission of modification signals. | |
QTableWidget * | d_table |
Pointer to the table widget. | |
double ** | dMatrix |
Stores the matrix data only before the user opens the matrix dialog in order to avoid data loses during number format changes. | |
QString | formula_str |
Last formula used to calculate cell values. | |
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. |
Matrix::Matrix | ( | ScriptingEnv * | env, | |
int | r, | |||
int | c, | |||
const QString & | label, | |||
QWidget * | parent = 0 , |
|||
const char * | name = 0 , |
|||
Qt::WFlags | f = 0 | |||
) |
Constructor.
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 | ( | ) | [inline] |
double ** Matrix::allocateMatrixData | ( | int | rows, | |
int | columns | |||
) | [static, slot] |
Allocate memory for a matrix buffer.
QwtDoubleRect Matrix::boundingRect | ( | ) | [inline, 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::cellEdited | ( | int | row, | |
int | col | |||
) | [slot] |
Called if any cell value was changed.
void Matrix::clearSelection | ( | ) | [slot] |
Clear cells.
bool Matrix::columnsSelected | ( | ) | [slot] |
Return whether any columns are fully selected.
int Matrix::columnsWidth | ( | ) | [slot] |
Return the width of all columns.
void Matrix::contextMenuEvent | ( | QContextMenuEvent * | e | ) |
Context menu event handler.
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.
bool Matrix::eventFilter | ( | QObject * | object, | |
QEvent * | e | |||
) |
void Matrix::exportPDF | ( | const QString & | fileName | ) | [virtual, slot] |
Reimplemented from MyWidget.
int Matrix::firstSelectedColumn | ( | ) | [slot] |
Return the first fully selected column or -1 if no column is fully selected.
void Matrix::forgetSavedCells | ( | ) | [slot] |
QString Matrix::formula | ( | ) | [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).
void Matrix::init | ( | int | rows, | |
int | cols | |||
) | [private] |
Initialize the matrix.
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.
bool Matrix::isColumnSelected | ( | int | col, | |
bool | full = false | |||
) | [slot] |
Returns whether a column contains selected cells (full=false) or is fully selected (full=true).
bool Matrix::isEmptyRow | ( | int | row | ) |
Returns whether the row is empty or not.
bool Matrix::isRowSelected | ( | int | row, | |
bool | full = false | |||
) | [slot] |
Returns whether a row contains selected cells (full=false) or is fully selected (full=true).
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().
void Matrix::print | ( | const QString & | fileName | ) | [slot] |
Print the Matrix to fileName.
void Matrix::range | ( | double * | min, | |
double * | max | |||
) | [slot] |
Min and max values of the matrix.
void Matrix::restore | ( | const QStringList & | l | ) | [virtual, slot] |
bool Matrix::rowsSelected | ( | ) | [slot] |
Return whether any rows are fully selected.
QString Matrix::saveAsTemplate | ( | const QString & | info | ) | [virtual, slot] |
void Matrix::saveCellsToMemory | ( | ) | [slot] |
QString Matrix::saveText | ( | ) | [slot] |
Return a string conaining the data of the matrix (<data> section).
QString Matrix::saveToString | ( | const QString & | info | ) | [virtual, slot] |
Return a string to save the matrix in a project file (<matrix> section).
Reimplemented from MyWidget.
void Matrix::setCell | ( | int | row, | |
int | col, | |||
double | value | |||
) | [slot] |
Set the value of the cell.
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::setFormula | ( | const QString & | s | ) | [slot] |
Set the matrix forumla.
void Matrix::setMatrixDimensions | ( | int | rows, | |
int | cols | |||
) | [slot] |
Set the Matrix size.
void Matrix::setNumericFormat | ( | const QChar & | f, | |
int | prec | |||
) | [slot] |
Set the number format for the cells.
You must call saveCellsToMemory() before and forgetSavedCells() after calling this! Format character and precision have the same meaning as for sprintf().
f | format character 'e', 'f', 'g' | |
prec |
|
void Matrix::setNumericPrecision | ( | int | prec | ) | [inline, slot] |
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.
void Matrix::showContextMenu | ( | ) | [signal] |
Show the context menu.
QTableWidget* Matrix::table | ( | ) | [inline, slot] |
Return a pointer to the QTableWidget.
QString Matrix::text | ( | int | row, | |
int | col | |||
) | [slot] |
Return the content of the cell as a string.
QChar Matrix::textFormat | ( | ) | [inline, slot] |
void Matrix::transpose | ( | ) | [slot] |
Transpose the matrix.
int Matrix::verticalHeaderWidth | ( | ) | [inline, slot] |
double Matrix::xEnd | ( | ) | [inline, slot] |
Return the X value corresponding to the last column.
double Matrix::xStart | ( | ) | [inline, slot] |
Return the X value corresponding to column 1.
double Matrix::yEnd | ( | ) | [inline, slot] |
Return the Y value corresponding to the last row.
double Matrix::yStart | ( | ) | [inline, slot] |
Return the Y value corresponding to row 1.
bool Matrix::allow_modification_signals [private] |
Toggle between allow/suppress the emission of modification signals.
Set this to false during long operations to prevent "emit modifiedWindow(this)" being called for each cell.
QTableWidget* Matrix::d_table [private] |
Pointer to the table widget.
double** Matrix::dMatrix [private] |
Stores the matrix data only before the user opens the matrix dialog in order to avoid data loses during number format changes.
QString Matrix::formula_str [private] |
Last formula used to calculate cell values.
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.