/* * 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 lYAxis,boost::shared_ptr 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> paramsTableData; for (std::map::iterator it = sauvaudPropertiesPtr->getTableParams().begin(); it != sauvaudPropertiesPtr->getTableParams().end(); ++it) { ParameterData &data = (*_pParameterValues)[it->second]; std::vector 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 */