Engauge Digitizer 2
Loading...
Searching...
No Matches
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
12static QHash<ColorPalette, QColor> colorPaletteLookupTable;
13static QHash<QSysInfo::Endian, QString> endianLookupTable;
14
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
43QString 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
@ COLOR_PALETTE_TRANSPARENT
@ COLOR_PALETTE_GREEN
@ COLOR_PALETTE_MAGENTA
@ COLOR_PALETTE_BLACK
@ COLOR_PALETTE_GOLD
@ COLOR_PALETTE_RED
@ COLOR_PALETTE_BLUE
@ COLOR_PALETTE_CYAN
@ COLOR_PALETTE_YELLOW
const int INNER_RADIUS_MIN
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
QString EndianToString(QSysInfo::Endian endian)
Definition EnumsToQt.cpp:43
QColor ColorPaletteToQColor(ColorPalette color)
Definition EnumsToQt.cpp:15