libosmscout 1.1.1
Loading...
Searching...
No Matches
ElevationChartWidget.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_ELEVATIONCHARTWIDGET_H
2#define OSMSCOUT_CLIENT_QT_ELEVATIONCHARTWIDGET_H
3
4/*
5 OSMScout - a Qt backend for libosmscout and libosmscout-map
6 Copyright (C) 2021 Lukáš Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
27
28#include <QQuickPaintedItem>
29#include <QColor>
30
31namespace osmscout {
32
33class OSMSCOUT_CLIENT_QT_API ElevationChartWidget : public QQuickPaintedItem {
34 Q_OBJECT
35 Q_PROPERTY(QObject *way READ getWay WRITE setWay NOTIFY wayChanged)
36 Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged)
37 Q_PROPERTY(QColor lineColor READ getLineColor WRITE setLineColor NOTIFY lineColorChanged)
38 Q_PROPERTY(qreal lineWidth READ getLineWidth WRITE setLineWidth NOTIFY lineWidthChanged)
41 Q_PROPERTY(QColor textColor READ getTextColor WRITE setTextColor NOTIFY textColorChanged)
44
45 Q_PROPERTY(qint64 pointCount READ getPointCount NOTIFY pointsUpdated)
46 Q_PROPERTY(double lowestElevation READ getLowestElevation NOTIFY pointsUpdated)
47 Q_PROPERTY(double highestElevation READ getHighestElevation NOTIFY pointsUpdated)
48 Q_PROPERTY(double ascent READ getAscent NOTIFY pointsUpdated)
49 Q_PROPERTY(double descent READ getDescent NOTIFY pointsUpdated)
50
51signals:
52 void wayChanged();
55 int requestId,
65
66public slots:
67 void onError(int requestId);
70
71public:
72 explicit ElevationChartWidget(QQuickItem* parent = nullptr);
74
75 void paint(QPainter *painter) override;
76
77 QObject* getWay() const;
78 void setWay(QObject* o);
79
80 bool isLoading() const
81 {
82 return loading;
83 }
84
85 QColor getLineColor() const
86 {
87 return lineColor;
88 }
89
90 void setLineColor(const QColor &color);
91
92 qreal getLineWidth() const
93 {
94 return lineWidth;
95 }
96
97 void setLineWidth(qreal w);
98
99 QColor getGradientTopColor() const
100 {
101 return gradientTopColor;
102 }
103
104 void setGradientTopColor(const QColor &c);
105
107 {
108 return gradientBottomColor;
109 }
110
111 void setGradientBottomColor(const QColor &c);
112
113 QColor getTextColor() const
114 {
115 return textColor;
116 }
117
118 void setTextColor(const QColor &c);
119
121 {
122 return textPixelSize;
123 }
124
125 void setTextPixelSize(int size);
126
127 int getTextPadding() const
128 {
129 return textPadding;
130 }
131
132 void setTextPadding(int size);
133
134 qint64 getPointCount() const
135 {
136 return points.size();
137 }
138
139 double getLowestElevation() const
140 {
141 if (lowest.has_value()) {
142 return lowest->elevation.AsMeter();
143 }
144 return 0;
145 }
146
147 double getHighestElevation() const
148 {
149 if (highest.has_value()) {
150 return highest->elevation.AsMeter();
151 }
152 return 0;
153 }
154
155 double getAscent() const
156 {
157 return ascent.AsMeter();
158 }
159
160 double getDescent() const
161 {
162 return descent.AsMeter();
163 }
164
165protected:
166 void reset();
167
168protected:
170 std::shared_ptr<OverlayWay> way;
172 bool loading=false;
174
176 std::optional<ElevationPoint> lowest;
177 std::optional<ElevationPoint> highest;
178 osmscout::Distance ascent;
179 osmscout::Distance descent;
180
181 QColor lineColor=Qt::darkBlue;
182 QColor textColor=Qt::darkBlue;
183 QColor gradientTopColor=QColor(lineColor.red(), lineColor.green(), lineColor.blue(), 0xA0);
184 QColor gradientBottomColor=Qt::transparent;
185 qreal lineWidth=5;
186 int textPixelSize=14;
187 int textPadding=4;
188
189 Locale locale=Locale::ByEnvironmentSafe();
190};
191
192}
193
194#endif // OSMSCOUT_CLIENT_QT_ELEVATIONCHARTWIDGET_H
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
void setGradientTopColor(const QColor &c)
void paint(QPainter *painter) override
int requestId
Definition ElevationChartWidget.h:173
double getAscent() const
Definition ElevationChartWidget.h:155
void onLoadingFinished(int requestId)
QColor gradientBottomColor
Definition ElevationChartWidget.h:40
double highestElevation
Definition ElevationChartWidget.h:47
void setLineColor(const QColor &color)
int getTextPadding() const
Definition ElevationChartWidget.h:127
QColor getTextColor() const
Definition ElevationChartWidget.h:113
QColor getGradientTopColor() const
Definition ElevationChartWidget.h:99
qreal getLineWidth() const
Definition ElevationChartWidget.h:92
double lowestElevation
Definition ElevationChartWidget.h:46
void onError(int requestId)
QObject * way
Definition ElevationChartWidget.h:35
double getHighestElevation() const
Definition ElevationChartWidget.h:147
double ascent
Definition ElevationChartWidget.h:48
std::optional< ElevationPoint > highest
Definition ElevationChartWidget.h:177
void onElevationProfileAppend(ElevationModule::ElevationPoints points, int requestId)
double descent
Definition ElevationChartWidget.h:49
double getLowestElevation() const
Definition ElevationChartWidget.h:139
ElevationModule * elevationModule
Definition ElevationChartWidget.h:169
QColor getGradientBottomColor() const
Definition ElevationChartWidget.h:106
osmscout::BreakerRef breaker
Definition ElevationChartWidget.h:171
double getDescent() const
Definition ElevationChartWidget.h:160
std::optional< ElevationPoint > lowest
Definition ElevationChartWidget.h:176
ElevationModule::ElevationPoints points
Definition ElevationChartWidget.h:175
QColor gradientTopColor
Definition ElevationChartWidget.h:39
void setTextColor(const QColor &c)
QColor getLineColor() const
Definition ElevationChartWidget.h:85
qreal lineWidth
Definition ElevationChartWidget.h:38
Locale locale
Definition ElevationChartWidget.h:189
bool isLoading() const
Definition ElevationChartWidget.h:80
int textPadding
Definition ElevationChartWidget.h:43
void setGradientBottomColor(const QColor &c)
void elevationProfileRequest(std::shared_ptr< OverlayWay > way, int requestId, osmscout::BreakerRef breaker)
qint64 pointCount
Definition ElevationChartWidget.h:45
qint64 getPointCount() const
Definition ElevationChartWidget.h:134
int textPixelSize
Definition ElevationChartWidget.h:42
int getTextPixelSize() const
Definition ElevationChartWidget.h:120
QColor lineColor
Definition ElevationChartWidget.h:37
bool loading
Definition ElevationChartWidget.h:36
ElevationChartWidget(QQuickItem *parent=nullptr)
QColor textColor
Definition ElevationChartWidget.h:41
Definition ElevationModule.h:41
std::vector< osmscout::ElevationPoint > ElevationPoints
Definition ElevationModule.h:44
Definition OverlayObject.h:190
Definition Area.h:39
std::shared_ptr< Breaker > BreakerRef
Definition Breaker.h:64
STL namespace.