Blame view

src/ParamOutputImpl/Plot/AxesNode.cc 4.77 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
 * AxesNode.cc
 *
 *  Created on: 26 nov. 2013
 *      Author: CS
 */

#include "AxesNode.hh"
#include "Panel.hh"
#include "DefaultPlotConfiguration.hh"

namespace plot {

void TimeAxisNode::proceed(xmlNodePtr pNode,
		const AMDA::Parameters::CfgContext& pCtx) {
	Panel* panel = pCtx.get<Panel*>();
	TimeAxis* axis = new TimeAxis(
			*DefaultPlotConfiguration::getInstance().getDefaultTimeAxis());

	// read dedicated attributes
	xmlChar* value = NULL;
	// -- axis id
	value = xmlGetProp(pNode, (const xmlChar *) "id");
	if (value && std::string((const char*)value).size() != 0) {
		axis->_id = (const char*) value;
		xmlFree(value);
	}
// Let default configuration of TimeAxis
// else {
//		axis->_id = DefaultPlotConfiguration::TIME_DEFAULT_ID;
//	}
	panel->addAxis(axis->_id, boost::shared_ptr<Axis>(axis));

	// -- time format type
	value = xmlGetProp(pNode, (const xmlChar *) "format");
	if (value) {
		axis->_timeFormat = (const char*) value;
		xmlFree(value);
	}

	AMDA::Parameters::CfgContext context;
	context.push<TimeAxis*>(axis);
	context.push<Panel*>(panel);

	AnyAxisNode<TimeAxis>::proceed(pNode, context);
}

void EpochAxisNode::proceed(xmlNodePtr pNode,
		const AMDA::Parameters::CfgContext& pCtx) {
	Panel* panel = pCtx.get<Panel*>();
	EpochAxis* axis = new EpochAxis(
			*DefaultPlotConfiguration::getInstance().getDefaultEpochAxis());

	// read dedicated attributes
	xmlChar* value = NULL;
	// -- axis id
	value = xmlGetProp(pNode, (const xmlChar *) "id");
	if (value && std::string((const char*)value).size() != 0) {
		axis->_id = (const char*) value;
	}
	if (value != NULL)
		xmlFree(value);

	// -- normalized
	value = xmlGetProp(pNode, (const xmlChar *) "normalized");
	if (value != NULL)
	{
		axis->setNormalized(strcmp((char*)value,"true") == 0);
		xmlFree(value);
	}

	panel->addAxis(axis->_id, boost::shared_ptr<Axis>(axis));

	AMDA::Parameters::CfgContext context;
	context.push<EpochAxis*>(axis);
	context.push<Panel*>(panel);

	AnyAxisNode<EpochAxis>::proceed(pNode, context);
}

void DigitalAxisNode::proceed(xmlNodePtr pNode,
		const AMDA::Parameters::CfgContext& pCtx) {
	LOG4CXX_DEBUG(gLogger, "DigitalAxisNode::proceed");
	Panel* panel = pCtx.get<Panel*>();
	const xmlChar * tagName = pCtx.get<const xmlChar*>();

	DigitalAxis* axis = new DigitalAxis(
			strcmp((const char *)tagName, (const char *)"xAxis") == 0 ?
					*DefaultPlotConfiguration::getInstance().getDefaultXAxis() :
					*DefaultPlotConfiguration::getInstance().getDefaultYAxis());
	// read dedicated attributes
	xmlChar* value = NULL;

	// -- axis id
	value = xmlGetProp(pNode, (const xmlChar *) "id");
	if (value) {
		axis->_id = (const char*) value;
		xmlFree(value);
	}
	panel->addAxis(axis->_id, boost::shared_ptr<Axis>(axis));

	AMDA::Parameters::CfgContext context;
	context.push<DigitalAxis*>(axis);
	context.push<Panel*>(panel);
	AnyAxisNode<DigitalAxis>::proceed(pNode, context);
}

void ColorAxisNode::proceed(xmlNodePtr pNode,
		const AMDA::Parameters::CfgContext& pCtx) {
	LOG4CXX_DEBUG(gLogger, "ColorAxisNode::proceed");
	Panel* panel = pCtx.get<Panel*>();

	ColorAxis* axis = new ColorAxis(
			*DefaultPlotConfiguration::getInstance().getDefaultColorAxis());

	xmlChar * value = NULL;
	Color color;
	std::string colorStr;

	// -- minValColor - all value lower than this value will be draw with this color
	value = xmlGetProp(pNode, (const xmlChar *) "minValColor");
	if( value ) {
		colorStr = (const char*)value;
		createColor(color, colorStr);
		axis->setMinValColor(color);
		xmlFree(value);
	}

	// -- maxValColor - all value greater than this value will be draw with this color
	value = xmlGetProp(pNode, (const xmlChar *) "maxValColor");
	if( value ) {
		colorStr = (const char*)value;
		createColor(color, colorStr);
		axis->setMaxValColor(color);
		xmlFree(value);
	}

	panel->addColorAxis(axis->_id, boost::shared_ptr<ColorAxis>(axis));

	AMDA::Parameters::CfgContext context;
	context.push<ColorAxis*>(axis);
	context.push<Panel*>(panel);
	AnyAxisNode<ColorAxis>::proceed(pNode, context);
}

void XAxisNode::proceed(xmlNodePtr pNode,
		const AMDA::Parameters::CfgContext& pContext) {
	Panel* panel = pContext.get<Panel*>();

	AMDA::Parameters::CfgContext context;
	context.push<Panel*>(panel);
	context.push<const xmlChar*>(pNode->name);
	NodeGrpCfg::proceed(pNode, context);
}

void YAxisNode::proceed(xmlNodePtr pNode,
		const AMDA::Parameters::CfgContext& pContext) {
	Panel* panel = pContext.get<Panel*>();

	AMDA::Parameters::CfgContext context;
	context.push<Panel*>(panel);
	context.push<const xmlChar*>(pNode->name);
	NodeGrpCfg::proceed(pNode, context);
}

void ZAxisNode::proceed(xmlNodePtr pNode,
		const AMDA::Parameters::CfgContext& pContext) {
	Panel* panel = pContext.get<Panel*>();

	AMDA::Parameters::CfgContext context;
	context.push<Panel*>(panel);
	context.push<const xmlChar*>(pNode->name);
	NodeGrpCfg::proceed(pNode, context);
}

}