refactorings, code improvements, no functional changes

This commit is contained in:
jkriege2 2022-11-03 15:48:48 +01:00
parent 8c36ce2196
commit 3132eb0102
20 changed files with 154 additions and 419 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -1384,7 +1384,9 @@ std::string JKQTPMathParser::readDelim(char delimiter){
} else {
break;
}
} else if ((*program) && (ch!=delimiter)) res=res+ch;
} else {
res=res+ch;
}
}
return res;

View File

@ -69,7 +69,7 @@ inline double jkqtpstatAverage(InputIt first, InputIt last, size_t* Noutput=null
}
}
if (Noutput) *Noutput=NN;
if (NN<=0) return JKQTP_DOUBLE_NAN;
if (NN==0) return JKQTP_DOUBLE_NAN;
else return sum/static_cast<double>(NN);
}
@ -112,7 +112,7 @@ inline double jkqtpstatWeightedAverage(InputIt first, InputIt last, InputWeightI
}
}
if (Noutput) *Noutput=NN;
if (NN<=0) return JKQTP_DOUBLE_NAN;
if (NN==0) return JKQTP_DOUBLE_NAN;
else return sum/sumW;
}
@ -191,7 +191,7 @@ inline void jkqtpstatMinMax(InputIt first, InputIt last, double& min, double& ma
NN++;
}
}
if (NN<=0) {
if (NN==0) {
min=JKQTP_DOUBLE_NAN;
max=JKQTP_DOUBLE_NAN;
}
@ -327,7 +327,7 @@ inline double jkqtpstatModifiedSum(InputIt first, InputIt last, FF modifierFunct
}
}
if (Noutput) *Noutput=NN;
if (NN<=0) return 0;
if (NN==0) return 0;
else return sum;
}
@ -482,7 +482,7 @@ inline double jkqtpstatVariance(InputIt first, InputIt last, double* averageOut=
}
}
if (averageOut) {
if (NN<=0) *averageOut=JKQTP_DOUBLE_NAN;
if (NN==0) *averageOut=JKQTP_DOUBLE_NAN;
else *averageOut=sum/static_cast<double>(NN);
}
if (Noutput) *Noutput=NN;
@ -556,7 +556,7 @@ inline double jkqtpstatWeightedVariance(InputIt first, InputIt last, InputWeight
}
if (averageOut) *averageOut=avg;
if (Noutput) *Noutput=NN;
if (NN<=0) return 0;
if (NN==0) return 0;
else return sum2/sumW;
}
@ -626,7 +626,7 @@ inline double jkqtpstatSkewness(InputIt first, InputIt last, double* averageOut=
}
if (averageOut) *averageOut=avg;
if (Noutput) *Noutput=NN;
if (NN<=0) return 0;
if (NN==0) return 0;
const double down=jkqtp_cube(sum2/double(NN));
return sum3/double(NN)/sqrt(down);
}
@ -669,7 +669,7 @@ inline double jkqtpstatCentralMoment(InputIt first, InputIt last, int order, dou
}
if (averageOut) *averageOut=avg;
if (Noutput) *Noutput=NN;
if (NN<=0) return 0;
if (NN==0) return 0;
return sum/double(NN);
}
@ -708,7 +708,7 @@ inline double jkqtpstatMoment(InputIt first, InputIt last, int order, size_t* No
}
}
if (Noutput) *Noutput=NN;
if (NN<=0) return 0;
if (NN==0) return 0;
return sum/double(NN);
}
@ -755,14 +755,14 @@ inline double jkqtpstatCorrelationCoefficient(InputIt1 first1, InputIt1 last1, I
}
if (Noutput) *Noutput=NN;
if (averageOut1) {
if (NN<=0) *averageOut1=JKQTP_DOUBLE_NAN;
if (NN==0) *averageOut1=JKQTP_DOUBLE_NAN;
else *averageOut1=xbar/static_cast<double>(NN);
}
if (averageOut2) {
if (NN<=0) *averageOut2=JKQTP_DOUBLE_NAN;
if (NN==0) *averageOut2=JKQTP_DOUBLE_NAN;
else *averageOut2=ybar/static_cast<double>(NN);
}
if (NN<=0) return JKQTP_DOUBLE_NAN;
if (NN==0) return JKQTP_DOUBLE_NAN;
xbar=xbar/NN;
ybar=ybar/NN;

View File

@ -2789,7 +2789,7 @@ class JKQTFASTPLOTTER_LIB_EXPORT JKQTFPRGBImageOverlayPlot: public JKQTFPPlot {
*/
JKQTFPRGBImageOverlayPlot(JKQTFastPlotter* parent, void* imageRed, JKQTFPImageFormat imageFormat, int width, int height, double xmin, double xmax, double ymin, double ymax) ;
JKQTFPRGBImageOverlayPlot(JKQTFastPlotter* parent, void* imageRed, JKQTFPImageFormat imageFormat, int width, int height);
JKQTFPRGBImageOverlayPlot(JKQTFastPlotter* parent);
explicit JKQTFPRGBImageOverlayPlot(JKQTFastPlotter* parent);
/** \brief draw the graph */
virtual void drawGraph(QPainter& painter) override;

View File

@ -380,78 +380,10 @@ bool JKQTPBarHorizontalErrorGraph::usesColumn(int c) const
bool JKQTPBarHorizontalErrorGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
{
if (xErrorColumn<0 || xErrorStyle==JKQTPNoError) {
minx=0;
maxx=0;
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
minx=getBaseline();
maxx=getBaseline();
}
if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
double yv=getBaseline();
if (JKQTPIsOKFloat(yv)) {
if (yv>maxx) maxx=yv;
if (yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxx) maxx=yv;
if (yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
}
return true;
}
return getMinMaxWithBaseline(xColumn, minx, maxx, smallestGreaterZero);
} else {
bool start=false;
minx=getBaseline();
maxx=getBaseline();
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
minx=getBaseline();
maxx=getBaseline();
}
if (parent==nullptr) return false;
const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
const double yv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
const double yvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
if (start || yv>maxx) maxx=yv;
if (start || yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (start || yvv>maxx) maxx=yvv;
if (start || yvv<minx) minx=yvv;
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
start=false;
}
}
return !start;
}
return getMinMaxWithErrorsAndBaseline(xColumn, xErrorColumn, xErrorColumnLower, xErrorSymmetric, minx, maxx, smallestGreaterZero);
}
return false;
}
void JKQTPBarHorizontalErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)
@ -534,78 +466,10 @@ bool JKQTPBarVerticalErrorGraph::usesColumn(int c) const
bool JKQTPBarVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
{
if (yErrorColumn<0 || yErrorStyle==JKQTPNoError) {
miny=0;
maxy=0;
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
miny=getBaseline();
maxy=getBaseline();
}
if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
double yv=getBaseline();
if (JKQTPIsOKFloat(yv)) {
if (yv>maxy) maxy=yv;
if (yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxy) maxy=yv;
if (yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
}
return true;
}
return getMinMaxWithBaseline(yColumn, miny, maxy, smallestGreaterZero);
} else {
bool start=false;
miny=getBaseline();
maxy=getBaseline();
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
miny=getBaseline();
maxy=getBaseline();
}
if (parent==nullptr) return false;
const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
const double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
if (start || yv>maxy) maxy=yv;
if (start || yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (start || yvv>maxy) maxy=yvv;
if (start || yvv<miny) miny=yvv;
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
start=false;
}
}
return !start;
}
return getMinMaxWithErrorsAndBaseline(yColumn, yErrorColumn, yErrorColumnLower, yErrorSymmetric, miny, maxy, smallestGreaterZero);
}
return false;
}
int JKQTPBarVerticalErrorGraph::getBarErrorColumn() const

View File

@ -25,8 +25,6 @@
#include <QDebug>
#include <iostream>
#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) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
@ -225,13 +223,7 @@ void JKQTPFilledCurveXGraph::draw(JKQTPEnhancedPainter& painter) {
bool JKQTPFilledCurveXGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
{
bool res=JKQTPXYGraph::getYMinMax(miny, maxy, smallestGreaterZero);
if (getBaseline()>0 && getBaseline()<smallestGreaterZero) {
smallestGreaterZero=getBaseline();
}
miny=qMin(miny,getBaseline());
maxy=qMax(maxy,getBaseline());
return res;
return getMinMaxWithBaseline(yColumn, miny,maxy,smallestGreaterZero);
}
JKQTPFilledCurveYGraph::JKQTPFilledCurveYGraph(JKQTBasePlotter* parent):
@ -247,13 +239,7 @@ JKQTPFilledCurveYGraph::JKQTPFilledCurveYGraph(JKQTPlotter *parent):
bool JKQTPFilledCurveYGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
{
bool res=JKQTPXYGraph::getXMinMax(minx, maxx, smallestGreaterZero);
if (getBaseline()>0 && getBaseline()<smallestGreaterZero) {
smallestGreaterZero=getBaseline();
}
minx=qMin(minx,getBaseline());
maxx=qMax(maxx,getBaseline());
return res;
return getMinMaxWithBaseline(xColumn, minx, maxx, smallestGreaterZero);
}
void JKQTPFilledCurveYGraph::draw(JKQTPEnhancedPainter &painter)
@ -406,78 +392,10 @@ void JKQTPFilledCurveXErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)
bool JKQTPFilledCurveXErrorGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
{
if (yErrorColumn<0 || yErrorStyle==JKQTPNoError) {
miny=0;
maxy=0;
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
miny=getBaseline();
maxy=getBaseline();
}
if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
double yv=getBaseline();
if (JKQTPIsOKFloat(yv)) {
if (yv>maxy) maxy=yv;
if (yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxy) maxy=yv;
if (yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
}
return true;
}
return getMinMaxWithBaseline(yColumn, miny, maxy, smallestGreaterZero);
} else {
bool start=false;
miny=getBaseline();
maxy=getBaseline();
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
miny=getBaseline();
maxy=getBaseline();
}
if (parent==nullptr) return false;
const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
const double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
if (start || yv>maxy) maxy=yv;
if (start || yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (start || yvv>maxy) maxy=yvv;
if (start || yvv<miny) miny=yvv;
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
start=false;
}
}
return !start;
}
return getMinMaxWithErrorsAndBaseline(yColumn, yErrorColumn, yErrorColumnLower, yErrorSymmetric, miny, maxy, smallestGreaterZero);
}
return false;
}
JKQTPFilledCurveYErrorGraph::JKQTPFilledCurveYErrorGraph(JKQTBasePlotter *parent):
@ -502,78 +420,10 @@ bool JKQTPFilledCurveYErrorGraph::usesColumn(int c) const
bool JKQTPFilledCurveYErrorGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
{
if (xErrorColumn<0 || xErrorStyle==JKQTPNoError) {
minx=0;
maxx=0;
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
minx=getBaseline();
maxx=getBaseline();
}
if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
double yv=getBaseline();
if (JKQTPIsOKFloat(yv)) {
if (yv>maxx) maxx=yv;
if (yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxx) maxx=yv;
if (yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
}
return true;
}
return getMinMaxWithBaseline(xColumn, minx, maxx, smallestGreaterZero);
} else {
bool start=false;
minx=getBaseline();
maxx=getBaseline();
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
minx=getBaseline();
maxx=getBaseline();
}
if (parent==nullptr) return false;
const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
const double yv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
const double yvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
if (start || yv>maxx) maxx=yv;
if (start || yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (start || yvv>maxx) maxx=yvv;
if (start || yvv<minx) minx=yvv;
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
start=false;
}
}
return !start;
}
return getMinMaxWithErrorsAndBaseline(xColumn, xErrorColumn, xErrorColumnLower, xErrorSymmetric, minx, maxx, smallestGreaterZero);
}
return false;
}
void JKQTPFilledCurveYErrorGraph::drawErrorsAfter(JKQTPEnhancedPainter &painter)

View File

@ -283,7 +283,6 @@ bool JKQTPImpulsesHorizontalGraph::getXMinMax(double &minx, double &maxx, double
bool JKQTPImpulsesHorizontalGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
{
return getPositionsMinMax(miny, maxy, smallestGreaterZero);
}
void JKQTPImpulsesHorizontalGraph::setKeyColumn(int __value)
@ -338,7 +337,6 @@ bool JKQTPImpulsesVerticalGraph::getXMinMax(double &minx, double &maxx, double &
bool JKQTPImpulsesVerticalGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
{
return getValuesMinMax(miny, maxy, smallestGreaterZero);
}
void JKQTPImpulsesVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
@ -439,53 +437,12 @@ bool JKQTPImpulsesHorizontalErrorGraph::usesColumn(int c) const
bool JKQTPImpulsesHorizontalErrorGraph::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
{
if (xErrorColumn>=0 && xErrorStyle!=JKQTPNoError) {
minx=0;
maxx=0;
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
minx=getBaseline();
maxx=getBaseline();
}
if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
double yv=getBaseline();
if (JKQTPIsOKFloat(yv)) {
if (yv>maxx) maxx=yv;
if (yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+datastore->get(static_cast<size_t>(xErrorColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxx) maxx=yv;
if (yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-datastore->get(static_cast<size_t>(xErrorColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxx) maxx=yv;
if (yv<minx) minx=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
}
return true;
}
if (xErrorColumn<0 || xErrorStyle==JKQTPNoError) {
return getMinMaxWithBaseline(xColumn, minx, maxx, smallestGreaterZero);
} else {
return JKQTPImpulsesHorizontalGraph::getXMinMax(minx,maxx,smallestGreaterZero);
return getMinMaxWithErrorsAndBaseline(xColumn, xErrorColumn, xErrorColumnLower, xErrorSymmetric, minx, maxx, smallestGreaterZero);
}
return false;
}
int JKQTPImpulsesHorizontalErrorGraph::getErrorColumn() const
@ -614,60 +571,11 @@ bool JKQTPImpulsesVerticalErrorGraph::usesColumn(int c) const
bool JKQTPImpulsesVerticalErrorGraph::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
{
if (yErrorColumn>=0 && yErrorStyle!=JKQTPNoError) {
miny=0;
maxy=0;
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
miny=getBaseline();
maxy=getBaseline();
}
if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
double yv=getBaseline();
if (JKQTPIsOKFloat(yv)) {
if (yv>maxy) maxy=yv;
if (yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxy) maxy=yv;
if (yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+datastore->get(static_cast<size_t>(yErrorColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxy) maxy=yv;
if (yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-datastore->get(static_cast<size_t>(yErrorColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxy) maxy=yv;
if (yv<miny) miny=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
}
return true;
}
if (yErrorColumn<0 || yErrorStyle==JKQTPNoError) {
return getMinMaxWithBaseline(yColumn, miny, maxy, smallestGreaterZero);
} else {
return JKQTPImpulsesVerticalGraph::getYMinMax(miny,maxy,smallestGreaterZero);
return getMinMaxWithErrorsAndBaseline(yColumn, yErrorColumn, yErrorColumnLower, yErrorSymmetric, miny, maxy, smallestGreaterZero);
}
return false;
}

View File

@ -89,7 +89,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxisStyle {
public:
JKQTPCoordinateAxisStyle();
JKQTPCoordinateAxisStyle(const JKQTBasePlotterStyle& baseStyle);
explicit JKQTPCoordinateAxisStyle(const JKQTBasePlotterStyle& baseStyle);
/** \brief loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object
@ -250,7 +250,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPColorbarCoordinateAxisStyle: public JKQTPCoord
JKQTPColorbarCoordinateAxisStyle();
/** \copydoc JKQTPCoordinateAxisStyle::JKQTPCoordinateAxisStyle(const JKQTBasePlotterStyle&) */
JKQTPColorbarCoordinateAxisStyle(const JKQTBasePlotterStyle& baseStyle);
explicit JKQTPColorbarCoordinateAxisStyle(const JKQTBasePlotterStyle& baseStyle);
private:
/** \brief modifies the members to match the requirements of colorbar axes */
void initMembersForColorbars();

View File

@ -1034,6 +1034,106 @@ void JKQTPXYBaselineGraph::setBaseline(double __value)
m_baseline=__value;
}
bool JKQTPXYBaselineGraph::getMinMaxWithBaseline(int dataColumn, double &minv, double &maxv, double &smallestGreaterZero)
{
minv=0;
maxv=0;
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
minv=getBaseline();
maxv=getBaseline();
}
if (parent==nullptr) return false;
JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
double yv=getBaseline();
if (JKQTPIsOKFloat(yv)) {
if (yv>maxv) maxv=yv;
if (yv<minv) minv=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
yv=datastore->get(static_cast<size_t>(dataColumn),static_cast<size_t>(i));
if (JKQTPIsOKFloat(yv)) {
if (yv>maxv) maxv=yv;
if (yv<minv) minv=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
}
}
return true;
}
return false;
}
bool JKQTPXYBaselineGraph::getMinMaxWithErrorsAndBaseline(int dataColumn, int errorColumn, int errorColumnLower, bool errorSymmetric, double &minv, double &maxv, double &smallestGreaterZero)
{
bool start=false;
minv=getBaseline();
maxv=getBaseline();
smallestGreaterZero=0;
if (getBaseline()>0) {
smallestGreaterZero=getBaseline();
minv=getBaseline();
maxv=getBaseline();
}
if (parent==nullptr) return false;
const JKQTPDatastore* datastore=parent->getDatastore();
int imax=0;
int imin=0;
if (getIndexRange(imin, imax)) {
for (int i=imin; i<imax; i++) {
const double yv=datastore->get(static_cast<size_t>(dataColumn),static_cast<size_t>(i))+getErrorU(i, datastore, errorColumn);
const double yvv=datastore->get(static_cast<size_t>(dataColumn),static_cast<size_t>(i))-getErrorL(i, datastore, errorColumn, errorColumnLower, errorSymmetric);
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
if (start || yv>maxv) maxv=yv;
if (start || yv<minv) minv=yv;
double xvsgz;
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
if (start || yvv>maxv) maxv=yvv;
if (start || yvv<minv) minv=yvv;
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
start=false;
}
}
return !start;
}
return false;
}
double JKQTPXYBaselineGraph::getErrorU(int i, const JKQTPDatastore *ds, int xErrorColumn) const
{
if (ds && xErrorColumn>=0 && i>=0 && i<static_cast<int>(ds->getRows(xErrorColumn))) {
return ds->get(xErrorColumn, static_cast<size_t>(i));
}
return 0.0;
}
double JKQTPXYBaselineGraph::getErrorL(int i, const JKQTPDatastore *ds, int xErrorColumn, int xErrorColumnLower, bool xErrorSymmetric) const
{
if (ds) {
if (xErrorSymmetric) {
if (xErrorColumn>=0 && i>=0 && i<static_cast<int>(ds->getRows(xErrorColumn))) return ds->get(xErrorColumn, static_cast<size_t>(i));
} else {
if (xErrorColumnLower>=0 && i>=0 && i<static_cast<int>(ds->getRows(xErrorColumnLower))) return ds->get(xErrorColumnLower, static_cast<size_t>(i));
}
}
return 0.0;
}
JKQTPPlotAnnotationElement::JKQTPPlotAnnotationElement(JKQTBasePlotter *parent):
JKQTPPlotElement(parent)
{

View File

@ -688,12 +688,24 @@ public slots:
void setBaseline(double __value);
protected:
/** \brief can be called by JKQTPGraph::getXMinMax() or JKQTPGraph::getYMinMax() calculates min/max/... for data from the given column, including the baseline */
bool getMinMaxWithBaseline(int dataColumn, double &minv, double &maxv, double &smallestGreaterZero);
/** \brief can be called by JKQTPGraph::getXMinMax() or JKQTPGraph::getYMinMax() calculates min/max/... for data from the given column, including the baseline and an optional error */
bool getMinMaxWithErrorsAndBaseline(int dataColumn, int errorColumn, int errorColumnLower, bool errorSymmetric, double &minv, double &maxv, double &smallestGreaterZero);
/** \brief baseline of the plot (NOTE: 0 is interpreted as until plot border in log-mode!!!)
*
* \image html impulsesplot_baseline.png
*/
double m_baseline;
private:
/** \brief returns the upper error for the i-th datapoint, read from datastore \a ds */
double getErrorU(int i, const JKQTPDatastore* ds, int xErrorColumn) const;
/** \brief returns the lower error for the i-th datapoint, read from datastore \a ds */
double getErrorL(int i, const JKQTPDatastore *ds, int xErrorColumn, int xErrorColumnLower, bool xErrorSymmetric) const;
};

View File

@ -121,7 +121,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTGeometricSpecificStyleProperties: public JKQTGr
Q_GADGET
#endif
public:
JKQTGeometricSpecificStyleProperties(const JKQTBasePlotterStyle& parent);
explicit JKQTGeometricSpecificStyleProperties(const JKQTBasePlotterStyle& parent);
JKQTGeometricSpecificStyleProperties(const JKQTBasePlotterStyle& parent, const JKQTGraphsSpecificStyleProperties& other);
JKQTGeometricSpecificStyleProperties(JKQTPPlotStyleType type, const JKQTBasePlotterStyle& parent);
JKQTGeometricSpecificStyleProperties(JKQTPPlotStyleType type, const JKQTGraphsSpecificStyleProperties& other, const JKQTBasePlotterStyle &parent);
@ -171,7 +171,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTAnnotationsSpecificStyleProperties: public JKQT
Q_GADGET
#endif
public:
JKQTAnnotationsSpecificStyleProperties(const JKQTBasePlotterStyle& parent);
explicit JKQTAnnotationsSpecificStyleProperties(const JKQTBasePlotterStyle& parent);
JKQTAnnotationsSpecificStyleProperties(const JKQTBasePlotterStyle& parent, const JKQTGraphsSpecificStyleProperties& other);
JKQTAnnotationsSpecificStyleProperties(const JKQTAnnotationsSpecificStyleProperties& other)=default;
JKQTAnnotationsSpecificStyleProperties(JKQTAnnotationsSpecificStyleProperties&& other)=default;
@ -216,7 +216,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBarchartSpecificStyleProperties: public JKQTGra
Q_GADGET
#endif
public:
JKQTBarchartSpecificStyleProperties(const JKQTBasePlotterStyle& parent);
explicit JKQTBarchartSpecificStyleProperties(const JKQTBasePlotterStyle& parent);
JKQTBarchartSpecificStyleProperties(const JKQTBasePlotterStyle& parent, const JKQTGraphsSpecificStyleProperties& other);
JKQTBarchartSpecificStyleProperties(const JKQTBarchartSpecificStyleProperties& other)=default;
JKQTBarchartSpecificStyleProperties(JKQTBarchartSpecificStyleProperties&& other)=default;
@ -262,7 +262,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTImpulseSpecificStyleProperties: public JKQTGrap
Q_GADGET
#endif
public:
JKQTImpulseSpecificStyleProperties(const JKQTBasePlotterStyle& parent);
explicit JKQTImpulseSpecificStyleProperties(const JKQTBasePlotterStyle& parent);
JKQTImpulseSpecificStyleProperties(const JKQTBasePlotterStyle& parent, const JKQTGraphsSpecificStyleProperties& other);
JKQTImpulseSpecificStyleProperties(const JKQTImpulseSpecificStyleProperties& other)=default;
JKQTImpulseSpecificStyleProperties(JKQTImpulseSpecificStyleProperties&& other)=default;
@ -301,7 +301,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTGraphsBaseStyle {
Q_GADGET
#endif
public:
JKQTGraphsBaseStyle(const JKQTBasePlotterStyle& parent);
explicit JKQTGraphsBaseStyle(const JKQTBasePlotterStyle& parent);

View File

@ -40,7 +40,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPKeyStyle {
Q_GADGET
public:
JKQTPKeyStyle();
JKQTPKeyStyle(const JKQTBasePlotterStyle& baseStyle);
explicit JKQTPKeyStyle(const JKQTBasePlotterStyle& baseStyle);
/** \brief loads the plot properties from a <a href="http://doc.qt.io/qt-5/qsettings.html")">QSettings</a> object

View File

@ -653,7 +653,6 @@ void JKQTPlotter::paintUserAction() {
QVector<QString> txts;
QVector<QColor> colors;
const int txtoffset=4;
QString txt;
double ascent=0,descent=0,strikeout=0,width=0;
getPlotter()->getMathText()->setFontSize(plotterStyle.userActionFontSize);
getPlotter()->getMathText()->setFontSpecial(plotterStyle.userActionFontName);
@ -1373,7 +1372,7 @@ void JKQTPlotter::synchronizeToMaster(JKQTPlotter *master, JKQTBasePlotter::Sync
if (masterPlotterX) disconnect(masterPlotterX->getPlotter(), SIGNAL(plotScalingRecalculated()), this, SLOT(masterPlotScalingRecalculated()));
if (masterPlotterY) disconnect(masterPlotterY->getPlotter(), SIGNAL(plotScalingRecalculated()), this, SLOT(masterPlotScalingRecalculated()));
plotter->synchronizeToMaster(master->getPlotter(), synchronizeDirection, synchronizeAxisLength, synchronizeZoomingMasterToSlave, synchronizeZoomingSlaveToMaster);
if (master) plotter->synchronizeToMaster(master->getPlotter(), synchronizeDirection, synchronizeAxisLength, synchronizeZoomingMasterToSlave, synchronizeZoomingSlaveToMaster);
if (synchronizeDirection==JKQTBasePlotter::sdXAxis || synchronizeDirection==JKQTBasePlotter::sdXYAxes) {
masterPlotterX=master;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB