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)  

Go to the documentation of this file.
1 /***************************************************************************
2  File : Matrix.h
3  Project : Matrix
4  Description : Spreadsheet with a MxN matrix data model
5  --------------------------------------------------------------------
6  Copyright : (C) 2008-2009 Tilman Benkert (
7  Copyright : (C) 2015-2017 Alexander Semke (
8  Copyright : (C) 2017 Stefan Gerlach (
10  ***************************************************************************/
12 /***************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the Free Software *
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
27  * Boston, MA 02110-1301 USA *
28  * *
29  ***************************************************************************/
30 #ifndef MATRIX_H
31 #define MATRIX_H
35 #include "backend/lib/macros.h"
37 class MatrixPrivate;
38 class MatrixModel;
39 class MatrixView;
41 class Matrix : public AbstractDataSource {
43  Q_ENUMS(HeaderFormat)
45 public:
48  explicit Matrix(const QString& name, bool loading = false,
50  Matrix(int rows, int cols, const QString& name,
52  ~Matrix() override;
54  QIcon icon() const override;
55  QMenu* createContextMenu() override;
56  QWidget* view() const override;
58  bool exportView() const override;
59  bool printView() override;
60  bool printPreview() const override;
62  void* data() const;
63  void setData(void*);
66  BASIC_D_ACCESSOR_DECL(int, rowCount, RowCount)
67  BASIC_D_ACCESSOR_DECL(int, columnCount, ColumnCount)
68  BASIC_D_ACCESSOR_DECL(char, numericFormat, NumericFormat)
69  BASIC_D_ACCESSOR_DECL(int, precision, Precision)
71  BASIC_D_ACCESSOR_DECL(double, xStart, XStart)
72  BASIC_D_ACCESSOR_DECL(double, xEnd, XEnd)
73  BASIC_D_ACCESSOR_DECL(double, yStart, YStart)
74  BASIC_D_ACCESSOR_DECL(double, yEnd, YEnd)
75  CLASS_D_ACCESSOR_DECL(QString, formula, Formula)
78  void setChanged();
80  int rowHeight(int row) const;
81  void setRowHeight(int row, int height);
82  int columnWidth(int col) const;
83  void setColumnWidth(int col, int width);
85  void setDimensions(int rows, int cols);
86  void setCoordinates(double x1, double x2, double y1, double y2);
88  void insertColumns(int before, int count);
89  void appendColumns(int count);
90  void removeColumns(int first, int count);
91  void clearColumn(int);
93  void insertRows(int before, int count);
94  void appendRows(int count);
95  void removeRows(int first, int count);
96  void clearRow(int);
98  template <typename T> T cell(int row, int col) const;
99  template <typename T> QString text(int row, int col);
100  template <typename T> void setCell(int row, int col, T value);
101  void clearCell(int row, int col);
103  template <typename T> QVector<T> columnCells(int col, int first_row, int last_row);
104  template <typename T> void setColumnCells(int col, int first_row, int last_row, const QVector<T>& values);
105  template <typename T> QVector<T> rowCells(int row, int first_column, int last_column);
106  template <typename T> void setRowCells(int row, int first_column, int last_column, const QVector<T>& values);
108  void copy(Matrix* other);
110  void save(QXmlStreamWriter*) const override;
111  bool load(XmlStreamReader*, bool preview) override;
113  int prepareImport(std::vector<void*>& dataContainer, AbstractFileFilter::ImportMode,
114  int rows, int cols, QStringList colNameList, QVector<AbstractColumn::ColumnMode>) override;
115  void finalizeImport(int columnOffset, int startColumn, int endColumn,
116  const QString& dateTimeFormat, AbstractFileFilter::ImportMode) override;
120 public slots:
121  void clear();
122  void transpose();
123  void mirrorVertically();
124  void mirrorHorizontally();
126  void addColumns();
127  void addRows();
128  void duplicate();
130 signals:
132  void columnsAboutToBeInserted(int before, int count);
133  void columnsInserted(int first, int count);
134  void columnsAboutToBeRemoved(int first, int count);
135  void columnsRemoved(int first, int count);
136  void rowsAboutToBeInserted(int before, int count);
137  void rowsInserted(int first, int count);
138  void rowsAboutToBeRemoved(int first, int count);
139  void rowsRemoved(int first, int count);
140  void dataChanged(int top, int left, int bottom, int right);
143  void rowCountChanged(int);
146  void xStartChanged(double);
147  void xEndChanged(double);
148  void yStartChanged(double);
149  void yEndChanged(double);
152  void precisionChanged(int);
155 private:
156  void init();
158  MatrixPrivate* const d;
159  mutable MatrixModel* m_model{nullptr};
160  mutable MatrixView* m_view{nullptr};
162  friend class MatrixPrivate;
163 };
165 #endif
QString name() const
Interface for the data sources.
Model for the access to data of a Matrix-object.
Definition: MatrixModel.h:37
Definition: Matrix.h:41
void setDimensions(int rows, int cols)
Definition: Matrix.cpp:479
void setData(void *)
Definition: Matrix.cpp:647
QMenu * createContextMenu() override
Definition: Matrix.cpp:114
void appendRows(int count)
Definition: Matrix.cpp:358
QVector< T > rowCells(int row, int first_column, int last_column)
Return the values in the given cells as vector (needs explicit instantiation)
Definition: Matrix.cpp:631
void duplicate()
Duplicate the matrix inside its folder.
Definition: Matrix.cpp:556
QVector< T > columnCells(int col, int first_row, int last_row)
Return the values in the given cells as vector.
Definition: Matrix.cpp:617
Definition: Matrix.h:46
bool printPreview() const override
Definition: Matrix.cpp:182
void insertRows(int before, int count)
Definition: Matrix.cpp:351
void setCoordinates(double x1, double x2, double y1, double y2)
Definition: Matrix.cpp:583
void columnsInserted(int first, int count)
void numericFormatChanged(char)
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.
Definition: Matrix.cpp:641
void addRows()
Definition: Matrix.cpp:563
Matrix(const QString &name, bool loading=false, const AbstractColumn::ColumnMode=AbstractColumn::ColumnMode::Numeric)
Definition: Matrix.cpp:70
QString text(int row, int col)
Return the text displayed in the given cell (needs explicit instantiation)
Definition: Matrix.cpp:427
void yEndChanged(double)
MatrixView * m_view
Definition: Matrix.h:160
bool printView() override
Definition: Matrix.cpp:169
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.
Definition: Matrix.cpp:623
T cell(int row, int col) const
Return the value in the given cell (needs explicit instantiation)
Definition: Matrix.cpp:416
void init()
Definition: Matrix.cpp:81
void xStartChanged(double)
void removeColumns(int first, int count)
Definition: Matrix.cpp:301
void mirrorHorizontally()
Definition: Matrix.cpp:733
void columnsRemoved(int first, int count)
void columnCountChanged(int)
void mirrorVertically()
Definition: Matrix.cpp:757
void save(QXmlStreamWriter *) const override
Save as XML.
Definition: Matrix.cpp:1031
void yStartChanged(double)
void setColumnWidth(int col, int width)
This method should only be called by the view.
Definition: Matrix.cpp:603
QWidget * view() const override
Construct a primary view on me.
Definition: Matrix.cpp:120
bool exportView() const override
Definition: Matrix.cpp:129
void * data() const
Definition: Matrix.cpp:191
void dataChanged(int top, int left, int bottom, int right)
int rowHeight(int row) const
Definition: Matrix.cpp:607
void insertColumns(int before, int count)
Definition: Matrix.cpp:290
void rowCountChanged(int)
void columnsAboutToBeInserted(int before, int count)
MatrixPrivate *const d
Definition: Matrix.h:158
int columnWidth(int col) const
Definition: Matrix.cpp:611
void headerFormatChanged(Matrix::HeaderFormat)
void setChanged()
Definition: Matrix.cpp:212
void clearCell(int row, int col)
Definition: Matrix.cpp:457
MatrixModel * m_model
Definition: Matrix.h:159
void rowsRemoved(int first, int count)
void finalizeImport(int columnOffset, int startColumn, int endColumn, const QString &dateTimeFormat, AbstractFileFilter::ImportMode) override
Definition: Matrix.cpp:1371
int prepareImport(std::vector< void * > &dataContainer, AbstractFileFilter::ImportMode, int rows, int cols, QStringList colNameList, QVector< AbstractColumn::ColumnMode >) override
Definition: Matrix.cpp:1300
void transpose()
Definition: Matrix.cpp:709
void setRowHeight(int row, int height)
This method should only be called by the view.
Definition: Matrix.cpp:595
void setCell(int row, int col, T value)
Set the value of the cell (needs explicit instantiation)
Definition: Matrix.cpp:446
void rowsInserted(int first, int count)
void precisionChanged(int)
void rowsAboutToBeRemoved(int first, int count)
void clearRow(int)
Definition: Matrix.cpp:387
void clear()
Clear the whole matrix (i.e. reset all cells)
Definition: Matrix.cpp:683
MatrixPrivate Private
Definition: Matrix.h:118
~Matrix() override
Definition: Matrix.cpp:77
void copy(Matrix *other)
Definition: Matrix.cpp:502
void setSuppressDataChangedSignal(bool)
Definition: Matrix.cpp:207
void requestProjectContextMenu(QMenu *)
void xEndChanged(double)
void clearColumn(int)
Definition: Matrix.cpp:326
bool load(XmlStreamReader *, bool preview) override
Load from XML.
Definition: Matrix.cpp:1130
void addColumns()
Definition: Matrix.cpp:573
void appendColumns(int count)
Definition: Matrix.cpp:297
void columnsAboutToBeRemoved(int first, int count)
void removeRows(int first, int count)
Definition: Matrix.cpp:362
void rowsAboutToBeInserted(int before, int count)
QIcon icon() const override
Definition: Matrix.cpp:107
void coordinatesChanged()
XML stream parser that supports errors as well as warnings. This class also adds line and column numb...
#define CLASS_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:134
#define BASIC_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:107
Definition: OriginObj.h:48