Create Grid plot collection and allow creation of new combination plots

This commit is contained in:
Gaute Lindkvist
2019-10-31 13:48:40 +01:00
parent e042b2d17b
commit 30db19a1d0
55 changed files with 1208 additions and 597 deletions

View File

@@ -123,24 +123,23 @@ void RimSummaryPlotYAxisFormatter::applyYAxisPropertiesToPlot( RiuSummaryQwtPlot
axisTitleY.setText( axisTitle );
Qt::AlignmentFlag titleAlignment;
switch ( m_axisProperties->titlePosition() )
{
case RimPlotAxisProperties::AXIS_TITLE_CENTER:
axisTitleY.setRenderFlags( Qt::AlignCenter );
titleAlignment = Qt::AlignCenter;
break;
case RimPlotAxisProperties::AXIS_TITLE_END:
axisTitleY.setRenderFlags( Qt::AlignRight );
titleAlignment = Qt::AlignRight;
break;
}
qwtPlot->setAxisTitle( m_axisProperties->qwtPlotAxisType(), axisTitleY );
}
{
QFont yAxisFont = qwtPlot->axisFont( m_axisProperties->qwtPlotAxisType() );
yAxisFont.setBold( false );
yAxisFont.setPointSize( m_axisProperties->valuesFontSize() );
qwtPlot->setAxisFont( m_axisProperties->qwtPlotAxisType(), yAxisFont );
// TODO: We currently call setAxisTitle just to set font size. Fix this.
qwtPlot->setAxisFontsAndAlignment( m_axisProperties->qwtPlotAxisType(),
m_axisProperties->titleFontSize(),
m_axisProperties->valuesFontSize(),
true,
titleAlignment );
qwtPlot->setAxisTitleText( m_axisProperties->qwtPlotAxisType(), axisTitle );
}
{

View File

@@ -32,6 +32,7 @@
#include "RimAsciiDataCurve.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimGridPlotWindow.h"
#include "RimGridTimeHistoryCurve.h"
#include "RimPlotAxisProperties.h"
#include "RimProject.h"
@@ -146,19 +147,14 @@ RimSummaryPlot::RimSummaryPlot()
m_description = "Summary Plot";
CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Plot Title", "", "", "" );
m_showPlotTitle.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitField( &m_showLegend, "ShowLegend", true, "Legend", "", "", "" );
m_showLegend.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitField( &m_legendFontSize, "LegendFontSize", 11, "Legend Font Size", "", "", "" );
m_showLegend.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitField( &m_showPlotTitle_OBSOLETE, "ShowPlotTitle", true, "Plot Title", "", "", "" );
m_showPlotTitle_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_showLegend_OBSOLETE, "ShowLegend", true, "Legend", "", "", "" );
m_showLegend_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto Title", "", "", "" );
m_useAutoPlotTitle.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitField( &m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves", "", "", "" );
m_normalizeCurveYValues.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_curveFilters_OBSOLETE, "SummaryCurveFilters", "", "", "", "" );
m_curveFilters_OBSOLETE.uiCapability()->setUiTreeHidden( true );
@@ -213,6 +209,7 @@ RimSummaryPlot::RimSummaryPlot()
m_textCurveSetEditor = new RimSummaryPlotFilterTextCurveSetEditor;
m_isCrossPlot = false;
m_isDraggable = false;
m_nameHelperAllCurves.reset( new RimSummaryPlotNameHelper );
@@ -585,7 +582,6 @@ void RimSummaryPlot::updateAll()
updatePlotTitle();
m_plotWidget->updateLegend();
updateAxes();
updateZoomInQwt();
}
}
@@ -1319,37 +1315,6 @@ caf::PdmFieldHandle* RimSummaryPlot::userDescriptionField()
return &m_description;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimSummaryPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_legendFontSize )
{
std::vector<int> fontSizes;
fontSizes.push_back( 8 );
fontSizes.push_back( 9 );
fontSizes.push_back( 10 );
fontSizes.push_back( 11 );
fontSizes.push_back( 12 );
fontSizes.push_back( 14 );
fontSizes.push_back( 16 );
fontSizes.push_back( 18 );
fontSizes.push_back( 24 );
for ( int value : fontSizes )
{
QString text = QString( "%1" ).arg( value );
options.push_back( caf::PdmOptionItemInfo( text, value ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1357,31 +1322,26 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
RimViewWindow::fieldChangedByUi( changedField, oldValue, newValue );
RimPlotWindow::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_description || changedField == &m_showPlotTitle || changedField == &m_useAutoPlotTitle )
if ( changedField == &m_showWindow )
{
updateWindowVisibility();
}
if ( changedField == &m_useAutoPlotTitle )
{
updatePlotTitle();
updateConnectedEditors();
}
if ( changedField == &m_showLegend )
{
if ( m_plotWidget ) m_plotWidget->setLegendVisible( m_showLegend );
}
if ( changedField == &m_legendFontSize )
{
if ( m_plotWidget ) m_plotWidget->setLegendFontSize( m_legendFontSize() );
}
if ( changedField == &m_useAutoPlotTitle && !m_useAutoPlotTitle )
{
// When auto name of plot is turned off, update the auto name for all curves
for ( auto c : summaryCurves() )
if ( !m_useAutoPlotTitle )
{
c->updateCurveNameNoLegendUpdate();
// When auto name of plot is turned off, update the auto name for all curves
for ( auto c : summaryCurves() )
{
c->updateCurveNameNoLegendUpdate();
}
}
}
@@ -1396,24 +1356,6 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
//--------------------------------------------------------------------------------------------------
QImage RimSummaryPlot::snapshotWindowContent()
{
#if 0
// This does not work with the color legend widgets. Is there a reason for doing this, and not to grab the widget ?
QImage image;
if (m_qwtPlot)
{
image = QImage(m_qwtPlot->size(), QImage::Format_ARGB32);
image.fill(QColor(Qt::white).rgb());
QPainter painter(&image);
QRectF rect(0, 0, m_qwtPlot->size().width(), m_qwtPlot->size().height());
QwtPlotRenderer plotRenderer;
plotRenderer.render(m_qwtPlot, &painter, rect);
}
return image;
#endif
QImage image;
if ( m_plotWidget )
@@ -1472,7 +1414,7 @@ void RimSummaryPlot::onLoadDataAndUpdate()
{
updatePlotTitle();
updateMdiWindowVisibility();
updateWindowVisibility();
if ( m_summaryCurveCollection )
{
@@ -1493,7 +1435,7 @@ void RimSummaryPlot::onLoadDataAndUpdate()
if ( m_plotWidget )
{
m_plotWidget->setLegendVisible( m_showLegend );
m_plotWidget->setLegendVisible( m_showPlotLegends && isStandalonePlot() );
m_plotWidget->setLegendFontSize( m_legendFontSize() );
m_plotWidget->updateLegend();
}
@@ -1582,6 +1524,39 @@ void RimSummaryPlot::removeEnsembleCurveSetLegend( RimEnsembleCurveSet* curveSet
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::removeFromMdiAreaAndCollection()
{
RimSummaryPlotCollection* summaryCollection = nullptr;
this->firstAncestorOrThisOfType( summaryCollection );
if ( summaryCollection )
{
summaryCollection->removeSummaryPlot( this );
this->revokeMdiWindowStatus();
summaryCollection->updateAllRequiredEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateAfterInsertingIntoGridPlotWindow()
{
if ( m_plotWidget )
{
m_plotWidget->setTitle( "" );
m_plotWidget->setLegendVisible( false );
}
if ( m_timeAxisProperties )
{
m_timeAxisProperties->showTitle = true;
}
updateAxes();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1617,9 +1592,17 @@ bool RimSummaryPlot::isChecked() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::enableShowPlotTitle( bool enable )
void RimSummaryPlot::setChecked( bool checked )
{
m_showPlotTitle = enable;
m_showWindow = checked;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::setDraggable( bool draggable )
{
m_isDraggable = draggable;
}
//--------------------------------------------------------------------------------------------------
@@ -1660,18 +1643,29 @@ void RimSummaryPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* mainOptions = uiOrdering.addNewGroup( "General Plot Options" );
mainOptions->setCollapsedByDefault( true );
mainOptions->add( &m_showPlotTitle );
if ( m_showPlotTitle )
if ( isStandalonePlot() )
{
mainOptions->add( &m_showTitleInPlot );
if ( m_showTitleInPlot )
{
mainOptions->add( &m_useAutoPlotTitle );
mainOptions->add( &m_description );
}
}
else
{
mainOptions->add( &m_useAutoPlotTitle );
mainOptions->add( &m_description );
}
m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle );
mainOptions->add( &m_showLegend );
if ( m_showLegend() )
if ( isStandalonePlot() )
{
mainOptions->add( &m_legendFontSize );
mainOptions->add( &m_showPlotLegends );
if ( m_showPlotLegends() )
{
mainOptions->add( &m_legendFontSize );
}
}
mainOptions->add( &m_normalizeCurveYValues );
@@ -1689,6 +1683,7 @@ QWidget* RimSummaryPlot::createViewWidget( QWidget* mainWindowParent )
if ( !m_plotWidget )
{
m_plotWidget = new RiuSummaryQwtPlot( this, mainWindowParent );
m_plotWidget->setDraggable( m_isDraggable );
for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves )
{
@@ -1769,6 +1764,16 @@ void RimSummaryPlot::initAfterRead()
m_useAutoPlotTitle = false;
}
}
if ( m_showPlotTitle_OBSOLETE() )
{
m_showTitleInPlot = true;
}
if ( m_showLegend_OBSOLETE() )
{
m_showPlotLegends = true;
}
}
//--------------------------------------------------------------------------------------------------
@@ -1776,13 +1781,13 @@ void RimSummaryPlot::initAfterRead()
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateMdiWindowTitle()
{
if ( m_plotWidget )
if ( m_plotWidget && isStandalonePlot() )
{
QString plotTitle = description();
QString plotTitle = fullPlotTitle();
m_plotWidget->setWindowTitle( plotTitle );
if ( m_showPlotTitle )
if ( m_showTitleInPlot )
{
m_plotWidget->setTitle( plotTitle );
}
@@ -1790,6 +1795,7 @@ void RimSummaryPlot::updateMdiWindowTitle()
{
m_plotWidget->setTitle( "" );
}
m_plotWidget->scheduleReplot();
}
}
@@ -1836,6 +1842,23 @@ void RimSummaryPlot::updateNameHelperWithCurveData( RimSummaryPlotNameHelper* na
nameHelper->setEnsembleCases( ensembleCases );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateWindowVisibility()
{
RimGridPlotWindow* plotWindow = nullptr;
this->firstAncestorOrThisOfType( plotWindow );
if ( plotWindow )
{
plotWindow->updateLayout();
}
else
{
updateMdiWindowVisibility();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1909,14 +1932,6 @@ void RimSummaryPlot::reattachAllCurves()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::showLegend( bool enable )
{
m_showLegend = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -2062,24 +2077,6 @@ size_t RimSummaryPlot::curveCount() const
return m_summaryCurveCollection->curves().size() + m_gridTimeHistoryCurves.size() + m_asciiDataCurves.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_showLegend || field == &m_showPlotTitle || field == &m_useAutoPlotTitle ||
field == &m_normalizeCurveYValues )
{
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->m_useNativeCheckBoxLabel = true;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -72,11 +72,12 @@ public:
RimSummaryPlot();
~RimSummaryPlot() override;
void setDescription( const QString& description );
QString description() const;
void setDescription( const QString& description ) override;
QString description() const override;
bool isChecked() const override;
void setChecked( bool checked ) override;
void setDraggable( bool draggable );
void enableShowPlotTitle( bool enable );
void enableAutoPlotTitle( bool enable );
bool autoPlotTitle() const;
@@ -100,7 +101,7 @@ public:
size_t curveCount() const;
void detachAllCurves();
void detachAllCurves() override;
void reattachAllCurves();
void updateCaseNameHasChanged();
@@ -154,9 +155,8 @@ public:
void setNormalizationEnabled( bool enable );
bool isNormalizationEnabled();
void showLegend( bool enable );
void handleKeyPressEvent( QKeyEvent* keyEvent );
void handleKeyPressEvent( QKeyEvent* keyEvent ) override;
virtual RimSummaryPlotSourceStepping* sourceSteppingObjectForKeyEventHandling() const;
virtual std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
@@ -171,11 +171,14 @@ public:
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
void onAxisSelected( int axis, bool toggle ) override;
void loadDataAndUpdate();
void loadDataAndUpdate() override;
void addOrUpdateEnsembleCurveSetLegend( RimEnsembleCurveSet* curveSet );
void removeEnsembleCurveSetLegend( RimEnsembleCurveSet* curveSet );
void removeFromMdiAreaAndCollection() override;
void updateAfterInsertingIntoGridPlotWindow() override;
public:
// RimViewWindow overrides
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
@@ -186,18 +189,15 @@ private:
void updateMdiWindowTitle() override;
void updateNameHelperWithCurveData( RimSummaryPlotNameHelper* nameHelper ) const;
void updateWindowVisibility();
protected:
// Overridden PDM methods
caf::PdmFieldHandle* userDescriptionField() override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
caf::PdmFieldHandle* userDescriptionField() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void onLoadDataAndUpdate() override;
@@ -222,12 +222,8 @@ private:
std::set<RimPlotAxisPropertiesInterface*> allPlotAxes() const;
private:
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<bool> m_showLegend;
caf::PdmField<bool> m_normalizeCurveYValues;
caf::PdmField<int> m_legendFontSize;
caf::PdmField<bool> m_useAutoPlotTitle;
caf::PdmChildArrayField<RimGridTimeHistoryCurve*> m_gridTimeHistoryCurves;
@@ -248,6 +244,7 @@ private:
std::unique_ptr<QwtPlotTextLabel> m_plotInfoLabel;
bool m_isCrossPlot;
bool m_isDraggable;
std::unique_ptr<RimSummaryPlotNameHelper> m_nameHelperAllCurves;
@@ -255,4 +252,7 @@ private:
caf::PdmChildArrayField<RimSummaryCurve*> m_summaryCurves_OBSOLETE;
caf::PdmChildArrayField<RimSummaryCurveFilter_OBSOLETE*> m_curveFilters_OBSOLETE;
caf::PdmField<bool> m_isAutoZoom_OBSOLETE;
caf::PdmField<bool> m_showPlotTitle_OBSOLETE;
caf::PdmField<bool> m_showLegend_OBSOLETE;
};

View File

@@ -94,3 +94,11 @@ void RimSummaryPlotCollection::summaryPlotItemInfos( QList<caf::PdmOptionItemInf
caf::PdmOptionItemInfo( displayName, plot, false, plot->uiCapability()->uiIconProvider() ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlotCollection::removeSummaryPlot( RimSummaryPlot* summaryPlot )
{
summaryPlots.removeChildObject( summaryPlot );
}

View File

@@ -42,4 +42,6 @@ public:
void updateSummaryNameHasChanged();
void summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const;
void removeSummaryPlot( RimSummaryPlot* summaryPlot );
};