[67] | 1 | /*! |
---|
| 2 | * \file globals.h |
---|
[97] | 3 | * \author Copyright © 2007-2010 Lёppa <contacts[at]oleksii[dot]name> |
---|
[21] | 4 | * |
---|
| 5 | * $Id: globals.h 109 2010-04-27 07:12:55Z laleppa $ |
---|
| 6 | * $URL: https://tspsg.svn.sourceforge.net/svnroot/tspsg/trunk/src/globals.h $ |
---|
| 7 | * |
---|
[67] | 8 | * \brief Contains TSPSG global defines. |
---|
| 9 | * |
---|
| 10 | * <b>TSPSG: TSP Solver and Generator</b> |
---|
| 11 | * |
---|
[21] | 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 | |
---|
[31] | 28 | #ifndef GLOBALS_H |
---|
| 29 | #define GLOBALS_H |
---|
[21] | 30 | |
---|
[31] | 31 | // INCLUDES |
---|
| 32 | #include <QtCore> |
---|
| 33 | #include <QtGui> |
---|
[109] | 34 | #if !defined(NOSVG) && (QT_VERSION >= 0x040500) |
---|
| 35 | #include <QtSvg> |
---|
| 36 | #endif // NOSVG && QT_VERSION >= 0x040500 |
---|
[31] | 37 | |
---|
[42] | 38 | // Version info |
---|
| 39 | #include "version.h" |
---|
[54] | 40 | // OS and ARCH detection |
---|
[31] | 41 | #include "os.h" |
---|
[87] | 42 | // TSPSG Defaults |
---|
| 43 | #include "defaults.h" |
---|
[107] | 44 | // TSPSolver |
---|
| 45 | #include "tspsolver.h" |
---|
[96] | 46 | #ifdef Q_OS_WIN32 |
---|
| 47 | // Vista/7 Eyecandy |
---|
| 48 | #include "qtwin.h" |
---|
| 49 | #endif // Q_OS_WIN32 |
---|
[31] | 50 | |
---|
| 51 | // DEFINES |
---|
[64] | 52 | //! Maximum available number of cities |
---|
[78] | 53 | #define MAX_NUM_CITIES 50 |
---|
[64] | 54 | //! Maximum allowed value for random generation limits |
---|
[57] | 55 | #define MAX_RAND_VALUE 1000 |
---|
| 56 | |
---|
| 57 | // Paths |
---|
[64] | 58 | /*! |
---|
[96] | 59 | * \def PATH_L10N |
---|
[100] | 60 | * \brief Path to internationalization files. |
---|
[64] | 61 | */ |
---|
[96] | 62 | #ifndef PATH_L10N |
---|
| 63 | #define PATH_L10N "l10n" |
---|
| 64 | #endif // PATH_L10N |
---|
[64] | 65 | /*! |
---|
| 66 | * \def PATH_DOCS |
---|
| 67 | * \brief Bath to documentation files. |
---|
| 68 | */ |
---|
[96] | 69 | #ifndef PATH_DOCS |
---|
[57] | 70 | #define PATH_DOCS "help" |
---|
[96] | 71 | #endif // PATH_DOCS |
---|
[57] | 72 | |
---|
[66] | 73 | //! TSPSG Task file signature - letters \c TSPT |
---|
[31] | 74 | #define TSPT quint32(0x54535054) |
---|
[64] | 75 | //! TSPSG Task file version |
---|
[31] | 76 | #define TSPT_VERSION quint8(1) |
---|
[64] | 77 | //! TSPSG Task file metadata version |
---|
[31] | 78 | #define TSPT_META_VERSION quint8(1) |
---|
[64] | 79 | //! TSPSG Task file metadata size in bytes (incl. version) |
---|
[31] | 80 | #define TSPT_META_SIZE 2 |
---|
[66] | 81 | //! ZKomModRd Task file signature - letters \c ZK |
---|
[31] | 82 | #define ZKT quint16(0x5A4B) |
---|
[64] | 83 | //! ZKomModRd Task file version |
---|
[31] | 84 | #define ZKT_VERSION quint8(1) |
---|
| 85 | |
---|
[64] | 86 | //! This string represents infinite value in the table |
---|
[42] | 87 | #define INFSTR "---" |
---|
[27] | 88 | |
---|
[81] | 89 | // FUNCTIONS |
---|
| 90 | /*! |
---|
[82] | 91 | * \brief Checks whether \a x contains an integer value. |
---|
| 92 | * \param x A value to check. |
---|
| 93 | * \return \c true if \a x countains an integer, oherwise \c false. |
---|
[81] | 94 | */ |
---|
[89] | 95 | inline bool isInteger(double x) |
---|
[81] | 96 | { |
---|
[89] | 97 | double i; |
---|
[81] | 98 | return (modf(x, &i) == 0.0); |
---|
| 99 | } |
---|
| 100 | |
---|
[98] | 101 | #ifdef Q_OS_WIN32 |
---|
| 102 | /*! |
---|
| 103 | * \brief Enables or disables a mask for the \a widget. |
---|
| 104 | * \param widget A widget to toggle mask on. |
---|
| 105 | * \param enable Set to \c true to enable mask or \c false to disable it. |
---|
| 106 | * |
---|
| 107 | * This function is used to enable an outlined font effect for \c QLabel with a static text. |
---|
| 108 | */ |
---|
| 109 | void toggleStyle(QWidget *widget, bool enable); |
---|
| 110 | #endif // Q_OS_WIN32 |
---|
| 111 | |
---|
[100] | 112 | #if defined(Q_OS_WINCE_WM) || defined(Q_OS_SYMBIAN) |
---|
| 113 | //! This is defined on handheld (e.g., Windows Mobile, Symbian) devices. |
---|
| 114 | #define HANDHELD |
---|
| 115 | #endif |
---|
| 116 | |
---|
[64] | 117 | // Sanity checks |
---|
[57] | 118 | // Check that default number of cities is sane (<= MAX_NUM_CITIES) |
---|
[50] | 119 | #if DEF_NUM_CITIES > MAX_NUM_CITIES |
---|
| 120 | #undef DEF_NUM_CITIES |
---|
| 121 | #define DEF_NUM_CITIES MAX_NUM_CITIES |
---|
| 122 | #endif |
---|
[57] | 123 | // Check that maximum for random generation is sane (<= MAX_RAND_VALUE) |
---|
| 124 | #if DEF_RAND_MAX > MAX_RAND_VALUE |
---|
| 125 | #undef DEF_RAND_MAX |
---|
| 126 | #define DEF_RAND_MAX MAX_RAND_VALUE |
---|
| 127 | #endif |
---|
| 128 | // Check that DEF_RAND_MIN <= DEF_RAND_MAX |
---|
| 129 | #if DEF_RAND_MIN > DEF_RAND_MAX |
---|
| 130 | #undef DEF_RAND_MIN |
---|
| 131 | #define DEF_RAND_MIN DEF_RAND_MAX |
---|
| 132 | #endif |
---|
[50] | 133 | |
---|
[31] | 134 | #endif // GLOBALS_H |
---|