Files
ResInsight/ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationBarChartTools.h
T
Magne Sjaastad 99910c3d7d #13903 Harmonize correlation and tornado bar-chart behavior
Extract shared helpers into a new RimCorrelationBarChartTools
namespace so RimCorrelationPlot and RimRftTornadoPlot share a
single source of truth for:

- highlightSelectedParameterBar and the click-to-parameter-name
  lookup
- the axis-label format, abs/sort-value math, and the
  addBarEntry call (with the "legendText must equal parameter
  name" convention) via addCorrelationBar

Also enable click-to-select on RimCorrelationPlot: use the
parameter name as the bar chart title so click-to-select works,
and recolor the selected bar via a new HighlightBarColor field,
mirroring the pattern used in RimRftTornadoPlot.
2026-04-20 11:41:26 +02:00

52 lines
2.2 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2026 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QColor>
#include <QString>
#include <memory>
class RiuGroupedBarChartBuilder;
class RiuPlotItem;
class RiuQwtPlotWidget;
//==================================================================================================
///
/// Presentation helpers shared by the correlation bar/tornado plots (RimCorrelationPlot,
/// RimRftTornadoPlot). The plots rely on the convention that the legendText passed to
/// RiuGroupedBarChartBuilder::addBarEntry equals the parameter name, so the bar chart's
/// title can be used to identify which parameter was clicked or should be highlighted.
///
//==================================================================================================
namespace RimCorrelationBarChartTools
{
void highlightSelectedParameterBar( RiuQwtPlotWidget* plotWidget,
const QString& selectedParamName,
const QColor& barColor,
const QColor& highlightColor );
QString parameterNameFromPlotItem( std::shared_ptr<RiuPlotItem> plotItem );
void addCorrelationBar( RiuGroupedBarChartBuilder& chartBuilder,
const QString& parameterName,
double correlation,
bool showAbsoluteValues,
bool sortByAbsoluteValues );
} // namespace RimCorrelationBarChartTools