printing: use independent profile instance for printing plan

In analogy to normal printing, don't misuse the mainwindow's
profile widget to do the printing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-04-07 08:04:56 +02:00 committed by Dirk Hohndel
parent 956a6d6c68
commit 811c8a441e

View file

@ -609,13 +609,15 @@ void PlannerWidgets::printDecoPlan()
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setRenderHint(QPainter::SmoothPixmapTransform);
ProfileWidget2 *profile = MainWindow::instance()->graphics; // TODO: Annoyingly, this still needs a parent window? Otherwise,
QSize origSize = profile->size(); // the profile is shown as its own window, when calling show() below.
auto profile = std::make_unique<ProfileWidget2>(DivePlannerPointsModel::instance(), MainWindow::instance());
profile->show(); // Ominous: if the scene isn't shown, parts of the plot are missing. Needs investigation.
profile->resize(renderSize.toSize()); profile->resize(renderSize.toSize());
profile->setPlanState(&displayed_dive, 0);
profile->plotDive(&displayed_dive, 0, true, true);
profile->setPrintMode(true); profile->setPrintMode(true);
profile->render(&painter); profile->render(&painter);
profile->resize(origSize);
profile->setPrintMode(false);
QByteArray byteArray; QByteArray byteArray;
QBuffer buffer(&byteArray); QBuffer buffer(&byteArray);