Show Plot Data missing for some plots

* Add plotContentAsText() to bar chart builder
* Add show plot data to analysis plot
* Refactor analysis plot
* Enable context menu in Analysis Plot
* Add show plot data for general RimPlots
* Show plot data for correlation report in three separate text dialogs
This commit is contained in:
Magne Sjaastad
2023-10-11 08:54:52 +02:00
committed by GitHub
parent 51fe80b897
commit cdda7480f3
19 changed files with 401 additions and 233 deletions
@@ -21,6 +21,8 @@
#include "RiaColorTables.h"
#include "RiaPreferences.h"
#include "RifCsvDataTableFormatter.h"
#include "RiuGuiTheme.h"
#include "cafFontTools.h"
@@ -836,6 +838,62 @@ void RiuGroupedBarChartBuilder::setLabelFontSize( int labelPointSize )
m_labelPointSize = labelPointSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuGroupedBarChartBuilder::plotContentAsText() const
{
QString text;
QTextStream stream( &text );
QString fieldSeparator = "\t";
RifCsvDataTableFormatter formatter( stream, fieldSeparator );
formatter.setUseQuotes( false );
bool hasTextForMajor = false;
bool hasTextForMid = false;
bool hasTextForMinor = false;
bool hasTextForLegend = false;
bool hasTextForBar = false;
for ( const BarEntry& barDef : m_sortedBarEntries )
{
if ( !barDef.m_majTickText.isEmpty() ) hasTextForMajor = true;
if ( !barDef.m_midTickText.isEmpty() ) hasTextForMid = true;
if ( !barDef.m_minTickText.isEmpty() ) hasTextForMinor = true;
if ( !barDef.m_legendText.isEmpty() ) hasTextForLegend = true;
if ( !barDef.m_barText.isEmpty() && barDef.m_barText != barDef.m_legendText ) hasTextForBar = true;
}
std::vector<RifTextDataTableColumn> header;
if ( hasTextForMajor ) header.emplace_back( RifTextDataTableColumn( "Major" ) );
if ( hasTextForMid ) header.emplace_back( RifTextDataTableColumn( "Mid" ) );
if ( hasTextForMinor ) header.emplace_back( RifTextDataTableColumn( "Minor" ) );
if ( hasTextForLegend ) header.emplace_back( RifTextDataTableColumn( "Legend" ) );
if ( hasTextForBar ) header.emplace_back( RifTextDataTableColumn( "Bar" ) );
header.emplace_back( RifTextDataTableColumn( "Value", RifTextDataTableDoubleFormat::RIF_FLOAT ) );
formatter.header( header );
for ( const BarEntry& barDef : m_sortedBarEntries )
{
if ( hasTextForMajor ) formatter.add( barDef.m_majTickText );
if ( hasTextForMid ) formatter.add( barDef.m_midTickText );
if ( hasTextForMinor ) formatter.add( barDef.m_minTickText );
if ( hasTextForLegend ) formatter.add( barDef.m_legendText );
if ( hasTextForBar ) formatter.add( barDef.m_barText );
formatter.add( barDef.m_value );
formatter.rowCompleted();
}
formatter.tableCompleted();
return text;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -50,6 +50,8 @@ public:
void addBarChartToPlot( QwtPlot* plot, Qt::Orientation orientation, int maxBarCount = -1 );
void setLabelFontSize( int labelPointSize );
QString plotContentAsText() const;
private:
double midPoint( double v1, double v2 ) { return v1 + 0.5 * ( v2 - 1.0 - v1 ); }
@@ -30,13 +30,30 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuContextMenuLauncher::RiuContextMenuLauncher( QWidget* widget, const caf::CmdFeatureMenuBuilder& commandIds )
RiuContextMenuLauncher::RiuContextMenuLauncher( QWidget* widget, const caf::CmdFeatureMenuBuilder& menuBuilder )
: QObject( widget )
, m_menuBuilder( commandIds )
, m_menuBuilder( menuBuilder )
{
widget->installEventFilter( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuContextMenuLauncher::RiuContextMenuLauncher( QWidget* widget, const QStringList& commandIds )
{
caf::CmdFeatureMenuBuilder menuBuilder;
for ( const auto& cmd : commandIds )
{
menuBuilder << cmd;
}
m_menuBuilder = menuBuilder;
widget->installEventFilter( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -32,7 +32,8 @@ class QWidget;
class RiuContextMenuLauncher : public QObject
{
public:
explicit RiuContextMenuLauncher( QWidget* widget, const caf::CmdFeatureMenuBuilder& commandIds );
explicit RiuContextMenuLauncher( QWidget* widget, const caf::CmdFeatureMenuBuilder& menuBuilder );
explicit RiuContextMenuLauncher( QWidget* widget, const QStringList& commandIds );
protected:
bool eventFilter( QObject* watched, QEvent* event ) override;