2015-07-11 18:56:02 +08:00
|
|
|
/*
|
2020-08-26 18:58:23 +08:00
|
|
|
Copyright (c) 2008-2020 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>
|
2019-05-30 04:40:02 +08:00
|
|
|
#include "jkqtplotter/jkqtptools.h"
|
2019-06-22 20:21:32 +08:00
|
|
|
#include "jkqtplotter/jkqtplotter_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-06-22 20:21:32 +08:00
|
|
|
class JKQTPLOTTER_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
|
|
|
|
|
|
|
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc visible */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setVisible(bool __value);
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc visible */
|
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-06-22 20:21:32 +08:00
|
|
|
class JKQTPLOTTER_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-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc x1 */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setX1(double __value);
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc x1 */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getX1() const;
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc x2 */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setX2(double __value);
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc x2 */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getX2() const;
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc y1 */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setY1(double __value);
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc y1 */
|
2019-04-22 19:27:50 +08:00
|
|
|
double getY1() const;
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc y2 */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setY2(double __value);
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc y2 */
|
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-06-22 20:21:32 +08:00
|
|
|
class JKQTPLOTTER_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-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc position */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setPosition(double __value);
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc position */
|
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-06-22 20:21:32 +08:00
|
|
|
class JKQTPLOTTER_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-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc position2 */
|
2019-04-22 19:27:50 +08:00
|
|
|
void setPosition2(double __value);
|
2019-05-19 04:41:38 +08:00
|
|
|
/*! \copydoc position2 */
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-19 00:13:18 +08:00
|
|
|
#endif // jkqtpelementsoverlay_H
|