#include "PlotFunctionNode.hh" #include "AxesNode.hh" #include "FillsNode.hh" #include "PanelPlotNodeRegistry.hh" #include "ParamsNode.hh" #include "PlotFunction.hh" #include "PlotLegendNode.hh" #include "PlotLogger.hh" // DD_Client_r_lib module includes #include "TimeUtil.hh" namespace plot { const std::string PlotFunctionNode::NODENAME = PlotFunction_NODENAME; std::string PlotFunctionNode::_key = PanelPlotNodeRegistry::getInstance().addElement( NODENAME, boost::shared_ptr(new PlotFunctionNode())); PlotFunctionNode::PlotFunctionNode() : AbstractPanelPlotNode() { getChildList()["legends"] = AMDA::XMLConfigurator::NodeCfgSPtr( new PlotLegendNode()); getChildList()["params"] = AMDA::XMLConfigurator::NodeCfgSPtr( new ParamsNode()); getChildList()["axes"] = AMDA::XMLConfigurator::NodeCfgSPtr(new AxesNode()); } PlotFunctionNode::~PlotFunctionNode() { } boost::shared_ptr PlotFunctionNode::proceed(xmlNodePtr pNode_, PlotOutput *plotManager_, Panel *panel_) { LOG4CXX_DEBUG(gLogger, "PlotFunctionNode::proceed"); boost::shared_ptr plot( new PlotFunction(plotManager_->getParameterManager(), boost::shared_ptr(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; // Read PlotFunction attributes xmlChar *value; value = xmlGetProp(pNode_, (const xmlChar *)PlotFunctuion_Type); if (value) { const char *valueString = (const char *)value; if (strcmp(valueString, PlotFunctuion_Type_SUM) == 0) plot->setFunction(PlotFunction::Function::SUM); else if (strcmp(valueString, PlotFunctuion_Type_FFT) == 0) plot->setFunction(PlotFunction::Function::FFT); else plot->setFunction(PlotFunction::Function::NONE); xmlFree(value); } value = xmlGetProp(pNode_, (const xmlChar *)PlotFunction_Abscisse); if (value && plot->getFunction() == PlotFunction::Function::FFT) { const char *valueString = (const char *)value; if (strcmp(valueString, PlotFunction_Abscisse_Frequency) == 0) { Abscisse abscisse("Freq. ", "(Hz)", Abscisse::Abscisse_Type::FREQUENCY); plot->setAbscisse(abscisse); } else if (strcmp(valueString, PlotFunction_Abscisse_Period) == 0) { Abscisse abscisse("Period. ", "(S)", Abscisse::Abscisse_Type::PERIOD); plot->setAbscisse(abscisse); } xmlFree(value); } else { Abscisse abscisse("Time, ", "UT", Abscisse::Abscisse_Type::TIME); plot->setAbscisse(abscisse); } value = xmlGetProp(pNode_, (const xmlChar *)PlotFunctuion_Params_Nb_Points); if (value) { const char *newValueBrut = (char *)value; std::string newValue = std::string(newValueBrut); std::vector tokens; std::string token; std::stringstream ss(newValue); while (getline(ss, token, '@')) { tokens.push_back(token); } LOG4CXX_DEBUG(gLogger, tokens[0] << " COUCOU " << tokens[1]); plot->setParamsNbPoints(tokens); xmlFree(value); } value = xmlGetProp(pNode_, (const xmlChar *)PlotFunction_Scale_Abscisse); if (value) { const char *valueAbscisseScale = (char *)value; if (strcmp(valueAbscisseScale, PlotFunction_Linear) == 0) plot->setAbscisseScale(Axis::Scale::LINEAR); else if (strcmp(valueAbscisseScale, PlotFunction_Log) == 0) plot->setAbscisseScale(Axis::Scale::LOGARITHMIC); LOG4CXX_DEBUG(gLogger, valueAbscisseScale); LOG4CXX_DEBUG(gLogger, plot->getAbscisseScale()); xmlFree(value); } value = xmlGetProp(pNode_, (const xmlChar *)PlotFunction_Scale_Ordonnee); if (value) { const char *valueOrdonneeScale = (char *)value; if (strcmp(valueOrdonneeScale, PlotFunction_Linear) == 0) plot->setOrdonneeScale(Axis::Scale::LINEAR); else if (strcmp(valueOrdonneeScale, PlotFunction_Log) == 0) plot->setOrdonneeScale(Axis::Scale::LOGARITHMIC); LOG4CXX_DEBUG(gLogger, valueOrdonneeScale); LOG4CXX_DEBUG(gLogger, plot->getOrdonneeScale()); xmlFree(value); } else { LOG4CXX_DEBUG(gLogger, "non value"); } AMDA::Parameters::CfgContext context; context.push(plot.get()); context.push(plot.get()); context.push(panel_); AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, context); return plot; } } /* namespace plot */