TimePlotNode.cc 2.46 KB
/*
 * TimePlotNode.cc
 *
 *  Created on: Dec 1, 2013
 *      Author: amdadev
 */

#ifndef TIMEPLOTNODE_CC_
#define TIMEPLOTNODE_CC_


#include "TimePlotNode.hh"
#include "PanelPlotNodeRegistry.hh"
#include "TimePlot.hh"
#include "AxesNode.hh"
#include "PlotLogger.hh"
#include "ParamsNode.hh"
#include "PlotLegendNode.hh"
#include "PlotOutput.hh"
#include "NodeCfg.hh"
#include "AdditionalObjectsNode.hh"
#include "FillsNode.hh"

namespace plot {


const std::string TimePlotNode::NODENAME = TIMEPLOT_NODENAME;

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

/**
 * default constructor implementation.
 */

TimePlotNode::TimePlotNode() :
		AbstractPanelPlotNode() {
	getChildList()["legends"] = AMDA::XMLConfigurator::NodeCfgSPtr(
					new PlotLegendNode());
	getChildList()["params"] = AMDA::XMLConfigurator::NodeCfgSPtr(
			new ParamsNode<TimePlot>());
	getChildList()["axes"] = AMDA::XMLConfigurator::NodeCfgSPtr(new AxesNode());
	getChildList()["additionalObjects"] = AMDA::XMLConfigurator::NodeCfgSPtr(new AdditionalObjectsNode());
	getChildList()["fills"] = AMDA::XMLConfigurator::NodeCfgSPtr(new FillsNode());
}

TimePlotNode::~TimePlotNode() {

}


boost::shared_ptr<PanelPlotOutput> TimePlotNode::proceed(xmlNodePtr pNode_, PlotOutput* plotManager_, Panel* panel_){

	LOG4CXX_DEBUG(gLogger, "TimeNode::proceed");

	boost::shared_ptr<TimePlot> plot(
			new TimePlot(plotManager_->getParameterManager(),
					boost::shared_ptr<Panel>(panel_)));

	// Copy default pages values for the panel if not already specified
	if (panel_->_leftMargin == -1)
		panel_->_leftMargin = panel_->_page->_defaultTimePlotLeftMargin;
	if (panel_->_rightMargin == -1)
		panel_->_rightMargin = panel_->_page->_defaultTimePlotRightMargin;
	if (panel_->_topMargin == -1)
		panel_->_topMargin = panel_->_page->_defaultTimePlotTopMargin;
	if (panel_->_bottomMargin == -1)
		panel_->_bottomMargin = panel_->_page->_defaultTimePlotBottomMargin;

	if (panel_->_preferedWidth == -1)
		panel_->_preferedWidth = panel_->_page->_defaultTimePlotWidth;
	if (panel_->_preferedHeight == -1)
		panel_->_preferedHeight = panel_->_page->_defaultTimePlotHeight;

	AMDA::Parameters::CfgContext context;
	context.push<PanelPlotOutput*>(plot.get());
	context.push<TimePlot*>(plot.get());
	context.push<Panel*>(panel_);
	AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, context);

	return plot;
}

}  // namespace plot

#endif /* TIMEPLOTNODE_CC_ */