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)  

Column.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : Column.h
3  Project : LabPlot
4  Description : Aspect that manages a column
5  --------------------------------------------------------------------
6  Copyright : (C) 2007-2009 Tilman Benkert (thzs@gmx.net)
7  Copyright : (C) 2013-2017 Alexander Semke (alexander.semke@web.de)
8  Copyright : (C) 2017 Stefan Gerlach (stefan.gerlach@uni.kn)
9 
10  ***************************************************************************/
11 
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 *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
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 
31 #ifndef COLUMN_H
32 #define COLUMN_H
33 
37 
38 class CartesianPlot;
39 class ColumnStringIO;
40 class QActionGroup;
41 
42 class Column : public AbstractColumn {
43  Q_OBJECT
44 
45 public:
46  explicit Column(const QString& name, AbstractColumn::ColumnMode = ColumnMode::Numeric);
47  // template constructor for all supported data types (AbstractColumn::ColumnMode) must be defined in header
48  template <typename T>
50  : AbstractColumn(name, AspectType::Column), d(new ColumnPrivate(this, mode, new QVector<T>(data))) {
51  init();
52  }
53  void init();
54  ~Column() override;
55 
56  QIcon icon() const override;
57  QMenu* createContextMenu() override;
58 
59  void updateLocale();
60 
61  AbstractColumn::ColumnMode columnMode() const override;
64 
65  bool isDraggable() const override;
66  QVector<AspectType> dropableOn() const override;
67 
68  bool copy(const AbstractColumn*) override;
69  bool copy(const AbstractColumn* source, int source_start, int dest_start, int num_rows) override;
70 
72  QString plotDesignationString() const override;
74 
75  bool isReadOnly() const override;
76  int rowCount() const override;
77  int availableRowCount() const override;
78  int width() const;
79  void setWidth(const int);
80  void clear() override;
83 
84  void setFormula(const QString& formula, const QStringList& variableNames,
85  const QVector<Column*>& columns, bool autoUpdate);
86  QString formula() const;
87  const QStringList& formulaVariableNames() const;
89  const QStringList& formulaVariableColumnPaths() const;
90  void setformulVariableColumnsPath(int index, const QString& path);
91  void setformulVariableColumn(int index, Column*);
92  bool formulaAutoUpdate() const;
93 
94  QString formula(int) const override;
95  QVector< Interval<int> > formulaIntervals() const override;
96  void setFormula(const Interval<int>&, const QString&) override;
97  void setFormula(int, const QString&) override;
98  void clearFormulas() override;
99 
101  void* data() const;
102  bool hasValues() const;
103 
104  void setFromColumn(int, AbstractColumn*, int);
105  QString textAt(int) const override;
106  void setTextAt(int, const QString&) override;
107  void replaceTexts(int, const QVector<QString>&) override;
108  QDate dateAt(int) const override;
109  void setDateAt(int, QDate) override;
110  QTime timeAt(int) const override;
111  void setTimeAt(int, QTime) override;
112  QDateTime dateTimeAt(int) const override;
113  void setDateTimeAt(int, const QDateTime&) override;
114  void replaceDateTimes(int, const QVector<QDateTime>&) override;
115  double valueAt(int) const override;
116  void setValueAt(int, double) override;
117  void replaceValues(int, const QVector<double>&) override;
118  int integerAt(int) const override;
119  void setIntegerAt(int, int) override;
120  void replaceInteger(int, const QVector<int>&) override;
121  qint64 bigIntAt(int) const override;
122  void setBigIntAt(int, qint64) override;
123  void replaceBigInt(int, const QVector<qint64>&) override;
124  Properties properties() const override;
125 
126  double maximum(int count = 0) const override;
127  double maximum(int startIndex, int endIndex) const override;
128  double minimum(int count = 0) const override;
129  double minimum(int startIndex, int endIndex) const override;
130  static int calculateMaxSteps(unsigned int value);
131  static int indexForValue(double x, QVector<double>& column, Properties properties = Properties::No);
132  static int indexForValue(const double x, const QVector<QPointF> &column, Properties properties = Properties::No);
133  static int indexForValue(double x, QVector<QLineF>& lines, Properties properties = Properties::No);
134  int indexForValue(double x) const override;
135  bool indicesMinMax(double v1, double v2, int& start, int& end) const override;
136 
137  void setChanged();
138  void setSuppressDataChangedSignal(const bool);
139 
141 
142  void save(QXmlStreamWriter*) const override;
143  bool load(XmlStreamReader*, bool preview) override;
144  void finalizeLoad();
145 
146 public slots:
147  void updateFormula();
148 
149 private:
154 
155  void handleRowInsertion(int before, int count) override;
156  void handleRowRemoval(int first, int count) override;
157 
158  void calculateStatistics() const;
159 
161  QAction* m_copyDataAction{nullptr};
162  QActionGroup* m_usedInActionGroup{nullptr};
163 
166 
167 signals:
169 
170 private slots:
171  void navigateTo(QAction*);
172  void handleFormatChange();
173  void copyData();
174 
175  friend class ColumnPrivate;
176  friend class ColumnStringIO;
177 };
178 
179 
180 #endif
AspectType
QString name() const
virtual QString path() const
Return the path that leads from the top-most Aspect (usually a Project) to me.
Interface definition for data with column logic.
Simplified filter interface for filters with only one output port.
A xy-plot.
Definition: CartesianPlot.h:58
String-IO interface of Column.
Aspect that manages a column.
Definition: Column.h:42
QString formula() const
Returns the formula used to generate column values.
Definition: Column.cpp:440
void setColumnMode(AbstractColumn::ColumnMode) override
Set the column mode.
Definition: Column.cpp:289
QAction * m_copyDataAction
Definition: Column.h:161
ColumnStringIO * asStringColumn() const
Return a wrapper column object used for String I/O.
Definition: Column.cpp:1451
QVector< Interval< int > > formulaIntervals() const override
Return the intervals that have associated formulas.
Definition: Column.cpp:1479
void setValueAt(int, double) override
Set the content of row 'row'.
Definition: Column.cpp:579
const QVector< Column * > & formulaVariableColumns() const
Definition: Column.cpp:448
QTime timeAt(int) const override
Return the time part of row 'row'.
Definition: Column.cpp:959
QDateTime dateTimeAt(int) const override
Return the QDateTime in row 'row'.
Definition: Column.cpp:968
void setFromColumn(int, AbstractColumn *, int)
Definition: Column.cpp:910
void replaceInteger(int, const QVector< int > &) override
Replace a range of values.
Definition: Column.cpp:607
QIcon icon() const override
Return an icon to be used for decorating the views and spreadsheet column headers.
Definition: Column.cpp:1015
const QStringList & formulaVariableNames() const
Definition: Column.cpp:444
bool indicesMinMax(double v1, double v2, int &start, int &end) const override
Column::indicesForX.
Definition: Column.cpp:2168
void replaceBigInt(int, const QVector< qint64 > &) override
Replace a range of values.
Definition: Column.cpp:629
double minimum(int count=0) const override
Definition: Column.cpp:1507
void handleRowRemoval(int first, int count) override
Remove 'count' rows starting from row 'first'.
Definition: Column.cpp:389
~Column() override
Definition: Column.cpp:107
Column(const QString &name, AbstractColumn::ColumnMode=ColumnMode::Numeric)
Definition: Column.cpp:80
void copyData()
Definition: Column.cpp:213
void replaceValues(int, const QVector< double > &) override
Replace a range of values.
Definition: Column.cpp:588
void setIntegerAt(int, int) override
Set the content of row 'row'.
Definition: Column.cpp:598
int rowCount() const override
Return the data vector size.
Definition: Column.cpp:1395
bool copy(const AbstractColumn *) override
Copy another column of the same type.
Definition: Column.cpp:348
bool m_suppressDataChangedSignal
Definition: Column.h:160
int availableRowCount() const override
Return the number of available data rows.
Definition: Column.cpp:1406
bool isReadOnly() const override
Return whether the object is read-only.
Definition: Column.cpp:1377
void setPlotDesignation(AbstractColumn::PlotDesignation) override
Set the column plot designation.
Definition: Column.cpp:403
QMenu * createContextMenu() override
Return a new context menu.
Definition: Column.cpp:112
ColumnStringIO * m_string_io
Definition: Column.h:165
void setChanged()
Definition: Column.cpp:998
void navigateTo(QAction *)
Definition: Column.cpp:206
void setSuppressDataChangedSignal(const bool)
Definition: Column.cpp:246
bool XmlReadInputFilter(XmlStreamReader *)
Read XML input filter element.
Definition: Column.cpp:1230
QActionGroup * m_usedInActionGroup
Definition: Column.h:162
bool XmlReadOutputFilter(XmlStreamReader *)
Read XML output filter element.
Definition: Column.cpp:1242
void clear() override
Clear the whole column.
Definition: Column.cpp:425
ColumnPrivate * d
Definition: Column.h:164
void requestProjectContextMenu(QMenu *)
void replaceTexts(int, const QVector< QString > &) override
Replace a range of values.
Definition: Column.cpp:532
AbstractColumn::ColumnMode columnMode() const override
Return the column mode.
Definition: Column.cpp:1388
const AbstractColumn::ColumnStatistics & statistics() const
Definition: Column.cpp:646
AbstractSimpleFilter * outputFilter() const
Definition: Column.cpp:1444
void updateLocale()
Definition: Column.cpp:200
QString textAt(int) const override
Return the content of row 'row'.
Definition: Column.cpp:941
static int calculateMaxSteps(unsigned int value)
Definition: Column.cpp:1795
static int indexForValue(double x, QVector< double > &column, Properties properties=Properties::No)
Definition: Column.cpp:1831
void setWidth(const int)
Set width.
Definition: Column.cpp:418
void setformulVariableColumnsPath(int index, const QString &path)
Definition: Column.cpp:456
qint64 bigIntAt(int) const override
Return the bigint value in row 'row'.
Definition: Column.cpp:989
void setTimeAt(int, QTime) override
Set the content of row 'row'.
Definition: Column.cpp:551
void setformulVariableColumn(int index, Column *)
Definition: Column.cpp:460
bool XmlReadRow(XmlStreamReader *)
Read XML row element.
Definition: Column.cpp:1314
void setBigIntAt(int, qint64) override
Set the content of row 'row'.
Definition: Column.cpp:617
double maximum(int count=0) const override
Definition: Column.cpp:1653
void setFormula(const QString &formula, const QStringList &variableNames, const QVector< Column * > &columns, bool autoUpdate)
Sets the formula used to generate column values.
Definition: Column.cpp:471
void setDateAt(int, QDate) override
Set the content of row 'row'.
Definition: Column.cpp:542
void setColumnModeFast(AbstractColumn::ColumnMode)
Definition: Column.cpp:313
void handleFormatChange()
Definition: Column.cpp:1483
void finalizeLoad()
Definition: Column.cpp:1223
AbstractColumn::PlotDesignation plotDesignation() const override
Return the column plot designation.
Definition: Column.cpp:1413
bool isDraggable() const override
Definition: Column.cpp:333
const QStringList & formulaVariableColumnPaths() const
Definition: Column.cpp:452
double valueAt(int) const override
Return the double value in row 'row'.
Definition: Column.cpp:975
Column(const QString &name, QVector< T > data, AbstractColumn::ColumnMode mode=ColumnMode::Numeric)
Definition: Column.h:49
void calculateStatistics() const
Definition: Column.cpp:653
void init()
Common part of ctors.
Definition: Column.cpp:89
void save(QXmlStreamWriter *) const override
Save the column as XML.
Definition: Column.cpp:1027
bool XmlReadFormula(XmlStreamReader *)
Read XML formula element.
Definition: Column.cpp:1254
QString plotDesignationString() const override
Definition: Column.cpp:1417
int integerAt(int) const override
Return the int value in row 'row'.
Definition: Column.cpp:982
int width() const
Get width.
Definition: Column.cpp:411
bool hasValues() const
Definition: Column.cpp:859
Properties properties() const override
Column::properties Returns the column properties of this curve (monoton increasing,...
Definition: Column.cpp:639
QVector< AspectType > dropableOn() const override
Definition: Column.cpp:337
void * data() const
Definition: Column.cpp:852
void addUsedInPlots(QVector< CartesianPlot * > &)
Definition: Column.cpp:250
void updateFormula()
Definition: Column.cpp:481
void setTextAt(int, const QString &) override
Set the content of row 'row'.
Definition: Column.cpp:523
QDate dateAt(int) const override
Return the date part of row 'row'.
Definition: Column.cpp:950
void clearFormulas() override
Clear all formulas.
Definition: Column.cpp:505
void replaceDateTimes(int, const QVector< QDateTime > &) override
Replace a range of values.
Definition: Column.cpp:569
void handleRowInsertion(int before, int count) override
Insert some empty (or initialized with zero) rows.
Definition: Column.cpp:375
void setDateTimeAt(int, const QDateTime &) override
Set the content of row 'row'.
Definition: Column.cpp:560
bool load(XmlStreamReader *, bool preview) override
Load the column from XML.
Definition: Column.cpp:1152
bool formulaAutoUpdate() const
Definition: Column.cpp:464
Auxiliary class for interval based data.
Definition: Interval.h:212
XML stream parser that supports errors as well as warnings. This class also adds line and column numb...