2020-08-26 16:36:07 +08:00
|
|
|
/*
|
2022-07-19 19:40:43 +08:00
|
|
|
Copyright (c) 2008-2022 Jan W. Krieger (<jan@jkrieger.de>)
|
2020-08-26 16:36:07 +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
|
|
|
|
the Free Software Foundation, either version 2.1 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 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 "jkqtplotter/graphs/jkqtpgeobase.h"
|
|
|
|
#include "jkqtplotter/jkqtpbaseplotter.h"
|
|
|
|
#include "jkqtplotter/jkqtplotter.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QApplication>
|
|
|
|
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTPGeoBaseLine::JKQTPGeoBaseLine(JKQTBasePlotter *parent, DrawMode drawMode):
|
2020-09-21 19:15:57 +08:00
|
|
|
JKQTPGeometricPlotElement(drawMode, parent)
|
2020-09-26 21:58:58 +08:00
|
|
|
{
|
|
|
|
initLineStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Geometric);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseLine::setStyle(QColor color, double lineWidth)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
}
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
void JKQTPGeoBaseLine::setStyle(QColor color, double lineWidth, Qt::PenStyle style)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
setLineStyle(style);
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
void JKQTPGeoBaseLine::setStyle(QColor color, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineStyle(style);}
|
|
|
|
|
2020-08-26 16:36:07 +08:00
|
|
|
void JKQTPGeoBaseLine::setAlpha(float alpha)
|
|
|
|
{
|
|
|
|
auto color=getLineColor();
|
|
|
|
color.setAlphaF(alpha);
|
|
|
|
setLineColor(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseLine::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setLineColor(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 05:24:59 +08:00
|
|
|
void JKQTPGeoBaseLine::drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) {
|
2020-08-26 16:36:07 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2022-08-30 15:44:40 +08:00
|
|
|
painter.setPen(getKeyLinePen(painter, rect, parent));
|
|
|
|
const double y=rect.top()+rect.height()/2.0;
|
|
|
|
painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
2020-08-26 16:36:07 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor JKQTPGeoBaseLine::getKeyLabelColor() const {
|
|
|
|
return getLineColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(JKQTBasePlotter *parent, JKQTPGeometricPlotElement::DrawMode drawMode):
|
|
|
|
JKQTPGeoBaseLine(parent, drawMode)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
initFillStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Geometric);
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setAlpha(float alpha)
|
|
|
|
{
|
|
|
|
JKQTPGeoBaseLine::setAlpha(alpha);
|
|
|
|
auto fillColor=getFillColor();
|
|
|
|
fillColor.setAlphaF(alpha);
|
|
|
|
setFillColor(fillColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setAlpha(float alphaLine, float alphaFill)
|
|
|
|
{
|
|
|
|
JKQTPGeoBaseLine::setAlpha(alphaLine);
|
|
|
|
auto fillColor=getFillColor();
|
|
|
|
fillColor.setAlphaF(alphaFill);
|
|
|
|
setFillColor(fillColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setColor(QColor c)
|
|
|
|
{
|
|
|
|
JKQTPGeoBaseLine::setColor(c);
|
2020-09-26 21:58:58 +08:00
|
|
|
setFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphsStyle.geometricStyle.fillColorDerivationMode, c));
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyle(QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
setLineStyle(style);
|
|
|
|
setFillColor(fillColor);
|
|
|
|
setFillStyle(fillStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyle(QColor color, double lineWidth, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
setLineStyle(style);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyle(QColor color, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineStyle(style);
|
|
|
|
setLineColor(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyle(QColor color, double lineWidth)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyle(QColor color, QColor fillColor)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setFillColor(fillColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyleTransparentFill(QColor color, double lineWidth, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
setLineStyle(style);
|
|
|
|
setFillColor(Qt::transparent);
|
|
|
|
setFillStyle(Qt::SolidPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyleTransparentFill(QColor color, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineStyle(style);
|
|
|
|
setFillColor(Qt::transparent);
|
|
|
|
setFillStyle(Qt::SolidPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyleTransparentFill(QColor color, double lineWidth)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
setFillColor(Qt::transparent);
|
|
|
|
setFillStyle(Qt::SolidPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setStyleTransparentFill(QColor color)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setFillColor(Qt::transparent);
|
|
|
|
setFillStyle(Qt::SolidPattern);
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 05:24:59 +08:00
|
|
|
void JKQTPGeoBaseFilled::drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) {
|
2020-08-26 16:36:07 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2022-08-30 15:44:40 +08:00
|
|
|
painter.setPen(getKeyLinePen(painter, rect, parent));
|
2020-08-26 16:36:07 +08:00
|
|
|
painter.setBrush(getFillBrush(painter, parent));
|
2022-08-30 15:44:40 +08:00
|
|
|
painter.drawRect(rect-QMarginsF(1,1,1,1));
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(JKQTPLineDecoratorStyle headStyle, JKQTBasePlotter *parent, DrawMode drawMode):
|
2020-09-21 19:15:57 +08:00
|
|
|
JKQTPGeometricPlotElement(drawMode, parent)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
int parStyleDummy=0;
|
|
|
|
initDecoratedHeadLineStyle(parent, parStyleDummy, JKQTPPlotStyleType::Geometric);
|
2020-08-26 16:36:07 +08:00
|
|
|
setHeadDecoratorStyle(headStyle);
|
|
|
|
}
|
|
|
|
|
- improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
- improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)
- new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves
2020-09-04 05:08:52 +08:00
|
|
|
JKQTPGeoBaseDecoratedHeadLine::JKQTPGeoBaseDecoratedHeadLine(JKQTBasePlotter *parent, DrawMode drawMode):
|
2020-09-21 19:15:57 +08:00
|
|
|
JKQTPGeometricPlotElement(drawMode, parent)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
initDecoratedHeadLineStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Geometric);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseDecoratedHeadLine::setStyle(QColor color, double lineWidth)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseDecoratedHeadLine::setStyle(QColor color, double lineWidth, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
setLineStyle(style);
|
|
|
|
}
|
2020-08-26 16:36:07 +08:00
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
void JKQTPGeoBaseDecoratedHeadLine::setStyle(QColor color, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineStyle(style);
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseDecoratedHeadLine::setAlpha(float alpha)
|
|
|
|
{
|
|
|
|
auto color=getLineColor();
|
|
|
|
color.setAlphaF(alpha);
|
|
|
|
setLineColor(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseDecoratedHeadLine::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setLineColor(c);
|
|
|
|
}
|
|
|
|
|
2023-12-19 05:24:59 +08:00
|
|
|
void JKQTPGeoBaseDecoratedHeadLine::drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
painter.setPen(getLinePen(painter, parent));
|
2022-08-30 15:44:40 +08:00
|
|
|
const double y=rect.top()+rect.height()/2.0;
|
|
|
|
painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor JKQTPGeoBaseDecoratedHeadLine::getKeyLabelColor() const
|
|
|
|
{
|
|
|
|
return getLineColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(JKQTPLineDecoratorStyle headStyle, JKQTPLineDecoratorStyle tailStyle, JKQTBasePlotter *parent, DrawMode drawMode):
|
2020-09-21 19:15:57 +08:00
|
|
|
JKQTPGeometricPlotElement(drawMode, parent)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
int parStyleDummy=0;
|
|
|
|
initDecoratedLineStyle(parent, parStyleDummy, JKQTPPlotStyleType::Geometric);
|
2020-08-26 16:36:07 +08:00
|
|
|
setTailDecoratorStyle(tailStyle);
|
|
|
|
setHeadDecoratorStyle(headStyle);
|
|
|
|
}
|
|
|
|
|
- improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
- improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)
- new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves
2020-09-04 05:08:52 +08:00
|
|
|
JKQTPGeoBaseDecoratedLine::JKQTPGeoBaseDecoratedLine(JKQTBasePlotter *parent, DrawMode drawMode):
|
2020-09-21 19:15:57 +08:00
|
|
|
JKQTPGeometricPlotElement(drawMode, parent)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
initDecoratedLineStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Geometric);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void JKQTPGeoBaseDecoratedLine::setStyle(QColor color, double lineWidth)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseDecoratedLine::setStyle(QColor color, double lineWidth, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
setLineStyle(style);
|
|
|
|
}
|
2020-08-26 16:36:07 +08:00
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
void JKQTPGeoBaseDecoratedLine::setStyle(QColor color, Qt::PenStyle style)
|
|
|
|
{
|
|
|
|
setLineColor(color);
|
|
|
|
setLineStyle(style);
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseDecoratedLine::setAlpha(float alpha)
|
|
|
|
{
|
|
|
|
auto color=getLineColor();
|
|
|
|
color.setAlphaF(alpha);
|
|
|
|
setLineColor(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoBaseDecoratedLine::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setLineColor(c);
|
|
|
|
}
|
|
|
|
|
2023-12-19 05:24:59 +08:00
|
|
|
void JKQTPGeoBaseDecoratedLine::drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2022-08-30 15:44:40 +08:00
|
|
|
QPen p=getLinePen(painter, parent);
|
|
|
|
p.setColor(getKeyLabelColor());
|
|
|
|
p.setWidthF(getKeyLineWidthPx(painter,rect,parent));
|
|
|
|
painter.setPen(p);
|
|
|
|
const double y=rect.top()+rect.height()/2.0;
|
|
|
|
painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor JKQTPGeoBaseDecoratedLine::getKeyLabelColor() const
|
|
|
|
{
|
|
|
|
return getLineColor();
|
|
|
|
}
|