-
Notifications
You must be signed in to change notification settings - Fork 3
/
qcpl_export.h
87 lines (66 loc) · 1.83 KB
/
qcpl_export.h
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
#ifndef QCPL_EXPORT_H
#define QCPL_EXPORT_H
#include <QVector>
#include <QJsonObject>
QT_BEGIN_NAMESPACE
class QTextStream;
QT_END_NAMESPACE
class QCustomPlot;
namespace QCPL {
struct GraphDataExportSettings
{
bool csv = false;
bool systemLocale = false;
bool transposed = false;
int numberPrecision = 6;
bool mergePoints = false;
};
class BaseGraphDataExporter
{
public:
BaseGraphDataExporter(const GraphDataExportSettings& settings, bool noResult = false);
virtual ~BaseGraphDataExporter();
QString format(const double& v);
void addValue(const QString& v) { addValue(_stream, v); }
void addValue(const double& v) { addValue(_stream, format(v)); }
void addSeparator() { addSeparator(_stream); }
void addNewline() { addNewline(_stream); }
virtual QString result() const { return _result; }
void toClipboard();
protected:
bool _quote, _csv;
QString _formatted;
QTextStream *_formatter;
QString _result;
QTextStream *_stream = nullptr;
void addValue(QTextStream* stream, const QString& v);
void addSeparator(QTextStream* stream);
void addNewline(QTextStream* stream);
};
class GraphDataExporter
{
public:
GraphDataExporter(const GraphDataExportSettings& settings);
~GraphDataExporter();
void add(const double& v);
void add(const double& x, const double& y);
void add(const QVector<double>& vs);
void toClipboard();
private:
class ExporterImpl* _impl;
QString _prev, _prevX, _prevY;
bool _merge;
};
struct ExportToImageProps
{
QString fileName;
int width = 0;
int height = 0;
bool proportional = true;
bool scalePixels = false;
QJsonObject toJson() const;
void fromJson(const QJsonObject& obj);
};
bool exportImageDlg(QCustomPlot* plot, ExportToImageProps& props);
} // namespace QCPL
#endif // QCPL_EXPORT_H