Blame view

src/ParamOutputImpl/Plot/SpectroNode.hh 2.65 KB
fbe3c2bb   Benjamin Renard   First commit
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
50
51
/*
 * SpectroNode.hh
 *
 *  Created on: Jul 2, 2014
 *      Author: AKKA
 */

#ifndef SPECTRONODE_HH_
#define SPECTRONODE_HH_

#include <libxml/globals.h>
#include <libxml/tree.h>
#include <libxml/xmlstring.h>
#include <iosfwd>

#include "FileConfigurator.hh"
#include "DrawingPropertiesNode.hh"
#include "PlotLogger.hh"
#include "SpectroProperties.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 SpectroNode: public plot::DrawingPropertiesNode<PlotType> {
public:
	SpectroNode():
		DrawingPropertiesNode<PlotType>() {
	}
	virtual ~SpectroNode() {
	}

	void proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& pContext_) {
		LOG4CXX_DEBUG(gLogger, "SpectroNode::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
		std::shared_ptr<SpectroProperties> spectroPropsPtr =
				std::shared_ptr<SpectroProperties>(new SpectroProperties(defaultProps));

fbe3c2bb   Benjamin Renard   First commit
52
53
		xmlChar * value = NULL;

724e3c7a   Benjamin Renard   Give the possibil...
54
55
56
57
58
59
60
61
		// -- parameter resolution
		value = xmlGetProp(pNode_, (const xmlChar *) "resolution");
		if( value ) {
			spectroPropsPtr->setMaxResolution(atoi((const char*)value));
			xmlFree(value);
		}

		// read index definition
fbe3c2bb   Benjamin Renard   First commit
62
63
64
65
66
67
68
69
70
		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()));

1003dcf4   Benjamin Renard   Add option to sho...
71
72
73
74
75
76
77
78
79
80
81
82
		// 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);
		}
c3eb35bf   Hacene SI HADJ MOHAND   progress
83
                
a436273c   Hacene SI HADJ MOHAND   evol ok
84
85
                                         // normalization
		value = xmlGetProp(pNode_, (const xmlChar*) "normalization");
c3eb35bf   Hacene SI HADJ MOHAND   progress
86
		if (value) {
a436273c   Hacene SI HADJ MOHAND   evol ok
87
			spectroPropsPtr->setNormalization((const char*) value);
c3eb35bf   Hacene SI HADJ MOHAND   progress
88
89
			xmlFree(value);
		}
1003dcf4   Benjamin Renard   Add option to sho...
90
		
fbe3c2bb   Benjamin Renard   First commit
91
92
93
94
95
96
97
98
99
		// add spectro definition to parameter
		plotOutput->getParameter((const char*)name).addSpectroProperties(spectroPropsPtr);
	}
};

}
/* namespace plot */

#endif /* SPECTRONODE_HH_ */