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)  

Histogram.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : Histogram.h
3  Project : LabPlot
4  Description : Histogram
5  --------------------------------------------------------------------
6  Copyright : (C) 2016 Anu Mittal (anu22mittal@gmail.com)
7  Copyright : (C) 2018 Alexander Semke (alexander.semke@web.de)
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 
30 #ifndef HISTOGRAM_H
31 #define HISTOGRAM_H
32 
38 #include "backend/lib/macros.h"
39 
40 class HistogramPrivate;
41 
42 class Histogram : public WorksheetElement, public Curve {
43  Q_OBJECT
44 
45 public:
53 
54  explicit Histogram(const QString &name);
55 
56  QIcon icon() const override;
57  QMenu* createContextMenu() override;
58  QGraphicsItem* graphicsItem() const override;
59  void save(QXmlStreamWriter*) const override;
60  bool load(XmlStreamReader*, bool preview) override;
61  void loadThemeConfig(const KConfig&) override;
62  void saveThemeConfig(const KConfig&) override;
63 
64  bool activateCurve(QPointF mouseScenePos, double maxDist = -1) override;
65  void setHover(bool on) override;
66 
67  POINTER_D_ACCESSOR_DECL(const AbstractColumn, dataColumn, DataColumn)
68  QString& dataColumnPath() const;
69 
73  BASIC_D_ACCESSOR_DECL(int, binCount, BinCount)
74  BASIC_D_ACCESSOR_DECL(float, binWidth, BinWidth)
75  BASIC_D_ACCESSOR_DECL(bool, autoBinRanges, AutoBinRanges)
76  BASIC_D_ACCESSOR_DECL(double, binRangesMin, BinRangesMin)
77  BASIC_D_ACCESSOR_DECL(double, binRangesMax, BinRangesMax)
78 
79  BASIC_D_ACCESSOR_DECL(float, xMin, XMin)
80  BASIC_D_ACCESSOR_DECL(float, xMax, XMax)
81  BASIC_D_ACCESSOR_DECL(float, yMin, YMin)
82  BASIC_D_ACCESSOR_DECL(float, yMax, YMax)
83 
85  CLASS_D_ACCESSOR_DECL(QPen, linePen, LinePen)
86  BASIC_D_ACCESSOR_DECL(qreal, lineOpacity, LineOpacity)
87 
88  BASIC_D_ACCESSOR_DECL(Symbol::Style, symbolsStyle, SymbolsStyle)
89  BASIC_D_ACCESSOR_DECL(qreal, symbolsOpacity, SymbolsOpacity)
90  BASIC_D_ACCESSOR_DECL(qreal, symbolsRotationAngle, SymbolsRotationAngle)
91  BASIC_D_ACCESSOR_DECL(qreal, symbolsSize, SymbolsSize)
92  CLASS_D_ACCESSOR_DECL(QBrush, symbolsBrush, SymbolsBrush)
93  CLASS_D_ACCESSOR_DECL(QPen, symbolsPen, SymbolsPen)
94 
96  POINTER_D_ACCESSOR_DECL(const AbstractColumn, valuesColumn, ValuesColumn)
97  QString& valuesColumnPath() const;
99  BASIC_D_ACCESSOR_DECL(qreal, valuesDistance, ValuesDistance)
100  BASIC_D_ACCESSOR_DECL(qreal, valuesRotationAngle, ValuesRotationAngle)
101  BASIC_D_ACCESSOR_DECL(qreal, valuesOpacity, ValuesOpacity)
102  BASIC_D_ACCESSOR_DECL(char, valuesNumericFormat, ValuesNumericFormat)
103  BASIC_D_ACCESSOR_DECL(int, valuesPrecision, ValuesPrecision)
104  CLASS_D_ACCESSOR_DECL(QString, valuesDateTimeFormat, ValuesDateTimeFormat)
105  CLASS_D_ACCESSOR_DECL(QString, valuesPrefix, ValuesPrefix)
106  CLASS_D_ACCESSOR_DECL(QString, valuesSuffix, ValuesSuffix)
107  CLASS_D_ACCESSOR_DECL(QColor, valuesColor, ValuesColor)
108  CLASS_D_ACCESSOR_DECL(QFont, valuesFont, ValuesFont)
109 
110  BASIC_D_ACCESSOR_DECL(bool, fillingEnabled, FillingEnabled)
111  BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundType, fillingType, FillingType)
112  BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundColorStyle, fillingColorStyle, FillingColorStyle)
113  BASIC_D_ACCESSOR_DECL(PlotArea::BackgroundImageStyle, fillingImageStyle, FillingImageStyle)
114  BASIC_D_ACCESSOR_DECL(Qt::BrushStyle, fillingBrushStyle, FillingBrushStyle)
115  CLASS_D_ACCESSOR_DECL(QColor, fillingFirstColor, FillingFirstColor)
116  CLASS_D_ACCESSOR_DECL(QColor, fillingSecondColor, FillingSecondColor)
117  CLASS_D_ACCESSOR_DECL(QString, fillingFileName, FillingFileName)
118  BASIC_D_ACCESSOR_DECL(qreal, fillingOpacity, FillingOpacity)
119 
121  BASIC_D_ACCESSOR_DECL(XYCurve::ErrorBarsType, errorBarsType, ErrorBarsType)
122  BASIC_D_ACCESSOR_DECL(qreal, errorBarsCapSize, ErrorBarsCapSize)
123  CLASS_D_ACCESSOR_DECL(QPen, errorBarsPen, ErrorBarsPen)
124  BASIC_D_ACCESSOR_DECL(qreal, errorBarsOpacity, ErrorBarsOpacity)
125 
126  void setVisible(bool on) override;
127  bool isVisible() const override;
128  void setPrinting(bool on) override;
130 
131  double getYMaximum() const;
132  double getYMinimum() const;
133  double getXMaximum() const;
134  double getXMinimum() const;
135 
138 
139 public slots:
140  void retransform() override;
141  void recalcHistogram();
142  void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
143 
144 private slots:
145  void updateValues();
148 
149  //SLOTs for changes triggered via QActions in the context menu
150  void visibilityChangedSlot();
151 
152 protected:
153  Histogram(const QString& name, HistogramPrivate* dd);
155 
156 private:
157  Q_DECLARE_PRIVATE(Histogram)
158  void init();
159  void initActions();
160  QAction* visibilityAction{nullptr};
161 
162 signals:
163  //General-Tab
164  void dataChanged();
166  void visibilityChanged(bool);
167 
171  void binCountChanged(int);
172  void binWidthChanged(float);
174  void binRangesMinChanged(double);
175  void binRangesMaxChanged(double);
176 
177  //Symbol-Tab
179  void symbolsSizeChanged(qreal);
182  void symbolsBrushChanged(QBrush);
183  void symbolsPenChanged(const QPen&);
184 
185  //Line-Tab
187  void linePenChanged(const QPen&);
188  void lineOpacityChanged(qreal);
189 
190  //Values-Tab
196  void valuesOpacityChanged(qreal);
200  void valuesPrefixChanged(QString);
201  void valuesSuffixChanged(QString);
202  void valuesFontChanged(QFont);
203  void valuesColorChanged(QColor);
204 
205  //Filling
210  void fillingBrushStyleChanged(Qt::BrushStyle);
213  void fillingFileNameChanged(QString&);
215 
216  //Error bars
222 };
223 
224 #endif
Base class of all persistent objects in a Project.
AspectType type() const
QString name() const
Interface definition for data with column logic.
Definition: Curve.h:34
A 2D-curve, provides an interface for editing many properties of the curve.
Definition: Histogram.h:42
QMenu * createContextMenu() override
Return a new context menu.
Definition: Histogram.cpp:150
void dataChanged()
QIcon icon() const override
Definition: Histogram.cpp:161
void fillingBrushStyleChanged(Qt::BrushStyle)
void errorTypeChanged(Histogram::ErrorType)
void fillingFirstColorChanged(QColor &)
@ ValuesCustomColumn
Definition: Histogram.h:50
@ ValuesBinEntries
Definition: Histogram.h:50
@ NoValues
Definition: Histogram.h:50
void symbolsSizeChanged(qreal)
bool activateCurve(QPointF mouseScenePos, double maxDist=-1) override
Definition: Histogram.cpp:185
void symbolsBrushChanged(QBrush)
QString & dataColumnPath() const
Definition: Histogram.cpp:209
QAction * visibilityAction
Definition: Histogram.h:160
void valuesTypeChanged(Histogram::ValuesType)
void symbolsStyleChanged(Symbol::Style)
void binningMethodChanged(Histogram::BinningMethod)
void recalcHistogram()
Definition: Histogram.cpp:668
void dataColumnAboutToBeRemoved(const AbstractAspect *)
Definition: Histogram.cpp:690
void fillingSecondColorChanged(QColor &)
void autoBinRangesChanged(bool)
void valuesFontChanged(QFont)
void visibilityChanged(bool)
void valuesRotationAngleChanged(qreal)
void setPrinting(bool on) override
Switches the printing mode on/off.
Definition: Histogram.cpp:180
void save(QXmlStreamWriter *) const override
Save as XML.
Definition: Histogram.cpp:1685
void valuesPrecisionChanged(int)
double getYMinimum() const
Definition: Histogram.cpp:266
bool load(XmlStreamReader *, bool preview) override
Load from XML.
Definition: Histogram.cpp:1761
void dataColumnChanged(const AbstractColumn *)
HistogramOrientation
Definition: Histogram.h:47
@ Horizontal
Definition: Histogram.h:47
@ Vertical
Definition: Histogram.h:47
void initActions()
Definition: Histogram.cpp:144
void valuesPrefixChanged(QString)
void fillingEnabledChanged(bool)
void valuesOpacityChanged(qreal)
void valuesPositionChanged(Histogram::ValuesPosition)
void orientationChanged(Histogram::HistogramOrientation)
void errorBarsOpacityChanged(qreal)
void errorBarsTypeChanged(XYCurve::ErrorBarsType)
void valuesNumericFormatChanged(char)
void valuesColumnChanged(const AbstractColumn *)
@ Cumulative
Definition: Histogram.h:46
@ AvgShift
Definition: Histogram.h:46
@ Ordinary
Definition: Histogram.h:46
void typeChanged(Histogram::HistogramType)
double getXMaximum() const
Definition: Histogram.cpp:270
void valuesDistanceChanged(qreal)
@ DropLines
Definition: Histogram.h:49
@ Envelope
Definition: Histogram.h:49
void setVisible(bool on) override
Show/hide the element.
Definition: Histogram.cpp:170
void suppressRetransform(bool)
void lineOpacityChanged(qreal)
void errorBarsCapSizeChanged(qreal)
void fillingImageStyleChanged(PlotArea::BackgroundImageStyle)
void loadThemeConfig(const KConfig &) override
Definition: Histogram.cpp:1895
void valuesColorChanged(QColor)
double getYMaximum() const
Definition: Histogram.cpp:262
ValuesPosition
Definition: Histogram.h:51
@ ValuesAbove
Definition: Histogram.h:51
@ ValuesUnder
Definition: Histogram.h:51
@ ValuesRight
Definition: Histogram.h:51
@ ValuesLeft
Definition: Histogram.h:51
void setHover(bool on) override
Definition: Histogram.cpp:190
void saveThemeConfig(const KConfig &) override
Definition: Histogram.cpp:1961
bool isVisible() const override
Return whether the element is (at least) partially visible.
Definition: Histogram.cpp:175
QString & valuesColumnPath() const
Definition: Histogram.cpp:229
void fillingOpacityChanged(float)
WorksheetElement BaseClass
Definition: Histogram.h:136
HistogramPrivate Private
Definition: Histogram.h:137
@ SquareRoot
Definition: Histogram.h:48
@ ByNumber
Definition: Histogram.h:48
void valuesDateTimeFormatChanged(QString)
void updateValues()
Definition: Histogram.cpp:686
HistogramPrivate *const d_ptr
Definition: Histogram.h:154
void linePenChanged(const QPen &)
void binRangesMaxChanged(double)
void symbolsPenChanged(const QPen &)
void binCountChanged(int)
void visibilityChangedSlot()
Definition: Histogram.cpp:709
void valuesColumnAboutToBeRemoved(const AbstractAspect *)
Definition: Histogram.cpp:698
void binRangesMinChanged(double)
double getXMinimum() const
Definition: Histogram.cpp:274
void fillingFileNameChanged(QString &)
void lineTypeChanged(Histogram::LineType)
void retransform() override
Definition: Histogram.cpp:664
void symbolsOpacityChanged(qreal)
void init()
Definition: Histogram.cpp:75
void binWidthChanged(float)
void valuesSuffixChanged(QString)
void symbolsRotationAngleChanged(qreal)
void fillingColorStyleChanged(PlotArea::BackgroundColorStyle)
void errorBarsPenChanged(QPen)
void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override
Definition: Histogram.cpp:673
Histogram(const QString &name)
Definition: Histogram.cpp:63
QGraphicsItem * graphicsItem() const override
Return the graphics item representing this element.
Definition: Histogram.cpp:165
void fillingTypeChanged(PlotArea::BackgroundType)
BackgroundColorStyle
Definition: PlotArea.h:46
BackgroundImageStyle
Definition: PlotArea.h:48
BackgroundType
Definition: PlotArea.h:45
Style
Definition: Symbol.h:38
Base class for all Worksheet children.
ErrorBarsType
Definition: XYCurve.h:65
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 POINTER_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:161
#define BASIC_D_ACCESSOR_DECL(type, method, Method)
Definition: macros.h:107