Engauge Digitizer
2
Loading...
Searching...
No Matches
util
EnumsToQt.cpp
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5
******************************************************************************************************/
6
7
#include "
EngaugeAssert.h
"
8
#include "
EnumsToQt.h
"
9
#include <QHash>
10
#include <QString>
11
12
static
QHash<ColorPalette, QColor>
colorPaletteLookupTable;
13
static
QHash<QSysInfo::Endian, QString>
endianLookupTable;
14
15
QColor
ColorPaletteToQColor
(
ColorPalette
color)
16
{
17
if
(colorPaletteLookupTable.count() == 0) {
18
19
// Initialize
20
colorPaletteLookupTable [
COLOR_PALETTE_BLACK
] =
QColor
(Qt::black);
21
colorPaletteLookupTable [
COLOR_PALETTE_BLUE
] =
QColor
(Qt::blue);
22
colorPaletteLookupTable [
COLOR_PALETTE_CYAN
] =
QColor
(Qt::cyan);
23
colorPaletteLookupTable [
COLOR_PALETTE_GOLD
] =
QColor
(255, 215, 0);
24
colorPaletteLookupTable [
COLOR_PALETTE_GREEN
] =
QColor
(Qt::green);
25
colorPaletteLookupTable [
COLOR_PALETTE_MAGENTA
] =
QColor
(255, 0, 255);
26
colorPaletteLookupTable [
COLOR_PALETTE_RED
] =
QColor
(Qt::red);
27
colorPaletteLookupTable [
COLOR_PALETTE_YELLOW
] =
QColor
(255, 255, 0);
28
colorPaletteLookupTable [
COLOR_PALETTE_TRANSPARENT
] =
QColor
(Qt::transparent);
29
}
30
31
if
(colorPaletteLookupTable.contains (color)) {
32
33
return
colorPaletteLookupTable [color];
34
35
}
else
{
36
37
ENGAUGE_ASSERT
(
false
);
38
return
colorPaletteLookupTable [
COLOR_PALETTE_BLACK
];
39
40
}
41
}
42
43
QString
EndianToString
(QSysInfo::Endian
endian
)
44
{
45
if
(endianLookupTable.count() == 0) {
46
47
// Initialize
48
endianLookupTable [QSysInfo::BigEndian] =
"BigEndian"
;
49
endianLookupTable [QSysInfo::LittleEndian] =
"LittleEndian"
;
50
}
51
52
if
(endianLookupTable.contains (
endian
)) {
53
54
return
endianLookupTable [
endian
];
55
56
}
else
{
57
58
return
"<Unknown>"
;
59
60
}
61
}
ColorPalette
ColorPalette
Definition
ColorPalette.h:12
COLOR_PALETTE_TRANSPARENT
@ COLOR_PALETTE_TRANSPARENT
Definition
ColorPalette.h:21
COLOR_PALETTE_GREEN
@ COLOR_PALETTE_GREEN
Definition
ColorPalette.h:17
COLOR_PALETTE_MAGENTA
@ COLOR_PALETTE_MAGENTA
Definition
ColorPalette.h:18
COLOR_PALETTE_BLACK
@ COLOR_PALETTE_BLACK
Definition
ColorPalette.h:13
COLOR_PALETTE_GOLD
@ COLOR_PALETTE_GOLD
Definition
ColorPalette.h:16
COLOR_PALETTE_RED
@ COLOR_PALETTE_RED
Definition
ColorPalette.h:19
COLOR_PALETTE_BLUE
@ COLOR_PALETTE_BLUE
Definition
ColorPalette.h:14
COLOR_PALETTE_CYAN
@ COLOR_PALETTE_CYAN
Definition
ColorPalette.h:15
COLOR_PALETTE_YELLOW
@ COLOR_PALETTE_YELLOW
Definition
ColorPalette.h:20
INNER_RADIUS_MIN
const int INNER_RADIUS_MIN
Definition
DlgSettingsDigitizeCurve.cpp:35
EngaugeAssert.h
ENGAUGE_ASSERT
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition
EngaugeAssert.h:20
EndianToString
QString EndianToString(QSysInfo::Endian endian)
Definition
EnumsToQt.cpp:43
ColorPaletteToQColor
QColor ColorPaletteToQColor(ColorPalette color)
Definition
EnumsToQt.cpp:15
EnumsToQt.h
Generated on Wed Aug 3 2022 00:00:00 for Engauge Digitizer by
1.10.0