1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 
8 #ifndef SCSPECTRALVALUESCONVERTOR_H
9 #define SCSPECTRALVALUESCONVERTOR_H
10 
11 #include <QMap>
12 #include <QVector>
13 
14 #include "sccieilluminants.h"
15 #include "sccieobservers.h"
16 #include "sccolormgmtstructs.h"
17 #include "sce308tables.h"
18 
19 class ScSpectralValuesConvertor
20 {
21 public:
22 	/**
23 	 * Construct spectral values to CIEXYZ convertor with specified
24 	 * illuminant and observer
25 	 */
26 	ScSpectralValuesConvertor(eIlluminant illuminant, eObserver observer);
27 
28 	/**
29 	* Construct spectral values to CIEXYZ convertor with specified E308 table
30 	*/
31 	ScSpectralValuesConvertor(const ScE308Table& e308table);
32 
33 	/**
34 	 * Retrieve CIE XYZ values of illuminant white
35 	 */
illumunantWhite()36 	const ScXYZ& illumunantWhite() const { return m_illuminantWhite; }
37 
38 	/**
39 	* Compute CIELab values for specified spectrum
40 	*/
41 	ScLab toLab(const QMap<int, double>& spectrum) const;
42 
43 	/**
44 	* Compute CIELab values for specified spectrum
45 	*/
46 	ScLab toLab(const QVector<int>& wavelengths, const QVector<double>& reflectances) const;
47 
48 	/**
49 	* Compute CIEXYZ values for specified spectrum
50 	*/
51 	ScXYZ toXYZ(const QMap<int, double>& spectrum) const;
52 
53 	/**
54 	 * Compute CIEXYZ values for specified spectrum
55 	 */
56 	ScXYZ toXYZ(const QVector<int>& wavelengths, const QVector<double>& reflectances) const;
57 
58 protected:
59 	ScXYZ m_illuminantWhite;
60 
61 	QMap<int, double> m_weightsX;
62 	QMap<int, double> m_weightsY;
63 	QMap<int, double> m_weightsZ;
64 
65 	ScXYZ computeIlluminantWhite(const ScCIEIlluminant& illuminant, const ScCIEObserver& observer);
66 	ScXYZ computeIlluminantWhite(const ScE308Table& e380table);
67 	void  computeWeights(const ScCIEIlluminant& illuminant, const ScCIEObserver& observer);
68 };
69 
70 #endif
71