1 /***************************************************************************
2 * Copyright (C) 2005, 2006 by Pino Toscano, toscano.pino@tiscali.it *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef KALZIUMGRADIENTTYPE_H
21 #define KALZIUMGRADIENTTYPE_H
23 class KalziumGradientType
;
29 * Factory for KalziumGradientType classes.
31 * @author Pino Toscano
33 class KalziumGradientTypeFactory
37 * Get the instance of this factory.
39 static KalziumGradientTypeFactory
* instance();
42 * Returns the KalziumGradientType with the @p id specified.
43 * It will gives 0 if none found.
45 KalziumGradientType
* build( int id
) const;
47 * Returns the KalziumGradientType whose name is the @p id
49 * It will gives 0 if none found.
51 KalziumGradientType
* build( const QByteArray
& id
) const;
54 * Returns a list with the names of the gradients we support.
56 QStringList
gradients() const;
59 KalziumGradientTypeFactory();
61 QList
<KalziumGradientType
*> m_gradients
;
65 * Base class representing a gradient.
66 * Inherit it and add its instance to the factory to add it globally.
68 * @author Pino Toscano
70 class KalziumGradientType
76 static KalziumGradientType
* instance();
78 virtual ~KalziumGradientType();
81 * Returns the ID of this gradient.
82 * Mainly used when saving/loading.
84 virtual QByteArray
name() const = 0;
86 * Returns the description of this gradient.
87 * Used in all the visible places.
89 virtual QString
description() const = 0;
92 * Calculate the coefficient of the element with atomic number
93 * @p el according to this gradient. The calculated coefficient
94 * will be always in the range [0, 1].
96 virtual double elementCoeff( int el
) const;
98 * Return the value, related to the current gradient, of the
99 * element with atomic number @p el.
100 * It will return -1 if the data is not available.
102 virtual double value( int el
) const = 0;
104 * Returns the minimum value of the data this gradient
107 virtual double minValue() const = 0;
109 * Returns the maximum value of the data this gradient
112 virtual double maxValue() const = 0;
114 * Returns whether to use a logarithmic gradient
115 * instead of a linear one.
117 virtual bool logarithmicGradient() const = 0;
119 * Returns the first color of the gradient.
121 virtual QColor
firstColor() const;
123 * Returns the second color of the gradient.
125 virtual QColor
secondColor() const;
127 * Returns the color used to represent an element whose data is
130 virtual QColor
notAvailableColor() const;
133 * Calculates the color of an element which has a @p coeff which
134 * is a percentage of the maximum value.
135 * @param coeff is the coefficient in the range [0, 1], usually
136 * calculated with elementCoeff()
138 QColor
calculateColor( const double coeff
) const;
141 KalziumGradientType();
145 * The gradient by covalent radius.
147 * @author Pino Toscano
149 class KalziumCovalentRadiusGradientType
: public KalziumGradientType
152 static KalziumCovalentRadiusGradientType
* instance();
154 QByteArray
name() const;
155 QString
description() const;
157 double value( int el
) const;
159 double minValue() const;
160 double maxValue() const;
162 bool logarithmicGradient() const;
165 KalziumCovalentRadiusGradientType();
169 * The gradient by van Der Waals radius.
171 * @author Pino Toscano
173 class KalziumVanDerWaalsRadiusGradientType
: public KalziumGradientType
176 static KalziumVanDerWaalsRadiusGradientType
* instance();
178 QByteArray
name() const;
179 QString
description() const;
181 double value( int el
) const;
183 double minValue() const;
184 double maxValue() const;
186 bool logarithmicGradient() const;
189 KalziumVanDerWaalsRadiusGradientType();
193 * The gradient by atomic mass.
195 * @author Pino Toscano
197 class KalziumMassGradientType
: public KalziumGradientType
200 static KalziumMassGradientType
* instance();
202 QByteArray
name() const;
203 QString
description() const;
205 double value( int el
) const;
207 double minValue() const;
208 double maxValue() const;
210 bool logarithmicGradient() const;
213 KalziumMassGradientType();
217 * The gradient by boiling point.
219 * @author Pino Toscano
221 class KalziumBoilingPointGradientType
: public KalziumGradientType
224 static KalziumBoilingPointGradientType
* instance();
226 QByteArray
name() const;
227 QString
description() const;
229 double value( int el
) const;
231 double minValue() const;
232 double maxValue() const;
234 bool logarithmicGradient() const;
237 KalziumBoilingPointGradientType();
241 * The gradient by melting point.
243 * @author Pino Toscano
245 class KalziumMeltingPointGradientType
: public KalziumGradientType
248 static KalziumMeltingPointGradientType
* instance();
250 QByteArray
name() const;
251 QString
description() const;
253 double value( int el
) const;
255 double minValue() const;
256 double maxValue() const;
258 bool logarithmicGradient() const;
261 KalziumMeltingPointGradientType();
265 * The gradient by electronegativity.
267 * @author Pino Toscano
269 class KalziumElectronegativityGradientType
: public KalziumGradientType
272 static KalziumElectronegativityGradientType
* instance();
274 QByteArray
name() const;
275 QString
description() const;
277 double value( int el
) const;
279 double minValue() const;
280 double maxValue() const;
282 bool logarithmicGradient() const;
285 KalziumElectronegativityGradientType();
289 * The gradient by discoverydate.
291 * @author Carsten Niehaus
293 class KalziumDiscoverydateGradientType
: public KalziumGradientType
296 static KalziumDiscoverydateGradientType
* instance();
298 QByteArray
name() const;
299 QString
description() const;
301 double value( int el
) const;
303 double minValue() const;
304 double maxValue() const;
306 bool logarithmicGradient() const;
309 KalziumDiscoverydateGradientType();
313 * The gradient by electronaffinity.
315 * @author Carsten Niehaus
317 class KalziumElectronaffinityGradientType
: public KalziumGradientType
320 static KalziumElectronaffinityGradientType
* instance();
322 QByteArray
name() const;
323 QString
description() const;
325 double value( int el
) const;
327 double minValue() const;
328 double maxValue() const;
330 bool logarithmicGradient() const;
333 KalziumElectronaffinityGradientType();
337 * The gradient by the first ionization energy.
339 * @author Carsten Niehaus
341 class KalziumIonizationGradientType
: public KalziumGradientType
344 static KalziumIonizationGradientType
* instance();
346 QByteArray
name() const;
347 QString
description() const;
349 double value( int el
) const;
351 double minValue() const;
352 double maxValue() const;
354 bool logarithmicGradient() const;
357 KalziumIonizationGradientType();
360 #endif // KALZIUMGRADIENTTYPE_H