source: tspsg-svn/trunk/src/globals.h @ 88

Last change on this file since 88 was 87, checked in by laleppa, 15 years ago

+ Added Fractional accuracy (in decimail places) to settings.
+ Created defaults.h file. Moved all default defines there.

  • Replaced all double types with qreal.
  • Replaced all calls to trUtf8() with tr() as we use setCodecForTr() to set UTF-8 encoding as default and tr() is enough.
  • Replaced all 2009 with 2010 in copyrights.
  • Fixed an error when loading .zkt file with less than 5 cities.
  • Property svn:keywords set to Id URL
File size: 3.2 KB
Line 
1/*!
2 * \file globals.h
3 * \author Copyright (C) 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
4 *
5 *  $Id: globals.h 87 2010-01-12 14:11:24Z 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#include <QtGui>
34
35// Version info
36#include "version.h"
37// OS and ARCH detection
38#include "os.h"
39// TSPSG Defaults
40#include "defaults.h"
41
42// DEFINES
43//! Maximum available number of cities
44#define MAX_NUM_CITIES 50
45//! Maximum allowed value for random generation limits
46#define MAX_RAND_VALUE 1000
47
48// Paths
49/*!
50 * \def PATH_I18N
51 * \brief Bath to internationalization files.
52 */
53/*!
54 * \def PATH_DOCS
55 * \brief Bath to documentation files.
56 */
57#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
58        #define PATH_I18N "/usr/share/tspsg/i18n"
59        #define PATH_DOCS "/usr/share/doc/tspsg"
60#else
61        #define PATH_I18N "i18n"
62        #define PATH_DOCS "help"
63#endif // Q_OS_LINUX
64
65//! TSPSG Task file signature - letters \c TSPT
66#define TSPT quint32(0x54535054)
67//! TSPSG Task file version
68#define TSPT_VERSION quint8(1)
69//! TSPSG Task file metadata version
70#define TSPT_META_VERSION quint8(1)
71//! TSPSG Task file metadata size in bytes (incl. version)
72#define TSPT_META_SIZE 2
73//! ZKomModRd Task file signature - letters \c ZK
74#define ZKT quint16(0x5A4B)
75//! ZKomModRd Task file version
76#define ZKT_VERSION quint8(1)
77
78/*!
79 * \def INFINITY
80 * \brief This value means infinity :-)
81 *
82 *  Some libraries already have \c INFINITY defined.
83 *  We need to redefine it for the \c INFINITY to always have the same value.
84 */
85#ifdef INFINITY
86        #undef INFINITY
87#endif
88#define INFINITY 1.7E+308
89//! This string represents infinite value in the table
90#define INFSTR "---"
91
92// FUNCTIONS
93/*!
94 * \brief Checks whether \a x contains an integer value.
95 * \param x A value to check.
96 * \return \c true if \a x countains an integer, oherwise \c false.
97 */
98inline bool isInteger(qreal x)
99{
100qreal i;
101        return (modf(x, &i) == 0.0);
102}
103
104// Sanity checks
105// Check that default number of cities is sane (<= MAX_NUM_CITIES)
106#if DEF_NUM_CITIES > MAX_NUM_CITIES
107        #undef DEF_NUM_CITIES
108        #define DEF_NUM_CITIES MAX_NUM_CITIES
109#endif
110// Check that maximum for random generation is sane (<= MAX_RAND_VALUE)
111#if DEF_RAND_MAX > MAX_RAND_VALUE
112        #undef DEF_RAND_MAX
113        #define DEF_RAND_MAX MAX_RAND_VALUE
114#endif
115// Check that DEF_RAND_MIN <= DEF_RAND_MAX
116#if DEF_RAND_MIN > DEF_RAND_MAX
117        #undef DEF_RAND_MIN
118        #define DEF_RAND_MIN DEF_RAND_MAX
119#endif
120
121#endif // GLOBALS_H
Note: See TracBrowser for help on using the repository browser.