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)  

AbstractColumn.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : AbstractColumn.h
3  Project : LabPlot
4  Description : Interface definition for data with column logic
5  --------------------------------------------------------------------
6  Copyright : (C) 2007,2008 Tilman Benkert (thzs@gmx.net)
7  Copyright : (C) 2013 Alexander Semke (alexander.semke@web.de)
8  Copyright : (C) 2017-2020 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 ABSTRACTCOLUMN_H
32 #define ABSTRACTCOLUMN_H
33 
35 #include <cmath> // NAN
36 
39 class QStringList;
40 class QString;
41 class QDateTime;
42 class QDate;
43 class QTime;
44 template<class T> class QVector;
45 template<class T> class Interval;
46 
48  Q_OBJECT
49  Q_ENUMS(PlotDesignation)
50  Q_ENUMS(ColumnMode)
51 
52 public:
54  enum class ColumnMode {
55  // BASIC FORMATS
56  Numeric = 0, // double
57  Text = 1, // QString
58  // Time = 2 and Date = 3 are skipped to avoid problems with old obsolete values
59  Month = 4, // month of year: numeric or "Jan", etc.
60  Day = 5, // day of week: numeric or "Mon", etc.
61  DateTime = 6, // any date-time format
62 // Bool = 7, // bool
63  // FLOATING POINT
64  // 10 = Half precision
65 // Float = 11, // float
66  // 12 = Long double
67  // 13 = Quad precision
68  // 14 = decimal 32
69  // 15 = decimal 64
70  // 16 = decimal 128
71  // COMPLEX
72  // 17 = complex<float>
73  // 18 = complex<double>
74  // 19 = complex<long double>
75  // INTEGER
76 // Int8 = 20, // qint8 (char)
77 // UInt8 = 21, // quint8 (unsigned char)
78 // Int16 = 22, // qint16 (short)
79 // UInt16 = 23, // quint16 (unsigned short)
80  Integer = 24, // qint32 (int)
81 // UInt32 = 25, // quint32 (unsigned int)
82  BigInt = 26, // qint64 (long)
83 // UInt64 = 27, // quint64 (unsigned long)
84  // MISC
85  // QBrush = 30
86  // QColor
87  // QFont
88  // QPoint
89  // QQuaternion
90  // QVector2D, QVector3D, QVector4D
91  // QMatrix
92  // etc.
93  };
94  enum class Properties { // TODO: why bit pattern? Aren't they exclusive?
95  No = 0x00,
96  Constant = 0x01,
97  MonotonicIncreasing = 0x02, // prev_value >= value for all values in column
98  MonotonicDecreasing = 0x04 // prev_value <= value for all values in column
99  // add new values with next bit set (0x08)
100  };
101 
104  size = 0;
105  minimum = NAN;
106  maximum = NAN;
107  arithmeticMean = NAN;
108  geometricMean = NAN;
109  harmonicMean = NAN;
110  contraharmonicMean = NAN;
111  mode = NAN;
112  firstQuartile = NAN;
113  median = NAN;
114  thirdQuartile = NAN;
115  iqr = NAN;
116  trimean = NAN;
117  variance = NAN;
118  standardDeviation = NAN;
119  meanDeviation = NAN;
121  medianDeviation = NAN;
122  skewness = NAN;
123  kurtosis = NAN;
124  entropy = NAN;
125  }
126  int size;
127  double minimum;
128  double maximum;
131  double harmonicMean;
133  double mode;
135  double median;
137  double iqr;
138  double trimean;
139  double variance;
141  double meanDeviation; // mean absolute deviation around mean
142  double meanDeviationAroundMedian; // mean absolute deviation around median
143  double medianDeviation; // median absolute deviation
144  double skewness;
145  double kurtosis;
146  double entropy;
147  };
148 
149  AbstractColumn(const QString& name, AspectType type);
150  ~AbstractColumn() override;
151 
152  static QStringList dateFormats(); // supported date formats
153  static QStringList timeFormats(); // supported time formats
154  static QStringList dateTimeFormats(); // supported datetime formats
155  static QIcon iconForMode(ColumnMode mode);
156 
157  virtual bool isReadOnly() const {
158  return true;
159  };
160  virtual ColumnMode columnMode() const = 0;
162  virtual PlotDesignation plotDesignation() const = 0;
163  virtual QString plotDesignationString() const = 0;
165  bool isNumeric() const;
166  bool isPlottable() const;
167 
168  virtual bool copy(const AbstractColumn *source);
169  virtual bool copy(const AbstractColumn *source, int source_start, int dest_start, int num_rows);
170 
171  virtual int rowCount() const = 0;
172  virtual int availableRowCount() const = 0;
173  void insertRows(int before, int count);
174  void removeRows(int first, int count);
175  virtual void clear();
176 
177  virtual double maximum(int count = 0) const;
178  virtual double maximum(int startIndex, int endIndex) const;
179  virtual double minimum(int count = 0) const;
180  virtual double minimum(int startIndex, int endIndex) const;
181  virtual bool indicesMinMax(double v1, double v2, int& start, int& end) const;
182  virtual int indexForValue(double x) const;
183 
184  bool isValid(int row) const;
185 
186  bool isMasked(int row) const;
187  bool isMasked(const Interval<int>& i) const;
189  void clearMasks();
190  void setMasked(const Interval<int>& i, bool mask = true);
191  void setMasked(int row, bool mask = true);
192 
193  virtual QString formula(int row) const;
194  virtual QVector< Interval<int> > formulaIntervals() const;
195  virtual void setFormula(const Interval<int>& i, const QString& formula);
196  virtual void setFormula(int row, const QString& formula);
197  virtual void clearFormulas();
198 
199  virtual QString textAt(int row) const;
200  virtual void setTextAt(int row, const QString& new_value);
201  virtual void replaceTexts(int first, const QVector<QString>& new_values);
202  virtual QDate dateAt(int row) const;
203  virtual void setDateAt(int row, QDate new_value);
204  virtual QTime timeAt(int row) const;
205  virtual void setTimeAt(int row, QTime new_value);
206  virtual QDateTime dateTimeAt(int row) const;
207  virtual void setDateTimeAt(int row, const QDateTime& new_value);
208  virtual void replaceDateTimes(int first, const QVector<QDateTime>& new_values);
209  virtual double valueAt(int row) const;
210  virtual void setValueAt(int row, double new_value);
211  virtual void replaceValues(int first, const QVector<double>& new_values);
212  virtual int integerAt(int row) const;
213  virtual void setIntegerAt(int row, int new_value);
214  virtual void replaceInteger(int first, const QVector<int>& new_values);
215  virtual qint64 bigIntAt(int row) const;
216  virtual void setBigIntAt(int row, qint64 new_value);
217  virtual void replaceBigInt(int first, const QVector<qint64>& new_values);
218  virtual Properties properties() const;
219 
220 signals:
223  void modeAboutToChange(const AbstractColumn* source);
224  void modeChanged(const AbstractColumn* source);
225  void dataAboutToChange(const AbstractColumn* source);
226  void dataChanged(const AbstractColumn* source);
227  void formatChanged(const AbstractColumn* source);
228  void rowsAboutToBeInserted(const AbstractColumn* source, int before, int count);
229  void rowsInserted(const AbstractColumn* source, int before, int count);
230  void rowsAboutToBeRemoved(const AbstractColumn* source, int first, int count);
231  void rowsRemoved(const AbstractColumn* source, int first, int count);
233  void maskingChanged(const AbstractColumn* source);
234  void aboutToBeDestroyed(const AbstractColumn* source);
235  void reset(const AbstractColumn* source); // this signal is emitted when the column is reused for another purpose. The curves must know that and disconnect all connections
236 
237 protected:
239  void XmlWriteMask(QXmlStreamWriter*) const;
240 
241  virtual void handleRowInsertion(int before, int count);
242  virtual void handleRowRemoval(int first, int count);
243 
244 private:
246 
251 };
252 
253 #endif
AspectType
Base class of all persistent objects in a Project.
AspectType type() const
QString name() const
Clear masking information.
Insert empty rows into a column.
Private data class of AbstractColumn.
Remove rows from a column.
Mark an interval of rows as masked.
Interface definition for data with column logic.
void reset(const AbstractColumn *source)
virtual void setFormula(const Interval< int > &i, const QString &formula)
Set a formula string for an interval of rows.
void insertRows(int before, int count)
Insert some empty (or initialized with invalid values) rows.
virtual void setTextAt(int row, const QString &new_value)
Set the content of row 'row'.
QVector< Interval< int > > maskedIntervals() const
Return all intervals of masked rows.
virtual void setTimeAt(int row, QTime new_value)
Set the content of row 'row'.
void plotDesignationAboutToChange(const AbstractColumn *source)
Column plot designation will be changed.
static QIcon iconForMode(ColumnMode mode)
Convenience method for mode-dependent icon.
bool isPlottable() const
virtual void setIntegerAt(int row, int new_value)
Set the content of row 'row'.
static QStringList timeFormats()
virtual double valueAt(int row) const
Return the double value in row 'row'.
AbstractColumnPrivate * d
virtual Properties properties() const
~AbstractColumn() override
bool isNumeric() const
virtual QString formula(int row) const
Return the formula associated with row 'row'.
virtual void setDateTimeAt(int row, const QDateTime &new_value)
Set the content of row 'row'.
virtual void replaceTexts(int first, const QVector< QString > &new_values)
Replace a range of values.
bool isMasked(int row) const
Return whether a certain row is masked.
AbstractColumn(const QString &name, AspectType type)
Ctor.
void modeAboutToChange(const AbstractColumn *source)
Column mode (possibly also the data type) will be changed.
static QStringList dateFormats()
void modeChanged(const AbstractColumn *source)
Column mode (possibly also the data type) changed.
virtual void handleRowInsertion(int before, int count)
virtual void setDateAt(int row, QDate new_value)
Set the content of row 'row'.
void maskingChanged(const AbstractColumn *source)
Rows have been masked or unmasked.
virtual int indexForValue(double x) const
void rowsRemoved(const AbstractColumn *source, int first, int count)
Rows have been deleted.
void plotDesignationChanged(const AbstractColumn *source)
Column plot designation changed.
void removeRows(int first, int count)
Remove 'count' rows starting from row 'first'.
virtual QString textAt(int row) const
Return the content of row 'row'.
virtual void handleRowRemoval(int first, int count)
virtual int rowCount() const =0
Return the data vector size.
void setMasked(const Interval< int > &i, bool mask=true)
Set an interval masked.
virtual QDate dateAt(int row) const
Return the date part of row 'row'.
void maskingAboutToChange(const AbstractColumn *source)
Rows are about to be masked or unmasked.
virtual void replaceInteger(int first, const QVector< int > &new_values)
Replace a range of values.
virtual void setColumnMode(AbstractColumn::ColumnMode)
Set the column mode.
virtual void replaceBigInt(int first, const QVector< qint64 > &new_values)
Replace a range of values.
void rowsInserted(const AbstractColumn *source, int before, int count)
Rows have been inserted.
virtual void setPlotDesignation(AbstractColumn::PlotDesignation)
Set the column plot designation.
virtual void clearFormulas()
Clear all formulas.
virtual double maximum(int count=0) const
virtual void replaceValues(int first, const QVector< double > &new_values)
Replace a range of values.
virtual double minimum(int count=0) const
virtual QVector< Interval< int > > formulaIntervals() const
Return the intervals that have associated formulas.
virtual void setBigIntAt(int row, qint64 new_value)
Set the content of row 'row'.
virtual QDateTime dateTimeAt(int row) const
Return the QDateTime in row 'row'.
void dataChanged(const AbstractColumn *source)
Data of the column has changed.
virtual qint64 bigIntAt(int row) const
Return the bigint value in row 'row'.
void rowsAboutToBeRemoved(const AbstractColumn *source, int first, int count)
Rows will be deleted.
virtual QString plotDesignationString() const =0
void formatChanged(const AbstractColumn *source)
void XmlWriteMask(QXmlStreamWriter *) const
Write XML mask element.
void dataAboutToChange(const AbstractColumn *source)
Data of the column will be changed.
void rowsAboutToBeInserted(const AbstractColumn *source, int before, int count)
Rows will be inserted.
virtual void replaceDateTimes(int first, const QVector< QDateTime > &new_values)
Replace a range of values.
bool isValid(int row) const
Convenience method for mode-independent testing of validity.
virtual void clear()
Clear the whole column.
virtual int integerAt(int row) const
Return the integer value in row 'row'.
virtual bool isReadOnly() const
Return whether the object is read-only.
virtual PlotDesignation plotDesignation() const =0
Return the column plot designation.
virtual int availableRowCount() const =0
Return the number of available data rows.
virtual ColumnMode columnMode() const =0
Return the column mode.
bool XmlReadMask(XmlStreamReader *)
Read XML mask element.
void clearMasks()
Clear all masking information.
virtual bool copy(const AbstractColumn *source)
Copy another column of the same type.
static QStringList dateTimeFormats()
virtual QTime timeAt(int row) const
Return the time part of row 'row'.
virtual bool indicesMinMax(double v1, double v2, int &start, int &end) const
void aboutToBeDestroyed(const AbstractColumn *source)
Emitted shortl before this column is deleted.
virtual void setValueAt(int row, double new_value)
Set the content of row 'row'.
Simplified filter interface for filters with only one output port.
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...