mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 09:31:40 +08:00
replaced QVector<QPointF> by QPolygonfF, as Qt changes from QVector to QList with Qt5->Qt6
This commit is contained in:
parent
586548c7d6
commit
c3afee2c1f
@ -348,18 +348,18 @@ double JKQTPLineDecoratorStyleCalcDecoratorSize(double line_width, double decora
|
||||
}
|
||||
|
||||
|
||||
QList<QPointF> JKQTPSimplifyPolyLines(const QList<QPointF> &lines_in, double maxDeltaXY)
|
||||
QPolygonF JKQTPSimplifyPolyLines(const QPolygonF &lines_in, double maxDeltaXY)
|
||||
{
|
||||
if (lines_in.size()<=1) return QList<QPointF>();
|
||||
if (lines_in.size()<=1) return QPolygonF();
|
||||
if (lines_in.size()<=10) return lines_in;
|
||||
QList<QPointF> l;
|
||||
QPolygonF l;
|
||||
l.reserve(lines_in.size());
|
||||
|
||||
int groupStart=0;
|
||||
int groupCount=1;
|
||||
QRectF groupSize(lines_in[0], QSizeF(0,0));
|
||||
|
||||
auto writeGroup=[](QList<QPointF>& l, const int& groupStart, const int& groupCount, const QRectF& groupSize, const QList<QPointF>& lines_in, double maxDeltaXY) {
|
||||
auto writeGroup=[](QPolygonF& l, const int& groupStart, const int& groupCount, const QRectF& groupSize, const QPolygonF& lines_in, double maxDeltaXY) {
|
||||
// group ends
|
||||
if (groupCount>4) {
|
||||
// we can optimize the group away
|
||||
@ -411,24 +411,24 @@ QList<QPointF> JKQTPSimplifyPolyLines(const QList<QPointF> &lines_in, double max
|
||||
return l;
|
||||
}
|
||||
|
||||
QList<QList<QPointF> > JKQTPClipPolyLine(const QList<QPointF> &polyline_in, const QRectF &clipRect)
|
||||
QList<QPolygonF > JKQTPClipPolyLine(const QPolygonF &polyline_in, const QRectF &clipRect)
|
||||
{
|
||||
QList<QList<QPointF>> l;
|
||||
QList<QPolygonF> l;
|
||||
l<<polyline_in;
|
||||
return JKQTPClipPolyLines(l, clipRect);
|
||||
}
|
||||
|
||||
QList<QList<QPointF> > JKQTPClipPolyLines(const QList<QList<QPointF> > &polylines_in, const QRectF &clipRect)
|
||||
QList<QPolygonF > JKQTPClipPolyLines(const QList<QPolygonF > &polylines_in, const QRectF &clipRect)
|
||||
{
|
||||
const double xmin=qMin(clipRect.left(), clipRect.right());
|
||||
const double xmax=qMax(clipRect.left(), clipRect.right());
|
||||
const double ymin=qMin(clipRect.top(), clipRect.bottom());
|
||||
const double ymax=qMax(clipRect.top(), clipRect.bottom());
|
||||
QList<QList<QPointF>> out;
|
||||
for (const QList<QPointF>& pl: polylines_in) {
|
||||
QList<QPolygonF> out;
|
||||
for (const QPolygonF& pl: polylines_in) {
|
||||
if (pl.size()>1) {
|
||||
if (out.size()==0 || out.last().size()>0) {
|
||||
out<<QList<QPointF>();
|
||||
out<<QPolygonF();
|
||||
}
|
||||
for (int i=1; i<pl.size(); i++) {
|
||||
const QLineF l(pl[i-1], pl[i]);
|
||||
@ -441,13 +441,13 @@ QList<QList<QPointF> > JKQTPClipPolyLines(const QList<QList<QPointF> > &polyline
|
||||
// p1 and p2 clipped, i.e. segment clipped on both ends: add clipped line as separate segment
|
||||
if (lclipped.length()==0) {
|
||||
if (out.last().size()>0) {
|
||||
out<<QList<QPointF>();
|
||||
out<<QPolygonF();
|
||||
}
|
||||
} else if (l==lclipped) {
|
||||
if (out.last().size()==0) {
|
||||
out.last()<<lclipped.p1();
|
||||
} if (out.last().last()!=lclipped.p1()) {
|
||||
out<<QList<QPointF>();
|
||||
out<<QPolygonF();
|
||||
out.last()<<lclipped.p1();
|
||||
}
|
||||
out.last()<<lclipped.p2();
|
||||
@ -455,26 +455,26 @@ QList<QList<QPointF> > JKQTPClipPolyLines(const QList<QList<QPointF> > &polyline
|
||||
if (out.last().size()==0) {
|
||||
out.last()<<lclipped.p1();
|
||||
} if (out.last().last()!=lclipped.p1()) {
|
||||
out<<QList<QPointF>();
|
||||
out<<QPolygonF();
|
||||
out.last()<<lclipped.p1();
|
||||
}
|
||||
out.last()<<lclipped.p2();
|
||||
out<<QList<QPointF>();
|
||||
out<<QPolygonF();
|
||||
} else if (l.p1()!=lclipped.p1() && l.p2()==lclipped.p2()) {
|
||||
if (out.last().size()==0) {
|
||||
out.last()<<lclipped.p1();
|
||||
} if (out.last().last()!=lclipped.p1()) {
|
||||
out<<QList<QPointF>();
|
||||
out<<QPolygonF();
|
||||
out.last()<<lclipped.p1();
|
||||
}
|
||||
out.last()<<lclipped.p2();
|
||||
} else if (l.p1()!=lclipped.p1() && l.p2()!=lclipped.p2()) {
|
||||
if (out.last().size()>0) {
|
||||
out<<QList<QPointF>();
|
||||
out<<QPolygonF();
|
||||
}
|
||||
out.last()<<lclipped.p1();
|
||||
out.last()<<lclipped.p2();
|
||||
out<<QList<QPointF>();
|
||||
out<<QPolygonF();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ inline QLineF JKQTPClipLine(const QLineF& line, const QRectF& clipRect) {
|
||||
\param clipRect rectangle to clip to
|
||||
\return a list of poly-lines representing the clipped lines. Note that some lines may be split further so the number of poly-lines in the output may actually be larger than the number of polylines in the input!
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QList<QList<QPointF>> JKQTPClipPolyLines(const QList<QList<QPointF>> & polylines_in, const QRectF& clipRect);
|
||||
JKQTCOMMON_LIB_EXPORT QList<QPolygonF> JKQTPClipPolyLines(const QList<QPolygonF> & polylines_in, const QRectF& clipRect);
|
||||
/*! \brief clips the given poly-line \a polyline_in to the given rectangle \a clipRect
|
||||
\ingroup jkqtptools_drawing
|
||||
|
||||
@ -398,7 +398,7 @@ JKQTCOMMON_LIB_EXPORT QList<QList<QPointF>> JKQTPClipPolyLines(const QList<QList
|
||||
\param clipRect rectangle to clip to
|
||||
\return a list of poly-lines representing the clipped line.
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QList<QList<QPointF>> JKQTPClipPolyLine(const QList<QPointF> & polyline_in, const QRectF& clipRect);
|
||||
JKQTCOMMON_LIB_EXPORT QList<QPolygonF> JKQTPClipPolyLine(const QPolygonF & polyline_in, const QRectF& clipRect);
|
||||
|
||||
/*! \brief tries to reduce the complexity of the given poly-line \a lines_in, but keeping the appearance as if all lines were drawn
|
||||
\ingroup jkqtptools_drawing
|
||||
@ -407,7 +407,7 @@ JKQTCOMMON_LIB_EXPORT QList<QList<QPointF>> JKQTPClipPolyLine(const QList<QPoint
|
||||
\param maxDeltaXY a group has to be either less wide or less high than this, typically equals the linewidth of the poly-line
|
||||
\return a simplified version of lines_in
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QList<QPointF> JKQTPSimplifyPolyLines(const QList<QPointF>& lines_in, double maxDeltaXY=1.0);
|
||||
JKQTCOMMON_LIB_EXPORT QPolygonF JKQTPSimplifyPolyLines(const QPolygonF& lines_in, double maxDeltaXY=1.0);
|
||||
|
||||
/*! \brief draw a tooltip, using the current brush and pen of the provided painter
|
||||
\ingroup jkqtptools_drawing
|
||||
|
@ -243,13 +243,13 @@ QRectF JKQTPGeoRectangle::getBottomLeftRectangle() const
|
||||
|
||||
|
||||
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTBasePlotter *parent, const QVector<QPointF> &points, JKQTPGeometricPlotElement::DrawMode drawMode):
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTBasePlotter *parent, const QPolygonF &points, JKQTPGeometricPlotElement::DrawMode drawMode):
|
||||
JKQTPGeoBaseFilled(parent, drawMode)
|
||||
{
|
||||
this->points=points;
|
||||
}
|
||||
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTPlotter *parent, const QVector<QPointF> &points, JKQTPGeometricPlotElement::DrawMode drawMode):
|
||||
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTPlotter *parent, const QPolygonF &points, JKQTPGeometricPlotElement::DrawMode drawMode):
|
||||
JKQTPGeoPolygon(parent->getPlotter(), points, drawMode)
|
||||
{
|
||||
|
||||
@ -314,13 +314,12 @@ void JKQTPGeoPolygon::draw(JKQTPEnhancedPainter& painter) {
|
||||
painter.setPen(getLinePen(painter, parent));
|
||||
painter.setBrush(getFillBrush(painter, parent));
|
||||
if ((getDrawMode()==DrawAsGraphicElement) || (getParent()->getXAxis()->isLinearAxis() && getParent()->getYAxis()->isLinearAxis())) {
|
||||
const QPolygonF path=transformToPolygon(points);
|
||||
painter.drawPolygon(path);
|
||||
painter.drawPolygon(points);
|
||||
} else {
|
||||
// for non-linear axes, a line might not be drawn as a line, so we need to segment the line (i.e. linear function in coordinate space)
|
||||
// and transform each node to draw the corresponding non-linear curve in pixel-space!
|
||||
auto fTransform=std::bind([](const JKQTPGeometricPlotElement* plot, const QPointF& p) { return plot->transform(p); }, this, std::placeholders::_1);
|
||||
QVector<QPointF> polyp=points;
|
||||
QPolygonF polyp=points;
|
||||
if (polyp.first()!=polyp.last()) polyp.push_back(polyp.first());
|
||||
QPolygonF path=JKQTPSplitPolylineIntoPoints(polyp, fTransform);
|
||||
path=JKQTPSimplyfyLineSegemnts(path);
|
||||
@ -335,12 +334,12 @@ void JKQTPGeoPolygon::draw(JKQTPEnhancedPainter& painter) {
|
||||
}
|
||||
}
|
||||
|
||||
void JKQTPGeoPolygon::setPoints(const QVector<QPointF> &__value)
|
||||
void JKQTPGeoPolygon::setPoints(const QPolygonF &__value)
|
||||
{
|
||||
this->points = __value;
|
||||
}
|
||||
|
||||
QVector<QPointF> JKQTPGeoPolygon::getPoints() const
|
||||
QPolygonF JKQTPGeoPolygon::getPoints() const
|
||||
{
|
||||
return this->points;
|
||||
}
|
||||
@ -378,22 +377,22 @@ void JKQTPGeoPolygon::removePoint(int i)
|
||||
points.remove(i);
|
||||
}
|
||||
|
||||
QVector<QPointF>::iterator JKQTPGeoPolygon::pointsBegin()
|
||||
QPolygonF::iterator JKQTPGeoPolygon::pointsBegin()
|
||||
{
|
||||
return points.begin();
|
||||
}
|
||||
|
||||
QVector<QPointF>::iterator JKQTPGeoPolygon::pointsEnd()
|
||||
QPolygonF::iterator JKQTPGeoPolygon::pointsEnd()
|
||||
{
|
||||
return points.end();
|
||||
}
|
||||
|
||||
QVector<QPointF>::const_iterator JKQTPGeoPolygon::pointsCBegin() const
|
||||
QPolygonF::const_iterator JKQTPGeoPolygon::pointsCBegin() const
|
||||
{
|
||||
return points.cbegin();
|
||||
}
|
||||
|
||||
QVector<QPointF>::const_iterator JKQTPGeoPolygon::pointsCEnd() const
|
||||
QPolygonF::const_iterator JKQTPGeoPolygon::pointsCEnd() const
|
||||
{
|
||||
return points.cend();
|
||||
}
|
||||
@ -460,7 +459,7 @@ void JKQTPGeoEllipse::drawInternal(JKQTPEnhancedPainter& painter, double angleSt
|
||||
} else if (mode==InternalDrawMode::Pie) {
|
||||
QPointF first, last;
|
||||
rect=JKQTPSplitEllipseIntoPoints(fTransform, x,y,width/2.0, height/2.0, angleStart, angleStop, 0, nullptr, nullptr, &first, &last);
|
||||
QVector<QPointF> pie;
|
||||
QPolygonF pie;
|
||||
pie<<last<<QPointF(x,y)<<first;
|
||||
rect.append(JKQTPSimplyfyLineSegemnts(JKQTPSplitPolylineIntoPoints(pie, fTransform)));
|
||||
} else if (mode==InternalDrawMode::Chord) {
|
||||
|
@ -208,14 +208,14 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPolygon: public JKQTPGeoBaseFilled {
|
||||
* \param points points on the polygon
|
||||
* \param drawMode draw the rectangle as a graphic or geometric element
|
||||
*/
|
||||
JKQTPGeoPolygon(JKQTBasePlotter* parent, const QVector<QPointF>& points, DrawMode drawMode=DrawAsGraphicElement);
|
||||
JKQTPGeoPolygon(JKQTBasePlotter* parent, const QPolygonF& points, DrawMode drawMode=DrawAsGraphicElement);
|
||||
/** \brief class constructor
|
||||
*
|
||||
* \param parent the parent plotter object
|
||||
* \param points points on the polygon
|
||||
* \param drawMode draw the rectangle as a graphic or geometric element
|
||||
*/
|
||||
JKQTPGeoPolygon(JKQTPlotter* parent, const QVector<QPointF>& points, DrawMode drawMode=DrawAsGraphicElement);
|
||||
JKQTPGeoPolygon(JKQTPlotter* parent, const QPolygonF& points, DrawMode drawMode=DrawAsGraphicElement);
|
||||
|
||||
/** \brief class constructor
|
||||
*
|
||||
@ -245,9 +245,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPolygon: public JKQTPGeoBaseFilled {
|
||||
virtual void draw(JKQTPEnhancedPainter& painter) override;
|
||||
|
||||
/** \copydoc points */
|
||||
void setPoints(const QVector<QPointF> & __value);
|
||||
void setPoints(const QPolygonF & __value);
|
||||
/** \copydoc points */
|
||||
QVector<QPointF> getPoints() const;
|
||||
QPolygonF getPoints() const;
|
||||
|
||||
/** \brief append a point to the polygon \see points */
|
||||
void appendPoint(const QPointF& p);
|
||||
@ -266,17 +266,17 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoPolygon: public JKQTPGeoBaseFilled {
|
||||
/** \brief deletes the i-the point \see points */
|
||||
void removePoint(int i);
|
||||
/** \brief returns an iterator to the first point \see points */
|
||||
QVector<QPointF>::iterator pointsBegin();
|
||||
QPolygonF::iterator pointsBegin();
|
||||
/** \brief returns an iterator after the last point \see points */
|
||||
QVector<QPointF>::iterator pointsEnd();
|
||||
QPolygonF::iterator pointsEnd();
|
||||
/** \brief returns a constant iterator to the first point \see points */
|
||||
QVector<QPointF>::const_iterator pointsCBegin() const;
|
||||
QPolygonF::const_iterator pointsCBegin() const;
|
||||
/** \brief returns a constant iterator after the last point \see points*/
|
||||
QVector<QPointF>::const_iterator pointsCEnd() const;
|
||||
QPolygonF::const_iterator pointsCEnd() const;
|
||||
|
||||
protected:
|
||||
/** \brief list with all points on the polygon */
|
||||
QVector<QPointF> points;
|
||||
QPolygonF points;
|
||||
};
|
||||
|
||||
/** \brief This JKQTPGeometricPlotElement is used to draw an ellipse
|
||||
|
@ -91,8 +91,8 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
if (getIndexRange(imin, imax)) {
|
||||
|
||||
|
||||
QList<QList<QPointF>> vec_linesP;
|
||||
vec_linesP.push_back(QList<QPointF>());
|
||||
QList<QPolygonF> vec_linesP;
|
||||
vec_linesP.push_back(QPolygonF());
|
||||
intSortData();
|
||||
for (int iii=imin; iii<imax; iii++) {
|
||||
const int i=qBound(imin, getDataIndex(iii), imax);
|
||||
@ -114,7 +114,7 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
} else {
|
||||
if (drawLine) {
|
||||
if (vec_linesP.size()==0 || vec_linesP.last().size()>0)
|
||||
vec_linesP.push_back(QList<QPointF>());
|
||||
vec_linesP.push_back(QPolygonF());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
if (drawLine) {
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): vec_linesP.size()=="<<vec_linesP.size();
|
||||
|
||||
const QList<QList<QPointF>> linesToDraw=JKQTPClipPolyLines(vec_linesP, cliprect);
|
||||
const QList<QPolygonF> linesToDraw=JKQTPClipPolyLines(vec_linesP, cliprect);
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): linesToDraw.size()=="<<linesToDraw.size()<<", clip: x="<<xmin<<".."<<xmax<<", y="<<ymin<<".."<<ymax;
|
||||
for (const auto &linesPFromV : linesToDraw) {
|
||||
//qDebug()<<"JKQTPXYLineGraph::draw(): linesPFromV.size()=="<<linesPFromV.size()<<" useNonvisibleLineCompression="<<getUseNonvisibleLineCompression();
|
||||
|
@ -144,7 +144,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
|
||||
QPolygonF pl, pf;
|
||||
QList<QPointF> ps;
|
||||
QPolygonF ps;
|
||||
|
||||
double xold=-1;
|
||||
double yold=-1;
|
||||
@ -266,7 +266,7 @@ void JKQTPSpecialLineHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
painter.drawPolygon(pf.intersected(cliprect));
|
||||
}
|
||||
|
||||
QList<QList<QPointF>> pl_fordrawing;
|
||||
QList<QPolygonF> pl_fordrawing;
|
||||
if (isHighlighted() || getDrawLine()) {
|
||||
pl_fordrawing=JKQTPClipPolyLine(pl, cliprect);
|
||||
}
|
||||
@ -350,7 +350,7 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
|
||||
QPolygonF pl, pf;
|
||||
QList<QPointF> ps;
|
||||
QPolygonF ps;
|
||||
|
||||
double xold=-1;
|
||||
double yold=-1;
|
||||
@ -452,7 +452,7 @@ void JKQTPSpecialLineVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
|
||||
painter.drawPolygon(pf.intersected(cliprect));
|
||||
}
|
||||
|
||||
QList<QList<QPointF>> pl_fordrawing;
|
||||
QList<QPolygonF> pl_fordrawing;
|
||||
if (isHighlighted() || getDrawLine()) {
|
||||
pl_fordrawing=JKQTPClipPolyLine(pl, cliprect);
|
||||
}
|
||||
|
@ -275,15 +275,15 @@ void JKQTPGraph::drawErrorsAfter(JKQTPEnhancedPainter &)
|
||||
|
||||
}
|
||||
|
||||
QVector<QPointF> JKQTPPlotElement::transform(const QVector<QPointF> &x) const {
|
||||
QVector<QPointF> res;
|
||||
QPolygonF JKQTPPlotElement::transform(const QPolygonF &x) const {
|
||||
QPolygonF res;
|
||||
for (int i=0; i<x.size(); i++) {
|
||||
res.append(transform(x[i]));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
QPainterPath JKQTPPlotElement::transformToLinePath(const QVector<QPointF> &x) const {
|
||||
QPainterPath JKQTPPlotElement::transformToLinePath(const QPolygonF &x) const {
|
||||
QPainterPath res;
|
||||
if (x.size()>0) {
|
||||
res.moveTo(transform(x[0]));
|
||||
|
@ -240,18 +240,13 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPPlotElement: public QObject {
|
||||
inline QPointF backTransform(double x, double y) const {
|
||||
return backTransform(QPointF(x,y));
|
||||
}
|
||||
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules (plot coordinate --> pixels) */
|
||||
QVector<QPointF> transform(const QVector<QPointF>& x) const;
|
||||
/** \brief tool routine that transforms a QPolygonF according to the parent's transformation rules (plot coordinate --> pixels) */
|
||||
QPolygonF transform(const QPolygonF& x) const;
|
||||
|
||||
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules
|
||||
/** \brief tool routine that transforms a QPolygonF according to the parent's transformation rules
|
||||
* and returns a (non-closed) path consisting of lines (plot coordinate --> pixels) */
|
||||
QPainterPath transformToLinePath(const QVector<QPointF>& x) const;
|
||||
QPainterPath transformToLinePath(const QPolygonF& x) const;
|
||||
|
||||
/** \brief tool routine that transforms a QVector<QPointF> according to the parent's transformation rules
|
||||
* and returns a polygon (plot coordinate --> pixels) */
|
||||
inline QPolygonF transformToPolygon(const QVector<QPointF>& x) const {
|
||||
return QPolygonF(transform(x));
|
||||
}
|
||||
|
||||
/** \brief transform all x-coordinates in a vector \a x */
|
||||
QVector<double> transformX(const QVector<double>& x) const;
|
||||
|
@ -304,7 +304,7 @@ void JKQTPGraphErrorStyleMixin::intPlotXYErrorIndicators(JKQTPEnhancedPainter& p
|
||||
bool pastFirst=false;
|
||||
double ebs_px=parent->pt2px(painter, m_errorBarCapSize);
|
||||
QPolygonF polyX, polyY;
|
||||
QList<QPointF> polyXTopPoints, polyXBottomPoints, polyYTopPoints, polyYBottomPoints;
|
||||
QPolygonF polyXTopPoints, polyXBottomPoints, polyYTopPoints, polyYBottomPoints;
|
||||
QList<QColor> errFC, errC;
|
||||
bool defaultErrorColor=true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user