Blame view

src/ParamOutputImpl/Plot/InstantPlot/InstantSpectroNode.hh 2.38 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
52
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
/*
 * InstantSpectroNode.hh
 *
 *  Created on: Dec 18, 2014
 *      Author: AKKA
 */

#ifndef INSTANTSPECTRONODE_HH_
#define INSTANTSPECTRONODE_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 "InstantSpectroProperties.hh"

namespace plot {
template<class PlotType>

class InstantSpectroNode: public plot::DrawingPropertiesNode<PlotType> {
public:
	InstantSpectroNode() :
			DrawingPropertiesNode<PlotType>() {
	}
	virtual ~InstantSpectroNode() {
	}
	void proceed(xmlNodePtr pNode_, const AMDA::Parameters::CfgContext& pContext_) {
		LOG4CXX_DEBUG(gLogger, "InstantSpectroNode::proceed");
		PlotType* plotOutput = pContext_.get<PlotType*>();
		xmlChar* name = pContext_.get<xmlChar*>();

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

		boost::shared_ptr<InstantSpectroProperties> isp(new InstantSpectroProperties(defaultProps));

		plotOutput->setOriginalParamId ((const char *) name);
		plotOutput->setInstantSpectroProperties (isp);

		// parse attributes...
		parseAttributes(pNode_, *isp);

		// parse children nodes
		AMDA::Parameters::CfgContext context;
		context.push<xmlChar*>(name);
		context.push<InstantSpectroProperties*>(isp.get());
		context.push<DrawingProperties*>(isp.get());

		AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, context);

	}
protected:
	void parseAttributes(xmlNodePtr pNode_, DrawingProperties& props_) {

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

		// specific spectro node attributes :
		xmlChar * value = NULL;

		// -- xAxis identifier
		value = xmlGetProp(pNode_, (const xmlChar *) "xAxis");
		if( value ) {
			((InstantSeriesProperties&) props_).setXAxisId((const char*)value);
			xmlFree(value);
		}

		// -- yAxis identifier
		value = xmlGetProp(pNode_, (const xmlChar *) "yAxis");
		if( value ) {
			((InstantSpectroProperties&) props_).setYAxisId((const char*)value);
			xmlFree(value);
		}

		// -- dimOnXAxis
		value = xmlGetProp(pNode_, (const xmlChar*) "dimOnXAxis");
		if (value) {
			((InstantSpectroProperties&) props_).setDimOnXAxis(atoi((const char*)value));
			xmlFree(value);
		}
	}
};

}
/* namespace plot */

#endif /* INSTANTSPECTRONODE_HH_ */