///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2020 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include #include #include #include #include class QwtPlot; class QColor; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- class RiuGroupedBarChartBuilder { public: RiuGroupedBarChartBuilder( bool sortGroupsByMaxValueInGroup = true ); void addBarEntry( const QString& majorTickText, const QString& midTickText, const QString& minTickText, const double sortValue, const QString& legendText, const QString& barText, const double value ); void setLegendColorMap( const std::map& legendColors ); void addBarChartToPlot( QwtPlot* plot, Qt::Orientation orientation, int maxBarCount = -1 ); void setLabelFontSize( int labelPointSize ); private: double midPoint( double v1, double v2 ) { return v1 + 0.5 * ( v2 - 1.0 - v1 ); } void addQwtBarChart( QwtPlot* plot, const QVector& posAndValue, const QString& legendText, const QColor& barColor, Qt::Orientation orientation ); struct BarEntry { BarEntry(); BarEntry( const QString& majorTickText, const QString& midTickText, const QString& minTickText, const double sortValue, const QString& legendText, const QString& barText, const double value ); QString m_majTickText; double m_majorSortValue = std::numeric_limits::infinity(); QString m_midTickText; double m_midSortValue = std::numeric_limits::infinity(); QString m_minTickText; double m_sortValue; QString m_legendText; QString m_barText; double m_value; bool operator<( const BarEntry& other ) const; }; std::multiset m_sortedBarEntries; Qt::Orientation m_orientation; std::map m_legendColors; bool m_isSortingByMaxValueInGroups; int m_labelPointSize; };