TSP Solver and Generator
|
00001 00028 #ifndef GLOBALS_H 00029 #define GLOBALS_H 00030 00031 // INCLUDES 00032 #include <QtCore> 00033 #if QT_VERSION < 0x040500 00034 # error You are using Qt version < 4.5 but minimum required version is 4.5.0. Compilation aborted. 00035 #endif 00036 #if defined(Q_WS_WINCE_WM) || defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) 00037 00038 # define HANDHELD 00039 # define QT_NO_STATUSTIP 00040 #endif 00041 #include <QtGui> 00042 #if defined(QT_NO_SVG) && !defined(NOSVG) 00043 # define NOSVG 00044 #endif 00045 #if !defined(NOSVG) 00046 # include <QtSvg> 00047 #endif // NOSVG 00048 00049 #ifndef HANDHELD 00050 # include "qttoolbardialog.h" 00051 #endif 00052 00053 // Version info 00054 #include "version.h" 00055 // OS and ARCH detection 00056 #include "os.h" 00057 // TSPSG Defaults 00058 #include "defaults.h" 00059 // TSPSolver 00060 #include "tspsolver.h" 00061 #ifndef HANDHELD 00062 // Eyecandy 00063 # include "qtwin.h" 00064 #endif // HANDHELD 00065 00066 // DEFINES 00068 #define MAX_NUM_CITIES 50 00069 00070 #define MAX_RAND_VALUE 1000 00071 00072 // Paths 00077 #ifndef PATH_L10N 00078 # define PATH_L10N "l10n" 00079 #endif // PATH_L10N 00080 00084 #ifndef PATH_DOCS 00085 # define PATH_DOCS "help" 00086 #endif // PATH_DOCS 00087 00089 #define TSPT quint32(0x54535054) 00090 00091 #define TSPT_VERSION quint8(1) 00092 00093 #define TSPT_META_VERSION quint8(1) 00094 00095 #define TSPT_META_SIZE 2 00096 00097 #define ZKT quint16(0x5A4B) 00098 00099 #define ZKT_VERSION quint8(1) 00100 00102 #define INFSTR "---" 00103 00105 #define CM_IN_INCH 2.54 00106 00107 #define HQ_FACTOR 2 00108 00109 // FUNCTIONS 00115 inline bool isInteger(double x) 00116 { 00117 double i; 00118 return (modf(x, &i) == 0.0); 00119 } 00120 00127 inline bool hasUpdater() 00128 { 00129 #ifdef Q_WS_WIN32 00130 return QFile::exists("updater/Update.exe"); 00131 #else // Q_WS_WIN32 00132 return false; 00133 #endif // Q_WS_WIN32 00134 } 00135 00136 #ifndef HANDHELD 00137 00144 void toggleStyle(QWidget *widget, bool enable); 00145 #endif // HANDHELD 00146 00147 #ifndef DOXYGEN_EXCLUDE 00148 00149 #ifndef QT_NO_PRINTER 00150 Q_DECLARE_METATYPE(QPrinter::PageSize) 00151 Q_DECLARE_METATYPE(QPrinter::Orientation) 00152 #endif 00153 00154 #ifdef HANDHELD 00155 # define ICON_SIZE "48x48" 00156 # define ICON_FORMAT "png" 00157 #else 00158 # define ICON_SIZE "128x128" 00159 # define ICON_FORMAT "png" 00160 #endif 00161 00162 #if QT_VERSION >= 0x040600 00163 # define GET_ICON(x) QIcon::fromTheme(x, QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT)) 00164 #else 00165 # define GET_ICON(x) QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT) 00166 // No QVariant::toReal() member in Qt < 4.6 00167 // A quick hack to maintain compatibility with Qt 4.5.x 00168 # define toReal toDouble 00169 #endif 00170 00171 // Sanity checks 00172 // Check that default number of cities is sane (<= MAX_NUM_CITIES) 00173 #if DEF_NUM_CITIES > MAX_NUM_CITIES 00174 # undef DEF_NUM_CITIES 00175 # define DEF_NUM_CITIES MAX_NUM_CITIES 00176 #endif 00177 // Check that maximum for random generation is sane (<= MAX_RAND_VALUE) 00178 #if DEF_RAND_MAX > MAX_RAND_VALUE 00179 # undef DEF_RAND_MAX 00180 # define DEF_RAND_MAX MAX_RAND_VALUE 00181 #endif 00182 // Check that DEF_RAND_MIN <= DEF_RAND_MAX 00183 #if DEF_RAND_MIN > DEF_RAND_MAX 00184 # undef DEF_RAND_MIN 00185 # define DEF_RAND_MIN DEF_RAND_MAX 00186 #endif 00187 00188 #endif // DOXYGEN_EXCLUDE 00189 00190 #endif // GLOBALS_H