Blame view

src/ParamOutputImpl/Plot/PlotLegendNode.cc 6.53 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
/*
 * PlotLegendNode.cc
 *
 *  Created on: Sep 22, 2014
 *      Author: AKKA
 */


#ifndef PLOTLEGENDNODE_CC_
#define PLOTLEGENDNODE_CC_

#include "PlotLegendNode.hh"

#include "PlotLogger.hh"
#include "NodeCfg.hh"
#include "Panel.hh"
#include "Page.hh"
#include "CommonNode.hh"

namespace plot {

ParamsLegendNode::ParamsLegendNode() : AMDA::XMLConfigurator::NodeGrpCfg()
{
	getChildList()["font"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new FontNode<ParamsLegendProperties>());
}

ParamsLegendNode::~ParamsLegendNode()
{
}

void ParamsLegendNode::proceed(xmlNodePtr pNode_,
		const AMDA::Parameters::CfgContext& pContext_){
	LOG4CXX_DEBUG(gLogger, "ParamsLegendNode::proceed");

	Panel* panel = pContext_.get<Panel *>();
	ParamsLegendProperties& paramsLegendProperties = panel->_paramsLegendProperties;

	paramsLegendProperties.setIsVisible(true);

	xmlChar* value;

	// -- type
	if ((value = xmlGetProp(pNode_, (const xmlChar *) "type")))
	{
		if (strcmp ((const char *) value, "text-line-symbol") == 0)
			paramsLegendProperties.setOnlyText(false);
		else if (strcmp ((const char *) value, "text-only") == 0)
			paramsLegendProperties.setOnlyText(true);
		else
		{
			LOG4CXX_DEBUG(gLogger, "ParamsLegendNode::proceed - type " << value << "not implemented => set to text-line-symbol mode");
			paramsLegendProperties.setOnlyText(false);
		}
		xmlFree(value);
	}

	// -- showParamInfo
	if ((value = xmlGetProp(pNode_, (const xmlChar *) "showParamInfo")))
	{
		paramsLegendProperties.setParamInfoVisible(strcmp ((const char *) value, "true") == 0);
		xmlFree(value);
	}
	else
		paramsLegendProperties.setParamInfoVisible(true);

	// -- showIntervalInfo
	if ((value = xmlGetProp(pNode_, (const xmlChar *) "showIntervalInfo")))
	{
		paramsLegendProperties.setIntervalInfoVisible(strcmp ((const char *) value, "true") == 0);
		xmlFree(value);
	}
	else
		paramsLegendProperties.setIntervalInfoVisible(panel->_page->_superposeMode);

	if (paramsLegendProperties.isIntervalInfoVisible())
	{
		// -- intervalInfoType
		if ((value = xmlGetProp(pNode_, (const xmlChar *) "intervalInfoType")))
		{
			if (strcmp ((const char *) value, "start-stop") == 0)
			{
				paramsLegendProperties.setIntervalInfoType(ParamsLegendProperties::IntervalInfoType::STARTSTOP);
			}
			else
				paramsLegendProperties.setIntervalInfoType(ParamsLegendProperties::IntervalInfoType::INDEX);
			xmlFree(value);
		}
	}

	// -- position
	if ((value = xmlGetProp(pNode_, (const xmlChar *) "position")))
	{
		if (strcmp ((const char *) value, "inside") == 0)
			paramsLegendProperties.setPosition(ParamsLegendPosition::POS_INSIDE);
		else if (strcmp ((const char *) value, "outside") == 0)
			paramsLegendProperties.setPosition(ParamsLegendPosition::POS_OUTSIDE);
		else
		{
			LOG4CXX_DEBUG(gLogger, "ParamsLegendNode::proceed - position " << value << "not implemented => set to inside");
			paramsLegendProperties.setPosition(ParamsLegendPosition::POS_INSIDE);
		}
		xmlFree(value);
	}

	// -- defaultTextColor
	Color textColor(0,0,0);
	updateColor(textColor, pNode_, (const xmlChar *)"defaultTextColor", (const xmlChar *)"defaultTextColorMapIndex");
	paramsLegendProperties.setDefaultTextColor(textColor);

	// -- borderVisible
	if ((value = xmlGetProp(pNode_, (const xmlChar *) "borderVisible")))
	{
		paramsLegendProperties.setIsBorderVisible(strcmp ((const char *) value, "true") == 0);
		xmlFree(value);
	}
	else
		paramsLegendProperties.setIsBorderVisible(false);

	// -- borderColor
	Color borderColor(0,0,0);
	updateColor(borderColor, pNode_, (const xmlChar *)"borderColor", (const xmlChar *)"borderColorMapIndex");
	paramsLegendProperties.setBorderColor(borderColor);

	//init with panel font
f6eaec4e   Benjamin Renard   Optimize plot ele...
126
	paramsLegendProperties.setFont(panel->getFont());
fbe3c2bb   Benjamin Renard   First commit
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147

	AMDA::Parameters::CfgContext context;
	context.push<ParamsLegendProperties*>(&paramsLegendProperties);
	AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, context);
}

TextLegendNode::TextLegendNode() : AMDA::XMLConfigurator::NodeGrpCfg()
{
	getChildList()["font"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new FontNode<TextLegendProperties>());
}

TextLegendNode::~TextLegendNode()
{
}

void TextLegendNode::proceed(xmlNodePtr pNode_,
		const AMDA::Parameters::CfgContext& pContext_){
	LOG4CXX_DEBUG(gLogger, "TextLegendNode::proceed");

	Panel* panel = pContext_.get<Panel *>();
ac0e4b16   Erdogan Furkan   Some modifications
148
	IntervalsProperties *intervalsProps = pContext_.get<IntervalsProperties *>();
fbe3c2bb   Benjamin Renard   First commit
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
177
178
179
180
181
182
183

	boost::shared_ptr<TextLegendProperties> pTextLegendProperties (new TextLegendProperties());

	xmlChar* value;

	// -- text
	if ((value = xmlGetProp(pNode_, (const xmlChar *) "text")))
	{
		pTextLegendProperties->setText((const char *) value);
		xmlFree(value);
	}

	// -- position
	if ((value = xmlGetProp(pNode_, (const xmlChar *) "position")))
	{
		if (strcasecmp ((const char *) value, "left") == 0)
			pTextLegendProperties->setPosition(TextLegendPosition::POS_LEFT);
		else if (strcmp ((const char *) value, "right") == 0)
			pTextLegendProperties->setPosition(TextLegendPosition::POS_RIGHT);
		else if (strcmp ((const char *) value, "top") == 0)
			pTextLegendProperties->setPosition(TextLegendPosition::POS_TOP);
		else if (strcmp ((const char *) value, "bottom") == 0)
			pTextLegendProperties->setPosition(TextLegendPosition::POS_BOTTOM);
		else
		{
			LOG4CXX_DEBUG(gLogger, "TextLegendNode::proceed - position " << value << "not implemented => set to RIGHT");
			pTextLegendProperties->setPosition(TextLegendPosition::POS_RIGHT);
		}
		xmlFree(value);
	}

	// -- color
	updateColor(pTextLegendProperties->getColor(), pNode_, (const xmlChar *)"color", (const xmlChar *)"colorMapIndex");

	//init with panel font
f6eaec4e   Benjamin Renard   Optimize plot ele...
184
	pTextLegendProperties->setFont(panel->getFont());
fbe3c2bb   Benjamin Renard   First commit
185
186
187

	panel->_textLegendPropertiesList.push_back(pTextLegendProperties);

ac0e4b16   Erdogan Furkan   Some modifications
188
189
190
191
192
	if (intervalsProps != nullptr)
	{
		intervalsProps->setLegend(pTextLegendProperties);
	}

fbe3c2bb   Benjamin Renard   First commit
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
	AMDA::Parameters::CfgContext context;
	context.push<TextLegendProperties*>(pTextLegendProperties.get());

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

PlotLegendNode::PlotLegendNode() : AMDA::XMLConfigurator::NodeGrpCfg()
{
	getChildList()["paramsLegend"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new ParamsLegendNode());
	getChildList()["textLegend"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new TextLegendNode());
}

PlotLegendNode::~PlotLegendNode()
{
}

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

	AMDA::Parameters::CfgContext context;
	context.push<Panel*>(panel);
	AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, context);
}

} /* namespace plot */

#endif /* PARAMSLEGENDNODE_CC_ */