PlotTools.hh
2.79 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: PlotTools.hh
* Author: hacene
*
* Created on January 7, 2022, 4:30 PM
*/
#ifndef PLOTTOOLS_HH
#define PLOTTOOLS_HH
#include"ParamTable.hh"
#include "Range.hh"
#include "Axis.hh"
namespace plot {
class PlotTools{
public:
PlotTools(){
}
~ PlotTools(){
}
static void configureAxisRangeFromTable(Range & lYAxisRange, boost::shared_ptr<Axis> lYAxis,boost::shared_ptr<AMDA::Info::ParamTable> leftTableSPtr)
{
AMDA::Info::t_TableBound crtBound;
if (!tableSPtr->isVariable(&_parameterManager))
{
for (int i = 0; i < parameterDimension; ++i)
{
crtBound = tableSPtr->getBound(&_parameterManager, i);
if (!std::isnan(crtBound.min))
{
if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0)))
lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin()));
}
if (!std::isnan(crtBound.max))
{
if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0)))
lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax()));
}
}
}
else
{
//Variable table => we need to loop under all records to find axis min & max values
for (int i = 0; i < (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getSize(); ++i)
{
std::map<std::string, std::vector<double>> paramsTableData;
for (std::map<std::string, std::string>::iterator it = sauvaudPropertiesPtr->getTableParams().begin(); it != sauvaudPropertiesPtr->getTableParams().end(); ++it)
{
ParameterData &data = (*_pParameterValues)[it->second];
std::vector<double> paramTableValues;
for (int j = 0; j < data.getDim1Size(); ++j)
{
if (i < data.getSize())
{
double *values = data.getValues(AMDA::Common::ParameterIndexComponent(j), i);
paramTableValues.push_back((*values));
}
}
paramsTableData[it->first] = paramTableValues;
}
for (int j = 0; j < parameterDimension; ++j)
{
crtBound = tableSPtr->getBound(&_parameterManager, j, ¶msTableData);
if (!std::isnan(crtBound.min))
{
if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.min <= 0)))
lYAxisRange.setMin(std::min(crtBound.min, lYAxisRange.getMin()));
}
if (!std::isnan(crtBound.max))
{
if (!((lYAxis->_scale == Axis::Scale::LOGARITHMIC) && (crtBound.max <= 0)))
lYAxisRange.setMax(std::max(crtBound.max, lYAxisRange.getMax()));
}
}
}
}
}
};
}
#endif /* PLOTTOOLS_HH */