/* * DrawingPropertiesNode.hh * * Created on: Dec 9, 2013 * Author: amdadev */ #ifndef DRAWINGPROPERTIESNODE_HH_ #define DRAWINGPROPERTIESNODE_HH_ #include #include #include "SerieSymbolNode.hh" #include "LineNode.hh" #include "ResamplingNode.hh" #include "TimeTickNode.hh" #include "IntervalTickNode.hh" #include "ErrorBarNode.hh" #include "PlotLogger.hh" #include "NodeCfg.hh" #include "FileConfigurator.hh" #include "DrawingProperties.hh" namespace plot { /** * Parse a "default" node in plot.xsd schema. */ template class DrawingPropertiesNode: public AMDA::XMLConfigurator::NodeGrpCfg { public: DrawingPropertiesNode() : NodeGrpCfg() { getChildList()["line"] = AMDA::XMLConfigurator::NodeCfgSPtr( new LineNode() ); getChildList()["symbol"] = AMDA::XMLConfigurator::NodeCfgSPtr( new SerieSymbolNode() ); getChildList()["timeTick"] = AMDA::XMLConfigurator::NodeCfgSPtr( new TimeTickNode() ); getChildList()["intervalTick"] = AMDA::XMLConfigurator::NodeCfgSPtr( new IntervalTickNode() ); getChildList()["resampling"] = AMDA::XMLConfigurator::NodeCfgSPtr( new ResamplingNode() ); getChildList()["errorBar"] = AMDA::XMLConfigurator::NodeCfgSPtr( new ErrorBarNode() ); } virtual ~DrawingPropertiesNode(){ } void proceed(xmlNodePtr pNode_,const AMDA::Parameters::CfgContext& ctx_){ LOG4CXX_DEBUG(gLogger, "DrawingPropertiesNode::proceed"); // panel plot we are building... PlotType* plotOutput = ctx_.get(); // related param name... xmlChar* name = ctx_.get(); // get default drawing properties object: DrawingProperties& props = plotOutput->getParameter((const char*)name).getDefaultProperties(); // parse node attributes parseAttributes(pNode_, props); // proceed children AMDA::Parameters::CfgContext childContext; childContext.push( &props ); AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, childContext); } protected: virtual void parseAttributes(xmlNodePtr pNode_, DrawingProperties& props_){ // attribute xmlChar* value = NULL; // -- xAxis information value = xmlGetProp(pNode_, (const xmlChar *) "xAxis"); if( value ){ props_.setXAxisId(std::string((const char*)value)); xmlFree(value); } // -- yAxis information value = xmlGetProp(pNode_, (const xmlChar *) "yAxis"); if( value ){ props_.setYAxisId(std::string((const char*)value)); xmlFree(value); } // -- zAxis information value = xmlGetProp(pNode_, (const xmlChar *) "zAxis"); if( value ){ props_.setZAxisId(std::string((const char*)value)); xmlFree(value); } // -- min information value = xmlGetProp(pNode_, (const xmlChar *) "min"); if( value ){ props_.setMin(atof((const char*)value)); xmlFree(value); } else { props_.setMin(nan("")); } // -- max information value = xmlGetProp(pNode_, (const xmlChar *) "max"); if( value ){ props_.setMax(atof((const char*)value)); xmlFree(value); } else { props_.setMax(nan("")); } // -- default color updateColor( props_.getColor(), pNode_,(const xmlChar*)"color",(const xmlChar*)"colorMapIndex"); if(props_.getColor().isSet()){ // the following properties will be overridden if defined in sub nodes props_.getLineProperties().setColor(props_.getColor()); props_.getSymbolProperties().setColor(props_.getColor()); } } }; } /* namespace plot */ #endif /* DRAWINGPROPERTIESNODE_HH_ */