StatusPlotNode.cc 1.87 KB
/*
 * StatusPlotNode.cc
 *
 *  Created on: 12 janv. 2015
 *      Author: AKKA
 */

#include "StatusPlotNode.hh"
#include "PanelPlotNodeRegistry.hh"
#include "StatusPlot.hh"
#include "PlotLogger.hh"
#include "ParamsNode.hh"
#include "PlotOutput.hh"
#include "PlotCommon.hh"
#include "NodeCfg.hh"
#include "StatusBarDecorator.hh"
#include "Time/TimePlot.hh"
#include <memory>

namespace plot {

const std::string StatusPlotNode::NODENAME = STATUSPLOT_NODENAME;

std::string StatusPlotNode::_key =
		PanelPlotNodeRegistry::getInstance().addElement(NODENAME,
				boost::shared_ptr<StatusPlotNode>(new StatusPlotNode()));

StatusPlotNode::StatusPlotNode() :
		AbstractDecoratorPlotNode() {
}

StatusPlotNode::~StatusPlotNode() {

}

boost::shared_ptr<DecoratorPlot> StatusPlotNode::createPlot(AMDA::Parameters::ParameterManager& manager, boost::shared_ptr<Panel> panel,
		bool isStandalone)
{
	LOG4CXX_DEBUG(gLogger, "StatusPlotNode::createPlot");
	return boost::shared_ptr<StatusPlot>(new StatusPlot(manager, panel, isStandalone));
}

void StatusPlotNode::parseAttributes(xmlNodePtr xmlNode_, boost::shared_ptr<DecoratorPlot> plot)
{
	LOG4CXX_DEBUG(gLogger, "StatusPlotNode::parseAttributes");
	// parse optional attribute :
	xmlChar* value = NULL;

	// colorMapIndex attribute
	value = xmlGetProp(xmlNode_, (const xmlChar *) "colorMapIndex");
	if (value != nullptr) {
		StatusBarDecorator *sbd = static_cast<StatusBarDecorator *>(plot->getTimeAxisDecorator().get());
		sbd->setColorMapIndex(atoi((const char*) value));
		xmlFree(value);
	}

	// position attribute
	value = xmlGetProp(xmlNode_, (const xmlChar *) "position");
	if (value != nullptr) {
		PlotCommon::Position position;
		PlotCommon::setPosition((const char*) value, position);
		StatusBarDecorator *sbd = static_cast<StatusBarDecorator *>(plot->getTimeAxisDecorator().get());
		sbd->setBarPosition(position);
		xmlFree(value);
	}
}

} /* namespace plot */