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)  

HistogramPrivate.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : HistogramPrivate.h
3  Project : LabPlot
4  Description : Private members of 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 HISTOGRAMPRIVATE_H
31 #define HISTOGRAMPRIVATE_H
32 
34 
35 #include <QGraphicsItem>
36 #include <vector>
37 
38 extern "C" {
39 #include <gsl/gsl_histogram.h>
40 }
41 
42 class QPen;
43 class QFont;
44 
45 class HistogramPrivate : public QGraphicsItem {
46 public:
47  explicit HistogramPrivate(Histogram* owner);
48  ~HistogramPrivate() override;
49 
50  QString name() const;
51  QRectF boundingRect() const override;
52  QPainterPath shape() const override;
53 
54  bool m_printing{false};
55  bool m_hovered{false};
56  bool m_suppressRetransform{false};
57  bool m_suppressRecalc{false};
58  QPixmap m_pixmap;
63 
64  void retransform();
65  void recalcHistogram();
66  void updateType();
67  void updateOrientation();
68  void updateLines();
69  void verticalHistogram();
70  void horizontalHistogram();
71  void updateSymbols();
72  void updateValues();
73  void updateFilling();
74  void updateErrorBars();
75  bool swapVisible(bool on);
77 
78  void setHover(bool on);
79  bool activateCurve(QPointF mouseScenePos, double maxDist);
80 
81  void drawSymbols(QPainter*);
82  void drawValues(QPainter*);
83  void drawFilling(QPainter*);
84  void draw(QPainter*);
85  void updatePixmap();
86 
87  double getYMaximum();
88  double getYMinimum();
89  double getXMinimum();
90  double getXMaximum();
92 
93  //General
94  const AbstractColumn* dataColumn{nullptr};
95  QString dataColumnPath;
99  int binCount{10};
100  float binWidth{1.0f};
101  bool autoBinRanges{true};
102  double binRangesMin{0.0};
103  double binRangesMax{1.0};
104 
105  //line
107  QPen linePen;
108  qreal lineOpacity;
109 
110  //symbols
112  QBrush symbolsBrush;
116  qreal symbolsSize;
117 
118  //values
119  int value{0};
121  const AbstractColumn* valuesColumn{nullptr};
127  char valuesNumericFormat; //'g', 'e', 'E', etc. for numeric values
128  int valuesPrecision; //number of digits for numeric values
130  QString valuesPrefix;
131  QString valuesSuffix;
132  QFont valuesFont;
133  QColor valuesColor;
134 
135  //filling
136  bool fillingEnabled{true};
140  Qt::BrushStyle fillingBrushStyle;
145 
146  //error bars
149  double errorBarsCapSize{1};
152 
153  QPainterPath linePath;
154  QPainterPath symbolsPath;
155  QPainterPath valuesPath;
157  QPainterPath curveShape;
158  //TODO: use Qt container
159  //TODO: add m_
161  QVector<QPointF> pointsLogical; //points in logical coordinates
162  QVector<QPointF> pointsScene; //points in scene coordinates
163  std::vector<bool> visiblePoints; //vector of the size of symbolPointsLogical with true of false for the points currently visible or not in the plot
166  QPolygonF fillPolygon;
167 
168  Histogram* const q;
169 
170 private:
171  gsl_histogram* m_histogram{nullptr};
172  size_t m_bins{0};
173 
174  void contextMenuEvent(QGraphicsSceneContextMenuEvent*) override;
175  void mousePressEvent(QGraphicsSceneMouseEvent*) override;
176  void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
177  void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
178 
179  void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override;
180 };
181 
182 #endif
Interface definition for data with column logic.
Histogram::HistogramOrientation orientation
void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override
Definition: Histogram.cpp:814
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *widget=nullptr) override
Definition: Histogram.cpp:1452
Symbol::Style symbolsStyle
gsl_histogram * m_histogram
QPainterPath shape() const override
Definition: Histogram.cpp:810
~HistogramPrivate() override
Definition: Histogram.cpp:722
QPainterPath linePath
Histogram::ErrorType errorType
Histogram::ValuesPosition valuesPosition
PlotArea::BackgroundImageStyle fillingImageStyle
bool m_selectionEffectImageIsDirty
Qt::BrushStyle fillingBrushStyle
QPainterPath valuesPath
Histogram::ValuesType valuesType
void setHover(bool on)
Definition: Histogram.cpp:1672
HistogramPrivate(Histogram *owner)
Definition: Histogram.cpp:717
const AbstractColumn * valuesColumn
QPainterPath symbolsPath
void draw(QPainter *)
Definition: Histogram.cpp:1391
Histogram *const q
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override
Definition: Histogram.cpp:1629
void mousePressEvent(QGraphicsSceneMouseEvent *) override
Definition: Histogram.cpp:1651
void drawFilling(QPainter *)
Definition: Histogram.cpp:1533
void drawSymbols(QPainter *)
Definition: Histogram.cpp:1500
Histogram::HistogramType type
bool activateCurve(QPointF mouseScenePos, double maxDist)
Definition: Histogram.cpp:1638
QVector< QPointF > pointsLogical
QImage m_selectionEffectImage
const AbstractColumn * dataColumn
double getMaximumOccuranceofHistogram()
Definition: Histogram.cpp:735
double getYMaximum()
Definition: Histogram.cpp:797
void updateOrientation()
Definition: Histogram.cpp:985
double getXMaximum()
Definition: Histogram.cpp:777
double getXMinimum()
Definition: Histogram.cpp:767
std::vector< bool > visiblePoints
QPainterPath curveShape
bool swapVisible(bool on)
Definition: Histogram.cpp:818
QString name() const
Definition: Histogram.cpp:727
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override
Definition: Histogram.cpp:1620
QVector< QPointF > valuesPoints
void recalcShapeAndBoundingRect()
Definition: Histogram.cpp:1364
double getYMinimum()
Definition: Histogram.cpp:787
Histogram::LineType lineType
QString valuesDateTimeFormat
void updateErrorBars()
Definition: Histogram.cpp:1357
QVector< QPointF > pointsScene
void horizontalHistogram()
Definition: Histogram.cpp:1079
QVector< QString > valuesStrings
PlotArea::BackgroundType fillingType
PlotArea::BackgroundColorStyle fillingColorStyle
QVector< QLineF > lines
QRectF boundingRect() const override
Definition: Histogram.cpp:731
void verticalHistogram()
Definition: Histogram.cpp:1025
void recalcHistogram()
Definition: Histogram.cpp:873
XYCurve::ErrorBarsType errorBarsType
void drawValues(QPainter *)
Definition: Histogram.cpp:1517
Histogram::BinningMethod binningMethod
A 2D-curve, provides an interface for editing many properties of the curve.
Definition: Histogram.h:42
@ NoValues
Definition: Histogram.h:50
HistogramOrientation
Definition: Histogram.h:47
@ Vertical
Definition: Histogram.h:47
@ Ordinary
Definition: Histogram.h:46
ValuesPosition
Definition: Histogram.h:51
@ ValuesAbove
Definition: Histogram.h:51
@ SquareRoot
Definition: Histogram.h:48
BackgroundColorStyle
Definition: PlotArea.h:46
BackgroundImageStyle
Definition: PlotArea.h:48
BackgroundType
Definition: PlotArea.h:45
Style
Definition: Symbol.h:38
ErrorBarsType
Definition: XYCurve.h:65