Blame view

src/ParamOutputImpl/Plot/SauvaudNode.hh 3.98 KB
793c4351   Hacene SI HADJ MOHAND   creation de class...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   SauvaudNode.hh
 * Author: hacene
 *
 * Created on January 3, 2022, 10:51 AM
 */

#ifndef SAUVAUDNODE_HH
#define SAUVAUDNODE_HH

namespace plot
{
	/**
 * Class that handle a <spectro> xml node.
 * Template class that should be instanciated for each subclass of PanelOutputPanel.
 */

	template <class PlotType>
	class SauvaudNode : public plot::DrawingPropertiesNode<PlotType>
	{
	public:
		SauvaudNode() : DrawingPropertiesNode<PlotType>()
		{
		}
		virtual ~SauvaudNode()
		{
		}

		void proceed(xmlNodePtr pNode_, const AMDA::Parameters::CfgContext &pContext_)
		{
			LOG4CXX_DEBUG(gLogger, "SauvaudNode::proceed");
			PlotType *plotOutput = pContext_.get<PlotType *>();
			xmlChar *name = pContext_.get<xmlChar *>();

			// initialize spectro with default properties
			DrawingProperties defaultProps = plotOutput->getParameter(
														   (const char *)name)
												 .getDefaultProperties();

			// read parent attributes
			DrawingPropertiesNode<PlotType>::parseAttributes(pNode_, defaultProps);

			// spectro properties
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
50
			std::shared_ptr<SauvaudProperties> sauvaudPropsPtr =
793c4351   Hacene SI HADJ MOHAND   creation de class...
51
52
53
54
55
56
57
58
				std::shared_ptr<SauvaudProperties>(new SauvaudProperties(defaultProps));

			xmlChar *value = NULL;

			// -- parameter resolution
			value = xmlGetProp(pNode_, (const xmlChar *)"resolution");
			if (value)
			{
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
59
				sauvaudPropsPtr->setMaxResolution(atoi((const char *)value));
793c4351   Hacene SI HADJ MOHAND   creation de class...
60
61
				xmlFree(value);
			}
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
62
63
                        
                                                            // -- dimension to put in right axis 
e1e55413   Hacene SI HADJ MOHAND   us ok
64
			value = xmlGetProp(pNode_, (const xmlChar *)"right_dim");
b0205fd9   Hacene SI HADJ MOHAND   plot ok reste que...
65
66
67
68
69
			if (value)
			{
				sauvaudPropsPtr->setRightDim(atoi((const char *)value));
				xmlFree(value);
			}
793c4351   Hacene SI HADJ MOHAND   creation de class...
70
71
72
73
74

			// read index definition
			value = xmlGetProp(pNode_, (const xmlChar *)"index");
			if (value)
			{
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
75
				sauvaudPropsPtr->setIndexDef((const char *)value);
793c4351   Hacene SI HADJ MOHAND   creation de class...
76
77
78
79
				xmlFree(value);
			}

			//set related dim
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
80
			sauvaudPropsPtr->setRelatedDim(AMDA::Common::ParameterIndexesTool::getRelatedDimForTab2D(sauvaudPropsPtr->getIndexDef()));
793c4351   Hacene SI HADJ MOHAND   creation de class...
81
82
83
84
85
86
87
88
89
90
91

			// 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;
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
92
				sauvaudPropsPtr->setUseLog0AsMin(uselog0asmin);
793c4351   Hacene SI HADJ MOHAND   creation de class...
93
94
95
96
97
98
99
				xmlFree(value);
			}

			// normalization
			value = xmlGetProp(pNode_, (const xmlChar *)"normalization");
			if (value)
			{
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
100
				sauvaudPropsPtr->setNormalization((const char *)value);
793c4351   Hacene SI HADJ MOHAND   creation de class...
101
102
103
104
105
106
107
108
109
110
				xmlFree(value);
			}

			value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_TYPE);
			if (value)
			{
				const char *valueString = (const char *)value;

				if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_CHANNEL) == 0)
				{
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
111
					sauvaudPropsPtr->setBackgroundSubType(SauvaudProperties::BackgroundSubType::BYCHANNEL);
793c4351   Hacene SI HADJ MOHAND   creation de class...
112
113
114
				}
				else if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_FIXED_VALUE) == 0)
				{
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
115
					sauvaudPropsPtr->setBackgroundSubType(SauvaudProperties::BackgroundSubType::FIXEDVALUE);
793c4351   Hacene SI HADJ MOHAND   creation de class...
116
117
118
119
120
121
122
123
124
125
				}

				xmlFree(value);
			}

			value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_VALUE);
			if (value)
			{
				char *newValueBrut = (char *)value;
				double newValue = std::stod(newValueBrut);
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
126
				sauvaudPropsPtr->setBackgroundSubValue(newValue);
793c4351   Hacene SI HADJ MOHAND   creation de class...
127
128
129
130
131
132
133
134
				xmlFree(value);
			}
			//setRelatedDim
			value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_DIM);
			if (value)
			{
				char *newValueBrut = (char *)value;
				int newValue = std::stoi(newValueBrut);
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
135
				sauvaudPropsPtr->setBackgroundSubDim(newValue);
793c4351   Hacene SI HADJ MOHAND   creation de class...
136
137
138
				xmlFree(value);
			}
			// add spectro definition to parameter
5f13f59c   Hacene SI HADJ MOHAND   in progress worki...
139
			plotOutput->getParameter((const char *)name).addSauvaudProperties(sauvaudPropsPtr);
793c4351   Hacene SI HADJ MOHAND   creation de class...
140
141
142
143
144
145
146
		}
	};

}
/* namespace plot */

#endif /* SAUVAUDNODE_HH */