2018-12-02 21:08:43 +08:00
|
|
|
/*
|
2022-07-19 19:40:43 +08:00
|
|
|
Copyright (c) 2008-2022 Jan W. Krieger (<jan@jkrieger.de>)
|
2018-12-02 21:08:43 +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
|
2018-12-02 21:08:43 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-20 22:06:31 +08:00
|
|
|
#include "jkqtplotter/graphs/jkqtpfilledcurve.h"
|
2018-12-02 21:08:43 +08:00
|
|
|
#include "jkqtplotter/jkqtpbaseplotter.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <iostream>
|
2019-05-30 04:40:02 +08:00
|
|
|
#include "jkqtplotter/jkqtptools.h"
|
2019-06-20 22:06:31 +08:00
|
|
|
#include "jkqtplotter/graphs/jkqtpimage.h"
|
2018-12-02 21:08:43 +08:00
|
|
|
#include "jkqtplotter/jkqtpbaseelements.h"
|
|
|
|
#include "jkqtplotter/jkqtplotter.h"
|
|
|
|
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 01:17:35 +08:00
|
|
|
JKQTPFilledCurveGraphBase::JKQTPFilledCurveGraphBase(JKQTBasePlotter *parent):
|
2022-05-12 04:55:23 +08:00
|
|
|
JKQTPXYBaselineGraph(parent), m_fillMode(FillMode::SingleFilling)
|
2020-09-20 01:17:35 +08:00
|
|
|
{
|
|
|
|
parentPlotStyle=-1;
|
2020-09-26 21:58:58 +08:00
|
|
|
initLineStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Filled);
|
|
|
|
initFillStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Filled);
|
2022-05-12 04:55:23 +08:00
|
|
|
m_fillStyleBelow.initFillStyleInvertedColor(this);
|
2020-09-20 01:17:35 +08:00
|
|
|
setFillCurve(true);
|
|
|
|
setDrawLine(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor JKQTPFilledCurveGraphBase::getKeyLabelColor() const
|
|
|
|
{
|
|
|
|
return getLineColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPFilledCurveGraphBase::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
|
|
|
|
{
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
QPen p=getLinePen(painter, parent);
|
2022-08-30 15:44:40 +08:00
|
|
|
p.setWidthF(getKeyLineWidthPx(painter, rect, parent));
|
2020-09-20 01:17:35 +08:00
|
|
|
QPen np(Qt::NoPen);
|
|
|
|
QBrush b=getFillBrush(painter, parent);
|
|
|
|
const double y=rect.top()+rect.height()/2.0;
|
|
|
|
painter.setPen(np);
|
|
|
|
if (getDrawLine()) painter.setPen(p);
|
|
|
|
painter.setBrush(b);
|
2022-05-12 04:55:23 +08:00
|
|
|
if (getFillCurve()) {
|
|
|
|
if (getFillMode()==FillMode::SingleFilling) {
|
|
|
|
painter.drawRect(rect);
|
|
|
|
} else {
|
|
|
|
QBrush belowB=fillStyleBelow().getFillBrush(painter, parent);
|
|
|
|
QPolygonF p,pb;
|
|
|
|
p<<rect.topLeft()<<rect.topRight()<<rect.bottomRight();
|
|
|
|
pb<<rect.topLeft()<<rect.bottomRight()<<rect.bottomLeft();
|
|
|
|
painter.drawPolygon(p);
|
|
|
|
painter.setBrush(belowB);
|
|
|
|
painter.drawPolygon(pb);
|
|
|
|
painter.setBrush(b);
|
|
|
|
}
|
|
|
|
}
|
2020-09-20 01:17:35 +08:00
|
|
|
if (!getFillCurve() && getDrawLine()) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
|
|
|
}
|
|
|
|
|
2022-05-12 04:55:23 +08:00
|
|
|
JKQTPGraphFillStyleMixin &JKQTPFilledCurveGraphBase::fillStyleBelow()
|
|
|
|
{
|
|
|
|
return m_fillStyleBelow;
|
|
|
|
}
|
|
|
|
|
|
|
|
const JKQTPGraphFillStyleMixin &JKQTPFilledCurveGraphBase::fillStyleBelow() const
|
|
|
|
{
|
|
|
|
return m_fillStyleBelow;
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPFilledCurveGraphBase::FillMode JKQTPFilledCurveGraphBase::getFillMode() const
|
|
|
|
{
|
|
|
|
return m_fillMode;
|
|
|
|
}
|
|
|
|
|
2020-09-20 01:17:35 +08:00
|
|
|
void JKQTPFilledCurveGraphBase::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setLineColor(c);
|
2020-09-26 21:58:58 +08:00
|
|
|
setFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphsStyle.filledStyle.fillColorDerivationMode, c));
|
2020-09-20 01:17:35 +08:00
|
|
|
c.setAlphaF(0.5);
|
|
|
|
setHighlightingLineColor(c);
|
2022-05-12 04:55:23 +08:00
|
|
|
m_fillStyleBelow.initFillStyleInvertedColor(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPFilledCurveGraphBase::setFillMode(FillMode mode)
|
|
|
|
{
|
|
|
|
m_fillMode=mode;
|
2020-09-20 01:17:35 +08:00
|
|
|
}
|
2018-12-02 21:08:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPFilledCurveXGraph::JKQTPFilledCurveXGraph(JKQTBasePlotter* parent):
|
2020-09-20 01:17:35 +08:00
|
|
|
JKQTPFilledCurveGraphBase(parent)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2020-09-20 01:17:35 +08:00
|
|
|
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPFilledCurveXGraph::JKQTPFilledCurveXGraph(JKQTPlotter *parent):
|
2019-02-08 00:24:46 +08:00
|
|
|
JKQTPFilledCurveXGraph(parent->getPlotter())
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-20 01:17:35 +08:00
|
|
|
void JKQTPFilledCurveXGraph::draw(JKQTPEnhancedPainter& painter) {
|
|
|
|
#ifdef JKQTBP_AUTOTIMER
|
|
|
|
JKQTPAutoOutputTimer jkaaot("JKQTPFilledCurveXGraph::draw");
|
|
|
|
#endif
|
|
|
|
if (parent==nullptr) return;
|
|
|
|
JKQTPDatastore* datastore=parent->getDatastore();
|
|
|
|
if (datastore==nullptr) return;
|
|
|
|
|
|
|
|
drawErrorsBefore(painter);
|
|
|
|
|
|
|
|
QPen p=getLinePen(painter, parent);
|
|
|
|
QPen ph=getHighlightingLinePen(painter, parent);
|
2022-07-22 04:17:37 +08:00
|
|
|
//QPen np(Qt::NoPen);
|
2020-09-20 01:17:35 +08:00
|
|
|
QBrush b=getFillBrush(painter, parent);
|
2022-05-12 04:55:23 +08:00
|
|
|
QBrush b_below=fillStyleBelow().getFillBrush(painter, parent);
|
2020-09-20 01:17:35 +08:00
|
|
|
|
|
|
|
int imax=0;
|
|
|
|
int imin=0;
|
|
|
|
|
|
|
|
if (getIndexRange(imin, imax)) {
|
|
|
|
|
2018-12-02 21:08:43 +08:00
|
|
|
|
2020-09-20 01:17:35 +08:00
|
|
|
QPainterPath pl, pf;
|
|
|
|
|
|
|
|
double xold=-1;
|
2022-07-22 04:17:37 +08:00
|
|
|
//double yold=-1;
|
2020-09-20 01:17:35 +08:00
|
|
|
double y0=transformY(getBaseline());
|
|
|
|
if (parent->getYAxis()->isLogAxis()) {
|
|
|
|
y0=transformY(parent->getYAxis()->getMin());
|
|
|
|
if (getBaseline()>0 && getBaseline()>parent->getYAxis()->getMin()) y0=transformY(getBaseline());
|
|
|
|
else y0=transformY(parent->getYAxis()->getMin());
|
|
|
|
}
|
|
|
|
bool subsequentItem=false;
|
|
|
|
intSortData();
|
|
|
|
for (int iii=imin; iii<imax; iii++) {
|
|
|
|
const int i=qBound(imin, getDataIndex(iii), imax);
|
|
|
|
const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
|
|
|
|
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
|
|
|
|
//std::cout<<"(xv, yv) = ( "<<xv<<", "<<yv<<" )\n";
|
|
|
|
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
|
|
|
|
const double x=transformX(xv);
|
|
|
|
const double y=transformY(yv);
|
|
|
|
if (JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) {
|
|
|
|
if (subsequentItem) {
|
|
|
|
pf.lineTo(x, y);
|
|
|
|
if (getDrawLine()) {
|
|
|
|
pl.lineTo(x, y);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (getDrawLine()) pl.moveTo(x,y);
|
|
|
|
pf.moveTo(x, y0);
|
|
|
|
pf.lineTo(x, y);
|
|
|
|
}
|
|
|
|
xold=x;
|
2022-07-22 04:17:37 +08:00
|
|
|
//yold=y;
|
2020-09-20 01:17:35 +08:00
|
|
|
subsequentItem=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (getFillCurve()) {
|
|
|
|
pf.lineTo(xold, y0);
|
|
|
|
pf.closeSubpath();
|
|
|
|
}
|
|
|
|
painter.save();
|
|
|
|
auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
|
|
|
|
if (getFillCurve()) {
|
2022-05-12 04:55:23 +08:00
|
|
|
if (getFillMode()==FillMode::SingleFilling) {
|
|
|
|
painter.fillPath(pf, b);
|
|
|
|
} else if (getFillMode()==FillMode::TwoColorFilling) {
|
|
|
|
QRectF rAbove=pf.boundingRect();
|
|
|
|
rAbove.setBottom(y0);
|
|
|
|
QPainterPath pAbove;
|
|
|
|
pAbove.addRect(rAbove);
|
|
|
|
QRectF rBelow=pf.boundingRect();
|
|
|
|
rBelow.setTop(y0);
|
|
|
|
QPainterPath pBelow;
|
|
|
|
pBelow.addRect(rBelow);
|
|
|
|
QPainterPath pfa=pf.intersected(pAbove);
|
|
|
|
QPainterPath pfb=pf.intersected(pBelow);
|
|
|
|
painter.fillPath(pfa, b);
|
|
|
|
painter.fillPath(pfb, b_below);
|
|
|
|
}
|
2020-09-20 01:17:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isHighlighted()) {
|
|
|
|
painter.setBrush(QBrush(Qt::transparent));
|
|
|
|
painter.setPen(ph);
|
|
|
|
painter.drawPath(pl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getDrawLine()) {
|
|
|
|
painter.setBrush(QBrush(Qt::transparent));
|
|
|
|
painter.setPen(p);
|
|
|
|
painter.drawPath(pl);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
drawErrorsAfter(painter);
|
|
|
|
}
|
2018-12-02 21:08:43 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPFilledCurveYGraph::JKQTPFilledCurveYGraph(JKQTBasePlotter* parent):
|
2020-09-20 01:17:35 +08:00
|
|
|
JKQTPFilledCurveGraphBase(parent)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPFilledCurveYGraph::JKQTPFilledCurveYGraph(JKQTPlotter *parent):
|
2019-02-08 00:24:46 +08:00
|
|
|
JKQTPFilledCurveYGraph(parent->getPlotter())
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-20 01:17:35 +08:00
|
|
|
void JKQTPFilledCurveYGraph::draw(JKQTPEnhancedPainter &painter)
|
|
|
|
{
|
|
|
|
#ifdef JKQTBP_AUTOTIMER
|
|
|
|
JKQTPAutoOutputTimer jkaaot("JKQTPSpecialLineVerticalGraph::draw");
|
|
|
|
#endif
|
|
|
|
if (parent==nullptr) return;
|
|
|
|
JKQTPDatastore* datastore=parent->getDatastore();
|
|
|
|
if (datastore==nullptr) return;
|
|
|
|
|
|
|
|
drawErrorsBefore(painter);
|
|
|
|
|
|
|
|
QPen p=getLinePen(painter, parent);
|
|
|
|
QPen ph=getHighlightingLinePen(painter, parent);
|
|
|
|
QPen np(Qt::NoPen);
|
|
|
|
QBrush b=getFillBrush(painter, parent);
|
2022-05-12 04:55:23 +08:00
|
|
|
QBrush b_below=fillStyleBelow().getFillBrush(painter, parent);
|
2020-09-20 01:17:35 +08:00
|
|
|
|
|
|
|
int imax=0;
|
|
|
|
int imin=0;
|
|
|
|
|
|
|
|
if (getIndexRange(imin, imax)) {
|
|
|
|
|
|
|
|
|
|
|
|
QPainterPath pl, pf;
|
|
|
|
|
2022-07-22 04:17:37 +08:00
|
|
|
//double xold=-1;
|
2020-09-20 01:17:35 +08:00
|
|
|
double yold=-1;
|
|
|
|
double x0=transformX(getBaseline());
|
|
|
|
if (parent->getXAxis()->isLogAxis()) {
|
|
|
|
if (getBaseline()>0 && getBaseline()>parent->getXAxis()->getMin()) x0=transformX(getBaseline());
|
|
|
|
else x0=transformX(parent->getXAxis()->getMin());
|
|
|
|
}
|
|
|
|
bool first=false;
|
|
|
|
intSortData();
|
|
|
|
for (int iii=imin; iii<imax; iii++) {
|
|
|
|
const int i=qBound(imin, getDataIndex(iii), imax);
|
|
|
|
const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
|
|
|
|
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
|
|
|
|
//std::cout<<"(xv, yv) = ( "<<xv<<", "<<yv<<" )\n";
|
|
|
|
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
|
|
|
|
const double x=transformX(xv);
|
|
|
|
const double y=transformY(yv);
|
|
|
|
if (JKQTPIsOKFloat(x) && JKQTPIsOKFloat(y)) {
|
|
|
|
if (first) {
|
|
|
|
|
|
|
|
pf.lineTo(x, y);
|
|
|
|
if (getDrawLine()) {
|
|
|
|
pl.lineTo(x, y);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (getDrawLine()) pl.moveTo(x,y);
|
|
|
|
pf.moveTo(x0, y);
|
|
|
|
pf.lineTo(x, y);
|
|
|
|
}
|
2022-07-22 04:17:37 +08:00
|
|
|
//xold=x;
|
2020-09-20 01:17:35 +08:00
|
|
|
yold=y;
|
|
|
|
first=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pf.lineTo(x0, yold);
|
|
|
|
pf.closeSubpath();
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
|
|
|
|
if (getFillCurve()) {
|
2022-05-12 04:55:23 +08:00
|
|
|
if (getFillMode()==FillMode::SingleFilling) {
|
|
|
|
painter.fillPath(pf, b);
|
|
|
|
} else if (getFillMode()==FillMode::TwoColorFilling) {
|
|
|
|
QRectF rAbove=pf.boundingRect();
|
|
|
|
rAbove.setLeft(x0);
|
|
|
|
QPainterPath pAbove;
|
|
|
|
pAbove.addRect(rAbove);
|
|
|
|
QRectF rBelow=pf.boundingRect();
|
|
|
|
rBelow.setRight(x0);
|
|
|
|
QPainterPath pBelow;
|
|
|
|
pBelow.addRect(rBelow);
|
|
|
|
QPainterPath pfa=pf.intersected(pAbove);
|
|
|
|
QPainterPath pfb=pf.intersected(pBelow);
|
|
|
|
painter.fillPath(pfa, b);
|
|
|
|
painter.fillPath(pfb, b_below);
|
|
|
|
}
|
2020-09-20 01:17:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isHighlighted()) {
|
|
|
|
painter.setBrush(QBrush(Qt::transparent));
|
|
|
|
painter.setPen(ph);
|
|
|
|
painter.drawPath(pl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getDrawLine()) {
|
|
|
|
painter.setBrush(QBrush(Qt::transparent));
|
|
|
|
painter.setPen(p);
|
|
|
|
painter.drawPath(pl);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
drawErrorsAfter(painter);
|
|
|
|
}
|
|
|
|
|
2022-09-10 19:38:29 +08:00
|
|
|
int JKQTPFilledCurveYGraph::getKeyColumn() const
|
|
|
|
{
|
|
|
|
return getYColumn();
|
|
|
|
}
|
|
|
|
|
|
|
|
int JKQTPFilledCurveYGraph::getValueColumn() const
|
|
|
|
{
|
|
|
|
return getXColumn();
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPFilledCurveYGraph::setKeyColumn(int __value)
|
|
|
|
{
|
|
|
|
setYColumn(__value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPFilledCurveYGraph::setValueColumn(int __value)
|
|
|
|
{
|
|
|
|
setXColumn(__value);
|
|
|
|
}
|
|
|
|
|
2018-12-02 21:08:43 +08:00
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPFilledCurveXErrorGraph::JKQTPFilledCurveXErrorGraph(JKQTBasePlotter *parent):
|
2019-05-06 01:31:20 +08:00
|
|
|
JKQTPFilledCurveXGraph(parent)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
setErrorColorFromGraphColor(getLineColor());
|
2020-09-26 21:58:58 +08:00
|
|
|
initErrorStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Filled);
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPFilledCurveXErrorGraph::JKQTPFilledCurveXErrorGraph(JKQTPlotter *parent):
|
2019-02-08 00:24:46 +08:00
|
|
|
JKQTPFilledCurveXErrorGraph(parent->getPlotter())
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPFilledCurveXErrorGraph::usesColumn(int c) const
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-01-20 17:49:29 +08:00
|
|
|
return JKQTPFilledCurveXGraph::usesColumn(c)|| JKQTPYGraphErrors::errorUsesColumn(c);
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPFilledCurveXErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-02-03 21:04:48 +08:00
|
|
|
if (sortData==JKQTPXYGraph::Unsorted) plotErrorIndicators(painter, parent, this, xColumn, yColumn);
|
|
|
|
else plotErrorIndicators(painter, parent, this, xColumn, yColumn, 0, 0, &sortedIndices);
|
2018-12-02 21:08:43 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPFilledCurveYErrorGraph::JKQTPFilledCurveYErrorGraph(JKQTBasePlotter *parent):
|
2019-05-06 01:31:20 +08:00
|
|
|
JKQTPFilledCurveYGraph(parent)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
setErrorColorFromGraphColor(getLineColor());
|
2020-09-26 21:58:58 +08:00
|
|
|
initErrorStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Filled);
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPFilledCurveYErrorGraph::JKQTPFilledCurveYErrorGraph(JKQTPlotter *parent):
|
2019-02-08 00:24:46 +08:00
|
|
|
JKQTPFilledCurveYErrorGraph(parent->getPlotter())
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPFilledCurveYErrorGraph::usesColumn(int c) const
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-01-20 17:49:29 +08:00
|
|
|
return JKQTPFilledCurveYGraph::usesColumn(c)|| JKQTPXGraphErrors::errorUsesColumn(c);
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPFilledCurveYErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-02-03 21:04:48 +08:00
|
|
|
if (sortData==JKQTPXYGraph::Unsorted) plotErrorIndicators(painter, parent, this, xColumn, yColumn);
|
|
|
|
else plotErrorIndicators(painter, parent, this, xColumn, yColumn, 0, 0, &sortedIndices);
|
2018-12-02 21:08:43 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPFilledVerticalRangeGraph::JKQTPFilledVerticalRangeGraph(JKQTBasePlotter *parent):
|
2020-09-19 20:41:53 +08:00
|
|
|
JKQTPXYYGraph(parent)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
initFillStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Filled);
|
|
|
|
initLineStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Filled);
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPFilledVerticalRangeGraph::JKQTPFilledVerticalRangeGraph(JKQTPlotter *parent):
|
2019-02-08 00:24:46 +08:00
|
|
|
JKQTPFilledVerticalRangeGraph(parent->getPlotter())
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPFilledVerticalRangeGraph::draw(JKQTPEnhancedPainter &painter)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
|
|
|
#ifdef JKQTBP_AUTOTIMER
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPAutoOutputTimer jkaaot("JKQTPFilledCurveXGraph::draw");
|
2018-12-02 21:08:43 +08:00
|
|
|
#endif
|
|
|
|
if (parent==nullptr) return;
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPDatastore* datastore=parent->getDatastore();
|
2018-12-02 21:08:43 +08:00
|
|
|
if (datastore==nullptr) return;
|
|
|
|
|
|
|
|
drawErrorsBefore(painter);
|
2019-02-08 00:24:46 +08:00
|
|
|
{
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
QPen p=getLinePen(painter, parent);
|
|
|
|
QPen ps=getHighlightingLinePen(painter, parent);
|
2019-02-08 00:24:46 +08:00
|
|
|
QPen np(Qt::NoPen);
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
QBrush b=getFillBrush(painter, parent);
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
int imax=0;
|
2019-02-08 00:24:46 +08:00
|
|
|
int imin=0;
|
2020-09-19 20:41:53 +08:00
|
|
|
if (getIndexRange(imin, imax)) {
|
|
|
|
|
|
|
|
// upper points are added to poly_all, lower points to plow
|
|
|
|
// then plow points are added to poly_all in vewerse order
|
|
|
|
// then the whole thing is drawn
|
|
|
|
QPolygonF poly_all, phigh, plow;
|
|
|
|
|
|
|
|
intSortData();
|
|
|
|
for (int iii=imin; iii<imax; iii++) {
|
|
|
|
int i=qBound(imin, getDataIndex(iii), imax);
|
|
|
|
const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
|
|
|
|
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
|
|
|
|
const double yv2=datastore->get(static_cast<size_t>(yColumn2),static_cast<size_t>(i));
|
|
|
|
//std::cout<<"(xv, yv) = ( "<<xv<<", "<<yv<<" )\n";
|
|
|
|
if (JKQTPIsOKFloat(xv)) {
|
|
|
|
const double x=transformX(xv); const bool xok=JKQTPIsOKFloat(x);
|
|
|
|
const double y=transformY(yv); const bool yok=JKQTPIsOKFloat(y);
|
|
|
|
const double y2=transformY(yv2); const bool y2ok=JKQTPIsOKFloat(y2);
|
|
|
|
|
|
|
|
if (xok&&yok) phigh.append(QPointF(x,y));
|
|
|
|
if (xok&&yok) poly_all.append(QPointF(x,y));
|
|
|
|
if (xok&&y2ok) plow.append(QPointF(x,y2));
|
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
2018-12-02 21:08:43 +08:00
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
if (plow.size()>0) {
|
|
|
|
for (int i=plow.size()-1; i>=0; i--) {
|
|
|
|
poly_all.append(plow[i]);
|
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
2020-09-19 20:55:46 +08:00
|
|
|
|
|
|
|
if (getFillCurve()) {
|
|
|
|
painter.setBrush(b);
|
|
|
|
painter.setPen(np);
|
|
|
|
painter.drawPolygon(poly_all);
|
|
|
|
}
|
2018-12-02 21:08:43 +08:00
|
|
|
|
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
if (getDrawLine()) {
|
|
|
|
painter.save(); auto __finalpaintline=JKQTPFinally([&painter]() {painter.restore();});
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
if (isHighlighted()) {
|
2019-04-22 19:27:50 +08:00
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
painter.setPen(ps);
|
2022-08-31 04:24:24 +08:00
|
|
|
painter.drawPolylineFast(phigh);
|
|
|
|
painter.drawPolylineFast(plow);
|
2020-09-19 20:41:53 +08:00
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
|
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
painter.setPen(p);
|
2022-08-31 04:24:24 +08:00
|
|
|
painter.drawPolylineFast(phigh);
|
|
|
|
painter.drawPolylineFast(plow);
|
2018-12-02 21:08:43 +08:00
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
drawErrorsAfter(painter);
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPFilledVerticalRangeGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2018-12-02 21:08:43 +08:00
|
|
|
QRectF r=rect;
|
|
|
|
r.setHeight(r.height()/2.0);
|
|
|
|
r.moveTo(r.x(), r.y()+r.height()-1);
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.fillRect(r, getFillBrush(painter, parent));
|
2020-09-19 20:41:53 +08:00
|
|
|
if (getDrawLine()) {
|
2022-08-30 15:44:40 +08:00
|
|
|
painter.setPen(getKeyLinePen(painter, rect, parent));
|
2018-12-02 21:08:43 +08:00
|
|
|
painter.drawLine(QLineF(r.topLeft(), r.topRight()));
|
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
QColor JKQTPFilledVerticalRangeGraph::getKeyLabelColor() const
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
return getLineColor();
|
|
|
|
}
|
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JKQTPFilledHorizontalRangeGraph::JKQTPFilledHorizontalRangeGraph(JKQTBasePlotter *parent):
|
|
|
|
JKQTPXXYGraph(parent)
|
2019-04-22 19:27:50 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
initFillStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Filled);
|
|
|
|
initLineStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Filled);
|
2019-04-22 19:27:50 +08:00
|
|
|
}
|
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
JKQTPFilledHorizontalRangeGraph::JKQTPFilledHorizontalRangeGraph(JKQTPlotter *parent):
|
|
|
|
JKQTPFilledHorizontalRangeGraph(parent->getPlotter())
|
2019-04-22 19:27:50 +08:00
|
|
|
{
|
2020-09-19 20:41:53 +08:00
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
}
|
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
void JKQTPFilledHorizontalRangeGraph::draw(JKQTPEnhancedPainter &painter)
|
|
|
|
{
|
|
|
|
#ifdef JKQTBP_AUTOTIMER
|
|
|
|
JKQTPAutoOutputTimer jkaaot("JKQTPFilledCurveXGraph::draw");
|
|
|
|
#endif
|
|
|
|
if (parent==nullptr) return;
|
|
|
|
JKQTPDatastore* datastore=parent->getDatastore();
|
|
|
|
if (datastore==nullptr) return;
|
|
|
|
|
|
|
|
drawErrorsBefore(painter);
|
|
|
|
{
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
|
|
|
|
QPen p=getLinePen(painter, parent);
|
|
|
|
QPen ps=getHighlightingLinePen(painter, parent);
|
|
|
|
QPen np(Qt::NoPen);
|
|
|
|
|
|
|
|
QBrush b=getFillBrush(painter, parent);
|
|
|
|
|
|
|
|
int imax=0;
|
|
|
|
int imin=0;
|
|
|
|
if (getIndexRange(imin, imax)) {
|
|
|
|
|
|
|
|
// upper points are added to poly_all, lower points to plow
|
|
|
|
// then plow points are added to poly_all in vewerse order
|
|
|
|
// then the whole thing is drawn
|
|
|
|
QPolygonF poly_all, phigh, plow;
|
|
|
|
|
|
|
|
intSortData();
|
|
|
|
for (int iii=imin; iii<imax; iii++) {
|
|
|
|
int i=qBound(imin, getDataIndex(iii), imax);
|
|
|
|
const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
|
|
|
|
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
|
|
|
|
const double xv2=datastore->get(static_cast<size_t>(xColumn2),static_cast<size_t>(i));
|
|
|
|
//std::cout<<"(xv, yv) = ( "<<xv<<", "<<yv<<" )\n";
|
|
|
|
if (JKQTPIsOKFloat(xv)) {
|
|
|
|
const double x=transformX(xv); const bool xok=JKQTPIsOKFloat(x);
|
|
|
|
const double y=transformY(yv); const bool yok=JKQTPIsOKFloat(y);
|
|
|
|
const double x2=transformX(xv2); const bool x2ok=JKQTPIsOKFloat(x2);
|
|
|
|
|
|
|
|
if (xok&&yok) phigh.append(QPointF(x,y));
|
|
|
|
if (xok&&yok) poly_all.append(QPointF(x,y));
|
|
|
|
if (xok&&x2ok) plow.append(QPointF(x2,y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plow.size()>0) {
|
|
|
|
for (int i=plow.size()-1; i>=0; i--) {
|
|
|
|
poly_all.append(plow[i]);
|
|
|
|
}
|
|
|
|
}
|
2020-09-19 20:55:46 +08:00
|
|
|
|
|
|
|
if (getFillCurve()) {
|
|
|
|
painter.setBrush(b);
|
|
|
|
painter.setPen(np);
|
|
|
|
painter.drawPolygon(poly_all);
|
|
|
|
}
|
2020-09-19 20:41:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
if (getDrawLine()) {
|
|
|
|
painter.save(); auto __finalpaintline=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
|
|
|
|
if (isHighlighted()) {
|
|
|
|
|
|
|
|
painter.setPen(ps);
|
2022-08-31 04:24:24 +08:00
|
|
|
painter.drawPolylineFast(phigh);
|
|
|
|
painter.drawPolylineFast(plow);
|
2020-09-19 20:41:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
painter.setPen(p);
|
2022-08-31 04:24:24 +08:00
|
|
|
painter.drawPolylineFast(phigh);
|
|
|
|
painter.drawPolylineFast(plow);
|
2020-09-19 20:41:53 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drawErrorsAfter(painter);
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
void JKQTPFilledHorizontalRangeGraph::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2020-09-19 20:41:53 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
QRectF r=rect;
|
|
|
|
r.setHeight(r.height()/2.0);
|
|
|
|
r.moveTo(r.x(), r.y()+r.height()-1);
|
|
|
|
painter.fillRect(r, getFillBrush(painter, parent));
|
|
|
|
if (getDrawLine()) {
|
2022-08-30 15:44:40 +08:00
|
|
|
painter.setPen(getKeyLinePen(painter, rect, parent));
|
2020-09-19 20:41:53 +08:00
|
|
|
painter.drawLine(QLineF(r.topLeft(), r.topRight()));
|
|
|
|
}
|
|
|
|
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
|
|
|
|
2020-09-19 20:41:53 +08:00
|
|
|
QColor JKQTPFilledHorizontalRangeGraph::getKeyLabelColor() const
|
2018-12-02 21:08:43 +08:00
|
|
|
{
|
2020-09-19 20:41:53 +08:00
|
|
|
return getLineColor();
|
2018-12-02 21:08:43 +08:00
|
|
|
}
|
2020-09-20 01:17:35 +08:00
|
|
|
|