/* Copyright (c) 2008-2019 Jan W. Krieger () 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 . */ #include "jkqtplotter/jkqtpgraphsbase.h" #include "jkqtplotter/jkqtpbaseplotter.h" #include #include #include #include "jkqtplottertools/jkqtptools.h" #include "jkqtplotter/jkqtpgraphsimage.h" #include "jkqtplotter/jkqtpbaseelements.h" #include "jkqtplotter/jkqtplotter.h" #include "jkqtpgraphsbase.h" #define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgzgetPlotter()) { } JKQTPGraph::JKQTPGraph(JKQTBasePlotter* parent): JKQTPPlotElement(parent) { } JKQTPGraph::JKQTPGraph(JKQTPlotter *parent): JKQTPPlotElement(parent) { } QImage JKQTPPlotElement::generateKeyMarker(QSize size) { QImage img(size.width(),size.height(),QImage::Format_ARGB32); if (parent) img.fill(Qt::transparent);//->getKeyBackgroundColor()); { JKQTPEnhancedPainter painter(&img); painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::TextAntialiasing, true); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); painter.setRenderHint(QPainter::HighQualityAntialiasing, true); QRectF rect(0,0,size.width(),size.height()); drawKeyMarker(painter, rect); } return img; } void JKQTPPlotElement::setTitle(const QString &__value) { this->title = __value; } QString JKQTPPlotElement::getTitle() const { return this->title; } void JKQTPPlotElement::setVisible(bool __value) { this->visible = __value; } bool JKQTPPlotElement::isVisible() const { return this->visible; } void JKQTPPlotElement::setHighlighted(bool __value) { highlighted=__value; } bool JKQTPPlotElement::isHighlighted() const { return highlighted; } void JKQTPPlotElement::setParent(JKQTBasePlotter* parent) { this->parent=parent; QObject::setParent(parent); } void JKQTPPlotElement::setParent(JKQTPlotter *parent) { setParent(parent->getPlotter()); } bool JKQTPGraph::getDataMinMax(int column, double &minx, double &maxx, double &smallestGreaterZero) { bool start=true; minx=0; maxx=0; smallestGreaterZero=0; if (parent==nullptr) return false; JKQTPDatastore* datastore=parent->getDatastore(); int imin=0; int imax=datastore->getColumn(column).getRows(); if (imin<0) imin=0; if (imax<0) imax=0; for (int i=imin; iget(column,i); if (start || xv>maxx) maxx=xv; if (start || xvgetXAxis()->x2p(x); } double JKQTPPlotElement::transformY(double y) const { return parent->getYAxis()->x2p(y); } double JKQTPPlotElement::backtransformX(double x) const { return parent->getXAxis()->p2x(x); } double JKQTPPlotElement::backtransformY(double y) const { return parent->getYAxis()->p2x(y); } bool JKQTPGraph::usesColumn(int /*column*/) const { return false; } void JKQTPGraph::drawErrorsBefore(JKQTPEnhancedPainter &) { } void JKQTPGraph::drawErrorsAfter(JKQTPEnhancedPainter &) { } QVector JKQTPPlotElement::transform(const QVector &x) { QVector res; for (int i=0; i &x) { QPainterPath res; if (x.size()>0) { res.moveTo(transform(x[0])); for (int i=1; igetDatastore(); int imin=0; int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); if (imaxget(static_cast(xColumn),static_cast(i)); if (JKQTPIsOKFloat(xv)) { if (start || xv>maxx) maxx=xv; if (start || xvgetDatastore(); int imin=0; int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); if (imaxget(static_cast(yColumn),static_cast(i)); if (JKQTPIsOKFloat(yv)) { if (start || yv>maxy) maxy=yv; if (start || yvgetPlotter()) { } void JKQTPSingleColumnGraph::setDataColumn(int __value) { this->dataColumn = __value; } int JKQTPSingleColumnGraph::getDataColumn() const { return this->dataColumn; } void JKQTPSingleColumnGraph::setDataColumn(size_t __value) { this->dataColumn = static_cast(__value); } void JKQTPSingleColumnGraph::setDataSortOrder(JKQTPSingleColumnGraph::DataSortOrder __value) { this->sortData = __value; } JKQTPSingleColumnGraph::DataSortOrder JKQTPSingleColumnGraph::getDataSortOrder() const { return this->sortData; } void JKQTPSingleColumnGraph::setDataSortOrder(int __value) { sortData=(DataSortOrder)__value; if (__value>0) sortData=Sorted; } void JKQTPSingleColumnGraph::setDataDirection(JKQTPSingleColumnGraph::DataDirection __value) { this->dataDirection = __value; } JKQTPSingleColumnGraph::DataDirection JKQTPSingleColumnGraph::getDataDirection() const { return this->dataDirection; } bool JKQTPSingleColumnGraph::usesColumn(int c) const { return c==dataColumn; } void JKQTPSingleColumnGraph::intSortData() { sortedIndices.clear(); if (parent==nullptr) return ; JKQTPDatastore* datastore=parent->getDatastore(); int imin=0; int imax=datastore->getColumn(dataColumn).getRows(); if (imax datas; if (sortData==JKQTPSingleColumnGraph::Sorted) { for (int i=0; iget(dataColumn,i); sortedIndices<getDatastore(); int imin=0; int imax=qMin(datastore->getColumn(static_cast(xColumn)).getRows(), datastore->getColumn(static_cast(yColumn)).getRows()); if (imax datas; if (sortData==JKQTPXYLineGraph::SortedX) { for (int i=0; iget(static_cast(xColumn),static_cast(i)); sortedIndices<get(static_cast(yColumn),static_cast(i)); sortedIndices<