forked from GoldenCheetah/GoldenCheetah
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.. The diagram now displays on a chart, but there are a few issues. Will work through them as more testing done.
- Loading branch information
1 parent
4f005d4
commit 70ed4e3
Showing
9 changed files
with
214 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2021 Mark Liversedge ([email protected]) | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., 51 | ||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <QChart> | ||
#include "GenericLines.h" | ||
|
||
GenericLines::GenericLines(GenericPlot *plot) : QGraphicsItem(NULL), plot(plot), curve(NULL) | ||
{ | ||
} | ||
|
||
GenericLines::~GenericLines() {} | ||
|
||
void | ||
GenericLines::paint(QPainter*painter, const QStyleOptionGraphicsItem *, QWidget*) | ||
{ | ||
if (curve == NULL) return; | ||
|
||
QPen pen(Qt::lightGray); | ||
painter->setPen(pen); | ||
|
||
painter->setClipRect(plot->qchart->plotArea()); | ||
|
||
foreach(QLineF line, lines) { | ||
QPointF from = plot->qchart->mapToPosition(line.p1(), curve); | ||
QPointF to = plot->qchart->mapToPosition(line.p2(), curve); | ||
|
||
painter->drawLine(from, to); | ||
} | ||
} | ||
|
||
void | ||
GenericLines::prepare() | ||
{ | ||
prepareGeometryChange(); | ||
} | ||
|
||
QRectF GenericLines::boundingRect() const | ||
{ | ||
// we cover the entire plot area generally | ||
return plot->qchart->plotArea(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2021 Mark Liversedge ([email protected]) | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., 51 | ||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#ifndef _GC_GenericLines_h | ||
#define _GC_GenericLines_h 1 | ||
|
||
#include <QPointF> | ||
#include <QtCharts> | ||
#include <QGraphicsItem> | ||
|
||
#include "GenericPlot.h" | ||
|
||
// for painting lines on a chart | ||
class GenericLines : public QGraphicsItem | ||
{ | ||
|
||
Q_INTERFACES(QGraphicsItem) | ||
|
||
public: | ||
|
||
GenericLines(GenericPlot *); | ||
~GenericLines(); | ||
|
||
void setCurve(QAbstractSeries *curve) { this->curve=curve; } | ||
void setLines(QList<QLineF> lines) { this->lines = lines; update(); } | ||
|
||
void paint(QPainter*, const QStyleOptionGraphicsItem *, QWidget*); | ||
QRectF boundingRect() const; | ||
|
||
void prepare(); | ||
private: | ||
|
||
// lines to draw | ||
QList<QLineF> lines; | ||
GenericPlot *plot; | ||
|
||
QAbstractSeries *curve; | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.