From 033ac9c9d2dbced9f2f9a2747bc479ebd1ffb074 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 23 May 2014 10:38:31 +0100 Subject: [PATCH] CP Delta Compare Part 2b of 2a/b .. now completed to allow model comparisons too. --- src/CPPlot.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/CPPlot.cpp b/src/CPPlot.cpp index 3c3542e45..27c4c9330 100644 --- a/src/CPPlot.cpp +++ b/src/CPPlot.cpp @@ -473,6 +473,23 @@ CPPlot::plotModel() } } +// our model for combining a model for delta mode +class DeltaModel : public QwtSyntheticPointData +{ + public: + + double x(unsigned int index) const { return baseline->x(index); } + double y(double t) const { return us->y(t) - baseline->y(t); } + + // use the same interval and size as the baseline model + DeltaModel(PDModel *us, PDModel *baseline) : QwtSyntheticPointData(baseline->size()), us(us), baseline(baseline) { + setInterval(baseline->interval()); + } + + private: + PDModel *us, *baseline; +}; + // in compare mode we can plot models and compare them... void CPPlot::plotModel(QVector vector, QColor plotColor, PDModel *baseline) @@ -515,8 +532,16 @@ CPPlot::plotModel(QVector vector, QColor plotColor, PDModel *baseline) if (appsettings->value(this, GC_ANTIALIAS, false).toBool() == true) curve->setRenderHint(QwtPlotItem::RenderAntialiased); - // set the point data - curve->setData(pdmodel); + if (baseline) { + + // doing a delta model + curve->setData(new DeltaModel(pdmodel, baseline)); + + } else { + + // set the point data + curve->setData(pdmodel); + } // curve cosmetics QPen pen(plotColor);