-
-
Notifications
You must be signed in to change notification settings - Fork 557
/
Copy pathutil.h
46 lines (37 loc) · 1 KB
/
util.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
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich
#ifndef UTIL
#define UTIL
#include <QColor>
#include <QVector3D>
#include <QEventLoop>
#include <QTimer>
class Util
{
public:
static double nMin(double v1, double v2)
{
if (!std::isnan(v1) && !std::isnan(v2)) return qMin<double>(v1, v2);
else if (!std::isnan(v1)) return v1;
else if (!std::isnan(v2)) return v2;
else return NAN;
}
static double nMax(double v1, double v2)
{
if (!std::isnan(v1) && !std::isnan(v2)) return qMax<double>(v1, v2);
else if (!std::isnan(v1)) return v1;
else if (!std::isnan(v2)) return v2;
else return NAN;
}
static QVector3D colorToVector(QColor color)
{
return QVector3D(color.redF(), color.greenF(), color.blueF());
}
static void waitEvents(int ms)
{
QEventLoop loop;
QTimer::singleShot(ms, &loop, SLOT(quit()));
loop.exec();
}
};
#endif // UTIL