DrawingPropertiesNode.hh
3.42 KB
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
/*
* DrawingPropertiesNode.hh
*
* Created on: Dec 9, 2013
* Author: amdadev
*/
#ifndef DRAWINGPROPERTIESNODE_HH_
#define DRAWINGPROPERTIESNODE_HH_
#include <libxml/tree.h>
#include <iosfwd>
#include "SerieSymbolNode.hh"
#include "LineNode.hh"
#include "ResamplingNode.hh"
#include "TimeTickNode.hh"
#include "IntervalTickNode.hh"
#include "ErrorBarNode.hh"
#include "PlotLogger.hh"
#include "NodeCfg.hh"
#include "FileConfigurator.hh"
#include "DrawingProperties.hh"
namespace plot {
/**
* Parse a "default" node in plot.xsd schema.
*/
template<class PlotType>
class DrawingPropertiesNode: public AMDA::XMLConfigurator::NodeGrpCfg {
public:
DrawingPropertiesNode() : 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 ~DrawingPropertiesNode(){
}
void proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& ctx_){
LOG4CXX_DEBUG(gLogger, "DrawingPropertiesNode::proceed");
// panel plot we are building...
PlotType* plotOutput = ctx_.get<PlotType*>();
// related param name...
xmlChar* name = ctx_.get<xmlChar*>();
// get default drawing properties object:
DrawingProperties& props = plotOutput->getParameter((const char*)name).getDefaultProperties();
// parse node attributes
parseAttributes(pNode_, props);
// proceed children
AMDA::Parameters::CfgContext childContext;
childContext.push<DrawingProperties*>( &props );
AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, childContext);
}
protected:
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);
}
// -- zAxis information
value = xmlGetProp(pNode_, (const xmlChar *) "zAxis");
if( value ){
props_.setZAxisId(std::string((const char*)value));
xmlFree(value);
}
// -- min information
value = xmlGetProp(pNode_, (const xmlChar *) "min");
if( value ){
props_.setMin(atof((const char*)value));
xmlFree(value);
}
else {
props_.setMin(nan(""));
}
// -- max information
value = xmlGetProp(pNode_, (const xmlChar *) "max");
if( value ){
props_.setMax(atof((const char*)value));
xmlFree(value);
}
else {
props_.setMax(nan(""));
}
// -- default color
updateColor( props_.getColor(), pNode_,(const xmlChar*)"color",(const xmlChar*)"colorMapIndex");
if(props_.getColor().isSet()){
// the following properties will be overridden if defined in sub nodes
props_.getLineProperties().setColor(props_.getColor());
props_.getSymbolProperties().setColor(props_.getColor());
}
}
};
} /* namespace plot */
#endif /* DRAWINGPROPERTIESNODE_HH_ */