-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.h
More file actions
59 lines (48 loc) · 1.63 KB
/
types.h
File metadata and controls
59 lines (48 loc) · 1.63 KB
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
#pragma once
#include <chrono>
#include <span>
#include <vector>
#include <QDebug>
#include <QObject>
#include <QPolygonF>
// using PolygonF = std::vector<PointF>;
using Degrees = std::vector<double>;
using Data = QPolygonF;
using DataPoint = QPointF;
using index_t = uint8_t;
using namespace Qt::Literals;
namespace r = std ::ranges;
namespace v = std ::views;
template <index_t size>
using MakeSeq = std::make_integer_sequence<index_t, size>;
template <index_t... is>
using Seq = std::integer_sequence<index_t, is...>;
inline constexpr index_t MaxDegree = 32;
namespace chrono = std ::chrono;
struct Clipboard {
virtual QString copy() const = 0;
virtual void paste(QString&&) = 0;
};
inline auto number(double val, int precision) -> QString {
return QString::number(val, 'G', precision).replace(u'.', u',');
};
struct Timer {
decltype(chrono::high_resolution_clock::now()) t1;
static inline std::map<const char*, double> avg{};
static inline std::map<const char*, size_t> ctr{};
std::string_view string_view;
Timer(std::string_view span)
: t1{chrono::high_resolution_clock::now()}
, string_view{span} {
// avg = fl ? avg : double {};
// ctr = fl ? ctr : int {};
}
~Timer() {
using chrono::duration;
using chrono::high_resolution_clock;
using chrono::milliseconds;
duration<double, std::micro> ms_double{chrono::high_resolution_clock::now() - t1};
avg[string_view.data()] += ms_double.count();
qDebug() << u"time ("_s << string_view.data() << u")"_s << (avg[string_view.data()] / ++ctr[string_view.data()]) << u"us"_s;
}
};