Skip to content

Commit

Permalink
Show Plot Data missing for some plots
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
magnesj authored Oct 11, 2023
1 parent 51fe80b commit cdda748
Show file tree
Hide file tree
Showing 19 changed files with 400 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
#include "RiaPreferencesSummary.h"
#include "RiaQDateTimeTools.h"

#include "RimAnalysisPlot.h"
#include "RimCorrelationMatrixPlot.h"
#include "RimCorrelationPlot.h"
#include "RimCorrelationReportPlot.h"
#include "RimGridCrossPlot.h"
#include "RimGridCrossPlotCurve.h"
#include "RimParameterResultCrossPlot.h"
#include "RimPlotWindow.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
Expand Down Expand Up @@ -72,10 +77,8 @@ class RiuTabbedSummaryPlotTextProvider : public RiuTabbedTextProvider
{
return "No Resampling";
}
else
{
return QString( "%1" ).arg( RiaQDateTimeTools::dateTimePeriodName( timePeriod ) );
}

return QString( "%1" ).arg( RiaQDateTimeTools::dateTimePeriodName( timePeriod ) );
}

QString tabText( int tabIndex ) const override
Expand All @@ -90,10 +93,8 @@ class RiuTabbedSummaryPlotTextProvider : public RiuTabbedTextProvider

return m_summaryPlot->asciiDataForSummaryPlotExport( timePeriod, prefs->showSummaryTimeAsLongString() );
}
else
{
return m_summaryPlot->asciiDataForSummaryPlotExport( RiaDefines::DateTimePeriod::NONE, true );
}

return m_summaryPlot->asciiDataForSummaryPlotExport( RiaDefines::DateTimePeriod::NONE, true );
}

int tabCount() const override { return (int)tabs().size(); }
Expand Down Expand Up @@ -192,7 +193,9 @@ bool RicShowPlotDataFeature::isCommandEnabled() const
{
if ( dynamic_cast<RimSummaryPlot*>( plot ) || dynamic_cast<RimWellLogPlot*>( plot ) || dynamic_cast<RimWellLogTrack*>( plot ) ||
dynamic_cast<RimGridCrossPlot*>( plot ) || dynamic_cast<RimVfpPlot*>( plot ) ||
dynamic_cast<RimWellAllocationOverTimePlot*>( plot ) )
dynamic_cast<RimWellAllocationOverTimePlot*>( plot ) || dynamic_cast<RimAnalysisPlot*>( plot ) ||
dynamic_cast<RimCorrelationMatrixPlot*>( plot ) || dynamic_cast<RimAbstractCorrelationPlot*>( plot ) ||
dynamic_cast<RimCorrelationReportPlot*>( plot ) )
{
validPlots++;
}
Expand Down Expand Up @@ -224,24 +227,20 @@ void RicShowPlotDataFeature::onActionTriggered( bool isChecked )
std::vector<RimPlotWindow*> selection;
getSelection( selection );

std::vector<RimSummaryPlot*> selectedSummaryPlots;
std::vector<RimWellLogPlot*> wellLogPlots;
std::vector<RimGridCrossPlot*> crossPlots;
std::vector<RimVfpPlot*> vfpPlots;
std::vector<RimWellLogTrack*> depthTracks;
std::vector<RimWellAllocationOverTimePlot*> wellAllocationOverTimePlots;
// Using RiuTabbedSummaryPlotTextProvider
std::vector<RimSummaryPlot*> summaryPlots;

// Using RiuTabbedGridCrossPlotTextProvider
std::vector<RimGridCrossPlot*> crossPlots;

// Show content using RimPlot::description() and RimPlot::asciiDataForPlotExport()
std::vector<RimPlot*> rimPlots;

for ( auto plot : selection )
{
if ( auto sumPlot = dynamic_cast<RimSummaryPlot*>( plot ) )
{
selectedSummaryPlots.push_back( sumPlot );
continue;
}

if ( auto wellPlot = dynamic_cast<RimWellLogPlot*>( plot ) )
{
wellLogPlots.push_back( wellPlot );
summaryPlots.push_back( sumPlot );
continue;
}

Expand All @@ -251,62 +250,42 @@ void RicShowPlotDataFeature::onActionTriggered( bool isChecked )
continue;
}

if ( auto vfpPlot = dynamic_cast<RimVfpPlot*>( plot ) )
if ( auto correlationReportPlot = dynamic_cast<RimCorrelationReportPlot*>( plot ) )
{
vfpPlots.push_back( vfpPlot );
continue;
}
// A correlation report plot contains three plots. Add them as individual plots to rimPlots to make the data available in three
// individual text dialogs.

if ( auto depthTrack = dynamic_cast<RimWellLogTrack*>( plot ) )
{
depthTracks.push_back( depthTrack );
rimPlots.push_back( correlationReportPlot->matrixPlot() );
rimPlots.push_back( correlationReportPlot->correlationPlot() );
rimPlots.push_back( correlationReportPlot->crossPlot() );
continue;
}

if ( auto wellAllocationOverTimePlot = dynamic_cast<RimWellAllocationOverTimePlot*>( plot ) )
if ( auto rimPlot = dynamic_cast<RimPlot*>( plot ) )
{
wellAllocationOverTimePlots.push_back( wellAllocationOverTimePlot );
continue;
rimPlots.push_back( rimPlot );
}
}

for ( RimSummaryPlot* summaryPlot : selectedSummaryPlots )
for ( RimSummaryPlot* summaryPlot : summaryPlots )
{
auto textProvider = new RiuTabbedSummaryPlotTextProvider( summaryPlot );
RicShowPlotDataFeature::showTabbedTextWindow( textProvider );
}

for ( RimWellLogPlot* wellLogPlot : wellLogPlots )
{
QString title = wellLogPlot->description();
QString text = wellLogPlot->asciiDataForPlotExport();
RicShowPlotDataFeature::showTextWindow( title, text );
}

for ( auto* plot : depthTracks )
{
QString title = plot->description();
QString text = plot->asciiDataForPlotExport();
RicShowPlotDataFeature::showTextWindow( title, text );
}

for ( RimVfpPlot* vfpPlot : vfpPlots )
{
QString title = vfpPlot->description();
QString text = vfpPlot->asciiDataForPlotExport();
RicShowPlotDataFeature::showTextWindow( title, text );
}

for ( RimGridCrossPlot* crossPlot : crossPlots )
{
auto textProvider = new RiuTabbedGridCrossPlotTextProvider( crossPlot );
RicShowPlotDataFeature::showTabbedTextWindow( textProvider );
}

for ( RimWellAllocationOverTimePlot* wellAllocationOverTimePlot : wellAllocationOverTimePlots )
for ( auto rimPlot : rimPlots )
{
QString title = wellAllocationOverTimePlot->description();
QString text = wellAllocationOverTimePlot->asciiDataForPlotExport();
QString title = rimPlot->description();
QString text = title;
text += "\n";
text += "\n";
text += rimPlot->asciiDataForPlotExport();

RicShowPlotDataFeature::showTextWindow( title, text );
}
}
Expand All @@ -328,7 +307,7 @@ void RicShowPlotDataFeature::showTabbedTextWindow( RiuTabbedTextProvider* textPr
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
CVF_ASSERT( plotwindow );

RiuTabbedTextDialog* textWidget = new RiuTabbedTextDialog( textProvider );
auto* textWidget = new RiuTabbedTextDialog( textProvider );
textWidget->setMinimumSize( 800, 600 );
plotwindow->addToTemporaryWidgets( textWidget );
textWidget->show();
Expand All @@ -343,7 +322,7 @@ void RicShowPlotDataFeature::showTextWindow( const QString& title, const QString
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
CVF_ASSERT( plotwindow );

RiuTextDialog* textWiget = new RiuTextDialog();
auto* textWiget = new RiuTextDialog();
textWiget->setMinimumSize( 400, 600 );

textWiget->setWindowTitle( title );
Expand All @@ -364,7 +343,7 @@ void RicShowPlotDataFeature::getSelection( std::vector<RimPlotWindow*>& selectio
QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<void*>() )
{
RimPlot* plot = static_cast<RimPlot*>( userData.value<void*>() );
auto* plot = static_cast<RimPlot*>( userData.value<void*>() );
if ( plot ) selection.push_back( plot );
}
}
Expand Down
20 changes: 18 additions & 2 deletions ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@
RifCsvDataTableFormatter::RifCsvDataTableFormatter( QTextStream& out, const QString fieldSeparator )
: m_out( out )
, m_fieldSeparator( fieldSeparator )
, m_useQuotes( true )
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifCsvDataTableFormatter::setUseQuotes( bool useQuotes )
{
m_useQuotes = useQuotes;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -43,8 +52,15 @@ RifCsvDataTableFormatter& RifCsvDataTableFormatter::header( const std::vector<Ri
//--------------------------------------------------------------------------------------------------
RifCsvDataTableFormatter& RifCsvDataTableFormatter::add( const QString& str )
{
QString quotedString = "\"" + str + "\"";
m_lineBuffer.push_back( quotedString );
if ( m_useQuotes )
{
QString quotedString = "\"" + str + "\"";
m_lineBuffer.push_back( quotedString );
}
else
{
m_lineBuffer.push_back( str );
}
return *this;
}

Expand Down
3 changes: 3 additions & 0 deletions ApplicationLibCode/FileInterface/RifCsvDataTableFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class RifCsvDataTableFormatter
public:
RifCsvDataTableFormatter( QTextStream& out, const QString fieldSeparator = "," );

void setUseQuotes( bool useQuotes );

RifCsvDataTableFormatter& header( const std::vector<RifTextDataTableColumn>& tableHeader );
RifCsvDataTableFormatter& add( const QString& str );
RifCsvDataTableFormatter& add( double num );
Expand All @@ -47,4 +49,5 @@ class RifCsvDataTableFormatter
std::vector<RifTextDataTableLine> m_buffer;
std::vector<QString> m_lineBuffer;
QString m_fieldSeparator;
bool m_useQuotes;
};
Loading

0 comments on commit cdda748

Please sign in to comment.