Avogadro  1.1.0
/home/kitware/dashboards/avogadro/libavogadro/src/global.h
00001 /**********************************************************************
00002   global.h - Setup some default defines.
00003 
00004   Copyright (C) 2007 by Donald Ephraim Curtis
00005   Copyright (C) 2008-2009 by Marcus D. Hanwell
00006 
00007   This file is part of the Avogadro molecular editor project.
00008   For more information, see <http://avogadro.openmolecules.net/>
00009 
00010   Avogadro is free software; you can redistribute it and/or modify
00011   it under the terms of the GNU General Public License as published by
00012   the Free Software Foundation; either version 2 of the License, or
00013   (at your option) any later version.
00014 
00015   Avogadro is distributed in the hope that it will be useful,
00016   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018   GNU General Public License for more details.
00019 
00020   You should have received a copy of the GNU General Public License
00021   along with this program; if not, write to the Free Software
00022   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00023   02110-1301, USA.
00024  **********************************************************************/
00025 
00026 #ifndef GLOBAL_H
00027 #define GLOBAL_H
00028 
00029 #include <QtCore/QTranslator>
00030 #include <QtCore/QPointer>
00031 
00038 #define LIBAVOGADRO_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
00039 
00040 // LIBAVOGADRO_VERSION is (major << 16) + (minor << 8) + patch
00041 #define LIBAVOGADRO_VERSION LIBAVOGADRO_VERSION_CHECK(@[email protected], @[email protected], @[email protected])
00042 
00043 #define EIGEN_WORK_AROUND_QT_BUG_CALLING_WRONG_OPERATOR_NEW_FIXED_IN_QT_4_5
00044 
00045 #ifdef WIN32
00046 # ifndef NOMINMAX
00047 #  define NOMINMAX 1
00048 #  include <limits>
00049 # endif
00050 #endif
00051 
00052 // If we are using a recent GCC version with visibility support use it
00053 // The Krazy checker doesn't like this, but it's a valid CMake conditional
00054 // krazy:excludeall=cpp
00055 #ifdef HAVE_GCC_VISIBILITY
00056   #define A_DECL_IMPORT __attribute__ ((visibility("default")))
00057   #define A_DECL_EXPORT __attribute__ ((visibility("default")))
00058   #define A_DECL_HIDDEN __attribute__ ((visibility("hidden")))
00059 #elif defined(WIN32)
00060   #define A_DECL_IMPORT __declspec(dllimport)
00061   #define A_DECL_EXPORT __declspec(dllexport)
00062   #define A_DECL_HIDDEN
00063 #else
00064   #define A_DECL_IMPORT
00065   #define A_DECL_EXPORT
00066   #define A_DECL_HIDDEN
00067 #endif
00068 
00069 // This macro should be used to export parts of the API
00070 #ifndef A_EXPORT
00071   #ifdef avogadro_EXPORTS
00072     #define A_EXPORT A_DECL_EXPORT
00073   #else
00074     #define A_EXPORT A_DECL_IMPORT
00075   #endif
00076 #endif
00077 
00078 // This macro allows the selective hiding of parts of our exposed API
00079 #ifndef A_HIDE
00080   #define A_HIDE A_DECL_HIDDEN
00081 #endif
00082 
00083 #ifndef GL_RESCALE_NORMAL
00084 # define GL_RESCALE_NORMAL 0x803A
00085 #endif
00086 
00087 #ifndef GL_COLOR_SUM_EXT
00088 # define GL_COLOR_SUM_EXT 0x8458
00089 #endif
00090 
00091 #ifndef GL_LIGHT_MODEL_COLOR_CONTROL_EXT
00092 # define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
00093 #endif
00094 
00095 #ifndef GL_SEPARATE_SPECULAR_COLOR_EXT
00096 # define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA
00097 #endif
00098 
00099 #ifndef GL_TEXTURE_RECTANGLE_ARB
00100 # define GL_TEXTURE_RECTANGLE_ARB 0x84F5
00101 #endif
00102 
00103 namespace Avogadro
00104 {
00105   const double   ROTATION_SPEED                    = 0.005;
00106   const double   ZOOM_SPEED                        = 0.02;
00107   const double   MOUSE_WHEEL_SPEED                 = 0.1;
00108   const double   CAMERA_MOL_RADIUS_MARGIN          = 10.0;
00109   const double   CAMERA_NEAR_DISTANCE              = 2.0;
00110   const int      SEL_BUF_MAX_SIZE                  = 262144;
00111   const int      SEL_BUF_MARGIN                    = 128;
00112   const int      SEL_BOX_HALF_SIZE                 = 4;
00113   const int      SEL_BOX_SIZE                      = 2 * SEL_BOX_HALF_SIZE + 1;
00114   const double   SEL_ATOM_EXTRA_RADIUS             = 0.18;
00115   const double   SEL_BOND_EXTRA_RADIUS             = 0.07;
00116 
00117   const float    LIGHT_AMBIENT[4]                  = {0.2f, 0.2f, 0.2f, 1.0f};
00118 
00119   const float    LIGHT0_DIFFUSE[4]                 = {1.0f, 1.0f, 1.0f, 1.0f};
00120   const float    LIGHT0_SPECULAR[4]                = {1.0f, 1.0f, 1.0f, 1.0f};
00121   const float    LIGHT0_POSITION[4]                = {0.8f, 0.7f, 1.0f, 0.0f};
00122 
00123   const float    LIGHT1_DIFFUSE[4]                 = {0.3f, 0.3f, 0.3f, 1.0f};
00124   const float    LIGHT1_SPECULAR[4]                = {0.5f, 0.5f, 0.5f, 1.0f};
00125   const float    LIGHT1_POSITION[4]                = {-0.8f, 0.7f, -0.5f, 0.0f};
00126 
00127   const double   cPi                               = 3.14159265358979323846;
00128   const double   cDegToRad                         = cPi / 180.0;
00129 
00136   class A_EXPORT Library
00137   {
00138     public:
00142       static QPointer<QTranslator> createTranslator();
00143 
00147       static QString version();
00148 
00152       static QString scmRevision();
00153 
00158       static QString prefix();
00159 
00163       static bool threadedGL();
00164   };
00165 }
00166 
00167 #endif  // __GLOBAL_H
00168