/* Copyright (c) 2008-2020 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/graphs/jkqtpevaluatedfunctionbase.h" #include "jkqtplotter/jkqtpbaseplotter.h" #include #include #include #include "jkqtplotter/jkqtptools.h" #include "jkqtplotter/graphs/jkqtpimage.h" #include "jkqtplotter/jkqtpbaseelements.h" #include "jkqtplotter/jkqtplotter.h" #define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgzgetPlotter()) { } JKQTPEvaluatedFunctionGraphBase::~JKQTPEvaluatedFunctionGraphBase() { data.clear(); } void JKQTPEvaluatedFunctionGraphBase::drawSamplePoints(JKQTPEnhancedPainter& painter, QColor graphColor) { QColor c=graphColor; c.setHsv(fmod(c.hue()+90, 360), c.saturation(), c.value()); painter.save(); auto __finalpaintsamplepoints=JKQTPFinally([&painter]() {painter.restore();}); for (const auto& d: data) { if (JKQTPIsOKFloat(d.x()) && JKQTPIsOKFloat(d.y())) { JKQTPPlotSymbol(painter, d.x(), d.y(), JKQTPCross, 6,1*parent->getLineWidthMultiplier(), c, QColor(Qt::transparent)); } } } void JKQTPEvaluatedFunctionGraphBase::setMinSamples(const unsigned int &__value) { this->minSamples = __value; } unsigned int JKQTPEvaluatedFunctionGraphBase::getMinSamples() const { return this->minSamples; } void JKQTPEvaluatedFunctionGraphBase::setMaxRefinementDegree(const unsigned int &__value) { this->maxRefinementDegree = __value; } unsigned int JKQTPEvaluatedFunctionGraphBase::getMaxRefinementDegree() const { return this->maxRefinementDegree; } void JKQTPEvaluatedFunctionGraphBase::setSlopeTolerance(double __value) { this->slopeTolerance = __value; } double JKQTPEvaluatedFunctionGraphBase::getSlopeTolerance() const { return this->slopeTolerance; } void JKQTPEvaluatedFunctionGraphBase::setMinPixelPerSample(double __value) { this->minPixelPerSample = __value; } double JKQTPEvaluatedFunctionGraphBase::getMinPixelPerSample() const { return this->minPixelPerSample; } void JKQTPEvaluatedFunctionGraphBase::setDataCleanupMaxAllowedAngleDegree(double __value) { dataCleanupMaxAllowedAngleDegree=__value; } double JKQTPEvaluatedFunctionGraphBase::getDataCleanupMaxAllowedAngleDegree() const { return dataCleanupMaxAllowedAngleDegree; } void JKQTPEvaluatedFunctionGraphBase::setDisplaySamplePoints(bool __value) { this->displaySamplePoints = __value; } bool JKQTPEvaluatedFunctionGraphBase::getDisplaySamplePoints() const { return this->displaySamplePoints; } bool JKQTPEvaluatedFunctionGraphBase::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero) { if (data.size()==0) createPlotData(); if (data.size()>0){ bool start=true; minx=0; maxx=0; smallestGreaterZero=0; for (auto const& d: data) { if (JKQTPIsOKFloat(d.x())) { if (start || d.x()>maxx) maxx=d.x(); if (start || d.x()0){ bool start=true; miny=0; maxy=0; smallestGreaterZero=0; for (auto const& d: data) { if (JKQTPIsOKFloat(d.y())) { if (start || d.y()>maxy) maxy=d.y(); if (start || d.y()getPlotter()) { } JKQTPEvaluatedFunctionWithParamsGraphBase::~JKQTPEvaluatedFunctionWithParamsGraphBase() { } void JKQTPEvaluatedFunctionWithParamsGraphBase::collectParameters() { if (parent && parameterColumn>=0) { iparams.clear(); JKQTPDatastore* datastore=parent->getDatastore(); int imin=0; int imax=static_cast(datastore->getRows(parameterColumn)); for (int i=imin; iget(parameterColumn,i); iparams<=0 && !JKQTPIsOKFloat(iparams[i])) { iparams.remove(i,1); i--; } } } void JKQTPEvaluatedFunctionWithParamsGraphBase::setParams(const QVector ¶ms) { iparams=params; } void JKQTPEvaluatedFunctionWithParamsGraphBase::setCopiedParams(const double *params, int N) { QVector v; for (int i=0; i p; p< p; p< p; p< p; p< p; p<parameterColumn = __value; } int JKQTPEvaluatedFunctionWithParamsGraphBase::getParameterColumn() const { return this->parameterColumn; } void JKQTPEvaluatedFunctionWithParamsGraphBase::setParameterColumn(size_t __value) { this->parameterColumn = static_cast(__value); } QVector JKQTPEvaluatedFunctionWithParamsGraphBase::getInternalParams() const { return iparams; } bool JKQTPEvaluatedFunctionWithParamsGraphBase::usesColumn(int c) const { return (c==parameterColumn); }