LayoutNode.cc 2.05 KB
/*
 * LayoutNode.cc
 *
 *  Created on: Sep, 2, 2014
 *      Author: AKKA
 */


#ifndef LAYOUTNODE_CC_
#define LAYOUTNODE_CC_

#include "LayoutNode.hh"

#include <libxml/tree.h>
#include <iosfwd>

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

namespace plot {

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

	Page *page = pContext_.get<Page*>();

	// read attributes :
	xmlChar* value = NULL;

	// overwrites default values if any...
	// type
	value = xmlGetProp(pNode_, (const xmlChar *)"type");
	if( value ){
		try{
			page->_layoutProperties.setType( stoLayoutType.at(std::string((const char*)value)) );
//			std::cout << "@type="<< value<< std::endl;
		}
		catch( std::out_of_range& err ){
			std::ostringstream msg {};
			msg << "LayoutNode::proceed invalid LayoutType value:" << value <<". Using default value.";
			LOG4CXX_DEBUG(gLogger, msg.str());
		}
		xmlFree(value);
	}

	// panelHeight
	value = xmlGetProp(pNode_, (const xmlChar *)"panelHeight");
	if( value ){
		page->_layoutProperties.setPanelHeight( std::stod ((const char*)value));
		xmlFree(value);
	}

	// panelSpacing
	value = xmlGetProp(pNode_, (const xmlChar *)"panelSpacing");
	if( value ){
		page->_layoutProperties.setPanelSpacing( std::stod ((const char*)value));
		xmlFree(value);
	}

	// firstPanelHeightFactor
	value = xmlGetProp(pNode_, (const xmlChar *)"firstPanelHeightFactor");
	if( value ){
		page->_layoutProperties.setFirstPanelHeightFactor( std::stod ((const char*)value));
		xmlFree(value);
	}

	// expand
	value = xmlGetProp(pNode_, (const xmlChar *)"expand");
	if( value ){
		page->_layoutProperties.setExpand( strcasecmp ((const char*)value, "true") == 0);
		xmlFree(value);
	}

	// onlyLowerTimeAxesLegend
	value = xmlGetProp(pNode_, (const xmlChar *)"onlyLowerTimeAxesLegend");
	if( value ){
		page->_layoutProperties.setOnlyLowerTimeAxesLegend( strcasecmp ((const char*)value, "true") == 0);
		xmlFree(value);
	}
}

} /* namespace plot */

#endif /* LAYOUTNODE_CC_ */