Blame view

src/ParamOutputImpl/Plot/InstantPlot/PlotFunctionNode.cc 5.05 KB
99ff615c   Menouard AZIB   Change nbEchantil...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65


#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<PlotFunctionNode>(new PlotFunctionNode()));

    PlotFunctionNode::PlotFunctionNode() : AbstractPanelPlotNode()
    {
        getChildList()["legends"] = AMDA::XMLConfigurator::NodeCfgSPtr(
            new PlotLegendNode());
        getChildList()["params"] = AMDA::XMLConfigurator::NodeCfgSPtr(
            new ParamsNode<PlotFunction>());
        getChildList()["axes"] = AMDA::XMLConfigurator::NodeCfgSPtr(new AxesNode());
    }

    PlotFunctionNode::~PlotFunctionNode()
    {
    }

    boost::shared_ptr<PanelPlotOutput> PlotFunctionNode::proceed(xmlNodePtr pNode_,
                                                                 PlotOutput *plotManager_, Panel *panel_)
    {

        LOG4CXX_DEBUG(gLogger, "PlotFunctionNode::proceed");
        boost::shared_ptr<PlotFunction> plot(
            new PlotFunction(plotManager_->getParameterManager(),
                             boost::shared_ptr<Panel>(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;
5a638eb1   Menouard AZIB   Adding comments
66
67
            if (strcmp(valueString, PlotFunctuion_Type_AVG) == 0)
                plot->setFunction(PlotFunction::Function::AVG);
99ff615c   Menouard AZIB   Change nbEchantil...
68
69
            else if (strcmp(valueString, PlotFunctuion_Type_FFT) == 0)
                plot->setFunction(PlotFunction::Function::FFT);
07bf1e7c   Menouard AZIB   EveryThing works ...
70
71
            else if (strcmp(valueString, PlotFunctuion_Type_DFT) == 0)
                plot->setFunction(PlotFunction::Function::DFT);
3cf11811   Menouard AZIB   FFT Validated and...
72
73
            else if (strcmp(valueString, PlotFunctuion_Type_SUM) == 0)
                plot->setFunction(PlotFunction::Function::SUM);
99ff615c   Menouard AZIB   Change nbEchantil...
74
75
76
77
            xmlFree(value);
        }

        value = xmlGetProp(pNode_, (const xmlChar *)PlotFunction_Abscisse);
07bf1e7c   Menouard AZIB   EveryThing works ...
78
        if (value && (plot->getFunction() == PlotFunction::Function::FFT || plot->getFunction() == PlotFunction::Function::DFT))
99ff615c   Menouard AZIB   Change nbEchantil...
79
80
81
82
83
84
85
86
87
88
89
90
        {
            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);
            }
99ff615c   Menouard AZIB   Change nbEchantil...
91
92
93
94
95
96
97
98
            xmlFree(value);
        }
        else
        {
            Abscisse abscisse("Time, ", "UT", Abscisse::Abscisse_Type::TIME);
            plot->setAbscisse(abscisse);
        }

99ff615c   Menouard AZIB   Change nbEchantil...
99
100
101
102
        value = xmlGetProp(pNode_, (const xmlChar *)PlotFunction_Scale_Abscisse);
        if (value)
        {
            const char *valueAbscisseScale = (char *)value;
ec9b5ba2   Menouard AZIB   Everything is wor...
103
            if (strcmp(valueAbscisseScale, PlotFunction_Log) == 0)
99ff615c   Menouard AZIB   Change nbEchantil...
104
                plot->setAbscisseScale(Axis::Scale::LOGARITHMIC);
ec9b5ba2   Menouard AZIB   Everything is wor...
105
106
            else
                plot->setAbscisseScale(Axis::Scale::LINEAR);
99ff615c   Menouard AZIB   Change nbEchantil...
107
108
109
110
111
112
113
            xmlFree(value);
        }

        value = xmlGetProp(pNode_, (const xmlChar *)PlotFunction_Scale_Ordonnee);
        if (value)
        {
            const char *valueOrdonneeScale = (char *)value;
ec9b5ba2   Menouard AZIB   Everything is wor...
114
            if (strcmp(valueOrdonneeScale, PlotFunction_Log) == 0)
99ff615c   Menouard AZIB   Change nbEchantil...
115
                plot->setOrdonneeScale(Axis::Scale::LOGARITHMIC);
ec9b5ba2   Menouard AZIB   Everything is wor...
116
117
            else
                plot->setOrdonneeScale(Axis::Scale::LINEAR);
99ff615c   Menouard AZIB   Change nbEchantil...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
            xmlFree(value);
        }
        else
        {
            LOG4CXX_DEBUG(gLogger, "non value");
        }

        AMDA::Parameters::CfgContext context;
        context.push<PanelPlotOutput *>(plot.get());
        context.push<PlotFunction *>(plot.get());
        context.push<Panel *>(panel_);
        AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, context);

        return plot;
    }

} /* namespace plot */