/* * PanelNode.cc * * Created on: 29 oct. 2013 * Author: CS */ #include "PanelNode.hh" #include "PlotLogger.hh" #include "Panel.hh" #include "Page.hh" #include "DefaultPlotConfiguration.hh" #include "CommonNode.hh" #include "PanelPlotNodeRegistry.hh" #include "ParamPlotNode.hh" #include #include namespace plot { PanelNode::PanelNode() : NodeGrpCfg() { getChildList()["bounds"] = AMDA::XMLConfigurator::NodeCfgSPtr( new BoundsNode()); getChildList()["font"] = AMDA::XMLConfigurator::NodeCfgSPtr( new FontNode()); getChildList()["title"] = AMDA::XMLConfigurator::NodeCfgSPtr( new TitleNode()); for( auto child : PanelPlotNodeRegistry::getInstance().getAllElements() ){ getChildList()[child.first] = child.second; } // paramPlot node specify a plot node where plot type is set // in parameter id description (as a paramPlot node attribute) getChildList()["paramPlot"] = AMDA::XMLConfigurator::NodeCfgSPtr( new ParamPlotNode()); } PanelNode::~PanelNode() { } void PanelNode::proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "PanelNode::proceed"); Page* page = pContext.get(); Panel* panel = new Panel(page); xmlChar* value = NULL; // -- id if ((value = xmlGetProp(pNode, (const xmlChar *) "id"))) { panel->_id = atoi((const char*) value); xmlFree(value); } // -- index if ((value = xmlGetProp(pNode, (const xmlChar *) "index"))) { panel->_index = atoi((const char*) value); xmlFree(value); } // -- resolution if ((value = xmlGetProp(pNode, (const xmlChar *) "resolution"))) { panel->_resolution = atoi((const char*) value); xmlFree(value); } // -- color Color bgcolor; value = xmlGetProp(pNode, (const xmlChar *) "backgroundColor"); if (value) { try { std::string strValue((const char*) value); createColor(bgcolor, strValue); } catch (std::logic_error& e) { LOG4CXX_WARN(gLogger, "Panel BackgroundColor : " << e.what()); bgcolor = DefaultPlotConfiguration::getInstance()._defaultPanel._backgroundColor; } xmlFree(value); } else { bgcolor = DefaultPlotConfiguration::getInstance()._defaultPanel._backgroundColor; } // -- plot area color Color pabgcolor; value = xmlGetProp(pNode, (const xmlChar *)"plotAreaBackgroundColor"); if (value) { try { std::string strValue((const char *)value); createColor(pabgcolor, strValue); } catch (std::logic_error &e) { LOG4CXX_WARN(gLogger, "Plot Area BackgroundColor : " << e.what()); } xmlFree(value); } panel->_plotAreaBackgroundColor = pabgcolor; // -- color map index value = xmlGetProp(pNode, (const xmlChar *) "colorMapIndex"); if (value) { bgcolor._colorMapIndex = atoi((const char*) value); xmlFree(value); } panel->_backgroundColor = bgcolor; // -- Prefered panel width value = xmlGetProp(pNode, (const xmlChar *) "preferedWidth"); if (value) { panel->_preferedWidth = std::stod((const char*) value); xmlFree(value); } else { panel->_preferedWidth = DefaultPlotConfiguration::getInstance()._defaultPanel._preferedWidth; } // -- Prefered panel height value = xmlGetProp(pNode, (const xmlChar *) "preferedHeight"); if (value) { panel->_preferedHeight = std::stod((const char*) value); xmlFree(value); } else { panel->_preferedHeight = DefaultPlotConfiguration::getInstance()._defaultPanel._preferedHeight; } // -- xMargin value = xmlGetProp(pNode, (const xmlChar *) "xMargin"); if (value) { int margin1, margin2; extractMargins ((const char*) value, &margin1, &margin2); panel->_leftMargin = margin1; panel->_rightMargin = margin2; xmlFree(value); } // -- yMargin value = xmlGetProp(pNode, (const xmlChar *) "yMargin"); if (value) { int margin1, margin2; extractMargins ((const char*) value, &margin1, &margin2); panel->_topMargin = margin1; panel->_bottomMargin = margin2; xmlFree(value); } AMDA::Parameters::CfgContext context; //page->addPanel(panel); context.push(panel); context.push(pContext.get()); context.push( pContext.get()); AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode, context); } void BoundsNode::proceed(xmlNodePtr pNode, const AMDA::Parameters::CfgContext& pContext) { LOG4CXX_DEBUG(gLogger, "BoundsNode::proceed"); Panel* panel = pContext.get(); xmlChar* value = NULL; Bounds bounds; // -- x position value = xmlGetProp(pNode, (const xmlChar *) "x"); if (value) { bounds._x = atof((const char*) value); xmlFree(value); } // -- y position value = xmlGetProp(pNode, (const xmlChar *) "y"); if (value) { bounds._y = atof((const char*) value); xmlFree(value); } // -- width value = xmlGetProp(pNode, (const xmlChar *) "width"); if (value) { bounds._width = atof((const char*) value); xmlFree(value); } // -- height value = xmlGetProp(pNode, (const xmlChar *) "height"); if (value) { bounds._height = atof((const char*) value); xmlFree(value); } panel->_bounds = bounds; } } /* namespace plot */