SciDAVis  1.D4
Public Slots | Signals | Public Member Functions | Public Attributes | Protected Slots | Private Member Functions | Private Attributes
Matrix Class Reference

Matrix worksheet class. More...

#include <Matrix.h>

Inheritance diagram for Matrix:
MatrixView scripted MyWidget

List of all members.

Public Slots

static double ** allocateMatrixData (int rows, int columns)
 Allocate memory for a matrix buffer.
virtual QString birthDate ()
 Return the creation date.
QwtDoubleRect boundingRect ()
 Returns the bounding rect of the matrix coordinates.
double cell (int row, int col)
 Return the value of the cell as a double.
void clearSelection ()
 Clear cells.
bool columnsSelected ()
 Return whether any columns are fully selected.
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.
void exportPDF (const QString &fileName)
void forgetSavedCells ()
QString formula ()
 Return the matrix formula.
static void freeMatrixData (double **data, int rows)
 Free memory used for a matrix buffer.
static MatrixfromImage (const QImage &image, ScriptingEnv *env)
void handleChange ()
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 ()
 Print the Matrix.
void print (const QString &fileName)
 Print the Matrix to fileName.
void range (double *min, double *max)
 Min and max values of the matrix.
bool recalculate ()
 Calculate matrix values using the formula for all selected cells.
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 (obsolete, only for OPJ import)
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)
 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.
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.
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.
- Public Slots inherited from MatrixView
void applyCoordinates ()
void applyFormat ()
void goToCell (int row, int col)
void handleHorizontalSectionResized (int logicalIndex, int oldSize, int newSize)
void handleVerticalSectionResized (int logicalIndex, int oldSize, int newSize)
void rereadSectionSizes ()
void selectAll ()
void showControlCoordinatesTab ()
void showControlFormatTab ()
void showControlFormulaTab ()
void toggleControlTabBar ()
void updateCoordinatesTab ()
void updateFormatTab ()
void updateFormulaTab ()

Signals

void showContextMenu ()
 Show the context menu.
- Signals inherited from MatrixView
void controlTabBarStatusChanged (bool visible)
- Signals inherited from MyWidget
void closedWindow (MyWidget *)
 Emitted when the window was closed.
void hiddenWindow (MyWidget *)
 Emitted when the window was hidden.
void modifiedWindow (QWidget *)
void resizedWindow (QWidget *)
void showTitleBarMenu ()
 Emitted when the title bar recieves a QContextMenuEvent.
void statusChanged (MyWidget *)
 Emitted when the window status changed.

Public Member Functions

void closeEvent (QCloseEvent *)
 Close event handler.
void customEvent (QEvent *e)
 Custom event handler.
 Matrix (ScriptingEnv *env, int r, int c, const QString &label, QWidget *parent=0, const char *name=0, Qt::WFlags f=0)
 Constructor.
virtual QString name ()
 Return the window name.
int numCols ()
 Return the number of columns.
int numRows ()
 Return the number of rows.
virtual void setBirthDate (const QString &s)
 Set the creation date.
void setCaptionPolicy (CaptionPolicy policy)
 Set the caption policy.
virtual void setName (const QString &s)
 Set the window name.
void setNumCols (int cols)
void setNumRows (int rows)
virtual void setWindowLabel (const QString &s)
 Set the window label.
void updateDecimalSeparators ()
virtual QWidget * view ()
virtual QString windowLabel ()
 Return the window label.
 ~Matrix ()
- Public Member Functions inherited from MatrixView
int columnWidth (int col) const
bool isControlTabBarVisible ()
 MatrixView (future::Matrix *matrix)
 Constructor.
int rowHeight (int row) const
void setColumnWidth (int col, int width)
void setRowHeight (int row, int height)
virtual ~MatrixView ()
 Destructor.
int selectedColumnCount (bool full=false)
 Return how many columns are selected.
bool isColumnSelected (int col, bool full=false)
 Returns true if column 'col' is selected; otherwise false.
int selectedRowCount (bool full=false)
 Return how many rows are (at least partly) selected.
bool isRowSelected (int row, bool full=false)
 Returns true if row 'row' is selected; otherwise false.
int firstSelectedColumn (bool full=false)
 Return the index of the first selected column.
int lastSelectedColumn (bool full=false)
 Return the index of the last selected column.
int firstSelectedRow (bool full=false)
 Return the index of the first selected row.
int lastSelectedRow (bool full=false)
 Return the index of the last selected row.
bool isCellSelected (int row, int col)
 Return whether a cell is selected.
void setCellSelected (int row, int col)
 Select a cell.
void setCellsSelected (int first_row, int first_col, int last_row, int last_col)
 Select a range of cells.
void getCurrentCell (int *row, int *col)
 Determine the current cell (-1 if no cell is designated as the current)
- Public Member Functions inherited from MyWidget
void askOnCloseEvent (bool ask)
 Toggle the "ask on close" flag.
QString aspect ()
 Return the window status as a string.
virtual CaptionPolicy captionPolicy ()
 Return the caption policy.
Folderfolder ()
 Returns the pointer to the parent folder of the window.
 MyWidget (const QString &label=QString(), QWidget *parent=0, const QString name=0, Qt::WFlags f=0)
 Constructor.
void notifyChanges ()
 Notifies the main application that the window has been modified.
virtual void restore (const QStringList &)
 Not implemented yet.
void setFolder (Folder *f)
 Initializes the pointer to the parent folder of the window.
virtual void setHidden ()
 Notifies that a window was hidden by a direct user action.
void setMaximized ()
void setMinimized ()
void setNormal ()
void setStatus (Status s)
 Set the window status flag (hidden, normal, minimized or maximized)
Status status ()
 Return the window status flag (hidden, normal, minimized or maximized)
- Public Member Functions inherited from scripted
 scripted (ScriptingEnv *env)
void scriptingChangeEvent (ScriptingChangeEvent *)
 ~scripted ()

Public Attributes

future::Matrixd_future_matrix

Protected Slots

void addCell ()
void addFunction ()
void applyFormula ()
void handleAspectDescriptionChange (const AbstractAspect *aspect)
void updateFunctionDoc ()
- Protected Slots inherited from MatrixView
void advanceCell ()
 Advance current cell after [Return] or [Enter] was pressed.
void updateTypeInfo ()
- Protected Slots inherited from MyWidget
void updateCaption ()
 Set caption according to current CaptionPolicy, name and label.

Private Member Functions

void init (int rows, int cols)
 Initialize the matrix.
 Matrix (future::Matrix *future_matrix, ScriptingEnv *env, int r, int c, const QString &label, QWidget *parent=0, const char *name=0, Qt::WFlags f=0)

Private Attributes

double ** dMatrix
 Stores the matrix data only before the user opens the matrix dialog in order to avoid data loses during number format changes.

Additional Inherited Members

- Protected Member Functions inherited from MatrixView
virtual void changeEvent (QEvent *event)
 Catches parent changes (in order to gain access to the title bar)
bool eventFilter (QObject *watched, QEvent *event)
 Filters other object's events (customizes title bar's context menu)
void init ()
 Initialization.
void retranslateStrings ()
- Protected Attributes inherited from MatrixView
QWidget * d_control_tabs
 Widget that contains the control tabs UI from ui.
QToolButton * d_hide_button
 Button to toogle the visibility of #d_tool_box.
QHBoxLayout * d_main_layout
future::Matrixd_matrix
MatrixModeld_model
 Pointer to the current underlying model.
MatrixViewWidgetd_view_widget
 The matrix view (first part of the UI)
Ui::MatrixControlTabs ui
- Protected Attributes inherited from MyWidget
bool askOnClose
 Toggle on/off: Ask the user "delete, hide, or cancel?" on a close event.
QString birthdate
 The creation date.
CaptionPolicy caption_policy
 The caption policy.
FolderparentFolder
 Pointer to the parent folder of the window.
QWidget * titleBar
 Title bar of this MDI window if it currently belongs to a QWorkspace, NULL else.
QString w_label
 The window label.
Status w_status
 The window status.
- Protected Attributes inherited from scripted
ScriptingEnvscriptEnv

Detailed Description

Matrix worksheet class.


Constructor & Destructor Documentation

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

Constructor.

Parameters:
envscripting interpreter
rinitial number of rows
cinitial number of columns
labelwindow label
parentparent object
name
namewindow name
fwindow flags

References d_future_matrix, and MatrixView::init().

Referenced by fromImage().

Matrix::~Matrix ( )
Matrix::Matrix ( future::Matrix future_matrix,
ScriptingEnv env,
int  r,
int  c,
const QString &  label,
QWidget *  parent = 0,
const char *  name = 0,
Qt::WFlags  f = 0 
)
private

Member Function Documentation

void Matrix::addCell ( )
protectedslot

References MatrixView::ui.

Referenced by init().

void Matrix::addFunction ( )
protectedslot

References MatrixView::ui.

Referenced by init().

double ** Matrix::allocateMatrixData ( int  rows,
int  columns 
)
staticslot
void Matrix::applyFormula ( )
protectedslot
virtual QString Matrix::birthDate ( )
inlinevirtualslot

Return the creation date.

Reimplemented from MyWidget.

References AbstractAspect::creationTime(), and d_future_matrix.

Referenced by saveToString().

QwtDoubleRect Matrix::boundingRect ( )
inlineslot

Returns the bounding rect of the matrix coordinates.

References xEnd(), xStart(), yEnd(), and yStart().

double Matrix::cell ( int  row,
int  col 
)
slot
void Matrix::clearSelection ( )
slot

Clear cells.

References future::Matrix::clearSelectedCells(), and d_future_matrix.

Referenced by cutSelection().

void Matrix::closeEvent ( QCloseEvent *  e)

Close event handler.

Ask the user "delete, hide, or cancel?" if the "ask on close" flag is set.

Reimplemented from MyWidget.

References MyWidget::askOnClose, d_future_matrix, MyWidget::hiddenWindow(), and AbstractAspect::remove().

bool Matrix::columnsSelected ( )
slot

Return whether any columns are fully selected.

References MatrixView::isColumnSelected(), and numCols().

Referenced by ApplicationWindow::showWindowContextMenu().

void Matrix::copy ( Matrix m)
slot
void Matrix::copySelection ( )
slot

Standard copy operation.

References future::Matrix::copySelection(), and d_future_matrix.

Referenced by cutSelection().

void Matrix::customEvent ( QEvent *  e)

Custom event handler.

Currently handles SCRIPTING_CHANGE_EVENT only.

References SCRIPTING_CHANGE_EVENT, and scripted::scriptingChangeEvent().

void Matrix::cutSelection ( )
slot

Standard cut operation.

References clearSelection(), and copySelection().

void Matrix::deleteSelectedColumns ( )
slot

Delte the selected columns.

References d_future_matrix, and future::Matrix::removeSelectedColumns().

void Matrix::deleteSelectedRows ( )
slot

Delete the selected rows.

References d_future_matrix, and future::Matrix::removeSelectedRows().

double Matrix::determinant ( )
slot

Calculate the determinant of the matrix.

References cell(), numCols(), and numRows().

Referenced by ApplicationWindow::matrixDeterminant().

void Matrix::exportPDF ( const QString &  fileName)
virtualslot

Reimplemented from MyWidget.

References print().

void Matrix::forgetSavedCells ( )
slot

\ brief Free memory of saved cells

See also:
setNumericFormat(), saveCellsToMemory(), dMatrix

References dMatrix, freeMatrixData(), and numRows().

Referenced by recalculate().

QString Matrix::formula ( )
slot

Return the matrix formula.

References d_future_matrix, and future::Matrix::formula().

Referenced by recalculate(), saveAsTemplate(), and saveToString().

void Matrix::freeMatrixData ( double **  data,
int  rows 
)
staticslot
Matrix * Matrix::fromImage ( const QImage &  image,
ScriptingEnv env 
)
staticslot

References Matrix().

Referenced by ApplicationWindow::importImage().

void Matrix::handleAspectDescriptionChange ( const AbstractAspect aspect)
protectedslot
void Matrix::handleChange ( )
slot

References MyWidget::modifiedWindow().

Referenced by init().

void Matrix::init ( int  rows,
int  cols 
)
private
void Matrix::insertColumn ( )
slot

Insert a column before the current cell.

References d_future_matrix, and future::Matrix::insertEmptyColumns().

void Matrix::insertRow ( )
slot

Insert a row before the current cell.

References d_future_matrix, and future::Matrix::insertEmptyRows().

void Matrix::invert ( )
slot
virtual QString Matrix::name ( )
inlinevirtual
int Matrix::numCols ( )
int Matrix::numRows ( )
int Matrix::numSelectedColumns ( )
slot

Return the number of selected columns.

References MatrixView::isColumnSelected(), and numCols().

int Matrix::numSelectedRows ( )
slot

Return the number of selected rows.

References MatrixView::isRowSelected(), and numRows().

void Matrix::pasteSelection ( )
slot

Standard paste operation.

References d_future_matrix, and future::Matrix::pasteIntoSelection().

int Matrix::precision ( )
inlineslot

Return the number precision digits.

See arguments of setNumericFormat().

See also:
setNumericFormat(), setTextFormat()

References d_future_matrix, and future::Matrix::displayedDigits().

void Matrix::print ( )
virtualslot

Print the Matrix.

Reimplemented from MyWidget.

Referenced by exportPDF(), and recalculate().

void Matrix::print ( const QString &  fileName)
slot
void Matrix::range ( double *  min,
double *  max 
)
slot

Min and max values of the matrix.

References cell(), numCols(), and numRows().

Referenced by MatrixData::MatrixData().

bool Matrix::recalculate ( )
slot
bool Matrix::rowsSelected ( )
slot

Return whether any rows are fully selected.

References MatrixView::isRowSelected(), and numRows().

Referenced by ApplicationWindow::showWindowContextMenu().

QString Matrix::saveAsTemplate ( const QString &  info)
virtualslot

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

Reimplemented from MyWidget.

References MatrixView::columnWidth(), d_future_matrix, future::Matrix::displayedDigits(), formula(), numCols(), future::Matrix::numericFormat(), numRows(), xEnd(), xStart(), yEnd(), and yStart().

void Matrix::saveCellsToMemory ( )
slot
QString Matrix::saveText ( )
slot

Return a string conaining the data of the matrix (<data> section)

References cell(), future::Matrix::columnCount(), d_future_matrix, and future::Matrix::rowCount().

Referenced by saveToString().

QString Matrix::saveToString ( const QString &  info)
virtualslot
virtual void Matrix::setBirthDate ( const QString &  s)
inlinevirtual

Set the creation date.

Reimplemented from MyWidget.

References MyWidget::birthdate, d_future_matrix, and AbstractAspect::importV0x0001XXCreationTime().

Referenced by ApplicationWindow::openMatrix().

void Matrix::setCaptionPolicy ( CaptionPolicy  policy)
inlinevirtual
void Matrix::setCell ( int  row,
int  col,
double  value 
)
slot
void Matrix::setColumnsWidth ( int  width)
slot

Set the width of all columns (obsolete, only for OPJ import)

Don't uses this. Use view()->setColumnWidth(column, width) instead.

References future::Matrix::columnCount(), d_future_matrix, and MatrixView::setColumnWidth().

Referenced by ImportOPJ::importTables(), and ApplicationWindow::openMatrix().

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

Set the X and Y coordinate intervals.

References d_future_matrix, and future::Matrix::setCoordinates().

Referenced by ApplicationWindow::openMatrix().

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

Set the Matrix size.

References d_future_matrix, and future::Matrix::setDimensions().

void Matrix::setFormula ( const QString &  s)
slot
virtual void Matrix::setName ( const QString &  s)
inlinevirtual
void Matrix::setNumCols ( int  cols)
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().

Parameters:
fformat character 'e', 'f', 'g'
prec
  • for 'e', 'f': the number of digits after the radix character (point)
  • for 'g': the maximum number of significant digits
See also:
saveCellsToMemory(), forgetSavedCells(), dMatrix

References d_future_matrix, future::Matrix::displayedDigits(), MyWidget::modifiedWindow(), future::Matrix::numericFormat(), future::Matrix::setDisplayedDigits(), and future::Matrix::setNumericFormat().

Referenced by ImportOPJ::importTables(), and ApplicationWindow::initMatrix().

void Matrix::setNumericPrecision ( int  prec)
inlineslot

Set the number of significant digits.

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

References d_future_matrix, and future::Matrix::setDisplayedDigits().

void Matrix::setNumRows ( int  rows)
void Matrix::setText ( int  row,
int  col,
const QString &  new_text 
)
slot
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 d_future_matrix, future::Matrix::setDisplayedDigits(), and future::Matrix::setNumericFormat().

Referenced by ApplicationWindow::openMatrix().

virtual void Matrix::setWindowLabel ( const QString &  s)
inlinevirtual
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.

References d_future_matrix, and future::Matrix::text().

Referenced by print().

QChar Matrix::textFormat ( )
inlineslot

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

See also:
setNumerFormat(), setTextFormat()

References d_future_matrix, and future::Matrix::numericFormat().

void Matrix::transpose ( )
slot

Transpose the matrix.

References d_future_matrix, and future::Matrix::transpose().

void Matrix::updateDecimalSeparators ( )
void Matrix::updateFunctionDoc ( )
protectedslot
virtual QWidget* Matrix::view ( )
inlinevirtual
virtual QString Matrix::windowLabel ( )
inlinevirtual

Return the window label.

Reimplemented from MyWidget.

References AbstractAspect::comment(), and d_future_matrix.

Referenced by ApplicationWindow::convertMatrixToTable(), and saveToString().

double Matrix::xEnd ( )
inlineslot
double Matrix::xStart ( )
inlineslot
double Matrix::yEnd ( )
inlineslot
double Matrix::yStart ( )
inlineslot

Member Data Documentation

future::Matrix* Matrix::d_future_matrix
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.

Referenced by cell(), forgetSavedCells(), init(), and saveCellsToMemory().


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