Qt 6 works on Windows host
This commit is contained in:
@@ -154,12 +154,16 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
|
||||
axis_type_x = Numeric;
|
||||
floating_axis_type = Free;
|
||||
min_repaint_int = 25;
|
||||
lastw = lasth = 0;
|
||||
inc_x = 1.;
|
||||
buffer = 0;
|
||||
//buffer = 0;
|
||||
gridx = gridy = 1.;
|
||||
history = 5.;
|
||||
visible_time = -1.;
|
||||
thick = lineThickness(this);
|
||||
#if QT_VERSION_MAJOR >= 5
|
||||
thick *= devicePixelRatio();
|
||||
#endif
|
||||
pause_phase = 0.;
|
||||
def_rect.setRect(0., 0., 1., 1.);
|
||||
selrect = def_rect;
|
||||
@@ -193,7 +197,7 @@ Graphic::~Graphic() {
|
||||
delete buttons_menu;
|
||||
#endif
|
||||
delete conf;
|
||||
if (buffer != 0) delete buffer;
|
||||
//if (buffer != 0) delete buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -360,8 +364,21 @@ void Graphic::totalUpdate() {
|
||||
|
||||
void Graphic::canvasPaintEvent() {
|
||||
if (is_lines_update) return;
|
||||
int wid = canvas->width(), hei = canvas->height();
|
||||
int wid = canvas->width (),hei = canvas->height();
|
||||
if (canvas->isHidden() || wid <= 1 || hei <= 1) return;
|
||||
if (!buffer.isNull()) {
|
||||
if (lastw != wid || lasth != hei)
|
||||
buffer = QPixmap();
|
||||
}
|
||||
if (buffer.isNull()) {
|
||||
#if QT_VERSION_MAJOR >= 5
|
||||
const qreal dpr = canvas->devicePixelRatio();
|
||||
buffer = QPixmap(canvas->size() * dpr);
|
||||
buffer.setDevicePixelRatio(dpr);
|
||||
#else
|
||||
buffer = QPixmap(canvas->size());
|
||||
#endif
|
||||
}
|
||||
lastw = wid;
|
||||
lasth = hei;
|
||||
font_sz = fontMetrics().size(0, "0");
|
||||
@@ -372,11 +389,12 @@ void Graphic::canvasPaintEvent() {
|
||||
font_sz.setWidth(font_sz.width() * 8);
|
||||
#endif
|
||||
thick = lineThickness(this);
|
||||
if (buffer != 0) if (buffer->width() != wid || buffer->height() != hei) {delete buffer; buffer = 0;}
|
||||
if (buffer == 0) buffer = new QImage(wid, hei, QImage::Format_RGB32);
|
||||
#if QT_VERSION_MAJOR >= 5
|
||||
thick *= canvas->devicePixelRatio();
|
||||
#endif
|
||||
if (bufferActive) {
|
||||
QPainter p(canvas);
|
||||
p.drawImage(0, 0, *buffer);
|
||||
p.drawPixmap(QPoint(), buffer);
|
||||
painter = &p;
|
||||
fp_size.clear();
|
||||
if (curpos != startpos) drawAction();
|
||||
@@ -391,7 +409,7 @@ void Graphic::canvasPaintEvent() {
|
||||
p.begin(canvas);
|
||||
} else
|
||||
#endif
|
||||
p.begin(buffer);
|
||||
p.begin(&buffer);
|
||||
p.fillRect(canvas->rect(), back_color);
|
||||
painter = &p;
|
||||
p.setFont(font());
|
||||
@@ -423,7 +441,7 @@ void Graphic::canvasPaintEvent() {
|
||||
p.end();
|
||||
if (isOGL && !m_fakeGL) return;
|
||||
p.begin(canvas);
|
||||
p.drawImage(0, 0, *buffer);
|
||||
p.drawPixmap(QPoint(), buffer);
|
||||
p.end();
|
||||
}
|
||||
|
||||
@@ -1137,6 +1155,9 @@ void Graphic::drawGrid() {
|
||||
cy = 0;
|
||||
cx = gbx - 5;
|
||||
grid_pen.setWidth(qMax<int>(qMax<int>(qRound(thick / 1.4), 1), grid_pen.width()));
|
||||
#if QT_VERSION_MAJOR >= 5
|
||||
grid_pen.setCosmetic(true);
|
||||
#endif
|
||||
QFont sf = font();
|
||||
QFont nf = sf;
|
||||
sf.setPointSizeF(qMax<qreal>(sf.pointSizeF() / 1.6, 7.));
|
||||
@@ -1254,7 +1275,11 @@ void Graphic::drawGrid() {
|
||||
painter->drawText(gbx, chei - font_sz.height(), wid, font_sz.height(), Qt::AlignCenter, label_x);
|
||||
}
|
||||
|
||||
painter->setPen(QPen(grid_pen.color(), qMax<int>(thick, grid_pen.width())));
|
||||
QPen outer_pen(grid_pen.color(), qMax<int>(thick, grid_pen.width()));
|
||||
#if QT_VERSION_MAJOR >= 5
|
||||
outer_pen.setCosmetic(true);
|
||||
#endif
|
||||
painter->setPen(outer_pen);
|
||||
painter->drawRect(gbx, -1, wid + 6, hei + 6);
|
||||
}
|
||||
|
||||
@@ -1369,7 +1394,12 @@ QString Graphic::pointCoords(QPointF point, bool x, bool y) {
|
||||
if (axis_type_x == Numeric)
|
||||
ret += QString::number(point.x(), 'f', 3);
|
||||
else
|
||||
ret += QDateTime::fromMSecsSinceEpoch(point.x()).toString(Qt::SystemLocaleShortDate);
|
||||
ret +=
|
||||
#if QT_VERSION_MAJOR <= 5
|
||||
QDateTime::fromMSecsSinceEpoch(point.x()).toString(Qt::SystemLocaleShortDate);
|
||||
#else
|
||||
locale().toString(QDateTime::fromMSecsSinceEpoch(point.x()), QLocale::ShortFormat);
|
||||
#endif
|
||||
}
|
||||
if (y) {
|
||||
if (ret.size() > 1) ret += " ; ";
|
||||
@@ -1384,7 +1414,11 @@ void Graphic::drawGuides() {
|
||||
if (!guides || !isHover) return;
|
||||
int wid = canvas->width(), hei = canvas->height();
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(QPen(grid_pen.color(), qMax<int>(qRound(thick / 1.4), 1)));
|
||||
QPen gpen(grid_pen.color(), qMax<int>(qRound(thick / 1.4), 1));
|
||||
#if QT_VERSION_MAJOR >= 5
|
||||
gpen.setCosmetic(true);
|
||||
#endif
|
||||
painter->setPen(gpen);
|
||||
painter->resetTransform();
|
||||
painter->setClipping(true);
|
||||
painter->setClipRect(QRect(gridborder.x(), 0, wid - gridborder.x(), hei - gridborder.y()));
|
||||
@@ -1640,7 +1674,7 @@ void Graphic::swapToBuffer() {
|
||||
#ifdef HAS_GL
|
||||
if (isOGL && canvas_gl) {
|
||||
timg = canvas_gl->grabFrameBuffer();
|
||||
QPainter p(buffer);
|
||||
QPainter p(&buffer);
|
||||
p.drawImage(0, 0, timg);
|
||||
p.end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user