fix for issue #45:

- for Qt 5.15: added missing #include statements that became necessary since Qt 5.15
- for Qt 5.15: fixed use of several deprecated functions
- for Qt 5.15/6: removed usage of QMatrix
This commit is contained in:
jkriege2 2020-08-14 14:12:59 +02:00
parent 35965b2e09
commit 7e9bad29b4
14 changed files with 18 additions and 30 deletions

View File

@ -38,7 +38,7 @@ In addition, a `JKQTPSpecialLineHorizontalGraph` is filled using an image `examp
graphF->setSpecialLineType(JKQTPDirectLine); graphF->setSpecialLineType(JKQTPDirectLine);
graphF->setDrawLine(true); graphF->setDrawLine(true);
graphF->setFillTexture(QPixmap(":/example.bmp")); graphF->setFillTexture(QPixmap(":/example.bmp"));
graphF->setFillTransform(QMatrix(0.5,0,0,0.5,0,0).rotate(45)); graphF->setFillTransform(QTransform(0.5,0,0,0.5,0,0).rotate(45));
graphF->setFillCurve(true); graphF->setFillCurve(true);
graphF->setLineWidth(0.5); graphF->setLineWidth(0.5);
``` ```

View File

@ -90,7 +90,7 @@ int main(int argc, char* argv[])
graphF->setSpecialLineType(JKQTPDirectLine); graphF->setSpecialLineType(JKQTPDirectLine);
graphF->setDrawLine(true); graphF->setDrawLine(true);
graphF->setFillTexture(QPixmap(":/example.bmp")); graphF->setFillTexture(QPixmap(":/example.bmp"));
graphF->setFillTransform(QMatrix(0.5,0,0,0.5,0,0).rotate(45)); graphF->setFillTransform(QTransform(0.5,0,0,0.5,0,0).rotate(45));
graphF->setFillCurve(true); graphF->setFillCurve(true);
graphF->setLineWidth(0.5); graphF->setLineWidth(0.5);

View File

@ -244,7 +244,7 @@ JKQTPGraphSymbols String2JKQTPGraphSymbols(const QString& pos) {
QPolygonF jkqtpRotateRect(QRectF r, double angle) { QPolygonF jkqtpRotateRect(QRectF r, double angle) {
QPolygonF p; QPolygonF p;
QMatrix m; QTransform m;
m.rotate(angle); m.rotate(angle);
p.append(m.map(r.bottomLeft())); p.append(m.map(r.bottomLeft()));
p.append(m.map(r.bottomRight())); p.append(m.map(r.bottomRight()));

View File

@ -29,7 +29,7 @@
#include <QAction> #include <QAction>
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <QPainterPath>
/** /**
* \brief saves the given property (for which also a default_property exists) into the given settings object * \brief saves the given property (for which also a default_property exists) into the given settings object
@ -1447,7 +1447,7 @@ void JKQTFPQScaleBarXPlot::drawGraph(QPainter& painter) {
painter.drawLine(QLineF(xx1, yy1, xx2, yy2)); painter.drawLine(QLineF(xx1, yy1, xx2, yy2));
painter.setFont(font); painter.setFont(font);
QFontMetrics fm=painter.fontMetrics(); QFontMetrics fm=painter.fontMetrics();
painter.drawText(static_cast<int>(xx1+(xx2-xx1)/2-fm.width(s)/2), static_cast<int>(yy1+3*lineWidth+fm.ascent()), s); painter.drawText(static_cast<int>(xx1+(xx2-xx1)/2-fm.horizontalAdvance(s)/2), static_cast<int>(yy1+3*lineWidth+fm.ascent()), s);
} else if (position==JKQTFPQScaleBarXPlot::TopLeft) { } else if (position==JKQTFPQScaleBarXPlot::TopLeft) {
yy1=parent->getInternalPlotBorderTop()+yDistance; yy1=parent->getInternalPlotBorderTop()+yDistance;
yy2=yy1; yy2=yy1;
@ -1458,7 +1458,7 @@ void JKQTFPQScaleBarXPlot::drawGraph(QPainter& painter) {
painter.drawLine(QLineF(xx1, yy1, xx2, yy2)); painter.drawLine(QLineF(xx1, yy1, xx2, yy2));
painter.setFont(font); painter.setFont(font);
QFontMetrics fm=painter.fontMetrics(); QFontMetrics fm=painter.fontMetrics();
painter.drawText(static_cast<int>(xx1+(xx2-xx1)/2-fm.width(s)/2), static_cast<int>(yy1+3*lineWidth+fm.ascent()), s); painter.drawText(static_cast<int>(xx1+(xx2-xx1)/2-fm.horizontalAdvance(s)/2), static_cast<int>(yy1+3*lineWidth+fm.ascent()), s);
} else if (position==JKQTFPQScaleBarXPlot::BottomLeft) { } else if (position==JKQTFPQScaleBarXPlot::BottomLeft) {
yy1=parent->getInternalPlotBorderTop()+parent->getPlotHeight()-yDistance; yy1=parent->getInternalPlotBorderTop()+parent->getPlotHeight()-yDistance;
yy2=yy1; yy2=yy1;
@ -1469,7 +1469,7 @@ void JKQTFPQScaleBarXPlot::drawGraph(QPainter& painter) {
painter.drawLine(QLineF(xx1, yy1, xx2, yy2)); painter.drawLine(QLineF(xx1, yy1, xx2, yy2));
painter.setFont(font); painter.setFont(font);
QFontMetrics fm=painter.fontMetrics(); QFontMetrics fm=painter.fontMetrics();
painter.drawText(static_cast<int>(xx1+(xx2-xx1)/2-fm.width(s)/2), static_cast<int>(yy1-3*lineWidth-fm.descent()), s); painter.drawText(static_cast<int>(xx1+(xx2-xx1)/2-fm.horizontalAdvance(s)/2), static_cast<int>(yy1-3*lineWidth-fm.descent()), s);
} else if (position==JKQTFPQScaleBarXPlot::BottomRight) { } else if (position==JKQTFPQScaleBarXPlot::BottomRight) {
yy1=parent->getInternalPlotBorderTop()+parent->getPlotHeight()-yDistance; yy1=parent->getInternalPlotBorderTop()+parent->getPlotHeight()-yDistance;
yy2=yy1; yy2=yy1;
@ -1480,7 +1480,7 @@ void JKQTFPQScaleBarXPlot::drawGraph(QPainter& painter) {
painter.drawLine(QLineF(xx1, yy1, xx2, yy2)); painter.drawLine(QLineF(xx1, yy1, xx2, yy2));
painter.setFont(font); painter.setFont(font);
QFontMetrics fm=painter.fontMetrics(); QFontMetrics fm=painter.fontMetrics();
painter.drawText(static_cast<int>(xx1+(xx2-xx1)/2-fm.width(s)/2), static_cast<int>(yy1-3*lineWidth-fm.descent()), s); painter.drawText(static_cast<int>(xx1+(xx2-xx1)/2-fm.horizontalAdvance(s)/2), static_cast<int>(yy1-3*lineWidth-fm.descent()), s);
} }

View File

@ -28,6 +28,7 @@
#include <QFontDatabase> #include <QFontDatabase>
#include <typeinfo> #include <typeinfo>
#include <QApplication> #include <QApplication>
#include <QPainterPath>
const double JKQTMathText::ABS_MIN_LINEWIDTH=0.02; const double JKQTMathText::ABS_MIN_LINEWIDTH=0.02;

View File

@ -733,8 +733,8 @@ JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, QPointF bottomleft, QP
this->y=bottomleft.y()+this->height/2.0; this->y=bottomleft.y()+this->height/2.0;
} }
QMatrix JKQTPGeoRectangle::getMatrix() { QTransform JKQTPGeoRectangle::getTransform() {
QMatrix trans; QTransform trans;
trans.rotate(angle); trans.rotate(angle);
return trans; return trans;
} }
@ -765,7 +765,7 @@ bool JKQTPGeoRectangle::getYMinMax(double& miny, double& maxy, double& smallestG
} }
QPolygonF JKQTPGeoRectangle::getPolygon() { QPolygonF JKQTPGeoRectangle::getPolygon() {
QMatrix m=getMatrix(); QTransform m=getTransform();
QPolygonF rect; QPolygonF rect;
rect.append(m.map(QPointF(0-width/2.0, 0-height/2.0))); rect.append(m.map(QPointF(0-width/2.0, 0-height/2.0)));
rect.append(m.map(QPointF(0-width/2.0, 0+height/2.0))); rect.append(m.map(QPointF(0-width/2.0, 0+height/2.0)));

View File

@ -679,7 +679,7 @@ protected:
/** \brief rotation angle of rectangle [degrees] around (x,y) */ /** \brief rotation angle of rectangle [degrees] around (x,y) */
double angle; double angle;
/** \brief returns the transformation matrix used for this rectangle */ /** \brief returns the transformation matrix used for this rectangle */
QMatrix getMatrix(); QTransform getTransform();
/** \brief returns a QPolygonF which represents the rectangle after rotation, but still in the world coordinate system, not in the screen/widget system */ /** \brief returns a QPolygonF which represents the rectangle after rotation, but still in the world coordinate system, not in the screen/widget system */
QPolygonF getPolygon(); QPolygonF getPolygon();
}; };
@ -974,7 +974,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGeoArc: public JKQTPGeoBaseLine {
/** \brief closing mode for arcs: secand or pie */ /** \brief closing mode for arcs: secand or pie */
/** \brief returns the transformation matrix used for this rectangle */ /** \brief returns the transformation matrix used for this rectangle */
QMatrix getMatrix(); QTransform getTransform();
/** \brief returns a QPolygonF which represents the rectangle after rotation, but still in the world coordinate system, not in the screen/widget system */ /** \brief returns a QPolygonF which represents the rectangle after rotation, but still in the world coordinate system, not in the screen/widget system */
QPolygonF getPolygon(); QPolygonF getPolygon();

View File

@ -449,7 +449,7 @@ void JKQTPRGBMathImage::drawOutside(JKQTPEnhancedPainter& painter, QRect /*leftS
QRectF cb(tX, tY, gbarWidth, parent->pt2px(painter, colorBarWidth)); QRectF cb(tX, tY, gbarWidth, parent->pt2px(painter, colorBarWidth));
QMatrix mt; QTransform mt;
mt.rotate(90); mt.rotate(90);
painter.drawImage(cb, l[li].paletteImage.transformed(mt)); painter.drawImage(cb, l[li].paletteImage.transformed(mt));
QPen p=painter.pen(); QPen p=painter.pen();

View File

@ -254,11 +254,6 @@ void JKQTPGraphErrorStyleMixin::setErrorFillBrush(const QBrush &b)
m_errorFillColor=b.color(); m_errorFillColor=b.color();
} }
void JKQTPGraphErrorStyleMixin::setErrorFillTransform(const QMatrix &b)
{
m_errorFillBrush.setMatrix(b);
}
void JKQTPGraphErrorStyleMixin::setErrorFillTransform(const QTransform &b) void JKQTPGraphErrorStyleMixin::setErrorFillTransform(const QTransform &b)
{ {
m_errorFillBrush.setTransform(b); m_errorFillBrush.setTransform(b);

View File

@ -146,8 +146,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphErrorStyleMixin {
/** \brief sets an error indicator fill brush (overwrites all internal properties!) */ /** \brief sets an error indicator fill brush (overwrites all internal properties!) */
void setErrorFillBrush(const QBrush& b); void setErrorFillBrush(const QBrush& b);
/** \brief sets an error indicator fill transformation matrix*/
void setErrorFillTransform(const QMatrix& b);
/** \brief sets an error indicator fill transformation */ /** \brief sets an error indicator fill transformation */
void setErrorFillTransform(const QTransform& b); void setErrorFillTransform(const QTransform& b);

View File

@ -364,10 +364,6 @@ void JKQTPGraphFillStyleMixin::setFillBrush(const QBrush &b)
m_fillColor=b.color(); m_fillColor=b.color();
} }
void JKQTPGraphFillStyleMixin::setFillTransform(const QMatrix &b)
{
m_fillBrush.setMatrix(b);
}
void JKQTPGraphFillStyleMixin::setFillTransform(const QTransform &b) void JKQTPGraphFillStyleMixin::setFillTransform(const QTransform &b)
{ {

View File

@ -313,8 +313,6 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPGraphFillStyleMixin {
/** \brief sets a fill brush (overwrites all internal properties!) */ /** \brief sets a fill brush (overwrites all internal properties!) */
void setFillBrush(const QBrush& b); void setFillBrush(const QBrush& b);
/** \brief sets a fill transformation matrix*/
void setFillTransform(const QMatrix& b);
/** \brief sets a fill transformation */ /** \brief sets a fill transformation */
void setFillTransform(const QTransform& b); void setFillTransform(const QTransform& b);

View File

@ -199,7 +199,7 @@ void JKQTPColorPaletteStyleAndToolsMixin::cbDrawOutside(JKQTPEnhancedPainter& pa
QRect cb(topSpace.x()+(topSpace.width()-barWidth)/2, static_cast<int>(topSpace.bottom()-cbParent->pt2px(painter, colorBarOffset+(colorBarWidth))), barWidth, static_cast<int>(cbParent->pt2px(painter, colorBarWidth))); QRect cb(topSpace.x()+(topSpace.width()-barWidth)/2, static_cast<int>(topSpace.bottom()-cbParent->pt2px(painter, colorBarOffset+(colorBarWidth))), barWidth, static_cast<int>(cbParent->pt2px(painter, colorBarWidth)));
//qDebug()<<"t: "<<imageName<<topSpace<<topSpace.bottom()<<colorBarOffset<<"\n "<<cb; //qDebug()<<"t: "<<imageName<<topSpace<<topSpace.bottom()<<colorBarOffset<<"\n "<<cb;
QMatrix rm; QTransform rm;
rm.rotate(90); rm.rotate(90);
painter.drawImage(cb, b.transformed(rm)); painter.drawImage(cb, b.transformed(rm));
QPen p=painter.pen(); QPen p=painter.pen();
@ -699,7 +699,7 @@ void JKQTPColorPaletteWithModifierStyleAndToolsMixin::cbDrawOutside(JKQTPEnhance
QRect cb(topSpace.x()+(topSpace.width()-barWidth)/2, topSpace.bottom()-cbParent->pt2px(painter, colorBarOffset+((modifierMode==JKQTPMathImageModifierMode::ModifyNone)?colorBarWidth:colorBarModifiedWidth)), barWidth, cbParent->pt2px(painter, (modifierMode==JKQTPMathImageModifierMode::ModifyNone)?colorBarWidth:colorBarModifiedWidth)); QRect cb(topSpace.x()+(topSpace.width()-barWidth)/2, topSpace.bottom()-cbParent->pt2px(painter, colorBarOffset+((modifierMode==JKQTPMathImageModifierMode::ModifyNone)?colorBarWidth:colorBarModifiedWidth)), barWidth, cbParent->pt2px(painter, (modifierMode==JKQTPMathImageModifierMode::ModifyNone)?colorBarWidth:colorBarModifiedWidth));
//qDebug()<<"t: "<<imageName<<topSpace<<topSpace.bottom()<<colorBarOffset<<"\n "<<cb; //qDebug()<<"t: "<<imageName<<topSpace<<topSpace.bottom()<<colorBarOffset<<"\n "<<cb;
QMatrix rm; QTransform rm;
rm.rotate(90); rm.rotate(90);
painter.drawImage(cb, b.transformed(rm)); painter.drawImage(cb, b.transformed(rm));
QPen p=painter.pen(); QPen p=painter.pen();

View File

@ -936,7 +936,7 @@ void JKQTPlotter::wheelEvent ( QWheelEvent * event ) {
if (itAction.value()==JKQTPMouseWheelActions::jkqtpmwaZoomByWheel) { if (itAction.value()==JKQTPMouseWheelActions::jkqtpmwaZoomByWheel) {
//if (act==JKQTPMouseWheelActions::jkqtpmwaZoomByWheel) { //if (act==JKQTPMouseWheelActions::jkqtpmwaZoomByWheel) {
//qDebug()<<"wheelEvent("<<event->modifiers()<<"):ZoomByWheel"; //qDebug()<<"wheelEvent("<<event->modifiers()<<"):ZoomByWheel";
double factor=pow(2.0, 1.0*static_cast<double>(event->delta())/120.0)*2.0; const double factor=pow(2.0, 1.0*static_cast<double>(event->angleDelta().y())/120.0)*2.0;
double xmin=plotter->p2x(static_cast<double>(event->x())/magnification-static_cast<double>(plotter->getPlotWidth())/factor); double xmin=plotter->p2x(static_cast<double>(event->x())/magnification-static_cast<double>(plotter->getPlotWidth())/factor);
double xmax=plotter->p2x(static_cast<double>(event->x())/magnification+static_cast<double>(plotter->getPlotWidth())/factor); double xmax=plotter->p2x(static_cast<double>(event->x())/magnification+static_cast<double>(plotter->getPlotWidth())/factor);
double ymin=plotter->p2y(static_cast<double>(event->y())/magnification-static_cast<double>(getPlotYOffset())+static_cast<double>(plotter->getPlotHeight())/factor); double ymin=plotter->p2y(static_cast<double>(event->y())/magnification-static_cast<double>(getPlotYOffset())+static_cast<double>(plotter->getPlotHeight())/factor);