1 | /*! |
---|
2 | * \file globals.h |
---|
3 | * \author Copyright © 2007-2010 Lёppa <contacts[at]oleksii[dot]name> |
---|
4 | * |
---|
5 | * $Id: globals.h 137 2010-09-15 14:57:37Z laleppa $ |
---|
6 | * $URL: https://tspsg.svn.sourceforge.net/svnroot/tspsg/trunk/src/globals.h $ |
---|
7 | * |
---|
8 | * \brief Contains TSPSG global defines. |
---|
9 | * |
---|
10 | * <b>TSPSG: TSP Solver and Generator</b> |
---|
11 | * |
---|
12 | * This file is part of TSPSG. |
---|
13 | * |
---|
14 | * TSPSG is free software: you can redistribute it and/or modify |
---|
15 | * it under the terms of the GNU General Public License as published by |
---|
16 | * the Free Software Foundation, either version 3 of the License, or |
---|
17 | * (at your option) any later version. |
---|
18 | * |
---|
19 | * TSPSG is distributed in the hope that it will be useful, |
---|
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
22 | * GNU General Public License for more details. |
---|
23 | * |
---|
24 | * You should have received a copy of the GNU General Public License |
---|
25 | * along with TSPSG. If not, see <http://www.gnu.org/licenses/>. |
---|
26 | */ |
---|
27 | |
---|
28 | #ifndef GLOBALS_H |
---|
29 | #define GLOBALS_H |
---|
30 | |
---|
31 | // INCLUDES |
---|
32 | #include <QtCore> |
---|
33 | #if QT_VERSION < 0x040500 |
---|
34 | #error You are using Qt version < 4.5 but minimum required version is 4.5.0. Compilation aborted. |
---|
35 | #endif |
---|
36 | #ifdef QT_NO_SVG |
---|
37 | #define NOSVG |
---|
38 | #endif |
---|
39 | #include <QtGui> |
---|
40 | #if !defined(NOSVG) |
---|
41 | #include <QtSvg> |
---|
42 | #endif // NOSVG |
---|
43 | |
---|
44 | #if defined(Q_OS_WINCE_WM) || defined(Q_OS_SYMBIAN) |
---|
45 | //! This is defined on handheld devices (e.g., Windows Mobile, Symbian). |
---|
46 | #define HANDHELD |
---|
47 | #endif |
---|
48 | |
---|
49 | #ifndef HANDHELD |
---|
50 | #include "qttoolbardialog.h" |
---|
51 | #endif |
---|
52 | |
---|
53 | // Version info |
---|
54 | #include "version.h" |
---|
55 | // OS and ARCH detection |
---|
56 | #include "os.h" |
---|
57 | // TSPSG Defaults |
---|
58 | #include "defaults.h" |
---|
59 | // TSPSolver |
---|
60 | #include "tspsolver.h" |
---|
61 | #ifdef Q_OS_WIN32 |
---|
62 | // Vista/7 Eyecandy |
---|
63 | #include "qtwin.h" |
---|
64 | #endif // Q_OS_WIN32 |
---|
65 | |
---|
66 | // DEFINES |
---|
67 | //! Maximum available number of cities |
---|
68 | #define MAX_NUM_CITIES 50 |
---|
69 | //! Maximum allowed value for random generation limits |
---|
70 | #define MAX_RAND_VALUE 1000 |
---|
71 | |
---|
72 | // Paths |
---|
73 | /*! |
---|
74 | * \def PATH_L10N |
---|
75 | * \brief Path to internationalization files. |
---|
76 | */ |
---|
77 | #ifndef PATH_L10N |
---|
78 | #define PATH_L10N "l10n" |
---|
79 | #endif // PATH_L10N |
---|
80 | /*! |
---|
81 | * \def PATH_DOCS |
---|
82 | * \brief Bath to documentation files. |
---|
83 | */ |
---|
84 | #ifndef PATH_DOCS |
---|
85 | #define PATH_DOCS "help" |
---|
86 | #endif // PATH_DOCS |
---|
87 | |
---|
88 | //! TSPSG Task file signature - letters \c TSPT |
---|
89 | #define TSPT quint32(0x54535054) |
---|
90 | //! TSPSG Task file version |
---|
91 | #define TSPT_VERSION quint8(1) |
---|
92 | //! TSPSG Task file metadata version |
---|
93 | #define TSPT_META_VERSION quint8(1) |
---|
94 | //! TSPSG Task file metadata size in bytes (incl. version) |
---|
95 | #define TSPT_META_SIZE 2 |
---|
96 | //! ZKomModRd Task file signature - letters \c ZK |
---|
97 | #define ZKT quint16(0x5A4B) |
---|
98 | //! ZKomModRd Task file version |
---|
99 | #define ZKT_VERSION quint8(1) |
---|
100 | |
---|
101 | //! This string represents infinite value in the table |
---|
102 | #define INFSTR "---" |
---|
103 | |
---|
104 | // FUNCTIONS |
---|
105 | /*! |
---|
106 | * \brief Checks whether \a x contains an integer value. |
---|
107 | * \param x A value to check. |
---|
108 | * \return \c true if \a x countains an integer, oherwise \c false. |
---|
109 | */ |
---|
110 | inline bool isInteger(double x) |
---|
111 | { |
---|
112 | double i; |
---|
113 | return (modf(x, &i) == 0.0); |
---|
114 | } |
---|
115 | |
---|
116 | #ifdef Q_OS_WIN32 |
---|
117 | /*! |
---|
118 | * \brief Enables or disables a mask for the \a widget. |
---|
119 | * \param widget A widget to toggle mask on. |
---|
120 | * \param enable Set to \c true to enable mask or \c false to disable it. |
---|
121 | * |
---|
122 | * This function is used to enable an outlined font effect for \c QLabel with a static text. |
---|
123 | */ |
---|
124 | void toggleStyle(QWidget *widget, bool enable); |
---|
125 | #endif // Q_OS_WIN32 |
---|
126 | |
---|
127 | #ifndef DOXYGEN_EXCLUDE |
---|
128 | |
---|
129 | #ifdef HANDHELD |
---|
130 | #define ICON_SIZE "32x32" |
---|
131 | #define ICON_FORMAT "png" |
---|
132 | #else |
---|
133 | #define ICON_SIZE "128x128" |
---|
134 | #define ICON_FORMAT "png" |
---|
135 | #endif |
---|
136 | |
---|
137 | #if QT_VERSION >= 0x040600 |
---|
138 | #define GET_ICON(x) QIcon::fromTheme(x, QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT)) |
---|
139 | #else |
---|
140 | #define GET_ICON(x) QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT) |
---|
141 | #endif |
---|
142 | |
---|
143 | // Sanity checks |
---|
144 | // Check that default number of cities is sane (<= MAX_NUM_CITIES) |
---|
145 | #if DEF_NUM_CITIES > MAX_NUM_CITIES |
---|
146 | #undef DEF_NUM_CITIES |
---|
147 | #define DEF_NUM_CITIES MAX_NUM_CITIES |
---|
148 | #endif |
---|
149 | // Check that maximum for random generation is sane (<= MAX_RAND_VALUE) |
---|
150 | #if DEF_RAND_MAX > MAX_RAND_VALUE |
---|
151 | #undef DEF_RAND_MAX |
---|
152 | #define DEF_RAND_MAX MAX_RAND_VALUE |
---|
153 | #endif |
---|
154 | // Check that DEF_RAND_MIN <= DEF_RAND_MAX |
---|
155 | #if DEF_RAND_MIN > DEF_RAND_MAX |
---|
156 | #undef DEF_RAND_MIN |
---|
157 | #define DEF_RAND_MIN DEF_RAND_MAX |
---|
158 | #endif |
---|
159 | |
---|
160 | #endif // DOXYGEN_EXCLUDE |
---|
161 | |
---|
162 | #endif // GLOBALS_H |
---|