Blame view

src/ParamOutputImpl/Plot/AbstractPlotConfigNode.hh 2.83 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
93
94
95
96
97
98
99
100
101
102
/*
 * AbstractPlotConfigNode.hh
 *
 *  Created on: Dec 10, 2013
 *      Author: amdadev
 */

#ifndef ABSTRACTPLOTCONFIGNODE_HH_
#define ABSTRACTPLOTCONFIGNODE_HH_

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


#include "DefaultPlotConfiguration.hh"
#include "DrawingPropertiesNode.hh"
#include "FileConfigurator.hh"
#include "DrawingProperties.hh"
#include "LineNode.hh"
#include "NodeCfg.hh"
#include "SerieSymbolNode.hh"
#include "TimeTickNode.hh"
#include "IntervalTickNode.hh"
#include "ResamplingNode.hh"
#include "ErrorBarNode.hh"

namespace plot {
/**
 * base class that manage default configuration nodes for any type of plot.
 */
class AbstractPlotConfigNode: public AMDA::XMLConfigurator::NodeGrpCfg {
public:
	AbstractPlotConfigNode() : NodeGrpCfg(){
		getChildList()["line"] = AMDA::XMLConfigurator::NodeCfgSPtr(
							new LineNode<DrawingProperties>()	);
		getChildList()["symbol"] = AMDA::XMLConfigurator::NodeCfgSPtr(
						new SerieSymbolNode() );
		getChildList()["timeTick"] = AMDA::XMLConfigurator::NodeCfgSPtr(
						new TimeTickNode() );
		getChildList()["intervalTick"] = AMDA::XMLConfigurator::NodeCfgSPtr(
								new IntervalTickNode() );
		getChildList()["resampling"] = AMDA::XMLConfigurator::NodeCfgSPtr(
								new ResamplingNode() );
		getChildList()["errorBar"] = AMDA::XMLConfigurator::NodeCfgSPtr(
								new ErrorBarNode() );
	}
	virtual ~AbstractPlotConfigNode(){
	}

	void proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& ctx_){
		LOG4CXX_DEBUG(gLogger, "AbstractPlotConfigNode::proceed");
		DefaultPlotConfiguration* pConfig = ctx_.get<DefaultPlotConfiguration*>();
		// initialize drawing properties object:
		DrawingProperties props;

		// parse node attributes
		parseAttributes(pNode_, props);

		// proceed children
		AMDA::Parameters::CfgContext childContext;
		childContext.push<DrawingProperties*>( &props );
		AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, childContext);

		pConfig->_defaultDrawingProperties[getNodeName()]=props;

	}

protected:
	virtual const std::string& getNodeName()=0;

	virtual void parseAttributes(xmlNodePtr pNode_, DrawingProperties& props_){

		// attribute
		xmlChar* value = NULL;
		// -- xAxis information
		value = xmlGetProp(pNode_, (const xmlChar *) "xAxis");
		if( value ){
			props_.setXAxisId(std::string((const char*)value));
			xmlFree(value);
		}
		// -- yAxis information
		value = xmlGetProp(pNode_, (const xmlChar *) "yAxis");
		if( value ){
			props_.setYAxisId(std::string((const char*)value));
			xmlFree(value);
		}
		// -- yAxis information
		value = xmlGetProp(pNode_, (const xmlChar *) "zAxis");
		if( value ){
				props_.setZAxisId(std::string((const char*)value));
				xmlFree(value);
		}
		// -- default color
		updateColor( props_.getColor(), pNode_,(const xmlChar*)"color",(const xmlChar*)"colorMapIndex");
	}

};


} /* namespace plot */

#endif /* ABSTRACTPLOTCONFIGNODE_HH_ */