forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreenshoter.hpp
107 lines (85 loc) · 2.32 KB
/
screenshoter.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once
#include "storage/storage_defines.hpp"
#include "drape_frontend/visual_params.hpp"
#include "geometry/rect2d.hpp"
#include <QtWidgets/QOpenGLWidget>
#include <list>
#include <string>
class Framework;
namespace qt
{
struct ScreenshotParams
{
static uint32_t constexpr kDefaultWidth = 576;
static uint32_t constexpr kDefaultHeight = 720;
using TStatusChangedFn = std::function<void(std::string const & /* status */, bool finished)>;
enum class Mode
{
Points,
Rects,
KmlFiles
};
Mode m_mode = Mode::Points;
std::string m_points;
std::string m_rects;
std::string m_kmlPath;
std::string m_dstPath;
uint32_t m_width = kDefaultWidth;
uint32_t m_height = kDefaultHeight;
double m_dpiScale = df::VisualParams::kXhdpiScale;
TStatusChangedFn m_statusChangedFn;
};
class Screenshoter
{
public:
Screenshoter(ScreenshotParams const & screenshotParams, Framework & framework,
QOpenGLWidget * widget);
void Start();
void OnCountryChanged(storage::CountryId countryId);
void OnPositionReady();
void OnGraphicsReady();
private:
enum class State : uint8_t
{
NotStarted,
LoadKml,
WaitPosition,
WaitCountries,
WaitGraphics,
Ready,
FileError,
ParamsError,
Done
};
void ProcessNextItem();
void PrepareToProcessKml();
void ProcessNextKml();
void ProcessNextRect();
void ProcessNextPoint();
void PrepareCountries();
void SaveScreenshot();
void WaitPosition();
void WaitGraphics();
void ChangeState(State newState, std::string const & msg = "");
size_t GetItemsToProcessCount();
bool PrepareItemsToProcess();
bool PrepareKmlFiles();
bool PreparePoints();
bool PrepareRects();
bool LoadRects(std::string const & rects);
bool LoadPoints(std::string const & points);
friend std::string DebugPrint(State state);
State m_state = State::NotStarted;
ScreenshotParams m_screenshotParams;
Framework & m_framework;
QOpenGLWidget * m_widget;
std::list<std::string> m_filesToProcess;
std::list<std::pair<m2::PointD, int>> m_pointsToProcess;
std::list<m2::RectD> m_rectsToProcess;
size_t m_itemsCount = 0;
std::set<storage::CountryId> m_countriesToDownload;
std::string m_nextScreenshotName;
};
std::string DebugPrint(Screenshoter::State state);
std::string DebugPrint(ScreenshotParams::Mode mode);
} // namespace qt