SciDAVis  1.D4
Classes | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | Friends
future::Matrix Class Reference

Aspect providing a spreadsheet to manage MxN matrix data. More...

#include <future_Matrix.h>

Inheritance diagram for future::Matrix:
AbstractPart scripted AbstractAspect

List of all members.

Classes

class  Private

Public Slots

void addColumns ()
 Append as many columns as are selected.
void addRows ()
 Append as many rows as are selected.
void clear ()
 Clear the whole matrix (i.e. set all cells to 0.0)
void clearSelectedCells ()
void clearSelectedColumns ()
void clearSelectedRows ()
void copySelection ()
void cutSelection ()
void dimensionsDialog ()
void duplicate ()
 Duplicate the matrix inside its folder.
void editCoordinates ()
void editFormat ()
void editFormula ()
void goToCell ()
void importImageDialog ()
void insertEmptyColumns ()
 Insert columns depending on the selection.
void insertEmptyRows ()
 Insert rows depending on the selection.
void mirrorHorizontally ()
void mirrorVertically ()
void pasteIntoSelection ()
void removeSelectedColumns ()
void removeSelectedRows ()
void selectAll ()
void showMatrixViewColumnContextMenu (const QPoint &pos)
 Show a context menu for the selected columns.
void showMatrixViewContextMenu (const QPoint &pos)
 Show a context menu for the selected cells.
void showMatrixViewRowContextMenu (const QPoint &pos)
 Show a context menu for the selected rows.
void transpose ()
- Public Slots inherited from AbstractPart
virtual void copy ()
 Copy current selection.
virtual void cut ()
 Cut current selection.
virtual void paste ()
 Paste at the current location or into the current selection.
- Public Slots inherited from AbstractAspect
virtual void remove ()
 Remove me from my parent's list of children.
void setCaptionSpec (const QString &value)
 Set the specification string used for constructing the caption().
void setComment (const QString &value)
void setName (const QString &value)
QString uniqueNameFor (const QString &current_name) const
 Make the specified name unique among my children by incrementing a trailing number.

Signals

void columnsAboutToBeInserted (int before, int count)
void columnsAboutToBeRemoved (int first, int count)
void columnsInserted (int first, int count)
void columnsRemoved (int first, int count)
void coordinatesChanged ()
void dataChanged (int top, int left, int bottom, int right)
void formatChanged ()
void formulaChanged ()
void rowsAboutToBeInserted (int before, int count)
void rowsAboutToBeRemoved (int first, int count)
void rowsInserted (int first, int count)
void rowsRemoved (int first, int count)

Public Member Functions

void appendColumns (int count)
void appendRows (int count)
double cell (int row, int col) const
 Return the value in the given cell.
QVector< qreal > columnCells (int col, int first_row, int last_row)
 Return the values in the given cells as double vector.
int columnCount () const
 Return the total number of columns.
int columnWidth (int col) const
void copy (Matrix *other)
QMenu * createColumnMenu (QMenu *append_to=0)
 Create a menu with column related operations.
virtual QMenu * createContextMenu () const
 Return a new context menu.
QMenu * createMatrixMenu (QMenu *append_to=0)
 Create a menu with table related operations.
QMenu * createRowMenu (QMenu *append_to=0)
 Create a menu with row related operations.
QMenu * createSelectionMenu (QMenu *append_to=0)
 Create a menu with selection related operations.
int displayedDigits () const
virtual bool fillProjectMenu (QMenu *menu)
 Fill the part specific menu for the main window including setting the title.
QString formula () const
virtual QIcon icon () const
 Return an icon to be used for decorating my views.
void insertColumns (int before, int count)
void insertRows (int before, int count)
 Matrix (AbstractScriptingEngine *engine, int rows, int cols, const QString &name)
 Constructor.
char numericFormat () const
void removeColumns (int first, int count)
void removeRows (int first, int count)
QVector< qreal > rowCells (int row, int first_column, int last_column)
 Return the values in the given cells as double vector.
int rowCount () const
 Return the total number of rows.
int rowHeight (int row) const
void setCell (int row, int col, double value)
 Set the value of the cell.
void setColumnCells (int col, int first_row, int last_row, const QVector< qreal > &values)
 Set the values in the given cells from a double vector.
void setColumnWidth (int col, int width)
 This method should only be called by the view.
void setCoordinates (double x1, double x2, double y1, double y2)
void setDimensions (int rows, int cols)
 Set the number of rows and columns.
void setDisplayedDigits (int digits)
void setFormula (const QString &formula)
void setNumericFormat (char format)
void setPlotMenu (QMenu *menu)
 Set a plot menu.
void setRowCells (int row, int first_column, int last_column, const QVector< qreal > &values)
 Set the values in the given cells from a double vector.
void setRowHeight (int row, int height)
 This method should only be called by the view.
void setXEnd (double x)
void setXStart (double x)
void setYEnd (double y)
void setYStart (double y)
QString text (int row, int col)
 Return the text displayed in the given cell.
virtual QWidget * view ()
 Construct a primary view on me.
double xEnd () const
double xStart () const
double yEnd () const
double yStart () const
 ~Matrix ()
serialize/deserialize
virtual void save (QXmlStreamWriter *) const
 Save as XML.
virtual bool load (XmlStreamReader *)
 Load from XML.
- Public Member Functions inherited from AbstractPart
 AbstractPart (const QString &name)
 Constructor.
virtual bool fillProjectToolBar (QToolBar *bar)
 Fill the part specific tool bar for the main window including setting the title.
PartMdiViewmdiSubWindow ()
 Wrap the view() into a PartMdiView.
- Public Member Functions inherited from AbstractAspect
 AbstractAspect (const QString &name)
void addChild (AbstractAspect *child)
 Add the given Aspect to my list of children.
QString caption () const
QString captionSpec () const
 Return the specification string used for constructing the caption().
AbstractAspectchild (int index) const
 Get a child by its position in my list of children.
int childCount () const
 Return the number of child Aspects.
QString comment () const
QDateTime creationTime () const
QList< AbstractAspect * > descendantsThatInherit (const char *class_name)
 Get all descendents that inherit the given class.
future::Folderfolder ()
 Return the folder the Aspect is contained in or 0 if not.
void importV0x0001XXCreationTime (const QString &str)
int index () const
 Return my position in my parent's list of children.
int indexOfChild (const AbstractAspect *child) const
 Return the position of child in my list of children.
void insertChild (AbstractAspect *child, int index)
 Insert the given Aspect at a specific position in my list of children.
bool isDescendantOf (AbstractAspect *other)
 Return whether the there is a path upwards to the given aspect.
void moveChild (int from, int to)
 Change the positon of a child in my list of children.
QString name () const
AbstractAspectparentAspect () const
 Return my parent Aspect or 0 if I currently don't have one.
virtual QString path () const
 Return the path that leads from the top-most Aspect (usually a Project) to me.
virtual const Projectproject () const
 Return the Project this Aspect belongs to, or 0 if it is currently not part of one.
virtual Projectproject ()
 Return the Project this Aspect belongs to, or 0 if it is currently not part of one.
virtual void removeAllChildAspects ()
 Remove all child aspects.
void removeChild (AbstractAspect *child, bool detach=false)
 Remove the given Aspect from my list of children.
void removeChild (int index)
 Remove the Aspect at the given index from my list of children.
void reparentChild (AbstractAspect *new_parent, AbstractAspect *child, int d_new_index)
 Move a child to another aspect and transfer ownership.
void reparentChild (AbstractAspect *new_parent, AbstractAspect *child)
 Move a child to another aspect and transfer ownership.
virtual ~AbstractAspect ()
virtual QUndoStack * undoStack () const
 Return the undo stack of the Project, or 0 if this Aspect is not part of a Project.
void exec (QUndoCommand *command)
 Execute the given command, pushing it on the undoStack() if available.
void beginMacro (const QString &text)
 Begin an undo stack macro (series of commands)
void endMacro ()
 End the undo stack macro.
- Public Member Functions inherited from scripted
 scripted (ScriptingEnv *env)
void scriptingChangeEvent (ScriptingChangeEvent *)
 ~scripted ()

Static Public Member Functions

static ActionManageractionManager ()
static int defaultColumnWidth ()
static int defaultRowHeight ()
static MatrixfromImage (const QImage &image)
static void initActionManager ()
static void setDefaultColumnWidth (int width)
static void setDefaultRowHeight (int height)

Private Slots

void adjustTabBarAction (bool visible)

Private Member Functions

void addActionsToView ()
void connectActions ()
void createActions ()
 Matrix ()
 Private ctor for initActionManager() only.
bool readCellElement (XmlStreamReader *reader)
 Read XML cell element.
bool readColumnWidthElement (XmlStreamReader *reader)
bool readCoordinatesElement (XmlStreamReader *reader)
 Read XML coodinates element.
bool readDisplayElement (XmlStreamReader *reader)
 Read XML display element.
bool readFormulaElement (XmlStreamReader *reader)
 Read XML formula element.
bool readRowHeightElement (XmlStreamReader *reader)

Private Attributes

Privated_matrix_private
QMenu * d_plot_menu
MatrixViewd_view
selection related actions
QAction * action_cut_selection
QAction * action_copy_selection
QAction * action_paste_into_selection
QAction * action_clear_selection
matrix related actions
QAction * action_toggle_tabbar
QAction * action_select_all
QAction * action_clear_matrix
QAction * action_go_to_cell
QAction * action_dimensions_dialog
QAction * action_edit_format
QAction * action_edit_coordinates
QAction * action_set_formula
QAction * action_recalculate
QAction * action_import_image
QAction * action_duplicate
QAction * action_transpose
QAction * action_mirror_vertically
QAction * action_mirror_horizontally
column related actions
QAction * action_insert_columns
QAction * action_remove_columns
QAction * action_clear_columns
QAction * action_add_columns
row related actions
QAction * action_insert_rows
QAction * action_remove_rows
QAction * action_clear_rows
QAction * action_add_rows

Static Private Attributes

static ActionManageraction_manager = 0
static int default_column_width = 120
static int default_row_height = 20

Friends

class Private

Additional Inherited Members

- Protected Attributes inherited from scripted
ScriptingEnvscriptEnv

Detailed Description

Aspect providing a spreadsheet to manage MxN matrix data.


Constructor & Destructor Documentation

Matrix::Matrix ( AbstractScriptingEngine *  engine,
int  rows,
int  cols,
const QString &  name 
)

Constructor.

Parameters:
enginescripting engine
rowsinitial number of rows
colsinitial number of columns
nameobject name

References appendColumns(), appendRows(), connectActions(), createActions(), d_matrix_private, d_view, and Private.

Matrix::~Matrix ( )

References d_view.

Matrix::Matrix ( )
private

Private ctor for initActionManager() only.

References createActions(), and d_view.

Referenced by duplicate(), fromImage(), and initActionManager().


Member Function Documentation

ActionManager * Matrix::actionManager ( )
static

References action_manager, and initActionManager().

Referenced by createActions().

void Matrix::addActionsToView ( )
private
void Matrix::addColumns ( )
slot
void Matrix::addRows ( )
slot
void Matrix::adjustTabBarAction ( bool  visible)
privateslot

References action_toggle_tabbar.

Referenced by view().

void future::Matrix::appendColumns ( int  count)
inline

References columnCount(), and insertColumns().

Referenced by Matrix(), and pasteIntoSelection().

void future::Matrix::appendRows ( int  count)
inline

References insertRows(), and rowCount().

Referenced by Matrix(), and pasteIntoSelection().

double Matrix::cell ( int  row,
int  col 
) const
void Matrix::clear ( )
slot
void Matrix::clearSelectedCells ( )
slot
void Matrix::clearSelectedColumns ( )
slot
void Matrix::clearSelectedRows ( )
slot
QVector< qreal > Matrix::columnCells ( int  col,
int  first_row,
int  last_row 
)

Return the values in the given cells as double vector.

References future::Matrix::Private::columnCells(), and d_matrix_private.

Referenced by copy().

int Matrix::columnCount ( ) const
void future::Matrix::columnsAboutToBeInserted ( int  before,
int  count 
)
signal
void future::Matrix::columnsAboutToBeRemoved ( int  first,
int  count 
)
signal
void future::Matrix::columnsInserted ( int  first,
int  count 
)
signal
void future::Matrix::columnsRemoved ( int  first,
int  count 
)
signal
int Matrix::columnWidth ( int  col) const
void Matrix::connectActions ( )
private
void future::Matrix::coordinatesChanged ( )
signal
void Matrix::copy ( Matrix other)
void Matrix::copySelection ( )
slot
void Matrix::createActions ( )
private
QMenu * Matrix::createColumnMenu ( QMenu *  append_to = 0)

Create a menu with column related operations.

Parameters:
append_toif a pointer to a QMenu is passed to the function, the actions are appended to it instead of the creation of a new menu.

References action_clear_columns, action_edit_coordinates, action_insert_columns, and action_remove_columns.

Referenced by showMatrixViewColumnContextMenu().

QMenu * Matrix::createContextMenu ( ) const
virtual

Return a new context menu.

The caller takes ownership of the menu.

Reimplemented from AbstractPart.

References action_duplicate.

QMenu * Matrix::createMatrixMenu ( QMenu *  append_to = 0)

Create a menu with table related operations.

Parameters:
append_toif a pointer to a QMenu is passed to the function, the actions are appended to it instead of the creation of a new menu.

References action_clear_matrix, action_edit_format, action_go_to_cell, action_recalculate, action_select_all, action_set_formula, and action_toggle_tabbar.

Referenced by showMatrixViewContextMenu().

QMenu * Matrix::createRowMenu ( QMenu *  append_to = 0)

Create a menu with row related operations.

Parameters:
append_toif a pointer to a QMenu is passed to the function, the actions are appended to it instead of the creation of a new menu.

References action_clear_rows, action_edit_coordinates, action_insert_rows, and action_remove_rows.

Referenced by showMatrixViewRowContextMenu().

QMenu * Matrix::createSelectionMenu ( QMenu *  append_to = 0)

Create a menu with selection related operations.

Parameters:
append_toif a pointer to a QMenu is passed to the function, the actions are appended to it instead of the creation of a new menu.

References action_clear_selection, action_copy_selection, action_cut_selection, and action_paste_into_selection.

Referenced by showMatrixViewContextMenu().

void Matrix::cutSelection ( )
slot
void future::Matrix::dataChanged ( int  top,
int  left,
int  bottom,
int  right 
)
signal
static int future::Matrix::defaultColumnWidth ( )
inlinestatic
static int future::Matrix::defaultRowHeight ( )
inlinestatic
void Matrix::dimensionsDialog ( )
slot

References columnCount(), rowCount(), and setDimensions().

Referenced by connectActions().

int Matrix::displayedDigits ( ) const
void Matrix::duplicate ( )
slot

Duplicate the matrix inside its folder.

References AbstractAspect::addChild(), columnCount(), copy(), AbstractAspect::folder(), Matrix(), AbstractAspect::name(), and rowCount().

Referenced by connectActions().

void Matrix::editCoordinates ( )
slot
void Matrix::editFormat ( )
slot
void Matrix::editFormula ( )
slot
bool Matrix::fillProjectMenu ( QMenu *  menu)
virtual

Fill the part specific menu for the main window including setting the title.

Returns:
true on success, otherwise false (e.g. part has no actions).

Reimplemented from AbstractPart.

References action_clear_matrix, action_dimensions_dialog, action_duplicate, action_edit_coordinates, action_edit_format, action_go_to_cell, action_import_image, action_mirror_horizontally, action_mirror_vertically, action_recalculate, action_set_formula, action_toggle_tabbar, and action_transpose.

void future::Matrix::formatChanged ( )
signal
QString Matrix::formula ( ) const
void future::Matrix::formulaChanged ( )
signal
Matrix * Matrix::fromImage ( const QImage &  image)
static

References Matrix(), and setColumnCells().

Referenced by importImageDialog().

void Matrix::goToCell ( )
slot
QIcon Matrix::icon ( ) const
virtual

Return an icon to be used for decorating my views.

Reimplemented from AbstractAspect.

void Matrix::importImageDialog ( )
slot
void Matrix::initActionManager ( )
static

References action_manager, and Matrix().

Referenced by actionManager().

void Matrix::insertColumns ( int  before,
int  count 
)
void Matrix::insertEmptyColumns ( )
slot
void Matrix::insertEmptyRows ( )
slot
void Matrix::insertRows ( int  before,
int  count 
)
bool Matrix::load ( XmlStreamReader reader)
virtual
void Matrix::mirrorHorizontally ( )
slot
void Matrix::mirrorVertically ( )
slot
char Matrix::numericFormat ( ) const
void Matrix::pasteIntoSelection ( )
slot
bool Matrix::readCellElement ( XmlStreamReader reader)
private

Read XML cell element.

References XmlStreamReader::raiseError(), XmlStreamReader::readAttributeInt(), and setCell().

Referenced by load().

bool Matrix::readColumnWidthElement ( XmlStreamReader reader)
private
bool Matrix::readCoordinatesElement ( XmlStreamReader reader)
private
bool Matrix::readDisplayElement ( XmlStreamReader reader)
private
bool Matrix::readFormulaElement ( XmlStreamReader reader)
private

Read XML formula element.

References setFormula().

Referenced by load().

bool Matrix::readRowHeightElement ( XmlStreamReader reader)
private
void Matrix::removeColumns ( int  first,
int  count 
)
void Matrix::removeRows ( int  first,
int  count 
)
void Matrix::removeSelectedColumns ( )
slot
void Matrix::removeSelectedRows ( )
slot
QVector< qreal > Matrix::rowCells ( int  row,
int  first_column,
int  last_column 
)

Return the values in the given cells as double vector.

References d_matrix_private, and future::Matrix::Private::rowCells().

int Matrix::rowCount ( ) const
int Matrix::rowHeight ( int  row) const
void future::Matrix::rowsAboutToBeInserted ( int  before,
int  count 
)
signal
void future::Matrix::rowsAboutToBeRemoved ( int  first,
int  count 
)
signal
void future::Matrix::rowsInserted ( int  first,
int  count 
)
signal
void future::Matrix::rowsRemoved ( int  first,
int  count 
)
signal
void Matrix::save ( QXmlStreamWriter *  writer) const
virtual
void Matrix::selectAll ( )
slot

References d_view, and MatrixView::selectAll().

Referenced by connectActions().

void Matrix::setCell ( int  row,
int  col,
double  value 
)
void Matrix::setColumnCells ( int  col,
int  first_row,
int  last_row,
const QVector< qreal > &  values 
)

Set the values in the given cells from a double vector.

References d_matrix_private, AbstractAspect::exec(), RESET_CURSOR, and WAIT_CURSOR.

Referenced by copy(), and fromImage().

void Matrix::setColumnWidth ( int  col,
int  width 
)

This method should only be called by the view.

This method does not change the view, it only changes the values that are saved when the matrix is saved. The view has to take care of reading and applying these values

References d_matrix_private, and future::Matrix::Private::setColumnWidth().

Referenced by copy(), MatrixView::handleHorizontalSectionResized(), and readColumnWidthElement().

void Matrix::setCoordinates ( double  x1,
double  x2,
double  y1,
double  y2 
)
static void future::Matrix::setDefaultColumnWidth ( int  width)
inlinestatic

References default_column_width.

static void future::Matrix::setDefaultRowHeight ( int  height)
inlinestatic

References default_row_height.

void Matrix::setDimensions ( int  rows,
int  cols 
)
void Matrix::setDisplayedDigits ( int  digits)
void Matrix::setFormula ( const QString &  formula)
void Matrix::setNumericFormat ( char  format)
void Matrix::setPlotMenu ( QMenu *  menu)

Set a plot menu.

The matrix takes ownership of the menu.

References d_plot_menu.

void Matrix::setRowCells ( int  row,
int  first_column,
int  last_column,
const QVector< qreal > &  values 
)

Set the values in the given cells from a double vector.

References d_matrix_private, AbstractAspect::exec(), RESET_CURSOR, and WAIT_CURSOR.

void Matrix::setRowHeight ( int  row,
int  height 
)

This method should only be called by the view.

This method does not change the view, it only changes the values that are saved when the matrix is saved. The view has to take care of reading and applying these values

References d_matrix_private, and future::Matrix::Private::setRowHeight().

Referenced by copy(), MatrixView::handleVerticalSectionResized(), and readRowHeightElement().

void Matrix::setXEnd ( double  x)
void Matrix::setXStart ( double  x)
void Matrix::setYEnd ( double  y)
void Matrix::setYStart ( double  y)
void Matrix::showMatrixViewColumnContextMenu ( const QPoint &  pos)
slot

Show a context menu for the selected columns.

Parameters:
posglobal position of the event

References createColumnMenu().

Referenced by MatrixView::eventFilter().

void Matrix::showMatrixViewContextMenu ( const QPoint &  pos)
slot

Show a context menu for the selected cells.

Parameters:
posglobal position of the event

References createMatrixMenu(), createSelectionMenu(), and d_view.

Referenced by MatrixView::eventFilter().

void Matrix::showMatrixViewRowContextMenu ( const QPoint &  pos)
slot

Show a context menu for the selected rows.

Parameters:
posglobal position of the event

References createRowMenu().

Referenced by MatrixView::eventFilter().

QString Matrix::text ( int  row,
int  col 
)
void Matrix::transpose ( )
slot
QWidget * Matrix::view ( )
virtual

Construct a primary view on me.

This method may be called multiple times during the life time of an Aspect, or it might not get called at all. Aspects must not depend on the existence of a view for their operation.

Implements AbstractPart.

References addActionsToView(), adjustTabBarAction(), and d_view.

Referenced by ApplicationWindow::handleAspectAboutToBeRemoved(), ApplicationWindow::handleAspectAdded(), MatrixModel::setData(), and Matrix::view().

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

Friends And Related Function Documentation

friend class Private
friend

Reimplemented from AbstractAspect.

Referenced by Matrix().


Member Data Documentation

QAction* future::Matrix::action_add_columns
private
QAction* future::Matrix::action_add_rows
private
QAction* future::Matrix::action_clear_columns
private
QAction* future::Matrix::action_clear_matrix
private
QAction* future::Matrix::action_clear_rows
private
QAction* future::Matrix::action_clear_selection
private
QAction* future::Matrix::action_copy_selection
private
QAction* future::Matrix::action_cut_selection
private
QAction* future::Matrix::action_dimensions_dialog
private
QAction* future::Matrix::action_duplicate
private
QAction* future::Matrix::action_edit_coordinates
private
QAction* future::Matrix::action_edit_format
private
QAction* future::Matrix::action_go_to_cell
private
QAction* future::Matrix::action_import_image
private
QAction* future::Matrix::action_insert_columns
private
QAction* future::Matrix::action_insert_rows
private
ActionManager * Matrix::action_manager = 0
staticprivate

Referenced by actionManager(), and initActionManager().

QAction* future::Matrix::action_mirror_horizontally
private
QAction* future::Matrix::action_mirror_vertically
private
QAction* future::Matrix::action_paste_into_selection
private
QAction* future::Matrix::action_recalculate
private
QAction* future::Matrix::action_remove_columns
private
QAction* future::Matrix::action_remove_rows
private
QAction* future::Matrix::action_select_all
private
QAction* future::Matrix::action_set_formula
private
QAction* future::Matrix::action_toggle_tabbar
private
QAction* future::Matrix::action_transpose
private
Private* future::Matrix::d_matrix_private
private
QMenu* future::Matrix::d_plot_menu
private

Referenced by setPlotMenu().

MatrixView* future::Matrix::d_view
private
int Matrix::default_column_width = 120
staticprivate
int Matrix::default_row_height = 20
staticprivate

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