OpenWalnut  1.5.0dev
WMPickingDVRHelper.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2015-2017 A. Betz, D. Gerlicher, OpenWalnut Community
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMPICKINGDVRHELPER_H
26 #define WMPICKINGDVRHELPER_H
27 
28 #include <vector>
29 
30 namespace PickingDVRHelper
31 {
32  /**
33  * Computes the first and second derivatives of a vector of values
34  *
35  * \param values Values for which the derivatives will be computed
36  * \param vecFirstDerivative The first derivative of the values
37  * \param vecSecondDerivative The second derivative of the values
38  */
39  void calculateDerivativesWYSIWYP( const std::vector<double>& values,
40  std::vector<double>& vecFirstDerivative,
41  std::vector<double>& vecSecondDerivative );
42 }
43 
44 /**
45  * Color converter for different scalings, i.e. [0,1] vs. [0,255]
46  */
47 template <typename T>
49 {
50 private:
51  T red; //!< Red color component value
52  T green; //!< Green color component value
53  T blue; //!< Blue color component value
54  T alpha; //!< Opacity compnent value
55 
56 public:
57  /**
58  * Standard constructor that creates transparent black.
59  */
61 
62  /**
63  * Constructor creating the color.
64  *
65  * \param red red color component value
66  * \param green green color component value
67  * \param blue blue color copmonent value
68  * \param alpha opacity component value
69  */
70  WMPickingColor( T red, T green, T blue, T alpha );
71 
72  /**
73  * Get red color component value.
74  *
75  * \return red value
76  */
77  T getRed();
78 
79  /**
80  * Get green color component value.
81  *
82  * \return green value
83  */
84  T getGreen();
85 
86  /**
87  * Get blue color component value.
88  *
89  * \return blue value
90  */
91  T getBlue();
92 
93  /**
94  * Get opacity color component value.
95  *
96  * \return opacity value
97  */
98  T getAlpha();
99 
100  /**
101  * Set red color component value.
102  *
103  * \param red red value
104  */
105  void setRed( T red );
106 
107  /**
108  * Set green color component value.
109  *
110  * \param green green value
111  */
112  void setGreen( T green );
113 
114  /**
115  * Set blue color component value.
116  *
117  * \param blue blue value
118  */
119  void setBlue( T blue );
120 
121  /**
122  * Set opacity color component value.
123  *
124  * \param alpha opacity value
125  */
126  void setAlpha( T alpha );
127 
128  void normalize(); //!< Scales color down from [0,255] to [0,1]
129 };
130 
131 
132 template <typename T>
134  : WMPickingColor( 0.0, 0.0, 0.0, 0.0 )
135 {
136 }
137 
138 template <typename T>
139 WMPickingColor<T>::WMPickingColor( T red, T green, T blue, T alpha )
140  : red( red ), green( green ), blue( blue ), alpha( alpha )
141 {
142 }
143 
144 //Getter
145 template <typename T>
147 {
148  return this->red;
149 }
150 
151 template <typename T>
153 {
154  return this->green;
155 }
156 
157 template <typename T>
159 {
160  return this->blue;
161 }
162 
163 template <typename T>
165 {
166  return this->alpha;
167 }
168 
169 //Setter
170 template <typename T>
172 {
173  this->red = red;
174 }
175 
176 template <typename T>
178 {
179  this->green = green;
180 }
181 
182 template <typename T>
184 {
185  this->blue = blue;
186 }
187 
188 template <typename T>
190 {
191  this->alpha = alpha;
192 }
193 
194 template <typename T>
196 {
197  this->red = this->red / 255.0;
198  this->green = this->green / 255.0;
199  this->blue = this->blue / 255.0;
200  this->alpha = this->alpha / 255.0;
201 }
202 
203 
204 #endif // WMPICKINGDVRHELPER_H
Color converter for different scalings, i.e.
void setRed(T red)
Set red color component value.
T getAlpha()
Get opacity color component value.
WMPickingColor()
Standard constructor that creates transparent black.
T getGreen()
Get green color component value.
T alpha
Opacity compnent value.
void setBlue(T blue)
Set blue color component value.
void normalize()
Scales color down from [0,255] to [0,1].
T getRed()
Get red color component value.
void setGreen(T green)
Set green color component value.
T blue
Blue color component value.
T green
Green color component value.
T red
Red color component value.
void setAlpha(T alpha)
Set opacity color component value.
T getBlue()
Get blue color component value.