1818#include " core/selection.h"
1919#include " core/taxonomy.h"
2020#include " core/sample.h"
21+ #include " core/string-format.h"
2122#include " profile-widget/profilescene.h"
23+ #include " core/qthelper.h"
2224#include < QDir>
2325#include < QFileInfo>
2426#include < QtConcurrent>
@@ -41,21 +43,51 @@ static constexpr int profileScale = 4;
4143static constexpr int profileWidth = 800 * profileScale;
4244static constexpr int profileHeight = 600 * profileScale;
4345
44- static void exportProfile (ProfileScene &profile, const struct dive &dive, const QString &filename)
46+ static QString profileText (const struct dive &dive)
47+ {
48+ QString text;
49+
50+ if (dive.dive_site ->name .length () > 0 )
51+ text += " 🗺 " + QString::fromStdString (dive.dive_site ->name ) + " \n " ;
52+ if (dive.when ) {
53+ text += " 🗓️ " + formatDiveDateTime (&dive) + " \n " ;
54+ }
55+ text += " ⏱️: " + formatDiveDuration (&dive) + " \n " ;
56+ text += " ⭳: " + get_depth_string (dive.maxdepth , true ) + " \n " ;
57+ if (dive.watertemp .mkelvin )
58+ text += " 🌡️: " + get_temperature_string (dive.watertemp , true ) + " \n " ;
59+ if (dive.visibility )
60+ text += " 👁: " + QString (" ⭐" ).repeated (dive.visibility ) + " \n " ;
61+ text += formatGas (&dive);
62+
63+ return text;
64+ }
65+
66+ static void exportProfile (ProfileScene &profile, const struct dive &dive, const QString &filename, bool diveinfo)
4567{
4668 QImage image = QImage (QSize (profileWidth, profileHeight), QImage::Format_RGB32);
4769 QPainter paint;
48- paint.begin (&image);
49- profile.draw (&paint, QRect (0 , 0 , profileWidth, profileHeight), &dive, 0 , nullptr , false );
50- image.save (filename);
70+ paint.begin (&image);
71+ profile.draw (&paint, QRect (0 , 0 , profileWidth, profileHeight), &dive, 0 , nullptr , false );
72+ if (diveinfo) {
73+ QPixmap logo (" :poster-icon" );
74+ paint.drawPixmap (profileWidth - 210 , profileHeight * 0.9 - 200 , 200 , 200 , logo);
75+ QString text = profileText (dive);
76+ QPen pen = QPen (Qt::darkBlue);
77+ paint.setPen (pen);
78+ QFont textfont (" Courier" , 60 , QFont::Bold);
79+ paint.setFont (textfont);
80+ paint.drawText (QRect (0.05 * profileWidth, 0 , profileWidth, profileHeight * 0.9 ), text, Qt::AlignBottom | Qt::AlignLeft);
81+ }
82+ image.save (filename);
5183}
5284
5385static std::unique_ptr<ProfileScene> getPrintProfile ()
5486{
5587 return std::make_unique<ProfileScene>((double )profileScale, true , false );
5688}
5789
58- void exportProfile (QString filename, bool selected_only, ExportCallback &cb)
90+ void exportProfile (QString filename, bool selected_only, ExportCallback &cb, bool diveinfo )
5991{
6092 int count = 0 ;
6193 if (!filename.endsWith (" .png" , Qt::CaseInsensitive))
@@ -73,7 +105,7 @@ void exportProfile(QString filename, bool selected_only, ExportCallback &cb)
73105 cb.setProgress (done++ * 1000 / todo);
74106 QString fn = count ? fi.path () + QDir::separator () + fi.completeBaseName ().append (QString (" -%1." ).arg (count)) + fi.suffix ()
75107 : filename;
76- exportProfile (*profile, *dive, fn);
108+ exportProfile (*profile, *dive, fn, diveinfo );
77109 ++count;
78110 }
79111}
@@ -138,7 +170,7 @@ void export_TeX(const char *filename, bool selected_only, bool plain, ExportCall
138170 if (selected_only && !dive->selected )
139171 continue ;
140172 cb.setProgress (done++ * 1000 / todo);
141- exportProfile (*profile, *dive, texdir.filePath (QString (" profile%1.png" ).arg (dive->number )));
173+ exportProfile (*profile, *dive, texdir.filePath (QString (" profile%1.png" ).arg (dive->number )), false );
142174 struct tm tm;
143175 utc_mkdate (dive->when , &tm);
144176
0 commit comments