/* * SpectroNode.hh * * Created on: Jul 2, 2014 * Author: AKKA */ #ifndef SPECTRONODE_HH_ #define SPECTRONODE_HH_ #include #include #include #include #include "DrawingPropertiesNode.hh" #include "FileConfigurator.hh" #include "PlotLogger.hh" #include "SpectroProperties.hh" namespace plot { /** * Class that handle a xml node. * Template class that should be instanciated for each subclass of PanelOutputPanel. */ template class SpectroNode : public plot::DrawingPropertiesNode { public: SpectroNode() : DrawingPropertiesNode() { } virtual ~SpectroNode() { } void proceed(xmlNodePtr pNode_, const AMDA::Parameters::CfgContext &pContext_) { LOG4CXX_DEBUG(gLogger, "SpectroNode::proceed"); PlotType *plotOutput = pContext_.get(); xmlChar *name = pContext_.get(); // initialize spectro with default properties DrawingProperties defaultProps = plotOutput->getParameter( (const char *)name) .getDefaultProperties(); // read parent attributes DrawingPropertiesNode::parseAttributes(pNode_, defaultProps); // spectro properties std::shared_ptr spectroPropsPtr = std::shared_ptr(new SpectroProperties(defaultProps)); xmlChar *value = NULL; // -- parameter resolution value = xmlGetProp(pNode_, (const xmlChar *)"resolution"); if (value) { spectroPropsPtr->setMaxResolution(atoi((const char *)value)); xmlFree(value); } // read index definition 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())); // read uselog0asmin value = xmlGetProp(pNode_, (const xmlChar *)"uselog0asmin"); if (value) { std::string strValue((const char *)value); std::transform(strValue.begin(), strValue.end(), strValue.begin(), ::tolower); std::istringstream is(strValue); bool uselog0asmin; is >> std::boolalpha >> uselog0asmin; spectroPropsPtr->setUseLog0AsMin(uselog0asmin); xmlFree(value); } // normalization value = xmlGetProp(pNode_, (const xmlChar *)"normalization"); if (value) { spectroPropsPtr->setNormalization((const char *)value); xmlFree(value); } value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_TYPE); if (value) { const char *valueString = (const char *)value; if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_CHANNEL) == 0) { spectroPropsPtr->setBackgroundSubType(SpectroProperties::BackgroundSubType::BYCHANNEL); } else if (strcmp(valueString, BACKGROUND_SUB_TYPE_BY_FIXED_VALUE) == 0) { spectroPropsPtr->setBackgroundSubType(SpectroProperties::BackgroundSubType::FIXEDVALUE); } xmlFree(value); } value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_VALUE); if (value) { char *newValueBrut = (char *)value; double newValue = std::stod(newValueBrut); spectroPropsPtr->setBackgroundSubValue(newValue); xmlFree(value); } else { spectroPropsPtr->setBackgroundSubValue(-1); } //setRelatedDim value = xmlGetProp(pNode_, (const xmlChar *)BACKGROUND_SUB_DIM); if (value) { char *newValueBrut = (char *)value; int newValue = std::stoi(newValueBrut); spectroPropsPtr->setBackgroundSubDim(newValue); xmlFree(value); } // add spectro definition to parameter plotOutput->getParameter((const char *)name).addSpectroProperties(spectroPropsPtr); } }; } /* namespace plot */ #endif /* SPECTRONODE_HH_ */