mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Add Gapped Curve
.. want to mod ride plot to not plot gaps in recording, but instead draw a break in the curve.
This commit is contained in:
63
qtsolutions/qwtcurve/qwt_plot_gapped_curve.cpp
Normal file
63
qtsolutions/qwtcurve/qwt_plot_gapped_curve.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "qwt_plot_gapped_curve.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
QwtPlotGappedCurve::QwtPlotGappedCurve(double gapValue)
|
||||
: QwtPlotCurve(),
|
||||
gapValue_(gapValue)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
QwtPlotGappedCurve::QwtPlotGappedCurve(const QwtText &title, double gapValue)
|
||||
: QwtPlotCurve(title),
|
||||
gapValue_(gapValue)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
QwtPlotGappedCurve::QwtPlotGappedCurve(const QString &title, double gapValue)
|
||||
: QwtPlotCurve(title),
|
||||
gapValue_(gapValue)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void QwtPlotGappedCurve::drawSeries(QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap, const QRectF &canvRect, int from, int to) const
|
||||
{
|
||||
if ( !painter || dataSize() <= 0 )
|
||||
return;
|
||||
|
||||
if (to < 0)
|
||||
to = dataSize() - 1;
|
||||
|
||||
int i = from;
|
||||
while (i < to)
|
||||
{
|
||||
// If data begins with missed values,
|
||||
// we need to find first non-missed point.
|
||||
double y = sample(i).y();
|
||||
while ((i < to) && (y == gapValue_))
|
||||
{
|
||||
++i;
|
||||
y = sample(i).y();
|
||||
}
|
||||
// First non-missed point will be the start of curve section.
|
||||
int start = i;
|
||||
y = sample(i).y();
|
||||
// Find the last non-missed point, it will be the end of curve section.
|
||||
while ((i < to) && (y != gapValue_))
|
||||
{
|
||||
++i;
|
||||
y = sample(i).y();
|
||||
}
|
||||
// Correct the end of the section if it is at missed point
|
||||
int end = (y == gapValue_) ? i - 1 : i;
|
||||
|
||||
// Draw the curve section
|
||||
if (start <= end)
|
||||
QwtPlotCurve::drawSeries(painter, xMap, yMap, canvRect, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
39
qtsolutions/qwtcurve/qwt_plot_gapped_curve.h
Normal file
39
qtsolutions/qwtcurve/qwt_plot_gapped_curve.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef QWT_PLOT_GAPPED_CURVE_H
|
||||
#define QWT_PLOT_GAPPED_CURVE_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_text.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_scale_map.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// This class is a plot curve that can have gaps at points
|
||||
/// with specific Y value.
|
||||
/// This specific "gap" value can be passed to constructors,
|
||||
/// it's zero by default.
|
||||
class QwtPlotGappedCurve: public QwtPlotCurve
|
||||
{
|
||||
public:
|
||||
/// gapValue is an Y value which denotes missed data
|
||||
QwtPlotGappedCurve(double gapValue = 0);
|
||||
|
||||
/// gapValue is an Y value which denotes missed data
|
||||
QwtPlotGappedCurve(const QwtText &title, double gapValue = 0);
|
||||
|
||||
/// gapValue is an Y value which denotes missed data
|
||||
QwtPlotGappedCurve(const QString &title, double gapValue = 0);
|
||||
|
||||
/// Override draw method to create gaps for missed Y values
|
||||
virtual void drawSeries(QPainter *painter, const QwtScaleMap &xMap,
|
||||
const QwtScaleMap &yMap, const QRectF &canvRect, int from, int to) const;
|
||||
|
||||
private:
|
||||
/// Value that denotes missed Y data at point
|
||||
double gapValue_;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
@@ -12,7 +12,7 @@ DEPENDPATH += .
|
||||
QMAKE_INFO_PLIST = ./mac/Info.plist.app
|
||||
|
||||
## qwt and libz
|
||||
INCLUDEPATH += ../qwt/src ../qxt/src $${LIBZ_INCLUDE} ../qtsolutions/json
|
||||
INCLUDEPATH += ../qwt/src ../qxt/src $${LIBZ_INCLUDE} ../qtsolutions/json ../qtsolutions/qwtcurve
|
||||
LIBS += ../qwt/lib/libqwt.a
|
||||
LIBS += -lm $${LIBZ_LIBS}
|
||||
|
||||
@@ -266,6 +266,10 @@ HEADERS += TPUpload.h TPUploadDialog.h TPDownload.h TPDownloadDialog.h
|
||||
SOURCES += TPUpload.cpp TPUploadDialog.cpp TPDownload.cpp TPDownloadDialog.cpp
|
||||
DEFINES += GC_HAVE_SOAP
|
||||
|
||||
# gapped curve
|
||||
HEADERS += ../qtsolutions/qwtcurve/qwt_plot_gapped_curve.h
|
||||
SOURCES += ../qtsolutions/qwtcurve/qwt_plot_gapped_curve.cpp
|
||||
|
||||
HEADERS += \
|
||||
AboutDialog.h \
|
||||
AddDeviceWizard.h \
|
||||
|
||||
Reference in New Issue
Block a user