HistoPlotNode.cc 2.08 KB
/*
 * HistoPlotNode.cc
 *
 *  Created on: Dec 6, 2013
 *      Author: amdadev
 */

#include "HistoPlotNode.hh"
#include "PlotLogger.hh"
#include "PanelPlotNodeRegistry.hh"
#include "HistoPlot.hh"
#include "AxesNode.hh"
#include "AdditionalObjectsNode.hh"
#include "PlotLegendNode.hh"

namespace plot {

const std::string HistoPlotNode::NODENAME = HISTOPLOT_NODENAME;

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

HistoPlotNode::HistoPlotNode() :
		AbstractPanelPlotNode() {
	getChildList()["legends"] = AMDA::XMLConfigurator::NodeCfgSPtr(
				new PlotLegendNode());
	getChildList()["params"] = AMDA::XMLConfigurator::NodeCfgSPtr(
			new HistoPlotParamsNode<HistoPlot>());
	getChildList()["axes"] = AMDA::XMLConfigurator::NodeCfgSPtr(new AxesNode());
}

HistoPlotNode::~HistoPlotNode() {
}

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

	LOG4CXX_DEBUG(gLogger, "HistoPlotNode::proceed");
	boost::shared_ptr<HistoPlot> plot(
			new HistoPlot(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->_defaultXYPlotLeftMargin;
	if (panel_->_rightMargin == -1)
		panel_->_rightMargin = panel_->_page->_defaultXYPlotRightMargin;
	if (panel_->_topMargin == -1)
		panel_->_topMargin = panel_->_page->_defaultXYPlotTopMargin;
	if (panel_->_bottomMargin == -1)
		panel_->_bottomMargin = panel_->_page->_defaultXYPlotBottomMargin;

	if (panel_->_preferedWidth == -1)
		panel_->_preferedWidth = panel_->_page->_defaultXYPlotWidth;
	if (panel_->_preferedHeight == -1)
		panel_->_preferedHeight = panel_->_page->_defaultXYPlotHeight;



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

	return plot;
}

} /* namespace plot */