File indexing completed on 2024-12-08 06:35:36

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2011-2012 Florian Eßer <f.esser@rwth-aachen.de>
0004 //
0005 
0006 #ifndef ELEVATIONPROFILEPLOTAXIS_H
0007 #define ELEVATIONPROFILEPLOTAXIS_H
0008 
0009 #include <QObject>
0010 #include <QVector>
0011 #include <QString>
0012 
0013 namespace Marble
0014 {
0015 
0016 struct AxisTick {
0017     int position;
0018     qreal value;
0019     AxisTick() :
0020         position(0),
0021         value(0.0)
0022     {
0023     }
0024     AxisTick(int position_, qreal value_) :
0025         position( position_ ),
0026         value( value_ )
0027     {
0028         // nothing to do
0029     }
0030 };
0031 using AxisTickList = QVector<AxisTick>;
0032 
0033  /**
0034  * @short A helper class handling a plot axis for the Elevation Profile
0035  *
0036  */
0037 class ElevationProfilePlotAxis : public QObject
0038 {
0039     Q_OBJECT
0040   private:
0041     qreal m_minValue;
0042     qreal m_maxValue;
0043     qreal m_displayScale;
0044     int m_pixelLength;
0045     int m_minTickCount;
0046     int m_maxTickCount;
0047     QString m_unitString;
0048     AxisTickList m_ticks;
0049 
0050     void updateTicks();
0051     void updateScale();
0052 
0053   public:
0054     explicit ElevationProfilePlotAxis( );
0055     void setRange(qreal minValue, qreal maxValue);
0056     void setLength(int length);
0057     void setTickCount( const int min, const int max );
0058     void update();
0059     qreal minValue() const;
0060     qreal maxValue() const;
0061     qreal range() const;
0062     qreal scale() const;
0063     QString unit() const;
0064     AxisTickList ticks() const;
0065 };
0066 
0067 }
0068 
0069 Q_DECLARE_TYPEINFO(Marble::AxisTick, Q_PRIMITIVE_TYPE);
0070 
0071 #endif // ELEVATIONPROFILEPLOTAXIS_H