mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2025-01-12 00:40:32 +08:00
- bugfix: improved handling of DRAGZOOM-UserAction for log-log plots
- code (style) improvements
This commit is contained in:
parent
f77bc97ca5
commit
95d885bc2c
@ -103,9 +103,7 @@ QVector<QPolygonF> JKQTPUnifyLinesToPolygons(const QVector<QLineF> &lines, doubl
|
||||
}
|
||||
//return res.toVector();
|
||||
// clean the resulting polygon
|
||||
for (QPolygonF& p: res) {
|
||||
p=JKQTPCleanPolygon(p, distanceThreshold);
|
||||
}
|
||||
std::transform(res.begin(), res.end(), res.begin(), std::bind(&JKQTPCleanPolygon, std::placeholders::_1, distanceThreshold));
|
||||
|
||||
int maxIterations=100;
|
||||
int iter=0;
|
||||
@ -266,7 +264,7 @@ QVector<QPointF> JKQTPAdaptiveFunctionGraphEvaluator::evaluate(double tmin, doub
|
||||
for (double t=tmin+delta_t0; t<tmax; t=t+delta_t0) {
|
||||
const double treal=t;
|
||||
intData.insert_after(a, std::pair<double, QPointF>(treal, fxy(treal)));
|
||||
InternalList::iterator b=a; b++;
|
||||
InternalList::iterator b=a; ++b;
|
||||
//qDebug()<<"t="<<t<<", dist(a,b)="<<std::distance(a,b);
|
||||
refine(intData, a, b, 0);
|
||||
//qDebug()<<" after refine: dist(a,b)="<<std::distance(a,b);
|
||||
@ -299,7 +297,7 @@ void JKQTPAdaptiveFunctionGraphEvaluator::refine(JKQTPAdaptiveFunctionGraphEvalu
|
||||
const double slope_mid_b=(pb.y()-pmid.y())/(pb.x()-pmid.x());
|
||||
if (fabs(slope_mid_b-slope_a_mid)>slopeTolerance || delta>minPixelPerSample) {
|
||||
intData.insert_after(a, std::pair<double, QPointF>(tmid, pmid));
|
||||
InternalList::iterator abmid=a; abmid++;
|
||||
InternalList::iterator abmid=a; ++abmid;
|
||||
refine(intData, a, abmid, degree+1);
|
||||
refine(intData, abmid, b, degree+1);
|
||||
}
|
||||
@ -324,9 +322,7 @@ QVector<QPointF> JKQTPSplitPolylineIntoPoints(const QVector<QPointF> &line, std:
|
||||
for (int i=1; i<line.size(); i++) {
|
||||
const QVector<QPointF> ps=JKQTPSplitLineIntoPoints(QLineF(line[i-1], line[i]), fTransform);
|
||||
result.reserve(result.size()+ps.size());
|
||||
for (auto& p: ps) {
|
||||
if (result.size()==0 || result.last()!=p) result.push_back(p);
|
||||
}
|
||||
std::copy_if(ps.begin(), ps.end(), std::back_inserter(result), [&](const QPointF&p) { return result.size()==0 || result.last()!=p; });
|
||||
//qDebug()<<"line: "<<QLineF(line[i-1], line[i])<<" --> ps.size()="<<ps.size()<<", result.size()="<<result.size();
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ class JKQTFASTPLOTTER_LIB_EXPORT JKQTFastPlotter : public QGLWidget {
|
||||
/** \brief return x-pixel coordinate from x coordinate */
|
||||
inline double x2p(double x) {
|
||||
if (xAxisLog) {
|
||||
if (x<0) return xOffset+log(xMin/10.0)/JKQTPSTATISTICS_LN10*xScale;
|
||||
if (x<=0) return xOffset+log(xMin/10.0)/JKQTPSTATISTICS_LN10*xScale;
|
||||
return xOffset+log(x)/JKQTPSTATISTICS_LN10*xScale;
|
||||
} else {
|
||||
return xOffset+x*xScale;
|
||||
@ -416,7 +416,7 @@ class JKQTFASTPLOTTER_LIB_EXPORT JKQTFastPlotter : public QGLWidget {
|
||||
/** \brief return y-pixel coordinate from y coordinate */
|
||||
inline double y2p(double y) {
|
||||
if (yAxisLog) {
|
||||
if (y<0) return yOffset-log(yMin/10.0)/JKQTPSTATISTICS_LN10*yScale;
|
||||
if (y<=0) return yOffset-log(yMin/10.0)/JKQTPSTATISTICS_LN10*yScale;
|
||||
return yOffset-log(y)/JKQTPSTATISTICS_LN10*yScale;
|
||||
} else {
|
||||
return yOffset-y*yScale;
|
||||
|
@ -342,13 +342,13 @@ void JKQTPBarHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
if (parent->getXAxis()->isLogAxis()) x0=transformX(parent->getXAxis()->getMin());
|
||||
// double y0=transformY(0);
|
||||
// if (parent->getYAxis()->isLogAxis()) y0=transformY(parent->getYAxis()->getMin());
|
||||
double delta=1;
|
||||
double deltap=0;
|
||||
double deltam=0;
|
||||
{
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
intSortData();
|
||||
const bool hasStackPar=hasStackParent();
|
||||
double delta=1;
|
||||
double deltap=0;
|
||||
double deltam=0;
|
||||
for (int iii=imin; iii<imax; iii++) {
|
||||
int i=qBound(imin, getDataIndex(iii), imax);
|
||||
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
|
||||
@ -625,8 +625,8 @@ bool JKQTPBarHorizontalErrorGraph::getXMinMax(double &minx, double &maxx, double
|
||||
if (start || xv<minx) minx=xv;
|
||||
xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
if (start || xvv>maxx) maxx=xvv;
|
||||
if (start || xvv<minx) minx=xvv;
|
||||
if (xvv>maxx) maxx=xvv;
|
||||
if (xvv<minx) minx=xvv;
|
||||
xvsgz=xvv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
}
|
||||
|
@ -119,13 +119,13 @@ void JKQTPContourPlot::draw(JKQTPEnhancedPainter &painter)
|
||||
// transform into plot coordinates
|
||||
for(auto polygon =contourLinesCache.at(i).begin(); polygon!=contourLinesCache.at(i).end();++polygon ) {
|
||||
contourLinesTransformedSingleLevel.push_back(QPolygonF());
|
||||
for (auto& p: *polygon) {
|
||||
contourLinesTransformedSingleLevel.last().append(transform(x+p.x()/double(Nx-1)*width, y+p.y()/double(Ny-1)*height));
|
||||
for (auto& poly: *polygon) {
|
||||
contourLinesTransformedSingleLevel.last().append(transform(x+poly.x()/double(Nx-1)*width, y+poly.y()/double(Ny-1)*height));
|
||||
}
|
||||
//qDebug()<<lineTranformed;
|
||||
}
|
||||
for (const QPolygonF& p: contourLinesTransformedSingleLevel) {
|
||||
painter.drawPolyline(p);
|
||||
for (const QPolygonF& poly: contourLinesTransformedSingleLevel) {
|
||||
painter.drawPolyline(poly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void JKQTPEvaluatedFunctionWithErrorsGraphDrawingBase::drawKeyMarker(JKQTPEnhanc
|
||||
if (drawLine) painter.setPen(p);
|
||||
painter.setBrush(b);
|
||||
if (fillCurve) painter.drawRect(rect);
|
||||
if (!fillCurve & drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
||||
if (!fillCurve && drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,21 +33,33 @@
|
||||
|
||||
|
||||
|
||||
JKQTPXYFunctionLineGraphBase::JKQTPXYFunctionLineGraphBase(JKQTBasePlotter* parent):
|
||||
JKQTPXYFunctionLineGraphBase::JKQTPXYFunctionLineGraphBase(double tmin_, double tmax_, JKQTBasePlotter *parent):
|
||||
JKQTPEvaluatedFunctionGraphBase(parent),
|
||||
tmin(0.0),
|
||||
tmax(1.0)
|
||||
tmin(tmin_),
|
||||
tmax(tmax_)
|
||||
{
|
||||
initLineStyle(parent, parentPlotStyle);
|
||||
setMaxRefinementDegree(8);
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraphBase::JKQTPXYFunctionLineGraphBase(double tmin_, double tmax_, JKQTPlotter *parent):
|
||||
JKQTPXYFunctionLineGraphBase(tmin_,tmax_,parent->getPlotter())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraphBase::JKQTPXYFunctionLineGraphBase(JKQTBasePlotter* parent):
|
||||
JKQTPXYFunctionLineGraphBase(0,1,parent)
|
||||
{
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraphBase::JKQTPXYFunctionLineGraphBase(JKQTPlotter* parent):
|
||||
JKQTPXYFunctionLineGraphBase(parent->getPlotter())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
JKQTPXYFunctionLineGraphBase::~JKQTPXYFunctionLineGraphBase()
|
||||
{
|
||||
|
||||
@ -161,13 +173,9 @@ JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(JKQTPlotter* parent):
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(const jkqtpSimpleParametricCurveFunctionType &f, const QString &title_, double tmin_, double tmax_, JKQTBasePlotter *parent):
|
||||
JKQTPXYFunctionLineGraph(parent)
|
||||
JKQTPXYFunctionLineGraphBase(tmin_, tmax_, parent), plotFunction(), simplePlotFunction(f)
|
||||
{
|
||||
tmin=tmin_;
|
||||
tmax=tmax_;
|
||||
setTitle(title_);
|
||||
plotFunction=jkqtpParametricCurveFunctionType();
|
||||
simplePlotFunction=f;
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(const jkqtpSimpleParametricCurveFunctionType &f, const QString &title_, double tmin_, double tmax_, JKQTPlotter *parent):
|
||||
@ -178,14 +186,9 @@ JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(const jkqtpSimpleParametricCu
|
||||
|
||||
|
||||
JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(jkqtpSimpleParametricCurveFunctionType &&f, const QString &title_, double tmin_, double tmax_, JKQTBasePlotter *parent):
|
||||
JKQTPXYFunctionLineGraph(parent)
|
||||
JKQTPXYFunctionLineGraphBase(tmin_, tmax_, parent), plotFunction(), simplePlotFunction(std::move(f))
|
||||
{
|
||||
tmin=tmin_;
|
||||
tmax=tmax_;
|
||||
setTitle(title_);
|
||||
plotFunction=jkqtpParametricCurveFunctionType();
|
||||
simplePlotFunction=std::move(f);
|
||||
data.clear();
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(jkqtpSimpleParametricCurveFunctionType &&f, const QString &title_, double tmin_, double tmax_, JKQTPlotter *parent):
|
||||
@ -195,14 +198,9 @@ JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(jkqtpSimpleParametricCurveFun
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(jkqtpParametricCurveFunctionType &&f, const QString &title_, double tmin_, double tmax_, JKQTBasePlotter *parent):
|
||||
JKQTPXYFunctionLineGraph(parent)
|
||||
JKQTPXYFunctionLineGraphBase(tmin_, tmax_, parent), plotFunction(std::move(f)), simplePlotFunction()
|
||||
{
|
||||
tmin=tmin_;
|
||||
tmax=tmax_;
|
||||
setTitle(title_);
|
||||
simplePlotFunction=jkqtpSimpleParametricCurveFunctionType();
|
||||
plotFunction=std::move(f);
|
||||
data.clear();
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(jkqtpParametricCurveFunctionType &&f, const QString &title_, double tmin_, double tmax_, JKQTPlotter *parent):
|
||||
@ -212,14 +210,9 @@ JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(jkqtpParametricCurveFunctionT
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(const jkqtpParametricCurveFunctionType &f, const QString &title_, double tmin_, double tmax_, JKQTBasePlotter *parent):
|
||||
JKQTPXYFunctionLineGraph(parent)
|
||||
JKQTPXYFunctionLineGraphBase(tmin_, tmax_, parent), plotFunction(f), simplePlotFunction()
|
||||
{
|
||||
tmin=tmin_;
|
||||
tmax=tmax_;
|
||||
setTitle(title_);
|
||||
simplePlotFunction=jkqtpSimpleParametricCurveFunctionType();
|
||||
plotFunction=std::move(f);
|
||||
data.clear();
|
||||
}
|
||||
|
||||
JKQTPXYFunctionLineGraph::JKQTPXYFunctionLineGraph(const jkqtpParametricCurveFunctionType &f, const QString &title_, double tmin_, double tmax_, JKQTPlotter *parent):
|
||||
|
@ -61,6 +61,13 @@ public:
|
||||
/** \brief class constructor */
|
||||
JKQTPXYFunctionLineGraphBase(JKQTPlotter* parent);
|
||||
|
||||
|
||||
/** \brief class constructor */
|
||||
JKQTPXYFunctionLineGraphBase(double tmin_, double tmax_, JKQTBasePlotter* parent);
|
||||
|
||||
/** \brief class constructor */
|
||||
JKQTPXYFunctionLineGraphBase(double tmin_, double tmax_, JKQTPlotter* parent);
|
||||
|
||||
/** \brief class destructor */
|
||||
virtual ~JKQTPXYFunctionLineGraphBase() override;
|
||||
|
||||
|
@ -190,22 +190,22 @@ void JKQTPRGBMathImage::getOutsideSize(JKQTPEnhancedPainter& painter, int& leftS
|
||||
getDataMinMax(internalDataMin, internalDataMax);
|
||||
if (data) {
|
||||
if (colorBarRightVisible) {
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
if (!colorbarsSideBySide || !firstC) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
colorBarRightAxis->setRange(internalDataMin, internalDataMax);
|
||||
colorBarRightAxis->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight());
|
||||
colorBarRightAxisB->setAxisLabel(imageNameR);
|
||||
QSizeF s2=colorBarRightAxis->getSize2(painter);
|
||||
QSizeF s1=colorBarRightAxis->getSize1(painter);
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.width()+s1.width());
|
||||
if (!colorbarsSideBySide || !firstC) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.width()+s1.width());
|
||||
}
|
||||
if (colorBarTopVisible) {
|
||||
//if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
//if (!colorbarsSideBySide || !firstC) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
colorBarTopAxis->setRange(internalDataMin, internalDataMax);
|
||||
colorBarTopAxis->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth());
|
||||
colorBarTopAxisB->setAxisLabel(imageNameR);
|
||||
QSizeF s2=colorBarTopAxisB->getSize2(painter);
|
||||
QSizeF s1=colorBarTopAxisB->getSize2(painter);
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.height()+s1.height());
|
||||
if (!colorbarsSideBySide || !firstC) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.height()+s1.height());
|
||||
}
|
||||
firstC=true;
|
||||
}
|
||||
@ -213,22 +213,22 @@ void JKQTPRGBMathImage::getOutsideSize(JKQTPEnhancedPainter& painter, int& leftS
|
||||
getDataMinMaxG(internalDataMinG, internalDataMaxG);
|
||||
if (dataG) {
|
||||
if (colorBarRightVisible) {
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
if (!colorbarsSideBySide || !firstC) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
colorBarRightAxisG->setRange(internalDataMinG, internalDataMaxG);
|
||||
colorBarRightAxisG->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight());
|
||||
colorBarRightAxisB->setAxisLabel(imageNameG);
|
||||
QSizeF s2=colorBarRightAxis->getSize2(painter);
|
||||
QSizeF s1=colorBarRightAxis->getSize1(painter);
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.width()+s1.width());
|
||||
if (!colorbarsSideBySide || !firstC) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.width()+s1.width());
|
||||
}
|
||||
if (colorBarTopVisible) {
|
||||
//if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
//if (!colorbarsSideBySide || !firstC) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
colorBarTopAxisG->setRange(internalDataMinG, internalDataMaxG);
|
||||
colorBarTopAxisG->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth());
|
||||
colorBarTopAxisB->setAxisLabel(imageNameG);
|
||||
QSizeF s2=colorBarTopAxisB->getSize2(painter);
|
||||
QSizeF s1=colorBarTopAxisB->getSize1(painter);
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.height()+s1.height());
|
||||
if (!colorbarsSideBySide || !firstC) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.height()+s1.height());
|
||||
}
|
||||
firstC=true;
|
||||
}
|
||||
@ -236,22 +236,22 @@ void JKQTPRGBMathImage::getOutsideSize(JKQTPEnhancedPainter& painter, int& leftS
|
||||
getDataMinMaxB(internalDataMinB, internalDataMaxB);
|
||||
if (dataB) {
|
||||
if (colorBarRightVisible) {
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
if (!colorbarsSideBySide || !firstC) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
colorBarRightAxisB->setRange(internalDataMinB, internalDataMaxB);
|
||||
colorBarRightAxisB->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotHeight());
|
||||
colorBarRightAxisB->setAxisLabel(imageNameB);
|
||||
QSizeF s2=colorBarRightAxis->getSize2(painter);
|
||||
QSizeF s1=colorBarRightAxis->getSize1(painter);
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.width()+s1.width());
|
||||
if (!colorbarsSideBySide || !firstC) rightSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.width()+s1.width());
|
||||
}
|
||||
if (colorBarTopVisible) {
|
||||
//if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
//if (!colorbarsSideBySide || !firstC) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset);
|
||||
colorBarTopAxisB->setRange(internalDataMinB, internalDataMaxB);
|
||||
colorBarTopAxisB->setAxisWidth(sizeFactor*colorBarRelativeHeight*parent->getPlotWidth());
|
||||
colorBarTopAxisB->setAxisLabel(imageNameB);
|
||||
QSizeF s2=colorBarTopAxisB->getSize2(painter);
|
||||
QSizeF s1=colorBarTopAxisB->getSize1(painter);
|
||||
if (!colorbarsSideBySide || (colorbarsSideBySide && !firstC)) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.height()+s1.height());
|
||||
if (!colorbarsSideBySide || !firstC) topSpace+=parent->pt2px(painter, colorBarWidth+colorBarOffset)+static_cast<double>(s2.height()+s1.height());
|
||||
}
|
||||
firstC=true;
|
||||
}
|
||||
|
@ -89,11 +89,6 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<3<<" imin="<<imin<<" imax="<<imax;
|
||||
//double xold=-1;
|
||||
//double yold=-1;
|
||||
//bool first=false;
|
||||
//QVector<QLineF> lines;
|
||||
std::vector<QPolygonF> vec_linesP;
|
||||
vec_linesP.push_back(QPolygonF());
|
||||
intSortData();
|
||||
@ -223,17 +218,18 @@ bool JKQTPXYLineErrorGraph::getXMinMax(double &minx, double &maxx, double &small
|
||||
if (imax<0) imax=0;
|
||||
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double xvsgz;
|
||||
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
|
||||
if (JKQTPIsOKFloat(xv)) {
|
||||
if (start || xv>maxx) maxx=xv;
|
||||
if (start || xv<minx) minx=xv;
|
||||
xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
|
||||
const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
|
||||
}
|
||||
xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
|
||||
if (JKQTPIsOKFloat(xv)) {
|
||||
if (start || xv>maxx) maxx=xv;
|
||||
if (start || xv<minx) minx=xv;
|
||||
xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
|
||||
const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
}
|
||||
}
|
||||
@ -269,13 +265,14 @@ bool JKQTPXYLineErrorGraph::getYMinMax(double &miny, double &maxy, double &small
|
||||
if (JKQTPIsOKFloat(yv)) {
|
||||
if (start || yv>maxy) maxy=yv;
|
||||
if (start || yv<miny) miny=yv;
|
||||
double xvsgz;
|
||||
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||
const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
|
||||
}
|
||||
yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
|
||||
if (JKQTPIsOKFloat(yv)) {
|
||||
if (start || yv>maxy) maxy=yv;
|
||||
if (start || yv<miny) miny=yv;
|
||||
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||
const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
}
|
||||
}
|
||||
@ -378,20 +375,21 @@ void JKQTPXYParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
|
||||
if (imin<0) imin=0;
|
||||
if (imax<0) imax=0;
|
||||
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<3<<" imin="<<imin<<" imax="<<imax;
|
||||
double xold=-1;
|
||||
double yold=-1;
|
||||
bool first=false;
|
||||
QVector<QLineF> lines;
|
||||
QPolygonF linesP;
|
||||
QVector<QColor> linecols;
|
||||
QVector<QColor> linecolss;
|
||||
QVector<double> linewidths;
|
||||
intSortData();
|
||||
double specSymbSize=0;
|
||||
bool hasSpecSymbSize=false;
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<3<<" imin="<<imin<<" imax="<<imax;
|
||||
{
|
||||
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
|
||||
double xold=-1;
|
||||
double yold=-1;
|
||||
bool first=false;
|
||||
|
||||
intSortData();
|
||||
double specSymbSize=0;
|
||||
bool hasSpecSymbSize=false;
|
||||
for (int iii=imin; iii<imax; iii++) {
|
||||
int i=qBound(imin, getDataIndex(iii), imax);
|
||||
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i));
|
||||
@ -912,17 +910,18 @@ bool JKQTPXYParametrizedErrorScatterGraph::getXMinMax(double &minx, double &maxx
|
||||
if (imax<0) imax=0;
|
||||
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double xvsgz;
|
||||
double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
|
||||
double xvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
|
||||
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(xvv) ) {
|
||||
const double xv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))+getXErrorU(i, datastore);
|
||||
if (JKQTPIsOKFloat(xv) ) {
|
||||
if (start || xv>maxx) maxx=xv;
|
||||
if (start || xv<minx) minx=xv;
|
||||
xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
|
||||
const double xvsgz=xv; SmallestGreaterZeroCompare_xvsgz();
|
||||
}
|
||||
const double xvv=datastore->get(static_cast<size_t>(xColumn),static_cast<size_t>(i))-getXErrorL(i, datastore);
|
||||
if (JKQTPIsOKFloat(xvv)) {
|
||||
start=false;
|
||||
if (start || xvv>maxx) maxx=xvv;
|
||||
if (start || xvv<minx) minx=xvv;
|
||||
xvsgz=xvv; SmallestGreaterZeroCompare_xvsgz();
|
||||
const double xvsgz=xvv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
}
|
||||
}
|
||||
@ -955,17 +954,18 @@ bool JKQTPXYParametrizedErrorScatterGraph::getYMinMax(double &miny, double &maxy
|
||||
if (imax<0) imax=0;
|
||||
|
||||
for (int i=imin; i<imax; i++) {
|
||||
double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
|
||||
double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
|
||||
if (JKQTPIsOKFloat(yv) && JKQTPIsOKFloat(yvv) ) {
|
||||
const double yv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))+getYErrorU(i, datastore);
|
||||
if (JKQTPIsOKFloat(yv)) {
|
||||
if (start || yv>maxy) maxy=yv;
|
||||
if (start || yv<miny) miny=yv;
|
||||
double xvsgz;
|
||||
xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||
const double xvsgz=yv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
}
|
||||
const double yvv=datastore->get(static_cast<size_t>(yColumn),static_cast<size_t>(i))-getYErrorL(i, datastore);
|
||||
if (JKQTPIsOKFloat(yvv) ) {
|
||||
if (start || yvv>maxy) maxy=yvv;
|
||||
if (start || yvv<miny) miny=yvv;
|
||||
xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
|
||||
const double xvsgz=yvv; SmallestGreaterZeroCompare_xvsgz();
|
||||
start=false;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPXYLineGraph: public JKQTPXYGraph, public JKQTP
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** \brief class constructor */
|
||||
JKQTPXYLineGraph(JKQTBasePlotter* parent=nullptr);
|
||||
explicit JKQTPXYLineGraph(JKQTBasePlotter* parent=nullptr);
|
||||
/** \brief class constructor */
|
||||
JKQTPXYLineGraph(JKQTPlotter* parent);
|
||||
|
||||
|
@ -68,7 +68,7 @@ void JKQTPSpecialLineHorizontalGraph::drawKeyMarker(JKQTPEnhancedPainter& painte
|
||||
if (m_drawLine) painter.setPen(p);
|
||||
painter.setBrush(b);
|
||||
if (m_fillCurve) painter.drawRect(rect);
|
||||
if (!m_fillCurve & m_drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
||||
if (!m_fillCurve && m_drawLine) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
||||
if (m_drawSymbols) {
|
||||
plotStyledSymbol(parent, painter, rect.center().x(), rect.center().y(), rect.width()*0.5);
|
||||
}
|
||||
@ -308,8 +308,8 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
if (m_drawSymbols) {
|
||||
painter.save();
|
||||
auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();});
|
||||
for (auto& p: ps) {
|
||||
plotStyledSymbol(parent, painter, p.x(), p.y());
|
||||
for (auto& ppoint: ps) {
|
||||
plotStyledSymbol(parent, painter, ppoint.x(), ppoint.y());
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,9 +480,9 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
if (m_drawSymbols) {
|
||||
painter.save();
|
||||
auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
for (auto& p: ps) {
|
||||
plotStyledSymbol(parent, painter, p.x(), p.y());
|
||||
auto __finalpaintsym=JKQTPFinally([&painter]() {painter.restore();});
|
||||
for (auto& point: ps) {
|
||||
plotStyledSymbol(parent, painter, point.x(), point.y());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,11 @@ JKQTPXFunctionLineGraph *jkqtpstatAddLinearWeightedRegression(JKQTPXYGraph *data
|
||||
JKQTBasePlotter* plt=datagraph->getParent();
|
||||
JKQTPDatastore* ds=plt->getDatastore();
|
||||
JKQTPYGraphErrorData* ge=dynamic_cast<JKQTPYGraphErrorData*>(datagraph);
|
||||
|
||||
JKQTPASSERT_M(ge!=nullptr, "datagraph needs to be convertible to JKQTPYGraphErrorData with a dynamic_cast!");
|
||||
return jkqtpstatAddLinearWeightedRegression(plt, ds->begin(datagraph->getXColumn()), ds->end(datagraph->getXColumn()), ds->begin(datagraph->getYColumn()), ds->end(datagraph->getYColumn()), ds->begin(ge->getYErrorColumn()), ds->end(ge->getYErrorColumn()), coeffA, coeffB, fixA, fixB, &jkqtp_inversePropSaveDefault<double>);
|
||||
if (ge) {
|
||||
return jkqtpstatAddLinearWeightedRegression(plt, ds->begin(datagraph->getXColumn()), ds->end(datagraph->getXColumn()), ds->begin(datagraph->getYColumn()), ds->end(datagraph->getYColumn()), ds->begin(ge->getYErrorColumn()), ds->end(ge->getYErrorColumn()), coeffA, coeffB, fixA, fixB, &jkqtp_inversePropSaveDefault<double>);
|
||||
} else {
|
||||
throw std::runtime_error("datagraph needs to be convertible to JKQTPYGraphErrorData with a dynamic_cast!");
|
||||
}
|
||||
}
|
||||
|
||||
JKQTPXFunctionLineGraph *jkqtpstatAddRobustIRLSLinearRegression(JKQTPXYGraph *datagraph, double *coeffA, double *coeffB, bool fixA, bool fixB, double p, int iterations)
|
||||
@ -60,8 +62,11 @@ JKQTPXFunctionLineGraph *jkqtpstatAddWeightedRegression(JKQTPXYGraph *datagraph,
|
||||
JKQTPDatastore* ds=plt->getDatastore();
|
||||
JKQTPYGraphErrorData* ge=dynamic_cast<JKQTPYGraphErrorData*>(datagraph);
|
||||
|
||||
JKQTPASSERT_M(ge!=nullptr, "datagraph needs to be convertible to JKQTPYGraphErrorData with a dynamic_cast!");
|
||||
return jkqtpstatAddWeightedRegression(plt, type, ds->begin(datagraph->getXColumn()), ds->end(datagraph->getXColumn()), ds->begin(datagraph->getYColumn()), ds->end(datagraph->getYColumn()), ds->begin(ge->getYErrorColumn()), ds->end(ge->getYErrorColumn()), coeffA, coeffB, fixA, fixB, &jkqtp_inversePropSaveDefault<double>);
|
||||
if (ge) {
|
||||
return jkqtpstatAddWeightedRegression(plt, type, ds->begin(datagraph->getXColumn()), ds->end(datagraph->getXColumn()), ds->begin(datagraph->getYColumn()), ds->end(datagraph->getYColumn()), ds->begin(ge->getYErrorColumn()), ds->end(ge->getYErrorColumn()), coeffA, coeffB, fixA, fixB, &jkqtp_inversePropSaveDefault<double>);
|
||||
} else {
|
||||
throw std::runtime_error("datagraph needs to be convertible to JKQTPYGraphErrorData with a dynamic_cast!");
|
||||
}
|
||||
}
|
||||
|
||||
JKQTPXFunctionLineGraph *jkqtpstatAddRobustIRLSRegression(JKQTPXYGraph *datagraph, JKQTPStatRegressionModelType type, double *coeffA, double *coeffB, bool fixA, bool fixB, double p, int iterations)
|
||||
|
@ -239,11 +239,6 @@ JKQTBasePlotter::JKQTBasePlotter(bool datastore_internal, QObject* parent, JKQTP
|
||||
actSavePDF=new QAction(QIcon(":/JKQTPlotter/jkqtp_savepdf.png"), tr("Save P&DF"), this);
|
||||
actSavePDF->setToolTip(tr("Save as PDF"));
|
||||
//toolbar->addAction(actSavePDF);
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
actSavePS=new QAction(QIcon(":/JKQTPlotter/jkqtp_saveps.png"), "Save P&S", this);
|
||||
actSavePS->setToolTip("Save as PostScript");
|
||||
//toolbar->addAction(actSavePS);
|
||||
#endif
|
||||
actSaveSVG=new QAction(QIcon(":/JKQTPlotter/jkqtp_savesvg.png"), tr("Save S&VG"), this);
|
||||
actSaveSVG->setToolTip(tr("Save as Scalable Vector Graphics (SVG)"));
|
||||
//toolbar->addAction(actSaveSVG);
|
||||
@ -278,9 +273,6 @@ JKQTBasePlotter::JKQTBasePlotter(bool datastore_internal, QObject* parent, JKQTP
|
||||
connect(actShowPlotData, SIGNAL(triggered()), this, SLOT(showPlotData()));
|
||||
|
||||
connect(actSavePDF, SIGNAL(triggered()), this, SLOT(saveAsPDF()));
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
connect(actSavePS, SIGNAL(triggered()), this, SLOT(saveAsPS()));
|
||||
#endif
|
||||
connect(actSaveSVG, SIGNAL(triggered()), this, SLOT(saveAsSVG()));
|
||||
connect(actSavePix, SIGNAL(triggered()), this, SLOT(saveAsPixelImage()));
|
||||
|
||||
@ -700,9 +692,15 @@ void JKQTBasePlotter::setXY(double xminn, double xmaxx, double yminn, double yma
|
||||
xAxis->setRange(xminn, xmaxx);
|
||||
yAxis->setRange(yminn, ymaxx);
|
||||
if (maintainAxisAspectRatio) {
|
||||
double mid=(yAxis->getMax()+yAxis->getMin())/2.0;
|
||||
double w=fabs(xmaxx-xminn)/axisAspectRatio;
|
||||
yAxis->setRange(mid-w/2.0, mid+w/2.0);
|
||||
if (xAxis->isLinearAxis() && yAxis->isLinearAxis()) {
|
||||
const double mid=(yAxis->getMax()+yAxis->getMin())/2.0;
|
||||
const double w=fabs(xmaxx-xminn)/axisAspectRatio;
|
||||
yAxis->setRange(mid-w/2.0, mid+w/2.0);
|
||||
} else if (xAxis->isLogAxis() && yAxis->isLogAxis()) {
|
||||
const double mid=(log(yAxis->getMax())+log(yAxis->getMin()))/2.0;
|
||||
const double w=fabs(log(xmaxx)-log(xminn))/axisAspectRatio;
|
||||
yAxis->setRange(exp(mid-w/2.0), exp(mid+w/2.0));
|
||||
}
|
||||
}
|
||||
if (emitSignals) emit zoomChangedLocally(xAxis->getMin(), xAxis->getMax(), yAxis->getMin(), yAxis->getMax(), this);
|
||||
}
|
||||
@ -710,19 +708,31 @@ void JKQTBasePlotter::setXY(double xminn, double xmaxx, double yminn, double yma
|
||||
void JKQTBasePlotter::setX(double xminn, double xmaxx){
|
||||
xAxis->setRange(xminn, xmaxx);
|
||||
if (maintainAxisAspectRatio) {
|
||||
double mid=(yAxis->getMax()+yAxis->getMin())/2.0;
|
||||
double w=fabs(xmaxx-xminn)/axisAspectRatio;
|
||||
yAxis->setRange(mid-w/2.0, mid+w/2.0);
|
||||
if (xAxis->isLinearAxis() && yAxis->isLinearAxis()) {
|
||||
const double mid=(yAxis->getMax()+yAxis->getMin())/2.0;
|
||||
const double w=fabs(xmaxx-xminn)/axisAspectRatio;
|
||||
yAxis->setRange(mid-w/2.0, mid+w/2.0);
|
||||
} else if (xAxis->isLogAxis() && yAxis->isLogAxis()) {
|
||||
const double mid=(log(yAxis->getMax())+log(yAxis->getMin()))/2.0;
|
||||
const double w=fabs(log(xmaxx)-log(xminn))/axisAspectRatio;
|
||||
yAxis->setRange(exp(mid-w/2.0), exp(mid+w/2.0));
|
||||
}
|
||||
}
|
||||
if (emitSignals) emit zoomChangedLocally(xAxis->getMin(), xAxis->getMax(), yAxis->getMin(), yAxis->getMax(), this);
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::setY(double yminn, double ymaxx){
|
||||
void JKQTBasePlotter::setY(double yminn, double ymaxx) {
|
||||
yAxis->setRange(yminn, ymaxx);
|
||||
if (maintainAxisAspectRatio) {
|
||||
double mid=(xAxis->getMax()+xAxis->getMin())/2.0;
|
||||
double w=fabs(ymaxx-yminn)*axisAspectRatio;
|
||||
xAxis->setRange(mid-w/2.0, mid+w/2.0);
|
||||
if (xAxis->isLinearAxis() && yAxis->isLinearAxis()) {
|
||||
const double mid=(xAxis->getMax()+xAxis->getMin())/2.0;
|
||||
const double w=fabs(ymaxx-yminn)*axisAspectRatio;
|
||||
xAxis->setRange(mid-w/2.0, mid+w/2.0);
|
||||
} else if (xAxis->isLogAxis() && yAxis->isLogAxis()) {
|
||||
const double mid=(log(xAxis->getMax())+log(xAxis->getMin()))/2.0;
|
||||
const double w=fabs(log(ymaxx)-log(yminn))/axisAspectRatio;
|
||||
xAxis->setRange(exp(mid-w/2.0), exp(mid+w/2.0));
|
||||
}
|
||||
}
|
||||
if (emitSignals) emit zoomChangedLocally(xAxis->getMin(), xAxis->getMax(), yAxis->getMin(), yAxis->getMax(), this);
|
||||
}
|
||||
@ -1438,14 +1448,14 @@ void JKQTBasePlotter::gridPaint(JKQTPEnhancedPainter& painter, QSizeF pageRect,
|
||||
for (int i=0; i< gridPrintingList.size(); i++) {
|
||||
//std::cout<<"printing "<<i<<" ...\n";
|
||||
painter.save(); auto __finalpaintinnerloop=JKQTPFinally([&painter]() {painter.restore();});
|
||||
int t_x=0;
|
||||
int t_y=0;
|
||||
int gt_x=0;
|
||||
int gt_y=0;
|
||||
//std::cout<<"printing "<<i<<" @g "<<gridPrintingList[i].x<<", "<<gridPrintingList[i].y<<" ...\n";
|
||||
//std::cout<<"colrowlistsizes "<<gridPrintingColumns.size()<<", "<<gridPrintingRows.size()<<" ...\n";
|
||||
for (size_t j=0; j<gridPrintingList[i].x; j++) { t_x+= static_cast<int>(gridPrintingColumns[static_cast<int>(j)]); }
|
||||
for (size_t j=0; j<gridPrintingList[i].y; j++) { t_y+= static_cast<int>(gridPrintingRows[static_cast<int>(j)]); }
|
||||
for (size_t j=0; j<gridPrintingList[i].x; j++) { gt_x+= static_cast<int>(gridPrintingColumns[static_cast<int>(j)]); }
|
||||
for (size_t j=0; j<gridPrintingList[i].y; j++) { gt_y+= static_cast<int>(gridPrintingRows[static_cast<int>(j)]); }
|
||||
//std::cout<<"printing "<<i<<" @ "<<t_x<<", "<<t_y<<" ...\n";
|
||||
painter.translate(t_x, t_y);
|
||||
painter.translate(gt_x, gt_y);
|
||||
gridPrintingList[i].plotter->drawPlot(painter, showOverlays);
|
||||
|
||||
}
|
||||
@ -1505,14 +1515,14 @@ void JKQTBasePlotter::gridPaintOverlays(JKQTPEnhancedPainter &painter, QSizeF pa
|
||||
for (int i=0; i< gridPrintingList.size(); i++) {
|
||||
//std::cout<<"printing "<<i<<" ...\n";
|
||||
painter.save(); auto __finalpaintinnerloop=JKQTPFinally([&painter]() {painter.restore();});
|
||||
int t_x=0;
|
||||
int t_y=0;
|
||||
int gt_x=0;
|
||||
int gt_y=0;
|
||||
//std::cout<<"printing "<<i<<" @g "<<gridPrintingList[i].x<<", "<<gridPrintingList[i].y<<" ...\n";
|
||||
//std::cout<<"colrowlistsizes "<<gridPrintingColumns.size()<<", "<<gridPrintingRows.size()<<" ...\n";
|
||||
for (size_t j=0; j<gridPrintingList[i].x; j++) { t_x+= static_cast<int>(gridPrintingColumns[static_cast<int>(j)]); }
|
||||
for (size_t j=0; j<gridPrintingList[i].y; j++) { t_y+= static_cast<int>(gridPrintingRows[static_cast<int>(j)]); }
|
||||
for (size_t j=0; j<gridPrintingList[i].x; j++) { gt_x+= static_cast<int>(gridPrintingColumns[static_cast<int>(j)]); }
|
||||
for (size_t j=0; j<gridPrintingList[i].y; j++) { gt_y+= static_cast<int>(gridPrintingRows[static_cast<int>(j)]); }
|
||||
//std::cout<<"printing "<<i<<" @ "<<t_x<<", "<<t_y<<" ...\n";
|
||||
painter.translate(t_x, t_y);
|
||||
painter.translate(gt_x, gt_y);
|
||||
gridPrintingList[i].plotter->drawOverlaysWithHints(painter);
|
||||
|
||||
}
|
||||
@ -1752,10 +1762,10 @@ bool JKQTBasePlotter::printpreviewNew(QPaintDevice* paintDevice, bool setAbsolut
|
||||
bool res=false;
|
||||
if (printer) {
|
||||
if (!displayPreview || dlg->exec()==QDialog::Accepted) {
|
||||
qDebug()<<svg<<printer<<delPrinter;
|
||||
//qDebug()<<svg<<printer<<delPrinter;
|
||||
if (svg) {
|
||||
printpreviewPaintRequestedNew(svg);
|
||||
} else if (printer && !delPrinter) {
|
||||
} else if (!delPrinter) {
|
||||
printpreviewPaintRequestedNew(printer);
|
||||
} else {
|
||||
printpreviewPaintRequestedNew(paintDevice);
|
||||
@ -2377,7 +2387,7 @@ void JKQTBasePlotter::drawNonGrid(JKQTPEnhancedPainter& painter, const QRect& re
|
||||
if ((scale*static_cast<double>(widgetWidth)/paintMagnification>static_cast<double>(rect.width())) || (scale*static_cast<double>(widgetHeight)/paintMagnification>static_cast<double>(rect.height()))) {
|
||||
scale=static_cast<double>(rect.height())/static_cast<double>(widgetHeight)*paintMagnification;
|
||||
}
|
||||
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
||||
painter.save(); auto __finalpaintinner=JKQTPFinally([&painter]() {painter.restore();});
|
||||
// scale the plot so it fits on the page
|
||||
painter.scale(scale, scale);
|
||||
#ifdef JKQTBP_DEBUGTIMING
|
||||
@ -3293,12 +3303,6 @@ QAction *JKQTBasePlotter::getActionSavePDF() const {
|
||||
return this->actSavePDF;
|
||||
}
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
QAction *JKQTBasePlotter::getActionSavePS() const {
|
||||
return this->actSavePS;
|
||||
}
|
||||
#endif
|
||||
|
||||
QAction *JKQTBasePlotter::getActionSavePix() const {
|
||||
return this->actSavePix;
|
||||
}
|
||||
@ -3704,51 +3708,12 @@ void JKQTBasePlotter::saveAsPDF(const QString& filename, bool displayPreview) {
|
||||
saveUserSettings();
|
||||
}
|
||||
|
||||
void JKQTBasePlotter::saveAsPS(const QString& filename, bool displayPreview) {
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
loadUserSettings();
|
||||
QString fn=filename;
|
||||
if (fn.isEmpty()) {
|
||||
fn = QFileDialog::getSaveFileName(nullptr, tr("Save Plot"),
|
||||
currentSaveDirectory,
|
||||
tr("PostScript File (*.ps)"));
|
||||
if (!fn.isEmpty()) currentSaveDirectory=QFileInfo(fn).absolutePath();
|
||||
}
|
||||
|
||||
if (!fn.isEmpty()) {
|
||||
QPrinter* printer=new QPrinter;
|
||||
bool doLandscape=widgetWidth>widgetHeight;
|
||||
if (gridPrinting) {
|
||||
gridPrintingCalc();
|
||||
doLandscape=gridPrintingSize.width()>gridPrintingSize.height();
|
||||
}
|
||||
if (doLandscape) {
|
||||
printer->setOrientation(QPrinter::Landscape);
|
||||
} else {
|
||||
printer->setOrientation(QPrinter::Portrait);
|
||||
}
|
||||
printer->setOutputFormat(QPrinter::PostScriptFormat);
|
||||
printer->setColorMode(QPrinter::Color);
|
||||
printer->setOutputFileName(fn);
|
||||
printer->setPageMargins(0,0,0,0,QPrinter::Millimeter);
|
||||
printpreviewNew(printer, true, -1.0, -1.0, displayPreview);
|
||||
delete printer;
|
||||
}
|
||||
saveUserSettings();
|
||||
#else
|
||||
saveAsPDF(filename+".pdf", displayPreview);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
|
||||
loadUserSettings();
|
||||
QString fn=filename;
|
||||
QStringList filt;
|
||||
filt<<tr("Portable Document Format PDF [Qt] (*.pdf)");
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
filt<<tr("PostScript [Qt] (*.ps)");
|
||||
#endif
|
||||
filt<<tr("Scalable Vector Graphics [Qt] (*.svg)");
|
||||
filt<<tr("PNG Image [Qt] (*.png)");
|
||||
filt<<tr("BMP Image [Qt] (*.bmp)");
|
||||
@ -3763,8 +3728,6 @@ void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
|
||||
for (int i=0; i<writerformats.size(); i++) {
|
||||
filt<<QString("%1 Image (*.%2)").arg(QString(writerformats[i]).toUpper()).arg(QString(writerformats[i].toLower()));
|
||||
}
|
||||
/*filt<<tr("X11 Bitmap [Qt] (*.xbm)");
|
||||
filt<<tr("X11 Pixmap [Qt] (*.xpm)");*/
|
||||
QString selFormat="";
|
||||
if (fn.isEmpty()) {
|
||||
selFormat=currentFileFormat;
|
||||
@ -3795,14 +3758,9 @@ void JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
|
||||
}
|
||||
}
|
||||
//qDebug()<<"filtID="<<filtID<<" isWithSpecialDeviceAdapter="<<isWithSpecialDeviceAdapter<<" adapterID="<<adapterID;
|
||||
int ids=0;
|
||||
if (filtID==ids++) {
|
||||
if (filtID==0) {
|
||||
saveAsPDF(fn, displayPreview);
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
} else if (filtID==ids++) {
|
||||
saveAsPS(fn, displayPreview);
|
||||
#endif
|
||||
} else if (filtID==ids++) {
|
||||
} else if (filtID==1) {
|
||||
saveAsSVG(fn, displayPreview);
|
||||
} else if (isWithSpecialDeviceAdapter && adapterID>=0 && adapterID<jkqtpPaintDeviceAdapters.size()) {
|
||||
QString tempFM="";
|
||||
@ -4222,9 +4180,7 @@ void JKQTBasePlotter::drawGraphs(JKQTPEnhancedPainter& painter){
|
||||
|
||||
|
||||
for (int j=0; j<graphs.size(); j++) {
|
||||
//int leftSpace, rightSpace, topSpace, bottomSpace;
|
||||
JKQTPPlotElement* g=graphs[j];
|
||||
//qDebug()<<" drawing JKQTPPlotElement"<<j<<g->getTitle()<<g->metaObject()->className();
|
||||
if (g->isVisible()) g->draw(painter);
|
||||
}
|
||||
|
||||
@ -4233,9 +4189,9 @@ void JKQTBasePlotter::drawGraphs(JKQTPEnhancedPainter& painter){
|
||||
}
|
||||
|
||||
for (int j=0; j<graphs.size(); j++) {
|
||||
int leftSpace, rightSpace, topSpace, bottomSpace;
|
||||
JKQTPPlotElement* g=graphs[j];
|
||||
if (g->isVisible()) {
|
||||
int leftSpace, rightSpace, topSpace, bottomSpace;
|
||||
g->getOutsideSize(painter, leftSpace, rightSpace, topSpace, bottomSpace);
|
||||
ibTop+=topSpace;
|
||||
ibLeft+=leftSpace;
|
||||
@ -4518,10 +4474,10 @@ void JKQTBasePlotter::getKeyExtent(JKQTPEnhancedPainter& painter, double* width,
|
||||
double keyHeight=graphs.size();
|
||||
double w=0;
|
||||
double txtH=0;
|
||||
QFont f=painter.font();
|
||||
f.setFamily(plotterStyle.defaultFontName);
|
||||
f.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
|
||||
painter.setFont(f);
|
||||
QFont floc=painter.font();
|
||||
floc.setFamily(plotterStyle.defaultFontName);
|
||||
floc.setPointSizeF(plotterStyle.keyStyle.fontSize*fontSizeMultiplier);
|
||||
painter.setFont(floc);
|
||||
|
||||
|
||||
for (int i=0; i<graphs.size(); i++) {
|
||||
@ -4662,11 +4618,11 @@ void JKQTBasePlotter::getGraphsYMinMax(double& miny, double& maxy, double& small
|
||||
|
||||
void JKQTBasePlotter::zoomToFit(bool zoomX, bool zoomY, bool includeX0, bool includeY0, double scaleX, double scaleY) {
|
||||
// std::cout<<"JKQTBasePlotter::zoomToFit():\n";
|
||||
double xxmin=0;
|
||||
double xxmax=0;
|
||||
double xsmallestGreaterZero=0;
|
||||
if (graphs.size()<=0) return;
|
||||
if (zoomX) {
|
||||
double xxmin=0;
|
||||
double xxmax=0;
|
||||
double xsmallestGreaterZero=0;
|
||||
getGraphsXMinMax(xxmin, xxmax, xsmallestGreaterZero);
|
||||
//std::cout<<" xxmin="<<xxmin<<" xxmax="<<xxmax<<std::endl;
|
||||
if (JKQTPIsOKFloat(xxmin) && JKQTPIsOKFloat(xxmax)) {
|
||||
@ -4708,11 +4664,11 @@ void JKQTBasePlotter::zoomToFit(bool zoomX, bool zoomY, bool includeX0, bool inc
|
||||
}
|
||||
}
|
||||
}
|
||||
double yymin=0;
|
||||
double yymax=0;
|
||||
double ysmallestGreaterZero=0;
|
||||
|
||||
if (zoomY) {
|
||||
double yymin=0;
|
||||
double yymax=0;
|
||||
double ysmallestGreaterZero=0;
|
||||
getGraphsYMinMax(yymin, yymax, ysmallestGreaterZero);
|
||||
//std::cout<<" yymin="<<yymin<<" yymax="<<yymax<<std::endl;
|
||||
bool doScale=true;
|
||||
|
@ -208,7 +208,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPaintDeviceAdapter {
|
||||
* - print() prints the graph on a QPrinter object
|
||||
* - saveAsPixelImage() saves the plot into a pixel image file (PNG, TIFF, ... formats, as supported by Qt)
|
||||
* - saveAsPDF() saves the graph as a PDF file (using the Qt printing engine)
|
||||
* - saveAsPS() saves the graph as a PDF file (using the Qt printing engine)
|
||||
* - saveAsSVG() saves the graph as a SVG file (using the Qt SVG library)
|
||||
* - saveImage() saves the graph
|
||||
* .
|
||||
@ -841,11 +840,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
QAction* getActionCopyMatlab() const;
|
||||
/*! \copydoc actSavePDF */
|
||||
QAction* getActionSavePDF() const;
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
/*! \copydoc actSavePS */
|
||||
QAction* getActionSavePS() const;
|
||||
#endif
|
||||
/*! \copydoc actSavePix */
|
||||
/*! \copydoc actSavePix */
|
||||
QAction* getActionSavePix() const;
|
||||
/*! \copydoc actSaveSVG */
|
||||
QAction* getActionSaveSVG() const;
|
||||
@ -1354,9 +1349,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
/** \brief save the current plot as a PDF file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */
|
||||
void saveAsPDF(const QString& filename=QString(""), bool displayPreview=true);
|
||||
|
||||
/** \brief save the current plot as a PS file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed */
|
||||
void saveAsPS(const QString& filename=QString(""), bool displayPreview=true);
|
||||
|
||||
/** \brief save the current plot as an image file, with the current widget aspect ratio, if filename is empty a file selection dialog is displayed.
|
||||
* The image format is extracted from the file extension (jpeg, tiff, png, pdf, ...) */
|
||||
void saveImage(const QString& filename=QString(""), bool displayPreview=true);
|
||||
@ -2019,9 +2011,23 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
/** \brief the aspect ratio of plotwidth and plotheight to maintain, if \c maintainAspectRatio==true */
|
||||
double aspectRatio;
|
||||
|
||||
/** \brief indicates whether the axes should maintain an aspect ratio */
|
||||
/** \brief indicates whether the axes should maintain an aspect ratio
|
||||
*
|
||||
* \note An axis aspect ration is only well defined for linear axes (if both axes are linear).
|
||||
* If both axes a logarithmic, the axis ration is defined for log(axismax)-log(axismin).
|
||||
* For other combinations of axes, this function is deactivated
|
||||
*
|
||||
* \see axisAspectRatio
|
||||
*/
|
||||
bool maintainAxisAspectRatio;
|
||||
/** \brief the aspect ratio of axis widths to maintain, if \c maintainAxisAspectRatio==true */
|
||||
/** \brief the aspect ratio of axis widths to maintain, if \c maintainAxisAspectRatio==true
|
||||
*
|
||||
* \note An axis aspect ration is only well defined for linear axes (if both axes are linear).
|
||||
* If both axes a logarithmic, the axis ration is defined for log(axismax)-log(axismin).
|
||||
* For other combinations of axes, this function is deactivated
|
||||
*
|
||||
* \see maintainAxisAspectRatio
|
||||
*/
|
||||
double axisAspectRatio;
|
||||
|
||||
|
||||
@ -2082,10 +2088,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
QAction* actCopyMatlab;
|
||||
/** \brief QAction which triggers the saving as PDF */
|
||||
QAction* actSavePDF;
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
/** \brief QAction which triggers the saving as PostScript */
|
||||
QAction* actSavePS;
|
||||
#endif
|
||||
/** \brief QAction which triggers the saving as pixel image */
|
||||
QAction* actSavePix;
|
||||
/** \brief QAction which triggers the saving as Scalable Vector Graphics (SVG) */
|
||||
|
@ -359,7 +359,7 @@ double JKQTPCoordinateAxis::calcLogTickSpacing() {
|
||||
|
||||
QString JKQTPCoordinateAxis::floattolabel(double data) {
|
||||
int past_comma=axisStyle.labelDigits;
|
||||
bool remove_trail0=true;
|
||||
const bool remove_trail0=true;
|
||||
QLocale loc=QLocale::system();
|
||||
loc.setNumberOptions(QLocale::OmitGroupSeparator);
|
||||
|
||||
@ -607,10 +607,10 @@ void JKQTPCoordinateAxis::saveCurrentAxisStyle(QSettings &settings, const QStrin
|
||||
}
|
||||
|
||||
void JKQTPCoordinateAxis::setRange(double aamin, double aamax) {
|
||||
double oldamin=axismin;
|
||||
double oldamax=axismax;
|
||||
double amin=aamin;
|
||||
double amax=aamax;
|
||||
const double oldamin=axismin;
|
||||
const double oldamax=axismax;
|
||||
double amin=std::min(aamin, aamax);
|
||||
double amax=std::max(aamin, aamax);
|
||||
if (axisMinWidth>0 && fabs(amax-amin)<axisMinWidth) {
|
||||
amax=amin+axisMinWidth;
|
||||
}
|
||||
@ -621,10 +621,7 @@ void JKQTPCoordinateAxis::setRange(double aamin, double aamax) {
|
||||
if (amin<axisabsoultemin) axismin=axisabsoultemin;
|
||||
if (amax>axisabsoultemax) axismax=axisabsoultemax;
|
||||
|
||||
if (axismin>axismax) {
|
||||
axismin=amax;
|
||||
axismax=amin;
|
||||
}
|
||||
|
||||
if (isLogAxis()) {
|
||||
if (axismin<=0) axismin=1e-306;
|
||||
if (axismax<=0) axismax=1e-306;
|
||||
@ -950,21 +947,15 @@ void JKQTPCoordinateAxis::setTickLabelAngle(double __value) {
|
||||
|
||||
|
||||
void JKQTPCoordinateAxis::setAbsoluteRange(double amin, double amax) {
|
||||
axisabsoultemin=amin;
|
||||
axisabsoultemax=amax;
|
||||
|
||||
if (axisabsoultemin>axisabsoultemax) {
|
||||
axisabsoultemin=amax;
|
||||
axisabsoultemax=amin;
|
||||
}
|
||||
axisabsoultemin=std::min(amin, amax);
|
||||
axisabsoultemax=std::max(amin, amax);
|
||||
|
||||
if (axisabsoultemin==axisabsoultemax) {
|
||||
axisabsoultemax=axisabsoultemin+1;
|
||||
}
|
||||
|
||||
// ensure that the actual axis range is within the absolute range
|
||||
setRange(axismin, axismax);
|
||||
/*paramsChanged=true;
|
||||
calcPlotScaling();
|
||||
redrawPlot();*/
|
||||
}
|
||||
|
||||
double JKQTPCoordinateAxis::getNextLabelDistance(double x) {
|
||||
@ -1363,7 +1354,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
// plot thick axis at y==0
|
||||
if (axisStyle.showZeroAxis && (0>axismin) && (0<axismax)) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): 0Axis").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaati(QString("JKQTPEnhancedPainter[%1]::drawAxes(): 0Axis").arg(objectName()));
|
||||
#endif
|
||||
QPen pmain1=pmain;
|
||||
pmain1.setWidthF(qMax(JKQTPlotterDrawingTools::ABS_MIN_LINEWIDTH, parent->pt2px(painter, axisStyle.lineWidthZeroAxis*parent->getLineWidthMultiplier())));
|
||||
@ -1399,7 +1390,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
{
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): calcLabels").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaatii(QString("JKQTPEnhancedPainter[%1]::drawAxes(): calcLabels").arg(objectName()));
|
||||
#endif
|
||||
while (getNextLabel(x, label, first) && cnt<200) {
|
||||
double mtdist=getNextLabelDistance(x)/static_cast<double>(axisStyle.minorTicks+1);
|
||||
@ -1498,7 +1489,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
}
|
||||
{
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): drawLines").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaati(QString("JKQTPEnhancedPainter[%1]::drawAxes(): drawLines").arg(objectName()));
|
||||
#endif
|
||||
painter.setPen(ptick);
|
||||
painter.drawLines(lines_ptick);
|
||||
@ -1511,7 +1502,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
// plot axis label
|
||||
if (!axisLabel.isEmpty() && JKQTPCADrawModeHasAxisLabel(axisStyle.drawMode1)) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): axisLabel1").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaati(QString("JKQTPEnhancedPainter[%1]::drawAxes(): axisLabel1").arg(objectName()));
|
||||
#endif
|
||||
getParentMathText()->setFontSize(axisStyle.labelFontSize*parent->getFontSizeMultiplier());
|
||||
getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName);
|
||||
@ -1553,7 +1544,7 @@ void JKQTPVerticalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
}
|
||||
if (!axisLabel.isEmpty() && JKQTPCADrawModeHasAxisLabel(axisStyle.drawMode2)) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes(): axisLabel2").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaati(QString("JKQTPEnhancedPainter[%1]::drawAxes(): axisLabel2").arg(objectName()));
|
||||
#endif
|
||||
getParentMathText()->setFontSize(axisStyle.labelFontSize*parent->getFontSizeMultiplier());
|
||||
getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName);
|
||||
@ -1992,7 +1983,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
{
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes(): calcLabels").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaati(QString("JKQTPHorizontalAxis[%1]::drawAxes(): calcLabels").arg(objectName()));
|
||||
#endif
|
||||
|
||||
while (getNextLabel(x, label, first) && cnt<200) {
|
||||
@ -2094,7 +2085,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
}
|
||||
{
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes(): drawLines").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaati(QString("JKQTPHorizontalAxis[%1]::drawAxes(): drawLines").arg(objectName()));
|
||||
#endif
|
||||
|
||||
painter.setPen(ptick);
|
||||
@ -2108,7 +2099,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
// plot axis label
|
||||
if (!axisLabel.isEmpty() && JKQTPCADrawModeHasAxisLabel(axisStyle.drawMode1)) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes(): axisLabel1").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaati(QString("JKQTPHorizontalAxis[%1]::drawAxes(): axisLabel1").arg(objectName()));
|
||||
#endif
|
||||
getParentMathText()->setFontSize(axisStyle.labelFontSize*parent->getFontSizeMultiplier());
|
||||
getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName);
|
||||
@ -2149,7 +2140,7 @@ void JKQTPHorizontalAxis::drawAxes(JKQTPEnhancedPainter& painter) {
|
||||
}
|
||||
if (!axisLabel.isEmpty() && JKQTPCADrawModeHasAxisLabel(axisStyle.drawMode2)) {
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes(): axisLabel2").arg(objectName()));
|
||||
JKQTPAutoOutputTimer jkaati(QString("JKQTPHorizontalAxis[%1]::drawAxes(): axisLabel2").arg(objectName()));
|
||||
#endif
|
||||
getParentMathText()->setFontSize(axisStyle.labelFontSize*parent->getFontSizeMultiplier());
|
||||
getParentMathText()->setFontRomanOrSpecial(getParent()->getCurrentPlotterStyle().defaultFontName);
|
||||
|
@ -80,13 +80,11 @@ size_t JKQTPColumn::getRows() const {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void JKQTPColumn::copyData(QVector<double> ©To) const
|
||||
{
|
||||
const double* d=getPointer(0);
|
||||
copyTo.clear();
|
||||
size_t i, cnt=getRows();
|
||||
const size_t cnt=getRows();
|
||||
if (cnt>0) {
|
||||
copyTo.resize(static_cast<int>(cnt));
|
||||
for (i=0; i<cnt; i++) {
|
||||
copyTo[static_cast<int>(i)]=d[i];
|
||||
for (size_t i=0; i<cnt; i++) {
|
||||
copyTo[static_cast<int>(i)]=getValue(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,7 +141,7 @@ void JKQTPColumn::subtract(double value)
|
||||
{
|
||||
if (!datastore) return ;
|
||||
double* data=getPointer();
|
||||
size_t N=getRows();
|
||||
const size_t N=getRows();
|
||||
if (data){
|
||||
for (size_t i=0; i<N; i++) {
|
||||
data[i]=data[i]-value;
|
||||
@ -202,7 +200,7 @@ JKQTPDatastoreItem::JKQTPDatastoreItem(size_t columns, size_t rows){
|
||||
this->dataformat=JKQTPDatastoreItemFormat::SingleColumn;
|
||||
this->storageType=StorageType::Vector;
|
||||
datavec.resize(static_cast<int>(columns*rows));
|
||||
for( double& d: datavec) { d=0.0; }
|
||||
std::fill(datavec.begin(), datavec.end(), 0.0);
|
||||
this->data=datavec.data();
|
||||
}
|
||||
this->columns=columns;
|
||||
@ -562,7 +560,7 @@ size_t JKQTPDatastore::addCopiedItem(JKQTPDatastoreItemFormat dataformat, double
|
||||
it->set(c, r, data[c*rows+r]);
|
||||
}
|
||||
}
|
||||
} else if (dataformat==JKQTPDatastoreItemFormat::MatrixColumn) {
|
||||
} else if (dataformat==JKQTPDatastoreItemFormat::MatrixRow) {
|
||||
it=new JKQTPDatastoreItem(columnsnum, rows);
|
||||
for (size_t r=0; r<rows; r++) {
|
||||
for (size_t c=0; c<columnsnum; c++) {
|
||||
@ -1033,8 +1031,8 @@ void JKQTPDatastore::saveMatlab(QTextStream &txt, const QSet<int>& userColumns)
|
||||
varnames.insert(newvar);
|
||||
txt<<QString("% data from columne %1 ('%2')\n").arg(col+1).arg(it.value().getName());
|
||||
txt<<QString("%1 = [ ").arg(newvar);
|
||||
for (size_t i=0; i<it.value().getRows(); i++) {
|
||||
txt<<loc.toString(get(it.key(), i))<<" ";
|
||||
for (size_t rr=0; rr<it.value().getRows(); rr++) {
|
||||
txt<<loc.toString(get(it.key(), rr))<<" ";
|
||||
|
||||
}
|
||||
txt<<"];\n\n";
|
||||
@ -1072,8 +1070,7 @@ void JKQTPDatastore::saveCSV(QTextStream& txt, const QSet<int>& userColumns, con
|
||||
}
|
||||
txt<<"\n";
|
||||
}
|
||||
size_t rows=getMaxRows();
|
||||
for (size_t i=0; i<rows; i++) {
|
||||
for (size_t i=0; i<getMaxRows(); i++) {
|
||||
bool first=true;
|
||||
QMapIterator<size_t, JKQTPColumn> it(columns);
|
||||
int j=0;
|
||||
@ -1127,15 +1124,14 @@ void JKQTPDatastore::saveSYLK(const QString& filename, const QSet<int>& userColu
|
||||
|
||||
|
||||
|
||||
size_t rows=getMaxRows();
|
||||
for (size_t i=0; i<rows; i++) {
|
||||
for (size_t rr=0; rr<getMaxRows(); rr++) {
|
||||
QMapIterator<size_t, JKQTPColumn> it(columns);
|
||||
c=1;
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (userColumns.isEmpty() || userColumns.contains(static_cast<int>(i))) {
|
||||
if (it.value().getRows()>i) {
|
||||
txt<<QString("C;X%1;Y%2;N;K%3\n").arg(c).arg(i+2).arg(get(it.key(), i));
|
||||
if (userColumns.isEmpty() || userColumns.contains(static_cast<int>(rr))) {
|
||||
if (it.value().getRows()>rr) {
|
||||
txt<<QString("C;X%1;Y%2;N;K%3\n").arg(c).arg(rr+2).arg(get(it.key(), rr));
|
||||
}
|
||||
c++;
|
||||
}
|
||||
@ -1202,7 +1198,7 @@ void JKQTPDatastore::saveDIF(const QString& filename, const QSet<int>& userColum
|
||||
if (!f.open(QIODevice::WriteOnly|QIODevice::Text)) return;
|
||||
QTextStream txt(&f);
|
||||
txt.setLocale(loc);
|
||||
size_t rows=getMaxRows();
|
||||
const size_t rows=getMaxRows();
|
||||
|
||||
// write DIF header
|
||||
txt<<QString("TABLE\n0,1\n\"\"\n");
|
||||
|
Loading…
Reference in New Issue
Block a user