QElectroTech
0.200.1-dev
Loading...
Searching...
No Matches
diagramsortkeys.h
Go to the documentation of this file.
1
/*
2
Copyright 2006-2026 The QElectroTech Team
3
This file is part of QElectroTech.
4
5
QElectroTech is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 2 of the License, or
8
(at your option) any later version.
9
10
QElectroTech is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
#ifndef DIAGRAMSORTKEYS_H
19
#define DIAGRAMSORTKEYS_H
20
21
#include <QPointF>
22
#include <QString>
23
#include <QtGlobal>
24
29
namespace
DiagramSortKeys
{
30
36
inline
QString
coordinateKey
(
double
v)
37
{
38
//Diagram coordinates are nowhere near this range; the offset and
39
//width just need to be big enough that shifted values are always
40
//non-negative and always the same digit count.
41
constexpr
double
offset = 1e9;
42
qint64 scaled = qint64(qRound64((v + offset) * 10000.0));
43
return
QStringLiteral(
"%1"
).arg(scaled, 20, 10, QLatin1Char(
'0'
));
44
}
45
46
inline
QString
positionKey
(
const
QPointF &pos)
47
{
48
return
coordinateKey
(pos.x()) + QLatin1Char(
'|'
) +
coordinateKey
(pos.y());
49
}
50
51
}
52
53
#endif
DiagramSortKeys
Definition
diagramsortkeys.h:29
DiagramSortKeys::coordinateKey
QString coordinateKey(double v)
Definition
diagramsortkeys.h:36
DiagramSortKeys::positionKey
QString positionKey(const QPointF &pos)
Definition
diagramsortkeys.h:46
sources
diagramsortkeys.h
Generated by
1.15.0