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 "Logger.h"
10#include <QHash>
11#include <QString>
12
13static QHash<ColorPalette, QColor> colorPaletteLookupTable;
14static QHash<QSysInfo::Endian, QString> endianLookupTable;
15
17{
18 if (colorPaletteLookupTable.count() == 0) {
19
20 // Initialize
21 colorPaletteLookupTable [COLOR_PALETTE_BLACK] = QColor (Qt::black);
22 colorPaletteLookupTable [COLOR_PALETTE_BLUE] = QColor (Qt::blue);
23 colorPaletteLookupTable [COLOR_PALETTE_CYAN] = QColor (Qt::cyan);
24 colorPaletteLookupTable [COLOR_PALETTE_GOLD] = QColor (255, 215, 0);
25 colorPaletteLookupTable [COLOR_PALETTE_GREEN] = QColor (Qt::green);
26 colorPaletteLookupTable [COLOR_PALETTE_MAGENTA] = QColor (255, 0, 255);
27 colorPaletteLookupTable [COLOR_PALETTE_RED] = QColor (Qt::red);
28 colorPaletteLookupTable [COLOR_PALETTE_YELLOW] = QColor (255, 255, 0);
29 colorPaletteLookupTable [COLOR_PALETTE_TRANSPARENT] = QColor (Qt::transparent);
30 }
31
32 if (colorPaletteLookupTable.contains (color)) {
33
34 return colorPaletteLookupTable [color];
35
36 } else {
37
38 LOG4CPP_ERROR_S ((*mainCat)) << "ColorPaletteToQColor unexpected color " << color;
39 ENGAUGE_ASSERT (false);
40 return colorPaletteLookupTable [COLOR_PALETTE_BLACK];
41
42 }
43}
44
45QString EndianToString (QSysInfo::Endian endian)
46{
47 if (endianLookupTable.count() == 0) {
48
49 // Initialize
50 endianLookupTable [QSysInfo::BigEndian] = "BigEndian";
51 endianLookupTable [QSysInfo::LittleEndian] = "LittleEndian";
52 }
53
54 if (endianLookupTable.contains (endian)) {
55
56 return endianLookupTable [endian];
57
58 } else {
59
60 return "<Unknown>";
61
62 }
63}
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
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
QString EndianToString(QSysInfo::Endian endian)
Definition EnumsToQt.cpp:45
QColor ColorPaletteToQColor(ColorPalette color)
Definition EnumsToQt.cpp:16
log4cpp::Category * mainCat
Definition Logger.cpp:14
#define LOG4CPP_ERROR_S(logger)
Definition convenience.h:12