SoWx  0.1.0
Coin3D GUI toolkit binding
Loading...
Searching...
No Matches
SoWxBasic.h
1#ifndef SOWX_BASIC_H
2#define SOWX_BASIC_H
3
4// NB: this is not a pure configure-input file, it's also a config header...
5
6/**************************************************************************\
7 * Copyright (c) Kongsberg Oil & Gas Technologies AS
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
13 *
14 * Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * Neither the name of the copyright holder nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36\**************************************************************************/
37
38// *************************************************************************
39
40/* Some useful inline template functions:
41 * SoWxMin(Val1, Val2) - returns minimum value
42 * SoWxMax(Val1, Val2) - returns maximum value
43 * SoWxClamp(Val, Min, Max) - returns clamped value
44 * SoWxSwap(Val1, Val2) - swaps the two values (no return value)
45 */
46
47template <class Type>
48inline Type SoWxAbs(Type Val) {
49 return (Val < 0) ? -Val : Val;
50}
51
52template <class Type>
53inline Type SoWxMin(Type a, Type b) {
54 return (b < a) ? b : a;
55}
56
57template <class Type>
58inline Type SoWxMax(Type a, Type b) {
59 return (b > a) ? b : a;
60}
61
62template <class Type>
63inline Type SoWxClamp(Type val, Type min, Type max) {
64 return SoWxMax(min, SoWxMin(max, val));
65}
66
67template <class Type>
68inline void SoWxSwap(Type & a, Type & b) {
69 Type t = a; a = b; b = t;
70}
71
72// *************************************************************************
73
74#define __COIN_SOWX__
75
76#if ! defined(SOWX_MAJOR_VERSION)
77#define SOWX_MAJOR_VERSION 0
78#endif /* ! SOWX_MAJOR_VERSION */
79#if ! defined(SOWX_MINOR_VERSION)
80#define SOWX_MINOR_VERSION 1
81#endif /* ! SOWX_MINOR_VERSION */
82#if ! defined(SOWX_MICRO_VERSION)
83#define SOWX_MICRO_VERSION 0
84#endif /* ! SOWX_MICRO_VERSION */
85#if ! defined(SOWX_BETA_VERSION)
86#define SOWX_BETA_VERSION
87#endif /* ! SOWX_BETA_VERSION */
88#if ! defined(SOWX_VERSION)
89#define SOWX_VERSION "0.1.0"
90#endif /* ! SOWX_VERSION */
91
92// *************************************************************************
93
94/* Precaution to avoid an error easily made by the application programmer. */
95#ifdef SOWX_DLL_API
96# error Leave the internal SOWX_DLL_API define alone.
97#endif /* SOWX_DLL_API */
98
99/*
100 On Microsoft Windows platforms, one of these defines must always be set when
101 building application programs:
102
103 - "SOWX_DLL", when the application programmer is using the
104 library in the form of a dynamic link library (DLL)
105
106 - "SOWX_NOT_DLL", when the application programmer is using the
107 library in the form of a static object library (LIB)
108
109 Note that either SOWX_DLL or SOWX_NOT_DLL _must_ be defined by
110 the application programmer on Microsoft Windows platforms, otherwise the
111 #error statement will be hit. Set up one or the other of these two
112 defines in your compiler environment according to how the library
113 was built -- as a DLL (use "SOWX_DLL") or as a LIB (use
114 "SOWX_NOT_DLL").
115
116 (Setting up defines for the compiler is typically done by either
117 adding something like "/DSOWX_DLL" to the compiler's argument
118 line (for command-line build processes), or by adding the define to
119 the list of preprocessor symbols in your IDE GUI (in the MSVC IDE,
120 this is done from the "Project"->"Settings" menu, choose the "C/C++"
121 tab, then "Preprocessor" from the drop down list and add the
122 appropriate define)).
123
124 It is extremely important that the application programmer uses the
125 correct define, as using "SOWX_NOT_DLL" when "SOWX_DLL" is
126 correct is likely to cause mysterious crashes.
127 */
128#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
129# ifdef SOWX_INTERNAL
130# ifdef SOWX_MAKE_DLL
131# define SOWX_DLL_API __declspec(dllexport)
132# endif /* SOWX_MAKE_DLL */
133# else /* !SOWX_INTERNAL */
134# ifdef SOWX_DLL
135# define SOWX_DLL_API __declspec(dllimport)
136# else /* !SOWX_DLL */
137# ifndef SOWX_NOT_DLL
138# error Define either SOWX_DLL or SOWX_NOT_DLL as appropriate for your linkage! See Inventor/Wx/SoWxBasic.h for further instructions.
139# endif /* SOWX_NOT_DLL */
140# endif /* !SOWX_DLL */
141# endif /* !SOWX_MAKE_DLL */
142#endif /* Microsoft Windows */
143
144/* Empty define to avoid errors when _not_ compiling an Microsoft Windows DLL. */
145#ifndef SOWX_DLL_API
146# define SOWX_DLL_API
147#endif /* !SOWX_DLL_API */
148
149#ifndef GUI_TOOLKIT_VERSION
150#define GUI_TOOLKIT_VERSION "3.2.0"
151#endif /* GUI_TOOLKIT_VERSION */
152
153#endif // ! SOWX_BASIC_H