/* * PageNode.cc * * Created on: 29 oct. 2013 * Author: CS */ #include "PageNode.hh" #include "PanelNode.hh" #include "PlotLogger.hh" #include "Page.hh" #include "PlotOutput.hh" #include "Constant.hh" #include "CommonNode.hh" #include "LayoutNode.hh" #include "PlotOutput.hh" #include "DefaultPlotConfiguration.hh" namespace plot { PageNode::PageNode() : NodeGrpCfg() { getChildList()["title"] = AMDA::XMLConfigurator::NodeCfgSPtr( new TitleNode()); getChildList()["margin"] = AMDA::XMLConfigurator::NodeCfgSPtr( new MarginNode()); getChildList()["font"] = AMDA::XMLConfigurator::NodeCfgSPtr( new FontNode()); getChildList()["layout"] = AMDA::XMLConfigurator::NodeCfgSPtr( new LayoutNode()); getChildList()["panelDefaults"] = AMDA::XMLConfigurator::NodeCfgSPtr( new PanelDefaultNode()); getChildList()["panel"] = AMDA::XMLConfigurator::NodeCfgSPtr( new PanelNode()); } PageNode::~PageNode() { } void PageNode::proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "PageNode::proceed"); boost::shared_ptr page( new Page(DefaultPlotConfiguration::getInstance())); xmlChar* value = NULL; // -- format value = xmlGetProp(pNode, (const xmlChar *) "format"); if (value) { page->_format = std::string((const char*) value); xmlFree(value); } else { ERROR_EXCEPTION(AMDA::XMLConfigurator::ERROR_MANDATORY_ATTRIBUTE_MISSING << pNode->name << "@format"); } // -- dimension value = xmlGetProp(pNode, (const xmlChar *) "dimension"); if (value) { page->setDimension((const char*) value); xmlFree(value); } // -- orientation value = xmlGetProp(pNode, (const xmlChar *) "orientation"); if (value) { page->setOrientation((const char*) value); xmlFree(value); } // -- mode value = xmlGetProp(pNode, (const xmlChar *) "mode"); if (value) { page->setMode((const char*) value); xmlFree(value); } // -- defaultTimePlotWidth value = xmlGetProp(pNode, (const xmlChar *) "defaultTimePlotWidth"); if (value) { page->_defaultTimePlotWidth = std::stod((const char*) value); xmlFree(value); } // -- defaultTimePlotHeight value = xmlGetProp(pNode, (const xmlChar *) "defaultTimePlotHeight"); if (value) { page->_defaultTimePlotHeight = std::stod((const char*) value); xmlFree(value); } // -- defaultTimePlotXMargin value = xmlGetProp(pNode, (const xmlChar *) "defaultTimePlotXMargin"); if (value) { int margin1, margin2; extractMargins ((const char*) value, &margin1, &margin2); page->_defaultTimePlotLeftMargin = margin1; page->_defaultTimePlotRightMargin = margin2; xmlFree(value); } // -- defaultTimePlotYMargin value = xmlGetProp(pNode, (const xmlChar *) "defaultTimePlotYMargin"); if (value) { int margin1, margin2; extractMargins ((const char*) value, &margin1, &margin2); page->_defaultTimePlotTopMargin = margin1; page->_defaultTimePlotBottomMargin = margin2; xmlFree(value); } // -- defaultXYPlotWidth value = xmlGetProp(pNode, (const xmlChar *) "defaultXYPlotWidth"); if (value) { page->_defaultXYPlotWidth = std::stod((const char*) value); xmlFree(value); } // -- defaultXYPlotHeight value = xmlGetProp(pNode, (const xmlChar *) "defaultXYPlotHeight"); if (value) { page->_defaultXYPlotHeight = std::stod((const char*) value); xmlFree(value); } // -- defaultXYPlotXMargin value = xmlGetProp(pNode, (const xmlChar *) "defaultXYPlotXMargin"); if (value) { int margin1, margin2; extractMargins ((const char*) value, &margin1, &margin2); page->_defaultXYPlotLeftMargin = margin1; page->_defaultXYPlotRightMargin = margin2; xmlFree(value); } // -- defaultXYPlotYMargin value = xmlGetProp(pNode, (const xmlChar *) "defaultXYPlotYMargin"); if (value) { int margin1, margin2; extractMargins ((const char*) value, &margin1, &margin2); page->_defaultXYPlotTopMargin = margin1; page->_defaultXYPlotBottomMargin = margin2; xmlFree(value); } // -- superposeMode value = xmlGetProp(pNode, (const xmlChar *) "superposeMode"); if (value) { page->_superposeMode = (strcasecmp ((const char*)value, "true") == 0); xmlFree(value); } AMDA::Parameters::CfgContext context; PlotOutput* plotOutput = pContext.get(); plotOutput->setPage(boost::shared_ptr(page)); context.push(page.get()); context.push(pContext.get()); context.push( pContext.get()); AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode, context); } PanelDefaultNode::PanelDefaultNode() : NodeGrpCfg() { getChildList()["font"] = AMDA::XMLConfigurator::NodeCfgSPtr( new FontNode()); } PanelDefaultNode::~PanelDefaultNode() { } void PanelDefaultNode::proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& /*pContext*/) { LOG4CXX_DEBUG(gLogger, "PanelDefaultNode::proceed"); xmlChar* value = NULL; // -- resolution if ((value = xmlGetProp(pNode, (const xmlChar *) "resolution"))) { DefaultPlotConfiguration::getInstance()._defaultPanel._resolution = atoi((const char*) value); xmlFree(value); } // -- color value = xmlGetProp(pNode, (const xmlChar *) "backgroundColor"); if (value) { try { std::string strValue((const char*) value); createColor( DefaultPlotConfiguration::getInstance()._defaultPanel._backgroundColor, strValue); } catch (std::logic_error& e) { LOG4CXX_WARN(gLogger, "Panel Default BackgroundColor : " << e.what()); } xmlFree(value); } // -- color map index value = xmlGetProp(pNode, (const xmlChar *) "colorMapIndex"); if (value) { DefaultPlotConfiguration::getInstance()._defaultPanel._backgroundColor._colorMapIndex = atoi((const char*) value); xmlFree(value); } AMDA::Parameters::CfgContext context; context.push( &DefaultPlotConfiguration::getInstance()._defaultPanel); AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode, context); } } /* namespace plot */