diff --git a/gui/include/Visualization/VisualizationGraphRenderingDelegate.h b/gui/include/Visualization/VisualizationGraphRenderingDelegate.h index e59fd18..20fb5a4 100644 --- a/gui/include/Visualization/VisualizationGraphRenderingDelegate.h +++ b/gui/include/Visualization/VisualizationGraphRenderingDelegate.h @@ -9,6 +9,7 @@ class IDataSeries; class QCustomPlot; class QMouseEvent; class Unit; +class Variable; class VisualizationGraphWidget; class VisualizationGraphRenderingDelegate { @@ -23,13 +24,14 @@ public: /// Updates rendering when data of plot changed void onPlotUpdated() noexcept; - /// Sets properties of the plot's axes from the data series passed as parameter - void setAxesProperties(std::shared_ptr dataSeries) noexcept; + /// Sets units of the plot's axes according to the properties of the variable passed as + /// parameter + void setAxesUnits(const Variable &variable) noexcept; - /// Sets rendering properties of the plottables passed as parameter, from the data series that + /// Sets graph properties of the plottables passed as parameter, from the variable that /// generated these - void setPlottablesProperties(std::shared_ptr dataSeries, - PlottablesMap &plottables) noexcept; + void setGraphProperties(const Variable &variable, PlottablesMap &plottables) noexcept; + /// Shows or hides graph overlay (name, close button, etc.) void showGraphOverlay(bool show) noexcept; diff --git a/gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp b/gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp index 30747c3..7764aa2 100644 --- a/gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp +++ b/gui/src/Visualization/VisualizationGraphRenderingDelegate.cpp @@ -9,6 +9,7 @@ #include #include +#include #include @@ -302,14 +303,14 @@ void VisualizationGraphRenderingDelegate::onPlotUpdated() noexcept impl->m_Plot.replot(); } -void VisualizationGraphRenderingDelegate::setAxesProperties( - std::shared_ptr dataSeries) noexcept +void VisualizationGraphRenderingDelegate::setAxesUnits(const Variable &variable) noexcept { - // Stores x-axis label to be able to retrieve it when x-axis pixmap is unselected - impl->m_XAxisLabel = dataSeries->xAxisUnit().m_Name; - auto axisHelper = IAxisHelperFactory::create(dataSeries); - axisHelper->setProperties(impl->m_Plot, impl->m_ColorScale); + auto axisHelper = IAxisHelperFactory::create(variable); + axisHelper->setUnits(impl->m_Plot, impl->m_ColorScale); + + // Stores x-axis label to be able to retrieve it when x-axis pixmap is unselected + impl->m_XAxisLabel = impl->m_Plot.xAxis->label(); // Updates x-axis state impl->updateXAxisState(); @@ -317,10 +318,15 @@ void VisualizationGraphRenderingDelegate::setAxesProperties( impl->m_Plot.layer(AXES_LAYER)->replot(); } -void VisualizationGraphRenderingDelegate::setPlottablesProperties( - std::shared_ptr dataSeries, PlottablesMap &plottables) noexcept +void VisualizationGraphRenderingDelegate::setGraphProperties(const Variable &variable, + PlottablesMap &plottables) noexcept { - auto plottablesHelper = IPlottablesHelperFactory::create(dataSeries); + // Axes' properties + auto axisHelper = IAxisHelperFactory::create(variable); + axisHelper->setProperties(impl->m_Plot, impl->m_ColorScale); + + // Plottables' properties + auto plottablesHelper = IPlottablesHelperFactory::create(variable); plottablesHelper->setProperties(plottables); }