Blame view

src/ParamOutputImpl/Plot/SpectroNode.hh 3.79 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
/*
 * SpectroNode.hh
 *
 *  Created on: Jul 2, 2014
 *      Author: AKKA
 */

#ifndef SPECTRONODE_HH_
#define SPECTRONODE_HH_

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
11
#include <iosfwd>
fbe3c2bb   Benjamin Renard   First commit
12
13
14
#include <libxml/globals.h>
#include <libxml/tree.h>
#include <libxml/xmlstring.h>
fbe3c2bb   Benjamin Renard   First commit
15

fbe3c2bb   Benjamin Renard   First commit
16
#include "DrawingPropertiesNode.hh"
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
17
#include "FileConfigurator.hh"
fbe3c2bb   Benjamin Renard   First commit
18
19
20
#include "PlotLogger.hh"
#include "SpectroProperties.hh"

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
21
22
23
namespace plot
{
	/**
fbe3c2bb   Benjamin Renard   First commit
24
25
26
27
 * Class that handle a <spectro> xml node.
 * Template class that should be instanciated for each subclass of PanelOutputPanel.
 */

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
28
29
30
31
32
33
34
35
36
37
	template <class PlotType>
	class SpectroNode : public plot::DrawingPropertiesNode<PlotType>
	{
	public:
		SpectroNode() : DrawingPropertiesNode<PlotType>()
		{
		}
		virtual ~SpectroNode()
		{
		}
fbe3c2bb   Benjamin Renard   First commit
38

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
39
40
41
42
43
		void proceed(xmlNodePtr pNode_, const AMDA::Parameters::CfgContext &pContext_)
		{
			LOG4CXX_DEBUG(gLogger, "SpectroNode::proceed");
			PlotType *plotOutput = pContext_.get<PlotType *>();
			xmlChar *name = pContext_.get<xmlChar *>();
fbe3c2bb   Benjamin Renard   First commit
44

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
45
46
47
48
			// initialize spectro with default properties
			DrawingProperties defaultProps = plotOutput->getParameter(
														   (const char *)name)
												 .getDefaultProperties();
724e3c7a   Benjamin Renard   Give the possibil...
49

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
50
51
			// read parent attributes
			DrawingPropertiesNode<PlotType>::parseAttributes(pNode_, defaultProps);
fbe3c2bb   Benjamin Renard   First commit
52

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
			// spectro properties
			std::shared_ptr<SpectroProperties> spectroPropsPtr =
				std::shared_ptr<SpectroProperties>(new SpectroProperties(defaultProps));

			xmlChar *value = NULL;

			// -- parameter resolution
			value = xmlGetProp(pNode_, (const xmlChar *)"resolution");
			if (value)
			{
				spectroPropsPtr->setMaxResolution(atoi((const char *)value));
				xmlFree(value);
			}

			// read index definition
			value = xmlGetProp(pNode_, (const xmlChar *)"index");
			if (value)
			{
				spectroPropsPtr->setIndexDef((const char *)value);
				xmlFree(value);
			}

			//set related dim
			spectroPropsPtr->setRelatedDim(AMDA::Common::ParameterIndexesTool::getRelatedDimForTab2D(spectroPropsPtr->getIndexDef()));

			// read uselog0asmin
			value = xmlGetProp(pNode_, (const xmlChar *)"uselog0asmin");
			if (value)
			{
				std::string strValue((const char *)value);
				std::transform(strValue.begin(), strValue.end(), strValue.begin(),
							   ::tolower);
				std::istringstream is(strValue);
				bool uselog0asmin;
				is >> std::boolalpha >> uselog0asmin;
				spectroPropsPtr->setUseLog0AsMin(uselog0asmin);
				xmlFree(value);
			}

			// normalization
			value = xmlGetProp(pNode_, (const xmlChar *)"normalization");
			if (value)
			{
				spectroPropsPtr->setNormalization((const char *)value);
				xmlFree(value);
			}

			value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_TYPE);
			if (value)
			{
9e7f1f63   Menouard AZIB   Remplacer les str...
103
104
105
106
107
108
109
110
111
112
113
				const char *valueString = (const char *)value;

				if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_CHANNEL) == 0)
				{
					spectroPropsPtr->setBackgroundSubType(SpectroProperties::BackgroundSubType::BYCHANNEL);
				}
				else if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_FIXED_VALUE) == 0)
				{
					spectroPropsPtr->setBackgroundSubType(SpectroProperties::BackgroundSubType::FIXEDVALUE);
				}

fe6b6521   Menouard AZIB   J'ai ajouté le tr...
114
115
116
117
118
119
120
121
122
123
124
				xmlFree(value);
			}

			value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_VALUE);
			if (value)
			{
				char *newValueBrut = (char *)value;
				double newValue = std::stod(newValueBrut);
				spectroPropsPtr->setBackgroundSubValue(newValue);
				xmlFree(value);
			}
fc5c0567   Menouard AZIB   Correction d'un b...
125
126
127
128
			else
			{
				spectroPropsPtr->setBackgroundSubValue(-1);
			}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
129
130
131
132
133
134
135
136
137
138
139
			//setRelatedDim
			value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_DIM);
			if (value)
			{
				char *newValueBrut = (char *)value;
				int newValue = std::stoi(newValueBrut);
				spectroPropsPtr->setBackgroundSubDim(newValue);
				xmlFree(value);
			}
			// add spectro definition to parameter
			plotOutput->getParameter((const char *)name).addSpectroProperties(spectroPropsPtr);
c3eb35bf   Hacene SI HADJ MOHAND   progress
140
		}
fe6b6521   Menouard AZIB   J'ai ajouté le tr...
141
	};
fbe3c2bb   Benjamin Renard   First commit
142
143
144
145
146

}
/* namespace plot */

#endif /* SPECTRONODE_HH_ */