SpectroNode.hh 1.83 KB
/*
 * SpectroNode.hh
 *
 *  Created on: Jul 2, 2014
 *      Author: AKKA
 */

#ifndef SPECTRONODE_HH_
#define SPECTRONODE_HH_

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

#include "FileConfigurator.hh"
#include "DrawingPropertiesNode.hh"
#include "PlotLogger.hh"
#include "SpectroProperties.hh"

namespace plot {
/**
 * Class that handle a <spectro> xml node.
 * Template class that should be instanciated for each subclass of PanelOutputPanel.
 */

template<class PlotType>
class SpectroNode: public plot::DrawingPropertiesNode<PlotType> {
public:
	SpectroNode():
		DrawingPropertiesNode<PlotType>() {
	}
	virtual ~SpectroNode() {
	}

	void proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& pContext_) {
		LOG4CXX_DEBUG(gLogger, "SpectroNode::proceed");
		PlotType* plotOutput = pContext_.get<PlotType*>();
		xmlChar* name = pContext_.get<xmlChar*>();

		// initialize spectro with default properties
		DrawingProperties defaultProps = plotOutput->getParameter(
				(const char*) name).getDefaultProperties();

		// read parent attributes
		DrawingPropertiesNode<PlotType>::parseAttributes(pNode_, defaultProps);

		// spectro properties
		std::shared_ptr<SpectroProperties> spectroPropsPtr =
				std::shared_ptr<SpectroProperties>(new SpectroProperties(defaultProps));

		// read index definition
		xmlChar * value = NULL;

		value = xmlGetProp(pNode_, (const xmlChar*) "index");
		if (value) {
			spectroPropsPtr->setIndexDef((const char*) value);
			xmlFree(value);
		}

		//set related dim
		spectroPropsPtr->setRelatedDim(AMDA::Common::ParameterIndexesTool::getRelatedDimForTab2D(spectroPropsPtr->getIndexDef()));

		// add spectro definition to parameter
		plotOutput->getParameter((const char*)name).addSpectroProperties(spectroPropsPtr);
	}
};

}
/* namespace plot */

#endif /* SPECTRONODE_HH_ */