mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: render profile on desktop via QtQuick
This breaks all dynamic features, including animations, zooming tooltips, planner-handles, etc. They will have to be converted one-by-one to QtQuick, which will be a major pain, as the ProfileView is destroyed by Qt6 on reparenting. This means that the view cannot store any persistent state. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7eecc85464
commit
75886dd4d6
25 changed files with 322 additions and 76 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "chartview.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <QGraphicsScene>
|
||||
#include <QQuickWindow>
|
||||
#include <QSGFlatColorMaterial>
|
||||
#include <QSGImageNode>
|
||||
|
|
@ -83,10 +84,15 @@ void ChartPixmapItem::render()
|
|||
|
||||
void ChartPixmapItem::resize(QSizeF size)
|
||||
{
|
||||
QSize s_int(round_up(size.width()), round_up(size.height()));
|
||||
if (img && s_int == img->size())
|
||||
return;
|
||||
painter.reset();
|
||||
img.reset(new QImage(round_up(size.width()), round_up(size.height()), QImage::Format_ARGB32));
|
||||
painter.reset(new QPainter(img.get()));
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
img.reset(new QImage(s_int, QImage::Format_ARGB32));
|
||||
if (!img->isNull()) {
|
||||
painter.reset(new QPainter(img.get()));
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
}
|
||||
rect.setSize(size);
|
||||
setTextureDirty();
|
||||
}
|
||||
|
|
@ -102,6 +108,16 @@ QRectF ChartPixmapItem::getRect() const
|
|||
return rect;
|
||||
}
|
||||
|
||||
void ChartGraphicsSceneItem::draw(QSizeF s, QColor background, QGraphicsScene &scene)
|
||||
{
|
||||
resize(s); // Noop if size doesn't change
|
||||
if (!painter)
|
||||
return; // Happens if we resize to (0,0)
|
||||
img->fill(background);
|
||||
scene.render(painter.get(), QRect(QPoint(), img->size()), scene.sceneRect(), Qt::IgnoreAspectRatio);
|
||||
setTextureDirty();
|
||||
}
|
||||
|
||||
ChartRectItem::ChartRectItem(ChartView &v, size_t z,
|
||||
const QPen &pen, const QBrush &brush, double radius) : ChartPixmapItem(v, z),
|
||||
pen(pen), brush(brush), radius(radius)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue