IntervalTickNode.cc 1.9 KB
/*
 * IntervalTickNode.cc
 *
 *  Created on: Jan 26, 2015
 *      Author: AKKA
 */


#include "IntervalTickNode.hh"

#include "NodeCfg.hh"
#include "PlotLogger.hh"
#include "SeriesProperties.hh"
#include "CommonNode.hh"


namespace plot {

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

	DrawingProperties* props = pContext_.get<DrawingProperties*>();
	IntervalTickProperties & itProps = props->getIntervalTickProperties();

	// read attributes :
	xmlChar* value = NULL;

	// TODO see if we have some default config values to retrieve...

	// overwrites default values if any...

	// -- color attributes
	updateColor (itProps.getColor(), pNode_, (const xmlChar *)"color", (const xmlChar *)"colorMapIndex");

	// -- mode attributes
	value = xmlGetProp(pNode_, (const xmlChar *)"mode");
	if( value ){
		if (strcmp((const char*)value, "symbol-only") == 0)
			itProps.setMode(IntervalTickMode::SYMBOL_ONLY);
		else if (strcmp((const char*)value, "interval-index") == 0)
			itProps.setMode(IntervalTickMode::INTERVAL_INDEX);
		else if (strcmp((const char*)value, "start-time") == 0)
			itProps.setMode(IntervalTickMode::START_TIME);
		else if (strcmp((const char*)value, "start-stop-time") == 0)
			itProps.setMode(IntervalTickMode::START_STOP_TIME);
		else
		{
			LOG4CXX_WARN(gLogger,
					"Unknown interval tick mode => set to IntervalTickMode::SYMBOL_ONLY");
			itProps.setMode(IntervalTickMode::SYMBOL_ONLY);
		}
		xmlFree(value);
	}
	else
		itProps.setMode(IntervalTickMode::SYMBOL_ONLY);

	// Push DrawingProperties & IntervalTickProperties in a new context
	// before proceeding childs node
	AMDA::Parameters::CfgContext context;
	context.push<DrawingProperties *> (props);
	context.push<IntervalTickProperties *> (&itProps);

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

} /* namespace plot */