mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: for printing/mobile access ProfileScene directly
Instead of using the interactive ProfileWidget2, just use the ProfileScene to render the profile for printing, export and mobile. One layer (QWidget) less. This removes all the kludges for handling DPR on mobile. Thus, the rendering will now be off and have to be fixed by redoing the scaling code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
84ebd1d67a
commit
51dc5113c2
10 changed files with 70 additions and 136 deletions
|
@ -1,16 +1,18 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "printer.h"
|
||||
#include "templatelayout.h"
|
||||
#include "core/dive.h" // for get_dive_by_uniq_id()
|
||||
#include "core/statistics.h"
|
||||
#include "core/qthelper.h"
|
||||
#include "profile-widget/profilescene.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <QPainter>
|
||||
#include <QPrinter>
|
||||
#include <QtWebKitWidgets>
|
||||
#include <QWebElementCollection>
|
||||
#include <QWebElement>
|
||||
#include "profile-widget/profilewidget2.h"
|
||||
|
||||
Printer::Printer(QPaintDevice *paintDevice, const print_options &printOptions, const template_options &templateOptions, PrintMode printMode, bool inPlanner) :
|
||||
paintDevice(paintDevice),
|
||||
|
@ -29,15 +31,14 @@ Printer::~Printer()
|
|||
}
|
||||
|
||||
void Printer::putProfileImage(const QRect &profilePlaceholder, const QRect &viewPort, QPainter *painter,
|
||||
struct dive *dive, ProfileWidget2 *profile)
|
||||
struct dive *dive, ProfileScene *profile)
|
||||
{
|
||||
int x = profilePlaceholder.x() - viewPort.x();
|
||||
int y = profilePlaceholder.y() - viewPort.y();
|
||||
// use the placeHolder and the viewPort position to calculate the relative position of the dive profile.
|
||||
QRect pos(x, y, profilePlaceholder.width(), profilePlaceholder.height());
|
||||
|
||||
profile->setProfileState(dive, 0);
|
||||
profile->plotDive(dive, 0, true);
|
||||
profile->plotDive(dive, 0, nullptr, true);
|
||||
profile->draw(painter, pos);
|
||||
}
|
||||
|
||||
|
@ -109,11 +110,7 @@ void Printer::render(int pages)
|
|||
// Scale the fonts in the printed profile accordingly.
|
||||
// This is arbitrary, but it seems to work reasonably well.
|
||||
double printFontScale = collection.count() > 0 ? collection[0].geometry().size().height() / 600.0 : 1.0;
|
||||
auto profile = std::make_unique<ProfileWidget2>(nullptr, printFontScale, nullptr);
|
||||
|
||||
// apply printing settings to profile
|
||||
profile->setFrameStyle(QFrame::NoFrame);
|
||||
profile->setPrintMode(!printOptions.color_selected);
|
||||
auto profile = std::make_unique<ProfileScene>(printFontScale, true, !printOptions.color_selected);
|
||||
|
||||
// render the Qwebview
|
||||
QPainter painter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue