2015-07-11 18:56:02 +08:00
|
|
|
/*
|
2019-01-12 23:01:55 +08:00
|
|
|
Copyright (c) 2008-2019 Jan W. Krieger (<jan@jkrieger.de>)
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2015-07-12 22:34:27 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
This software is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License (LGPL) as published by
|
2019-02-08 00:24:46 +08:00
|
|
|
the Free Software Foundation, either version 2.1 of the License, or
|
2015-07-11 18:56:02 +08:00
|
|
|
(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 Lesser General Public License (LGPL) for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License (LGPL)
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPair>
|
2018-11-26 03:25:44 +08:00
|
|
|
#include "jkqtplottertools/jkqtptools.h"
|
|
|
|
#include "jkqtplottertools/jkqtp_imexport.h"
|
2019-04-22 19:27:50 +08:00
|
|
|
#include "jkqtplotter/jkqtpgraphsbasestylingmixins.h"
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2018-12-19 00:13:18 +08:00
|
|
|
#ifndef jkqtpelementsoverlay_H
|
|
|
|
#define jkqtpelementsoverlay_H
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
// forward declarations
|
2019-01-20 17:49:29 +08:00
|
|
|
class JKQTBasePlotter;
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
/*! \brief this virtual base class describes an interface for graph overlay elements, which are simple geometric
|
|
|
|
forms drawn ONTO the graphe, so a redraw of the overlays does NOT require a redraw of the graph.
|
|
|
|
\ingroup jkqtplotter_overlays
|
|
|
|
|
|
|
|
These simple primitive elements can be used to e.g. display fast changing indicators on the graph ...
|
|
|
|
*/
|
2019-02-03 21:04:48 +08:00
|
|
|
class JKQTP_LIB_EXPORT JKQTPOverlayElement : public QObject {
|
2015-07-11 18:56:02 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-22 19:27:50 +08:00
|
|
|
explicit JKQTPOverlayElement(JKQTBasePlotter *parent = nullptr);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
/** \brief plots the graph to the plotter object specified as parent */
|
|
|
|
virtual void draw(JKQTPEnhancedPainter& painter)=0;
|
|
|
|
|
|
|
|
/** \brief returns the parent painter class */
|
2019-01-20 17:49:29 +08:00
|
|
|
inline JKQTBasePlotter* getParent() { return parent; }
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
/** \brief sets the parent painter class */
|
2019-01-20 17:49:29 +08:00
|
|
|
virtual void setParent(JKQTBasePlotter* parent);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*! \copydoc visible
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see visible for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setVisible(bool __value);
|
|
|
|
/*! \copydoc visible
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see visible for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
bool isVisible() const;
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/** \brief the plotter object this object belongs to */
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTBasePlotter* parent;
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief indictaes whether the overlay is visible (at all) */
|
2015-07-11 18:56:02 +08:00
|
|
|
bool visible;
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief tool routine that transforms a QPointF according to the parent's transformation rules */
|
|
|
|
QPointF transform(const QPointF& x);
|
|
|
|
|
|
|
|
double transfromX(double x);
|
|
|
|
double transfromY(double y);
|
|
|
|
|
|
|
|
/** \brief tool routine that back-transforms a QPointF according to the parent's transformation rules */
|
|
|
|
QPointF backTransform(const QPointF& x);
|
|
|
|
|
|
|
|
/** \brief tool routine that transforms a QPointF according to the parent's transformation rules */
|
|
|
|
inline QPointF transform(double x, double y) {
|
|
|
|
return transform(QPointF(x,y));
|
2019-04-22 19:27:50 +08:00
|
|
|
}
|
2015-07-11 18:56:02 +08:00
|
|
|
/** \brief tool routine that back-transforms a QPointF according to the parent's transformation rules */
|
|
|
|
inline QPointF backTransform(double x, double y) {
|
|
|
|
return backTransform(QPointF(x,y));
|
2019-04-22 19:27:50 +08:00
|
|
|
}
|
2015-07-11 18:56:02 +08:00
|
|
|
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules */
|
|
|
|
QVector<QPointF> transform(const QVector<QPointF>& x);
|
|
|
|
|
|
|
|
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules
|
|
|
|
* and returns a (non-closed) path consisting of lines */
|
|
|
|
QPainterPath transformToLinePath(const QVector<QPointF>& x);
|
|
|
|
|
|
|
|
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules
|
|
|
|
* and returns a polygon */
|
|
|
|
inline QPolygonF transformToPolygon(const QVector<QPointF>& x) {
|
|
|
|
return QPolygonF(transform(x));
|
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief baseclass for a two-position overlay
|
|
|
|
\ingroup jkqtplotter_overlays
|
|
|
|
*/
|
2019-02-03 21:04:48 +08:00
|
|
|
class JKQTP_LIB_EXPORT JKQTPOverlayTwoPositionOverlay : public JKQTPOverlayElement {
|
2015-07-11 18:56:02 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-22 19:27:50 +08:00
|
|
|
explicit JKQTPOverlayTwoPositionOverlay(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent = nullptr);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
/*! \copydoc x1
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see x1 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setX1(double __value);
|
|
|
|
/*! \copydoc x1
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see x1 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getX1() const;
|
|
|
|
/*! \copydoc x2
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see x2 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setX2(double __value);
|
|
|
|
/*! \copydoc x2
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see x2 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getX2() const;
|
|
|
|
/*! \copydoc y1
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see y1 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setY1(double __value);
|
|
|
|
/*! \copydoc y1
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see y1 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getY1() const;
|
|
|
|
/*! \copydoc y2
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see y2 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setY2(double __value);
|
|
|
|
/*! \copydoc y2
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see y2 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getY2() const;
|
2015-07-11 18:56:02 +08:00
|
|
|
protected:
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief x-coordinate of first point of overlay */
|
2015-07-11 18:56:02 +08:00
|
|
|
double x1;
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief y-coordinate of first point of overlay */
|
2015-07-11 18:56:02 +08:00
|
|
|
double y1;
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief x-coordinate of first second of overlay */
|
2015-07-11 18:56:02 +08:00
|
|
|
double x2;
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief y-coordinate of first second of overlay */
|
2015-07-11 18:56:02 +08:00
|
|
|
double y2;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief baseclass for one-coordinate indicator overlays (horizontal/vertical lines
|
|
|
|
\ingroup jkqtplotter_overlays
|
|
|
|
*/
|
2019-02-03 21:04:48 +08:00
|
|
|
class JKQTP_LIB_EXPORT JKQTPOverlayOneCoordOverlay : public JKQTPOverlayElement {
|
2015-07-11 18:56:02 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-22 19:27:50 +08:00
|
|
|
explicit JKQTPOverlayOneCoordOverlay(double pos, JKQTBasePlotter *parent = nullptr);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
/*! \copydoc position
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see position for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setPosition(double __value);
|
|
|
|
/*! \copydoc position
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see position for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getPosition() const;
|
2015-07-11 18:56:02 +08:00
|
|
|
protected:
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief second position for the element */
|
2015-07-11 18:56:02 +08:00
|
|
|
double position;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief baseclass for two-coordinate indicator overlays (horizontal/vertical lines
|
|
|
|
\ingroup jkqtplotter_overlays
|
|
|
|
*/
|
2019-02-03 21:04:48 +08:00
|
|
|
class JKQTP_LIB_EXPORT JKQTPOverlayTwoCoordOverlay : public JKQTPOverlayOneCoordOverlay {
|
2015-07-11 18:56:02 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-22 19:27:50 +08:00
|
|
|
explicit JKQTPOverlayTwoCoordOverlay(double pos, double pos2, JKQTBasePlotter *parent = nullptr);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
/*! \copydoc position2
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see position2 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setPosition2(double __value);
|
|
|
|
/*! \copydoc position2
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see position2 for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getPosition2() const;
|
2015-07-11 18:56:02 +08:00
|
|
|
protected:
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief second position for the element */
|
2015-07-11 18:56:02 +08:00
|
|
|
double position2;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief draws a vertical line as an overlay
|
|
|
|
\ingroup jkqtplotter_overlays
|
|
|
|
|
|
|
|
These simple primitive elements can be used to e.g. display fast changing indicators on the graph ...
|
|
|
|
*/
|
2019-04-22 19:27:50 +08:00
|
|
|
class JKQTP_LIB_EXPORT JKQTPOverlayVerticalLine : public JKQTPOverlayOneCoordOverlay, public JKQTPGraphLineStyleMixin, public JKQTPGraphTextStyleMixin {
|
2015-07-11 18:56:02 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-22 19:27:50 +08:00
|
|
|
explicit JKQTPOverlayVerticalLine(double pos, JKQTBasePlotter *parent = nullptr);
|
|
|
|
explicit JKQTPOverlayVerticalLine(double pos, const QString& text, JKQTBasePlotter *parent = nullptr);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
/** \brief plots the graph to the plotter object specified as parent */
|
|
|
|
virtual void draw(JKQTPEnhancedPainter& painter);
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief set element color */
|
|
|
|
virtual void setColor(QColor c);
|
|
|
|
|
|
|
|
/*! \copydoc text
|
|
|
|
\see see text for details */
|
|
|
|
void setText(const QString & __value);
|
|
|
|
/*! \copydoc text
|
|
|
|
\see see text for details */
|
|
|
|
QString getText() const;
|
|
|
|
protected:
|
|
|
|
/** \brief a text to display next to the vertical line */
|
|
|
|
QString text;
|
2015-07-11 18:56:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief draws a vertical range as an overlay
|
|
|
|
\ingroup jkqtplotter_overlays
|
|
|
|
|
|
|
|
These simple primitive elements can be used to e.g. display fast changing indicators on the graph ...
|
|
|
|
*/
|
2019-04-22 19:27:50 +08:00
|
|
|
class JKQTP_LIB_EXPORT JKQTPOverlayVerticalRange : public JKQTPOverlayTwoCoordOverlay, public JKQTPGraphLineStyleMixin, public JKQTPGraphFillStyleMixin, public JKQTPGraphTextStyleMixin {
|
2015-07-11 18:56:02 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-22 19:27:50 +08:00
|
|
|
explicit JKQTPOverlayVerticalRange(double pos, double pos2, JKQTBasePlotter *parent = nullptr);
|
|
|
|
explicit JKQTPOverlayVerticalRange(double pos, double pos2, const QString& text, JKQTBasePlotter *parent = nullptr);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
/** \brief plots the graph to the plotter object specified as parent */
|
|
|
|
virtual void draw(JKQTPEnhancedPainter& painter);
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief set element color */
|
|
|
|
virtual void setColor(QColor c);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
/*! \copydoc inverted
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see inverted for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setInverted(bool __value);
|
|
|
|
/*! \copydoc inverted
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see inverted for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
bool getInverted() const;
|
|
|
|
|
|
|
|
/*! \copydoc text
|
|
|
|
\see see text for details */
|
|
|
|
void setText(const QString & __value);
|
|
|
|
/*! \copydoc text
|
|
|
|
\see see text for details */
|
|
|
|
QString getText() const;
|
2015-07-11 18:56:02 +08:00
|
|
|
protected:
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief a text to display next to the range */
|
|
|
|
QString text;
|
2015-07-11 18:56:02 +08:00
|
|
|
/** \brief if set \c false, the range is filled, otherwise everything outside the range is filled */
|
|
|
|
bool inverted;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! \brief draws a line throught two points
|
|
|
|
\ingroup jkqtplotter_overlays
|
|
|
|
|
|
|
|
*/
|
2019-04-22 19:27:50 +08:00
|
|
|
class JKQTP_LIB_EXPORT JKQTPOverlayLine : public JKQTPOverlayTwoPositionOverlay, public JKQTPGraphLineStyleMixin {
|
2015-07-11 18:56:02 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-22 19:27:50 +08:00
|
|
|
explicit JKQTPOverlayLine(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent = nullptr);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
/** \brief plots the graph to the plotter object specified as parent */
|
|
|
|
virtual void draw(JKQTPEnhancedPainter& painter);
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
/*! \copydoc infinite
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see infinite for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setInfinite(bool __value);
|
|
|
|
/*! \copydoc infinite
|
2019-02-08 00:24:46 +08:00
|
|
|
\see see infinite for details */
|
2019-04-22 19:27:50 +08:00
|
|
|
bool getInfinite() const;
|
|
|
|
/** \brief set element color */
|
|
|
|
virtual void setColor(QColor c);
|
2015-07-11 18:56:02 +08:00
|
|
|
protected:
|
|
|
|
/** \brief the line goes on infinitely */
|
|
|
|
bool infinite;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! \brief draws a rectangle, spanned by two points
|
|
|
|
\ingroup jkqtplotter_overlays
|
|
|
|
|
|
|
|
*/
|
2019-04-22 19:27:50 +08:00
|
|
|
class JKQTP_LIB_EXPORT JKQTPOverlayRectangle : public JKQTPOverlayTwoPositionOverlay, public JKQTPGraphLineStyleMixin, public JKQTPGraphFillStyleMixin {
|
2015-07-11 18:56:02 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-04-22 19:27:50 +08:00
|
|
|
explicit JKQTPOverlayRectangle(double x1, double y1, double x2, double y2, JKQTBasePlotter *parent = nullptr);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
/** \brief plots the graph to the plotter object specified as parent */
|
|
|
|
virtual void draw(JKQTPEnhancedPainter& painter);
|
2019-04-22 19:27:50 +08:00
|
|
|
/** \brief set element color */
|
|
|
|
virtual void setColor(QColor c);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
};
|
|
|
|
|
2018-12-19 00:13:18 +08:00
|
|
|
#endif // jkqtpelementsoverlay_H
|