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)  

XYCurvePrivate.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : XYCurvePrivate.h
3  Project : LabPlot
4  Description : Private members of XYCurve
5  --------------------------------------------------------------------
6  Copyright : (C) 2010-2020 Alexander Semke (alexander.semke@web.de)
7  Copyright : (C) 2013-2020 by Stefan Gerlach (stefan.gerlach@uni.kn)
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  * This program is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU General Public License *
23  * along with this program; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
25  * Boston, MA 02110-1301 USA *
26  * *
27  ***************************************************************************/
28 
29 #ifndef XYCURVEPRIVATE_H
30 #define XYCURVEPRIVATE_H
31 
32 #include <QGraphicsItem>
33 #include <vector>
34 
35 class CartesianPlot;
37 class XYCurve;
38 
39 class XYCurvePrivate : public QGraphicsItem {
40 public:
41  explicit XYCurvePrivate(XYCurve*);
42 
43  QRectF boundingRect() const override;
44  QPainterPath shape() const override;
45 
46  QString name() const;
47  void retransform();
48  void recalcLogicalPoints();
49  void updateLines();
50  void addLine(QPointF p0, QPointF p1, QPointF& lastPoint, qint64& pixelDiff, int numberOfPixelX); // for any x scale
51  void addLinearLine(QPointF p0, QPointF p1, QPointF& lastPoint, double minLogicalDiffX, qint64& pixelDiff); // optimized for linear x scale
52  void addUniqueLine(QPointF p0, QPointF p1, QPointF& lastPoint, qint64& pixelDiff); // finally add line if unique (no overlay)
53  void updateDropLines();
54  void updateSymbols();
55  void updateValues();
56  void updateFilling();
57  void updateErrorBars();
58  bool swapVisible(bool);
60  void updatePixmap();
61  void setPrinting(bool);
62  void suppressRetransform(bool);
63 
64  void setHover(bool on);
65  bool activateCurve(QPointF mouseScenePos, double maxDist);
66  bool pointLiesNearLine(const QPointF p1, const QPointF p2, const QPointF pos, const double maxDist) const;
67  bool pointLiesNearCurve(const QPointF mouseScenePos, const QPointF curvePosPrevScene, const QPointF curvePosScene, const int index, const double maxDist) const;
68 
69  //data source
70  const AbstractColumn* xColumn{nullptr};
71  const AbstractColumn* yColumn{nullptr};
73  QString xColumnPath;
74  QString yColumnPath;
76 
77  //line
82  QPen linePen;
83  qreal lineOpacity;
84 
85  //drop lines
89 
90  //symbols
92  QBrush symbolsBrush;
93  QPen symbolsPen;
96  qreal symbolsSize;
97 
98  //values
100  const AbstractColumn* valuesColumn{nullptr};
106  char valuesNumericFormat; //'g', 'e', 'E', etc. for numeric values
107  int valuesPrecision; //number of digits for numeric values
109  QString valuesPrefix;
110  QString valuesSuffix;
111  QFont valuesFont;
112  QColor valuesColor;
113 
114  //filling
119  Qt::BrushStyle fillingBrushStyle;
124 
125  //error bars
131 
137 
142 
143  XYCurve* const q;
144  friend class XYCurve;
145 
146  const CartesianPlot* plot{nullptr};
148 
149 private:
150  void contextMenuEvent(QGraphicsSceneContextMenuEvent*) override;
151  void mousePressEvent(QGraphicsSceneMouseEvent*) override;
152  void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override;
153 
154  void drawSymbols(QPainter*);
155  void drawValues(QPainter*);
156  void drawFilling(QPainter*);
157  void draw(QPainter*);
158 
159  //TODO: add m_
160  QPainterPath linePath;
161  QPainterPath dropLinePath;
162  QPainterPath valuesPath;
163  QPainterPath errorBarsPath;
164  QPainterPath symbolsPath;
166  QPainterPath curveShape;
168  QVector<QPointF> m_logicalPoints; //points in logical coordinates
169  QVector<QPointF> m_scenePoints; //points in scene coordinates
170  QVector<bool> m_pointVisible; //if point is currently visible in plot (size of m_logicalPoints)
171  QVector<QPointF> m_valuePoints; //points for showing value
172  QVector<QString> m_valueStrings; //strings for showing value
173  QVector<QPolygonF> m_fillPolygons; //polygons for filling
174  //TODO: QVector, rename, usage
175  std::vector<int> validPointsIndicesLogical; //original indices in the source columns for valid and non-masked values (size of m_logicalPoints)
176  std::vector<bool> connectedPointsLogical; //true for points connected with the consecutive point (size of m_logicalPoints)
177 
178  QPixmap m_pixmap;
183  bool m_hovered{false};
184  bool m_suppressRecalc{false};
186  bool m_printing{false};
187 };
188 
189 #endif
Interface definition for data with column logic.
Cartesian coordinate system for plots.
A xy-plot.
Definition: CartesianPlot.h:58
BackgroundColorStyle
Definition: PlotArea.h:46
BackgroundImageStyle
Definition: PlotArea.h:48
BackgroundType
Definition: PlotArea.h:45
Style
Definition: Symbol.h:38
QPainterPath linePath
double errorBarsCapSize
QRectF boundingRectangle
QString xColumnPath
void retransform()
Definition: XYCurve.cpp:963
int lineInterpolationPointsCount
void updateSymbols()
Definition: XYCurve.cpp:1678
void recalcShapeAndBoundingRect()
Definition: XYCurve.cpp:2610
PlotArea::BackgroundType fillingType
const AbstractColumn * xErrorMinusColumn
QString yColumnPath
bool sourceDataChangedSinceLastRecalc
bool activateCurve(QPointF mouseScenePos, double maxDist)
Definition: XYCurve.cpp:2293
QString yErrorMinusColumnPath
QString yErrorPlusColumnPath
QString dataSourceCurvePath
std::vector< bool > connectedPointsLogical
std::vector< int > validPointsIndicesLogical
void updateErrorBars()
Definition: XYCurve.cpp:2495
XYCurve::ErrorBarsType errorBarsType
XYCurvePrivate(XYCurve *)
Definition: XYCurve.cpp:914
QPainterPath shape() const override
Definition: XYCurve.cpp:930
void updateDropLines()
Definition: XYCurve.cpp:1616
bool pointLiesNearCurve(const QPointF mouseScenePos, const QPointF curvePosPrevScene, const QPointF curvePosScene, const int index, const double maxDist) const
Definition: XYCurve.cpp:2430
void updateValues()
Definition: XYCurve.cpp:1709
QVector< QString > m_valueStrings
PlotArea::BackgroundImageStyle fillingImageStyle
QVector< QPointF > m_scenePoints
XYCurve::ErrorType xErrorType
void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override
Definition: XYCurve.cpp:934
XYCurve::ValuesType valuesType
QPainterPath dropLinePath
QRectF boundingRect() const override
Definition: XYCurve.cpp:923
qreal symbolsRotationAngle
QImage m_selectionEffectImage
QVector< QPointF > m_logicalPoints
const AbstractColumn * xColumn
QString xErrorPlusColumnPath
bool swapVisible(bool)
Definition: XYCurve.cpp:942
void drawValues(QPainter *)
Definition: XYCurve.cpp:2804
XYCurve::ValuesPosition valuesPosition
Qt::BrushStyle fillingBrushStyle
QColor fillingSecondColor
void drawFilling(QPainter *)
Definition: XYCurve.cpp:2819
QVector< QPolygonF > m_fillPolygons
void addUniqueLine(QPointF p0, QPointF p1, QPointF &lastPoint, qint64 &pixelDiff)
XYCurvePrivate::addUniqueLine This function is called from the other two addLine() functions to avoid...
Definition: XYCurve.cpp:1221
void updatePixmap()
Definition: XYCurve.cpp:2702
bool lineIncreasingXOnly
QString valuesDateTimeFormat
QColor fillingFirstColor
const CartesianPlot * plot
void drawSymbols(QPainter *)
Definition: XYCurve.cpp:2786
void setPrinting(bool)
Definition: XYCurve.cpp:2908
QImage m_hoverEffectImage
XYCurve::FillingPosition fillingPosition
void recalcLogicalPoints()
Definition: XYCurve.cpp:1090
QVector< bool > m_pointVisible
XYCurve *const q
const CartesianCoordinateSystem * cSystem
QString xErrorMinusColumnPath
QPainterPath errorBarsPath
const AbstractColumn * yErrorPlusColumn
void updateLines()
Definition: XYCurve.cpp:1252
QPainterPath valuesPath
XYCurve::ErrorType yErrorType
QString fillingFileName
bool m_hoverEffectImageIsDirty
void draw(QPainter *)
Definition: XYCurve.cpp:2649
QVector< QPointF > m_valuePoints
const AbstractColumn * xErrorPlusColumn
bool pointLiesNearLine(const QPointF p1, const QPointF p2, const QPointF pos, const double maxDist) const
XYCurve::pointLiesNearLine Calculates if a point pos lies near than maxDist to the line created by th...
Definition: XYCurve.cpp:2403
QString valuesColumnPath
const AbstractColumn * valuesColumn
void mousePressEvent(QGraphicsSceneMouseEvent *) override
Definition: XYCurve.cpp:2922
bool m_suppressRetransform
QString valuesPrefix
void updateFilling()
Definition: XYCurve.cpp:1882
void addLine(QPointF p0, QPointF p1, QPointF &lastPoint, qint64 &pixelDiff, int numberOfPixelX)
Definition: XYCurve.cpp:1182
const AbstractColumn * yErrorMinusColumn
void setHover(bool on)
Definition: XYCurve.cpp:2942
QPainterPath symbolsPath
qreal valuesRotationAngle
const AbstractColumn * yColumn
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *widget=nullptr) override
Definition: XYCurve.cpp:2735
XYCurve::DropLineType dropLineType
void suppressRetransform(bool)
Definition: XYCurve.cpp:2912
QString name() const
Definition: XYCurve.cpp:919
QVector< QLineF > m_lines
QString valuesSuffix
QPainterPath curveShape
void addLinearLine(QPointF p0, QPointF p1, QPointF &lastPoint, double minLogicalDiffX, qint64 &pixelDiff)
Definition: XYCurve.cpp:1165
XYCurve::LineType lineType
PlotArea::BackgroundColorStyle fillingColorStyle
bool m_selectionEffectImageIsDirty
Symbol::Style symbolsStyle
A 2D-curve, provides an interface for editing many properties of the curve.
Definition: XYCurve.h:46
LineType
Definition: XYCurve.h:57
ErrorType
Definition: XYCurve.h:63
ValuesType
Definition: XYCurve.h:61
ValuesPosition
Definition: XYCurve.h:62
FillingPosition
Definition: XYCurve.h:64
ErrorBarsType
Definition: XYCurve.h:65
DropLineType
Definition: XYCurve.h:60