File indexing completed on 2025-01-26 03:34:18
0001 /* 0002 File : XYCurvePrivate.h 0003 Project : LabPlot 0004 Description : Private members of XYCurve 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2010-2023 Alexander Semke <alexander.semke@web.de> 0007 SPDX-FileCopyrightText: 2013-2020 Stefan Gerlach <stefan.gerlach@uni.kn> 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #ifndef XYCURVEPRIVATE_H 0013 #define XYCURVEPRIVATE_H 0014 0015 #include "backend/worksheet/plots/cartesian/PlotPrivate.h" 0016 #include <vector> 0017 0018 class Background; 0019 class CartesianPlot; 0020 class CartesianCoordinateSystem; 0021 class Symbol; 0022 class XYCurve; 0023 0024 class XYCurvePrivate : public PlotPrivate { 0025 public: 0026 explicit XYCurvePrivate(XYCurve*); 0027 0028 void retransform() override; 0029 void recalcLogicalPoints(); 0030 void updateLines(); 0031 void addLine(QPointF p, 0032 double& x, 0033 double& minY, 0034 double& maxY, 0035 QPointF& lastPoint, 0036 int& pixelDiff, 0037 int numberOfPixelX, 0038 double minDiffX, 0039 RangeT::Scale scale, 0040 bool& prevPixelDiffZero); // for any x scale 0041 static void addUniqueLine(QPointF p, 0042 double& minY, 0043 double& maxY, 0044 QPointF& lastPoint, 0045 int& pixelDiff, 0046 QVector<QLineF>& lines, 0047 bool& prevPixelDiffZero); // finally add line if unique (no overlay) 0048 void updateDropLines(); 0049 void updateSymbols(); 0050 void updateRug(); 0051 void updateValues(); 0052 void updateFilling(); 0053 void updateErrorBars(); 0054 void recalcShapeAndBoundingRect() override; 0055 void updatePixmap(); 0056 0057 virtual bool activatePlot(QPointF mouseScenePos, double maxDist = -1) override; 0058 bool pointLiesNearLine(const QPointF p1, const QPointF p2, const QPointF pos, const double maxDist) const; 0059 bool 0060 pointLiesNearCurve(const QPointF mouseScenePos, const QPointF curvePosPrevScene, const QPointF curvePosScene, const int index, const double maxDist) const; 0061 0062 // data source 0063 const AbstractColumn* xColumn{nullptr}; 0064 const AbstractColumn* yColumn{nullptr}; 0065 QString dataSourceCurvePath; 0066 QString xColumnPath; 0067 QString yColumnPath; 0068 bool sourceDataChangedSinceLastRecalc{false}; 0069 0070 // line 0071 XYCurve::LineType lineType{XYCurve::LineType::Line}; 0072 bool lineSkipGaps{false}; 0073 bool lineIncreasingXOnly{false}; 0074 int lineInterpolationPointsCount{1}; 0075 Line* line{nullptr}; 0076 Line* dropLine{nullptr}; 0077 0078 // symbols 0079 Symbol* symbol{nullptr}; 0080 0081 // rug 0082 bool rugEnabled{false}; 0083 WorksheetElement::Orientation rugOrientation{WorksheetElement::Orientation::Vertical}; 0084 double rugOffset{0.0}; 0085 double rugLength{Worksheet::convertToSceneUnits(5, Worksheet::Unit::Point)}; 0086 double rugWidth{0.0}; 0087 QPainterPath rugPath; 0088 0089 // values 0090 XYCurve::ValuesType valuesType{XYCurve::ValuesType::NoValues}; 0091 const AbstractColumn* valuesColumn{nullptr}; 0092 QString valuesColumnPath; 0093 XYCurve::ValuesPosition valuesPosition{XYCurve::ValuesPosition::Above}; 0094 qreal valuesDistance{Worksheet::convertToSceneUnits(5, Worksheet::Unit::Point)}; 0095 qreal valuesRotationAngle{0.0}; 0096 qreal valuesOpacity{1.0}; 0097 char valuesNumericFormat{'f'}; //'g', 'e', 'E', etc. for numeric values 0098 int valuesPrecision{2}; // number of digits for numeric values 0099 QString valuesDateTimeFormat; 0100 QString valuesPrefix; 0101 QString valuesSuffix; 0102 QFont valuesFont; 0103 QColor valuesColor; 0104 0105 // filling 0106 Background* background{nullptr}; 0107 0108 // error bars 0109 ErrorBar* xErrorBar{nullptr}; 0110 ErrorBar* yErrorBar{nullptr}; 0111 ErrorBarStyle* errorBarStyle{nullptr}; 0112 0113 XYCurve* const q; 0114 friend class XYCurve; 0115 0116 // CartesianPlot* plot{nullptr}; 0117 // const CartesianCoordinateSystem* cSystem{nullptr}; //current cSystem 0118 0119 private: 0120 CartesianPlot* plot() const { 0121 return q->m_plot; 0122 } // convenience method 0123 void mousePressEvent(QGraphicsSceneMouseEvent*) override; 0124 QVariant itemChange(GraphicsItemChange change, const QVariant& value) override; 0125 void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override; 0126 0127 void drawValues(QPainter*); 0128 void draw(QPainter*); 0129 void calculateScenePoints(); 0130 0131 // TODO: add m_ 0132 QPainterPath linePath; 0133 QPainterPath dropLinePath; 0134 QPainterPath valuesPath; 0135 QPainterPath errorBarsPath; 0136 QPainterPath symbolsPath; 0137 QVector<QLineF> m_lines; 0138 QVector<QPointF> m_logicalPoints; // points in logical coordinates 0139 QVector<QPointF> m_scenePoints; // points in scene coordinates 0140 bool m_scenePointsDirty{true}; // true whenever the scenepoints have to be recalculated before using 0141 std::vector<bool> m_pointVisible; // if point is currently visible in plot (size of m_logicalPoints) 0142 QVector<QPointF> m_valuePoints; // points for showing value 0143 QVector<QString> m_valueStrings; // strings for showing value 0144 QVector<QPolygonF> m_fillPolygons; // polygons for filling 0145 // TODO: QVector, rename, usage 0146 std::vector<int> validPointsIndicesLogical; // original indices in the source columns for valid and non-masked values (size of m_logicalPoints) 0147 std::vector<bool> connectedPointsLogical; // true for points connected with the consecutive point (size of m_logicalPoints) 0148 0149 QPointF mousePos; 0150 0151 friend class RetransformTest; 0152 friend class XYCurveTest; 0153 }; 0154 0155 #endif