source: tspsg/src/globals.h @ 7aaa0b0ec7

0.1.3.145-beta1-symbian0.1.4.170-beta2-bb10appveyorimgbotreadme
Last change on this file since 7aaa0b0ec7 was 3cadf24d00, checked in by Oleksii Serdiuk, 15 years ago
  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*!
2 * \file globals.h
3 * \author Copyright &copy; 2007-2010 Lёppa <contacts[at]oleksii[dot]name>
4 *
5 *  $Id$
6 *  $URL$
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#if !defined(NOSVG) && (QT_VERSION >= 0x040500)
35        #include <QtSvg>
36#endif // NOSVG && QT_VERSION >= 0x040500
37
38#if defined(Q_OS_WINCE_WM) || defined(Q_OS_SYMBIAN)
39        //! This is defined on handheld devices (e.g., Windows Mobile, Symbian).
40        #define HANDHELD
41#endif
42
43#ifndef HANDHELD
44        #include "qttoolbardialog.h"
45#endif
46
47// Version info
48#include "version.h"
49// OS and ARCH detection
50#include "os.h"
51// TSPSG Defaults
52#include "defaults.h"
53// TSPSolver
54#include "tspsolver.h"
55#ifdef Q_OS_WIN32
56        // Vista/7 Eyecandy
57        #include "qtwin.h"
58#endif // Q_OS_WIN32
59
60// DEFINES
61//! Maximum available number of cities
62#define MAX_NUM_CITIES 50
63//! Maximum allowed value for random generation limits
64#define MAX_RAND_VALUE 1000
65
66// Paths
67/*!
68 * \def PATH_L10N
69 * \brief Path to internationalization files.
70 */
71#ifndef PATH_L10N
72        #define PATH_L10N "l10n"
73#endif // PATH_L10N
74/*!
75 * \def PATH_DOCS
76 * \brief Bath to documentation files.
77 */
78#ifndef PATH_DOCS
79        #define PATH_DOCS "help"
80#endif // PATH_DOCS
81
82//! TSPSG Task file signature - letters \c TSPT
83#define TSPT quint32(0x54535054)
84//! TSPSG Task file version
85#define TSPT_VERSION quint8(1)
86//! TSPSG Task file metadata version
87#define TSPT_META_VERSION quint8(1)
88//! TSPSG Task file metadata size in bytes (incl. version)
89#define TSPT_META_SIZE 2
90//! ZKomModRd Task file signature - letters \c ZK
91#define ZKT quint16(0x5A4B)
92//! ZKomModRd Task file version
93#define ZKT_VERSION quint8(1)
94
95//! This string represents infinite value in the table
96#define INFSTR "---"
97
98// FUNCTIONS
99/*!
100 * \brief Checks whether \a x contains an integer value.
101 * \param x A value to check.
102 * \return \c true if \a x countains an integer, oherwise \c false.
103 */
104inline bool isInteger(double x)
105{
106double i;
107        return (modf(x, &i) == 0.0);
108}
109
110/*!
111 * \brief Returns the default font for solution output.
112 * \return The family name of the default font.
113 */
114inline QString getDefaultFont()
115{
116QFont f;
117#ifdef HANDHELD
118        f.setStyleHint(QFont::SansSerif);
119#else // HANDHELD
120        f.setStyleHint(QFont::TypeWriter);
121#endif // HANDHELD
122        return f.defaultFamily();
123}
124
125#ifdef Q_OS_WIN32
126/*!
127 * \brief Enables or disables a mask for the \a widget.
128 * \param widget A widget to toggle mask on.
129 * \param enable Set to \c true to enable mask or \c false to disable it.
130 *
131 *  This function is used to enable an outlined font effect for \c QLabel with a static text.
132 */
133void toggleStyle(QWidget *widget, bool enable);
134#endif // Q_OS_WIN32
135
136// Sanity checks
137// Check that default number of cities is sane (<= MAX_NUM_CITIES)
138#if DEF_NUM_CITIES > MAX_NUM_CITIES
139        #undef DEF_NUM_CITIES
140        #define DEF_NUM_CITIES MAX_NUM_CITIES
141#endif
142// Check that maximum for random generation is sane (<= MAX_RAND_VALUE)
143#if DEF_RAND_MAX > MAX_RAND_VALUE
144        #undef DEF_RAND_MAX
145        #define DEF_RAND_MAX MAX_RAND_VALUE
146#endif
147// Check that DEF_RAND_MIN <= DEF_RAND_MAX
148#if DEF_RAND_MIN > DEF_RAND_MAX
149        #undef DEF_RAND_MIN
150        #define DEF_RAND_MIN DEF_RAND_MAX
151#endif
152
153#endif // GLOBALS_H
Note: See TracBrowser for help on using the repository browser.