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

Last change on this file since 165 was 162, checked in by laleppa, 14 years ago
  • NEW: Solution graph size can now be controlled using Output/GraphWidth? setting in tspsg.ini (see ticket:8). Value is in centimeters.
  • NEW: Support for embedded base64 encoded images when saving solution as HTML (closed ticket:4).
  • Renamed Output/ShowGraph? setting to Output/GenerateGraph?.
  • Made some other small tweaks and fixes.
  • FIX: Solution graph is still exported to HTML when graph generation is disabled (fixed bug:9).
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id URL
File size: 4.8 KB
RevLine 
[116]1/*!
2 * \file globals.h
[151]3 * \author Copyright &copy; 2007-2011 Lёppa <contacts[at]oleksii[dot]name>
[116]4 *
5 *  $Id: globals.h 162 2011-04-14 19:30:23Z 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>
[134]33#if QT_VERSION < 0x040500
[149]34#   error You are using Qt version < 4.5 but minimum required version is 4.5.0. Compilation aborted.
[134]35#endif
[143]36#if defined(Q_WS_WINCE_WM) || defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
[149]37    //! This is defined on handheld devices (e.g., Windows Mobile, Symbian).
38#   define HANDHELD
39#   define QT_NO_STATUSTIP
[143]40#endif
41#include <QtGui>
42#if defined(QT_NO_SVG) && !defined(NOSVG)
[149]43#   define NOSVG
[134]44#endif
45#if !defined(NOSVG)
[149]46#   include <QtSvg>
[134]47#endif // NOSVG
[116]48
[118]49#ifndef HANDHELD
[149]50#   include "qttoolbardialog.h"
[118]51#endif
52
[116]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"
[150]61#ifndef HANDHELD
62    // Eyecandy
[149]63#   include "qtwin.h"
[150]64#endif // HANDHELD
[116]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
[149]78#   define PATH_L10N "l10n"
[116]79#endif // PATH_L10N
80/*!
81 * \def PATH_DOCS
82 * \brief Bath to documentation files.
83 */
84#ifndef PATH_DOCS
[149]85#   define PATH_DOCS "help"
[116]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
[162]104//! Number of centimeters in 1 inch
105#define CM_IN_INCH 2.54
106//! Factor for high quality graph generation
107#define HQ_FACTOR 2
108
[116]109// FUNCTIONS
110/*!
111 * \brief Checks whether \a x contains an integer value.
112 * \param x A value to check.
113 * \return \c true if \a x countains an integer, oherwise \c false.
114 */
115inline bool isInteger(double x)
116{
117double i;
[149]118    return (modf(x, &i) == 0.0);
[116]119}
120
[139]121/*!
122 * \brief Checks whether the updater app is installed/available.
123 * \return \c true if updater app is available, oherwise \c false.
124 * \note The updater app is only available under Windows at this moment.
125 *  On other systems this function always returns \c false.
126 */
127inline bool hasUpdater()
128{
[141]129#ifdef Q_WS_WIN32
[149]130    return QFile::exists("updater/Update.exe");
[141]131#else // Q_WS_WIN32
[149]132    return false;
[141]133#endif // Q_WS_WIN32
[139]134}
135
[150]136#ifndef HANDHELD
[116]137/*!
138 * \brief Enables or disables a mask for the \a widget.
139 * \param widget A widget to toggle mask on.
140 * \param enable Set to \c true to enable mask or \c false to disable it.
141 *
142 *  This function is used to enable an outlined font effect for \c QLabel with a static text.
143 */
144void toggleStyle(QWidget *widget, bool enable);
[150]145#endif // HANDHELD
[116]146
[136]147#ifndef DOXYGEN_EXCLUDE
148
[158]149#ifndef QT_NO_PRINTER
150    Q_DECLARE_METATYPE(QPrinter::PageSize)
151    Q_DECLARE_METATYPE(QPrinter::Orientation)
152#endif
153
[136]154#ifdef HANDHELD
[157]155#   define ICON_SIZE "48x48"
[149]156#   define ICON_FORMAT "png"
[136]157#else
[149]158#   define ICON_SIZE "128x128"
159#   define ICON_FORMAT "png"
[136]160#endif
161
[134]162#if QT_VERSION >= 0x040600
[149]163#   define GET_ICON(x) QIcon::fromTheme(x, QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT))
[134]164#else
[149]165#   define GET_ICON(x) QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT)
[134]166#endif
167
[116]168// Sanity checks
169// Check that default number of cities is sane (<= MAX_NUM_CITIES)
170#if DEF_NUM_CITIES > MAX_NUM_CITIES
[149]171#   undef DEF_NUM_CITIES
172#   define DEF_NUM_CITIES MAX_NUM_CITIES
[116]173#endif
174// Check that maximum for random generation is sane (<= MAX_RAND_VALUE)
175#if DEF_RAND_MAX > MAX_RAND_VALUE
[149]176#   undef DEF_RAND_MAX
177#   define DEF_RAND_MAX MAX_RAND_VALUE
[116]178#endif
179// Check that DEF_RAND_MIN <= DEF_RAND_MAX
180#if DEF_RAND_MIN > DEF_RAND_MAX
[149]181#   undef DEF_RAND_MIN
182#   define DEF_RAND_MIN DEF_RAND_MAX
[116]183#endif
184
[136]185#endif // DOXYGEN_EXCLUDE
186
[116]187#endif // GLOBALS_H
Note: See TracBrowser for help on using the repository browser.