labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Matrix Class Reference

#include <Matrix.h>

Inheritance diagram for Matrix:
[legend]
Collaboration diagram for Matrix:
[legend]

Public Types

enum class  HeaderFormat { HeaderRowsColumns , HeaderValues , HeaderRowsColumnsValues }
 
typedef MatrixPrivate Private
 
- Public Types inherited from AbstractAspect
enum class  ChildIndexFlag { IncludeHidden = 0x01 , Recursive = 0x02 , Compress = 0x04 }
 Flags which control numbering scheme of children. More...
 

Public Slots

void clear ()
 Clear the whole matrix (i.e. reset all cells) More...
 
void transpose ()
 
void mirrorVertically ()
 
void mirrorHorizontally ()
 
void addColumns ()
 
void addRows ()
 
void duplicate ()
 Duplicate the matrix inside its folder. More...
 
- Public Slots inherited from AbstractAspect
bool setName (const QString &, bool autoUnique=true)
 AbstractAspect::setName sets the name of the abstract aspect. More...
 
void setComment (const QString &)
 
void remove ()
 Remove me from my parent's list of children. More...
 

Signals

void requestProjectContextMenu (QMenu *)
 
void columnsAboutToBeInserted (int before, int count)
 
void columnsInserted (int first, int count)
 
void columnsAboutToBeRemoved (int first, int count)
 
void columnsRemoved (int first, int count)
 
void rowsAboutToBeInserted (int before, int count)
 
void rowsInserted (int first, int count)
 
void rowsAboutToBeRemoved (int first, int count)
 
void rowsRemoved (int first, int count)
 
void dataChanged (int top, int left, int bottom, int right)
 
void coordinatesChanged ()
 
void rowCountChanged (int)
 
void columnCountChanged (int)
 
void xStartChanged (double)
 
void xEndChanged (double)
 
void yStartChanged (double)
 
void yEndChanged (double)
 
void numericFormatChanged (char)
 
void precisionChanged (int)
 
void headerFormatChanged (Matrix::HeaderFormat)
 
- Signals inherited from AbstractPart
void showRequested ()
 
void importFromFileRequested ()
 
void importFromSQLDatabaseRequested ()
 
void exportRequested ()
 
void printRequested ()
 
void printPreviewRequested ()
 
- Signals inherited from AbstractAspect
void aspectDescriptionAboutToChange (const AbstractAspect *)
 Emitted before the name, comment or caption spec is changed. More...
 
void aspectDescriptionChanged (const AbstractAspect *)
 Emitted after the name, comment or caption spec have changed. More...
 
void aspectAboutToBeAdded (const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
 Emitted before a new child is inserted. More...
 
void aspectAdded (const AbstractAspect *)
 Emitted after a new Aspect has been added to the tree. More...
 
void aspectAboutToBeRemoved (const AbstractAspect *)
 Emitted before an aspect is removed from its parent. More...
 
void aspectRemoved (const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
 Emitted from the parent after removing a child. More...
 
void aspectHiddenAboutToChange (const AbstractAspect *)
 Emitted before the hidden attribute is changed. More...
 
void aspectHiddenChanged (const AbstractAspect *)
 Emitted after the hidden attribute has changed. More...
 
void statusInfo (const QString &)
 Emitted whenever some aspect in the tree wants to give status information to the user. More...
 
void renameRequested ()
 
void selected (const AbstractAspect *)
 
void deselected (const AbstractAspect *)
 
void childAspectSelectedInView (const AbstractAspect *)
 
void childAspectDeselectedInView (const AbstractAspect *)
 

Public Member Functions

 Matrix (const QString &name, bool loading=false, const AbstractColumn::ColumnMode=AbstractColumn::ColumnMode::Numeric)
 
 Matrix (int rows, int cols, const QString &name, const AbstractColumn::ColumnMode=AbstractColumn::ColumnMode::Numeric)
 
 ~Matrix () override
 
QIcon icon () const override
 
QMenu * createContextMenu () override
 
QWidget * view () const override
 Construct a primary view on me. More...
 
bool exportView () const override
 
bool printView () override
 
bool printPreview () const override
 
void * data () const
 
void setData (void *)
 
void setSuppressDataChangedSignal (bool)
 
void setChanged ()
 
int rowHeight (int row) const
 
void setRowHeight (int row, int height)
 This method should only be called by the view. More...
 
int columnWidth (int col) const
 
void setColumnWidth (int col, int width)
 This method should only be called by the view. More...
 
void setDimensions (int rows, int cols)
 
void setCoordinates (double x1, double x2, double y1, double y2)
 
void insertColumns (int before, int count)
 
void appendColumns (int count)
 
void removeColumns (int first, int count)
 
void clearColumn (int)
 
void insertRows (int before, int count)
 
void appendRows (int count)
 
void removeRows (int first, int count)
 
void clearRow (int)
 
template<typename T >
cell (int row, int col) const
 Return the value in the given cell (needs explicit instantiation) More...
 
template<typename T >
QString text (int row, int col)
 Return the text displayed in the given cell (needs explicit instantiation) More...
 
template<typename T >
void setCell (int row, int col, T value)
 Set the value of the cell (needs explicit instantiation) More...
 
void clearCell (int row, int col)
 
template<typename T >
QVector< T > columnCells (int col, int first_row, int last_row)
 Return the values in the given cells as vector. More...
 
template<typename T >
void setColumnCells (int col, int first_row, int last_row, const QVector< T > &values)
 Set the values in the given cells from a type T vector. More...
 
template<typename T >
QVector< T > rowCells (int row, int first_column, int last_column)
 Return the values in the given cells as vector (needs explicit instantiation) More...
 
template<typename T >
void setRowCells (int row, int first_column, int last_column, const QVector< T > &values)
 Set the values in the given cells from a type T vector. More...
 
void copy (Matrix *other)
 
void save (QXmlStreamWriter *) const override
 Save as XML. More...
 
bool load (XmlStreamReader *, bool preview) override
 Load from XML. More...
 
int prepareImport (std::vector< void * > &dataContainer, AbstractFileFilter::ImportMode, int rows, int cols, QStringList colNameList, QVector< AbstractColumn::ColumnMode >) override
 
void finalizeImport (int columnOffset, int startColumn, int endColumn, const QString &dateTimeFormat, AbstractFileFilter::ImportMode) override
 
template<>
QString text (int row, int col)
 
template<>
QString text (int row, int col)
 
- Public Member Functions inherited from AbstractDataSource
 AbstractDataSource (const QString &name, AspectType type)
 
 ~AbstractDataSource () override=default
 
void clear ()
 
- Public Member Functions inherited from AbstractPart
 AbstractPart (const QString &name, AspectType type)
 
 ~AbstractPart () override
 
void deleteView () const
 
PartMdiViewmdiSubWindow () const
 Wrap the view() into a PartMdiView. More...
 
bool hasMdiSubWindow () const
 
bool isDraggable () const override
 
QVector< AspectTypedropableOn () const override
 
virtual void registerShortcuts ()
 
virtual void unregisterShortcuts ()
 
- Public Member Functions inherited from AbstractAspect
 AbstractAspect (const QString &name, AspectType type)
 
 ~AbstractAspect () override
 
QString name () const
 
QString comment () const
 
void setCreationTime (const QDateTime &)
 
QDateTime creationTime () const
 
virtual Projectproject ()
 Return the Project this Aspect belongs to, or 0 if it is currently not part of one. More...
 
virtual QString path () const
 Return the path that leads from the top-most Aspect (usually a Project) to me. More...
 
void setHidden (bool)
 Set "hidden" property, i.e. whether to exclude this aspect from being shown in the explorer. More...
 
bool hidden () const
 
void setIsLoading (bool)
 
bool isLoading () const
 
AspectType type () const
 
bool inherits (AspectType type) const
 
AbstractAspectparentAspect () const
 Return my parent Aspect or 0 if I currently don't have one. More...
 
AbstractAspectparent (AspectType type) const
 In the parent-child hierarchy, return the first parent of type. More...
 
void setParentAspect (AbstractAspect *)
 
Folderfolder ()
 Return the folder the Aspect is contained in or 0 if there is none. More...
 
bool isDescendantOf (AbstractAspect *other)
 Return whether the there is a path upwards to the given aspect. More...
 
void addChild (AbstractAspect *)
 Add the given Aspect to my list of children. More...
 
void addChildFast (AbstractAspect *)
 Add the given Aspect to my list of children without any checks and without putting this step onto the undo-stack. More...
 
virtual void finalizeAdd ()
 
QVector< AbstractAspect * > children (AspectType type, ChildIndexFlags flags={}) const
 
void insertChildBefore (AbstractAspect *child, AbstractAspect *before)
 Insert the given Aspect at a specific position in my list of children. More...
 
void insertChildBeforeFast (AbstractAspect *child, AbstractAspect *before)
 Insert the given Aspect at a specific position in my list of children.without any checks and without putting this step onto the undo-stack. More...
 
void reparent (AbstractAspect *newParent, int newIndex=-1)
 Move a child to another parent aspect and transfer ownership. More...
 
void removeChild (AbstractAspect *)
 Remove the given Aspect from my list of children. More...
 
void removeAllChildren ()
 Remove all child Aspects. More...
 
virtual QVector< AbstractAspect * > dependsOn () const
 
virtual void processDropEvent (const QVector< quintptr > &)
 
template<class T >
T * ancestor () const
 Return the closest ancestor of class T (or NULL if none found). More...
 
template<class T >
QVector< T * > children (ChildIndexFlags flags={}) const
 
template<class T >
T * child (int index, ChildIndexFlags flags={}) const
 
template<class T >
T * child (const QString &name) const
 Get child by name and class. More...
 
template<class T >
int childCount (ChildIndexFlags flags={}) const
 Return the number of child Aspects inheriting from given class. More...
 
template<class T >
int indexOfChild (const AbstractAspect *child, ChildIndexFlags flags={}) const
 Return (0 based) index of child in the list of children inheriting from class T. More...
 
void setSelected (bool)
 
void setUndoAware (bool)
 
virtual QUndoStack * undoStack () const
 Return the undo stack of the Project, or 0 if this Aspect is not part of a Project. More...
 
void exec (QUndoCommand *)
 Execute the given command, pushing it on the undoStack() if available. More...
 
void exec (QUndoCommand *command, const char *preChangeSignal, const char *postChangeSignal, QGenericArgument val0=QGenericArgument(), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument())
 Execute command and arrange for signals to be sent before/after it is redone or undone. More...
 
void beginMacro (const QString &text)
 Begin an undo stack macro (series of commands) More...
 
void endMacro ()
 End the current undo stack macro. More...
 

Private Member Functions

void init ()
 

Private Attributes

MatrixPrivate *const d
 
MatrixModelm_model {nullptr}
 
MatrixViewm_view {nullptr}
 

Friends

class MatrixPrivate
 

Additional Inherited Members

- Protected Slots inherited from AbstractAspect
virtual void childSelected (const AbstractAspect *)
 
virtual void childDeselected (const AbstractAspect *)
 
- Protected Member Functions inherited from AbstractAspect
void info (const QString &text)
 Implementations should call this whenever status information should be given to the user. More...
 
bool readBasicAttributes (XmlStreamReader *)
 Load name and creation time from XML. More...
 
void writeBasicAttributes (QXmlStreamWriter *) const
 Save name and creation time to XML. More...
 
void writeCommentElement (QXmlStreamWriter *) const
 Save the comment to XML. More...
 
bool readCommentElement (XmlStreamReader *)
 Load comment from an XML element. More...
 
- Protected Attributes inherited from AbstractPart
QWidget * m_partView {nullptr}
 
- Protected Attributes inherited from AbstractAspect
const AspectType m_type
 

Detailed Description

Definition at line 41 of file Matrix.h.

Member Typedef Documentation

◆ Private

Definition at line 118 of file Matrix.h.

Member Enumeration Documentation

◆ HeaderFormat

enum Matrix::HeaderFormat
strong
Enumerator
HeaderRowsColumns 
HeaderValues 
HeaderRowsColumnsValues 

Definition at line 46 of file Matrix.h.

Constructor & Destructor Documentation

◆ Matrix()

Matrix::Matrix ( const QString &  name,
bool  loading = false,
const AbstractColumn::ColumnMode  mode = AbstractColumn::ColumnMode::Numeric 
)
explicit

Definition at line 70 of file Matrix.cpp.

References init().

Referenced by duplicate().

◆ ~Matrix()

Matrix::~Matrix ( )
override

Definition at line 77 of file Matrix.cpp.

References d.

Member Function Documentation

◆ addColumns

◆ addRows

◆ appendColumns()

void Matrix::appendColumns ( int  count)

Definition at line 297 of file Matrix.cpp.

References insertColumns().

Referenced by MatrixView::addColumns(), init(), Matrix(), and MatrixView::pasteIntoSelection().

◆ appendRows()

void Matrix::appendRows ( int  count)

Definition at line 358 of file Matrix.cpp.

References insertRows().

Referenced by MatrixView::addRows(), init(), Matrix(), MatrixView::pasteIntoSelection(), and setDimensions().

◆ cell()

template<typename T >
template QString Matrix::cell< QString > ( int  row,
int  col 
) const

Return the value in the given cell (needs explicit instantiation)

Definition at line 416 of file Matrix.cpp.

References MatrixPrivate::cell(), and d.

Referenced by MatrixView::copySelection(), AddSubtractValueDialog::generateForMatrices(), and AddSubtractValueDialog::setMatrices().

◆ clear

◆ clearCell()

◆ clearColumn()

◆ clearRow()

◆ columnCells()

template<typename T >
QVector< T > Matrix::columnCells ( int  col,
int  first_row,
int  last_row 
)

Return the values in the given cells as vector.

Definition at line 617 of file Matrix.cpp.

References MatrixPrivate::columnCells(), and d.

Referenced by copy().

◆ columnCountChanged

◆ columnsAboutToBeInserted

void Matrix::columnsAboutToBeInserted ( int  before,
int  count 
)
signal

◆ columnsAboutToBeRemoved

void Matrix::columnsAboutToBeRemoved ( int  first,
int  count 
)
signal

◆ columnsInserted

void Matrix::columnsInserted ( int  first,
int  count 
)
signal

◆ columnsRemoved

void Matrix::columnsRemoved ( int  first,
int  count 
)
signal

◆ columnWidth()

int Matrix::columnWidth ( int  col) const

Definition at line 611 of file Matrix.cpp.

References MatrixPrivate::columnWidth(), and d.

Referenced by MatrixView::adjustHeaders(), and copy().

◆ coordinatesChanged

void Matrix::coordinatesChanged ( )
signal

◆ copy()

◆ createContextMenu()

QMenu * Matrix::createContextMenu ( )
overridevirtual

Returns a new context menu. The caller takes ownership of the menu.

Reimplemented from AbstractPart.

Definition at line 114 of file Matrix.cpp.

References AbstractPart::createContextMenu(), and requestProjectContextMenu().

Referenced by WorkbookView::showTabContextMenu().

◆ data()

◆ dataChanged

void Matrix::dataChanged ( int  top,
int  left,
int  bottom,
int  right 
)
signal

◆ duplicate

void Matrix::duplicate ( )
slot

Duplicate the matrix inside its folder.

Definition at line 556 of file Matrix.cpp.

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

◆ exportView()

◆ finalizeImport()

void Matrix::finalizeImport ( int  columnOffset,
int  startColumn,
int  endColumn,
const QString &  dateTimeFormat,
AbstractFileFilter::ImportMode  importMode 
)
overridevirtual

◆ headerFormatChanged

void Matrix::headerFormatChanged ( Matrix::HeaderFormat  )
signal

◆ icon()

QIcon Matrix::icon ( ) const
overridevirtual

Returns an icon to be used for decorating my views.

Reimplemented from AbstractAspect.

Definition at line 107 of file Matrix.cpp.

◆ init()

◆ insertColumns()

void Matrix::insertColumns ( int  before,
int  count 
)

◆ insertRows()

void Matrix::insertRows ( int  before,
int  count 
)

Definition at line 351 of file Matrix.cpp.

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

Referenced by appendRows(), and MatrixView::insertEmptyRows().

◆ load()

bool Matrix::load ( XmlStreamReader ,
bool  preview 
)
overridevirtual

Load from XML.

XmlStreamReader supports errors as well as warnings. If only warnings (non-critical errors) occur, this function must return the reader at the end element corresponding to the current element at the time the function was called.

This function is normally intended to be called directly after the ctor. If you want to call load on an aspect that has been altered, you must make sure beforehand that it is in the same state as after creation, e.g., remove all its child aspects.

Returns
false on error

Implements AbstractAspect.

Definition at line 1130 of file Matrix.cpp.

References AbstractColumn::BigInt, MatrixPrivate::columnCount, MatrixPrivate::columnWidths, d, MatrixPrivate::data, AbstractColumn::DateTime, AbstractColumn::Day, DEBUG, MatrixPrivate::formula, MatrixPrivate::headerFormat, i18n, AbstractColumn::Integer, MatrixPrivate::mode, AbstractColumn::Month, AbstractColumn::Numeric, MatrixPrivate::numericFormat, MatrixPrivate::precision, XmlStreamReader::raiseWarning(), AbstractAspect::readBasicAttributes(), AbstractAspect::readCommentElement(), MatrixPrivate::rowCount, MatrixPrivate::rowHeights, XmlStreamReader::skipToEndElement(), AbstractColumn::Text, MatrixPrivate::xEnd, MatrixPrivate::xStart, MatrixPrivate::yEnd, and MatrixPrivate::yStart.

Referenced by Workbook::load(), and Folder::readChildAspectElement().

◆ mirrorHorizontally

◆ mirrorVertically

◆ numericFormatChanged

void Matrix::numericFormatChanged ( char  )
signal

◆ precisionChanged

void Matrix::precisionChanged ( int  )
signal

◆ prepareImport()

◆ printPreview()

bool Matrix::printPreview ( ) const
overridevirtual

Implements AbstractPart.

Definition at line 182 of file Matrix.cpp.

References m_view, and MatrixView::print().

◆ printView()

bool Matrix::printView ( )
overridevirtual

Implements AbstractPart.

Definition at line 169 of file Matrix.cpp.

References m_view, and MatrixView::print().

◆ removeColumns()

◆ removeRows()

◆ requestProjectContextMenu

void Matrix::requestProjectContextMenu ( QMenu *  )
signal

◆ rowCells()

template<typename T >
template QVector< QDateTime > Matrix::rowCells< QDateTime > ( int  row,
int  first_column,
int  last_column 
)

Return the values in the given cells as vector (needs explicit instantiation)

Definition at line 631 of file Matrix.cpp.

References d, and MatrixPrivate::rowCells().

Referenced by MatrixView::showRowStatistics().

◆ rowCountChanged

◆ rowHeight()

int Matrix::rowHeight ( int  row) const

Definition at line 607 of file Matrix.cpp.

References d, and MatrixPrivate::rowHeight().

Referenced by MatrixView::adjustHeaders(), and copy().

◆ rowsAboutToBeInserted

void Matrix::rowsAboutToBeInserted ( int  before,
int  count 
)
signal

◆ rowsAboutToBeRemoved

void Matrix::rowsAboutToBeRemoved ( int  first,
int  count 
)
signal

◆ rowsInserted

void Matrix::rowsInserted ( int  first,
int  count 
)
signal

◆ rowsRemoved

void Matrix::rowsRemoved ( int  first,
int  count 
)
signal

◆ save()

◆ setCell()

template<typename T >
template void Matrix::setCell< QDateTime > ( int  row,
int  col,
value 
)

Set the value of the cell (needs explicit instantiation)

Definition at line 446 of file Matrix.cpp.

References d, and AbstractAspect::exec().

Referenced by AddSubtractValueDialog::generateForMatrices(), OriginProjectParser::loadMatrix(), MatrixView::pasteIntoSelection(), and MatrixModel::setData().

◆ setChanged()

void Matrix::setChanged ( )

Definition at line 212 of file Matrix.cpp.

References m_model, and MatrixModel::setChanged().

Referenced by finalizeImport().

◆ setColumnCells()

template<typename T >
void Matrix::setColumnCells ( int  col,
int  first_row,
int  last_row,
const QVector< T > &  values 
)

Set the values in the given cells from a type T vector.

Definition at line 623 of file Matrix.cpp.

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

Referenced by copy().

◆ setColumnWidth()

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

Definition at line 603 of file Matrix.cpp.

References d, and MatrixPrivate::setColumnWidth().

Referenced by copy(), MatrixView::handleHorizontalSectionResized(), and OriginProjectParser::loadMatrix().

◆ setCoordinates()

void Matrix::setCoordinates ( double  x1,
double  x2,
double  y1,
double  y2 
)

Definition at line 583 of file Matrix.cpp.

References d, and AbstractAspect::exec().

Referenced by copy().

◆ setData()

◆ setDimensions()

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

◆ setRowCells()

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

Set the values in the given cells from a type T vector.

Definition at line 641 of file Matrix.cpp.

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

◆ setRowHeight()

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

Definition at line 595 of file Matrix.cpp.

References d, and MatrixPrivate::setRowHeight().

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

◆ setSuppressDataChangedSignal()

void Matrix::setSuppressDataChangedSignal ( bool  b)

◆ text() [1/3]

template<>
QString Matrix::text ( int  row,
int  col 
)

◆ text() [2/3]

template<>
template QString Matrix::text< QDateTime > ( int  row,
int  col 
)

Definition at line 437 of file Matrix.cpp.

◆ text() [3/3]

template<typename T >
QString Matrix::text ( int  row,
int  col 
)

Return the text displayed in the given cell (needs explicit instantiation)

Definition at line 427 of file Matrix.cpp.

References SET_NUMBER_LOCALE.

Referenced by MatrixModel::data(), MatrixView::exportToLaTeX(), and FITSFilterPrivate::writeCHDU().

◆ transpose

◆ view()

QWidget * Matrix::view ( ) const
overridevirtual

Construct a primary view on me.

The caller receives ownership of the view.

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

Implements AbstractPart.

Definition at line 120 of file Matrix.cpp.

References m_model, AbstractPart::m_partView, m_view, and MatrixView::model().

Referenced by MainWin::updateGUI(), and FITSFilterPrivate::writeCHDU().

◆ xEndChanged

void Matrix::xEndChanged ( double  )
signal

◆ xStartChanged

void Matrix::xStartChanged ( double  )
signal

◆ yEndChanged

void Matrix::yEndChanged ( double  )
signal

◆ yStartChanged

void Matrix::yStartChanged ( double  )
signal

Friends And Related Function Documentation

◆ MatrixPrivate

friend class MatrixPrivate
friend

Definition at line 162 of file Matrix.h.

Member Data Documentation

◆ d

◆ m_model

MatrixModel* Matrix::m_model {nullptr}
mutableprivate

Definition at line 159 of file Matrix.h.

Referenced by setChanged(), and view().

◆ m_view

MatrixView* Matrix::m_view {nullptr}
mutableprivate

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