mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Parameter result cross plot
This commit is contained in:
parent
494ce6306f
commit
7e3fc1c886
@ -1,10 +1,12 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewCorrelationPlotFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewParameterResultCrossPlotFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewCorrelationPlotFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewParameterResultCrossPlotFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,81 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicNewParameterResultCrossPlotFeature.h"
|
||||
|
||||
#include "RimCorrelationPlotCollection.h"
|
||||
#include "RimParameterResultCrossPlot.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewParameterResultCrossPlotFeature, "RicNewParameterResultCrossPlotFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewParameterResultCrossPlotFeature::isCommandEnabled()
|
||||
{
|
||||
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
}
|
||||
|
||||
if ( correlationPlotColl ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewParameterResultCrossPlotFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
}
|
||||
|
||||
if ( !correlationPlotColl ) return;
|
||||
|
||||
auto newPlot = correlationPlotColl->createParameterResultCrossPlot();
|
||||
newPlot->loadDataAndUpdate();
|
||||
|
||||
correlationPlotColl->updateConnectedEditors();
|
||||
|
||||
RiuPlotMainWindowTools::setExpanded( newPlot );
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( newPlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewParameterResultCrossPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "New Parameter vs Result Cross Plot" );
|
||||
actionToSetup->setIcon( QIcon( ":/AnalysisPlot16x16.png" ) );
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewParameterResultCrossPlotFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
@ -1,11 +1,15 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimAbstractCorrelationPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimParameterResultCrossPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationPlotCollection.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimAbstractCorrelationPlot.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationPlot.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimParameterResultCrossPlot.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationPlotCollection.cpp
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,315 @@
|
||||
#include "RimAbstractCorrelationPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include "RiuQwtPlotWidget.h"
|
||||
#include "RiuSummaryVectorSelectionDialog.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT( RimAbstractCorrelationPlot, "AbstractCorrelationPlot" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimAbstractCorrelationPlot::RimAbstractCorrelationPlot()
|
||||
{
|
||||
CAF_PDM_InitObject( "Abstract Correlation Plot", ":/CorrelationPlot16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryAddressUiField, "SelectedVariableDisplayVar", "Vector", "", "", "" );
|
||||
m_summaryAddressUiField.xmlCapability()->disableIO();
|
||||
m_summaryAddressUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryAddress, "SummaryAddress", "Summary Address", "", "", "" );
|
||||
m_summaryAddress.uiCapability()->setUiHidden( true );
|
||||
m_summaryAddress.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "", "", "", "" );
|
||||
caf::PdmUiPushButtonEditor::configureEditorForField( &m_pushButtonSelectSummaryAddress );
|
||||
m_pushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
m_pushButtonSelectSummaryAddress = false;
|
||||
|
||||
m_summaryAddress = new RimSummaryAddress;
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_timeStep, "TimeStep", "Time Step", "", "", "" );
|
||||
m_timeStep.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" );
|
||||
CAF_PDM_InitField( &m_useAutoPlotTitle, "AutoTitle", true, "Automatic Plot Title", "", "", "" );
|
||||
CAF_PDM_InitField( &m_description, "PlotTitle", QString( "Correlation Plot" ), "Custom Plot Title", "", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimAbstractCorrelationPlot::~RimAbstractCorrelationPlot()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAbstractCorrelationPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
RimPlot::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
if ( changedField == &m_pushButtonSelectSummaryAddress )
|
||||
{
|
||||
RiuSummaryVectorSelectionDialog dlg( nullptr );
|
||||
RimSummaryCaseCollection* candidateEnsemble = m_ensemble;
|
||||
RifEclipseSummaryAddress candicateAddress = m_summaryAddress->address();
|
||||
|
||||
dlg.hideSummaryCases();
|
||||
dlg.setEnsembleAndAddress( candidateEnsemble, candicateAddress );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
auto curveSelection = dlg.curveSelection();
|
||||
if ( !curveSelection.empty() )
|
||||
{
|
||||
m_summaryAddress->setAddress( curveSelection[0].summaryAddress() );
|
||||
|
||||
this->loadDataAndUpdate();
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
m_pushButtonSelectSummaryAddress = false;
|
||||
}
|
||||
else if ( changedField == &m_timeStep )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
else if ( changedField == &m_ensemble )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
else if ( changedField == &m_showPlotTitle || changedField == &m_useAutoPlotTitle || changedField == &m_description )
|
||||
{
|
||||
this->updatePlotTitle();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAbstractCorrelationPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
||||
if ( attrib )
|
||||
{
|
||||
attrib->m_buttonText = "...";
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimAbstractCorrelationPlot::userDescriptionField()
|
||||
{
|
||||
return &m_description;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RimAbstractCorrelationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options = RimPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
|
||||
|
||||
if ( fieldNeedingOptions == &m_ensemble )
|
||||
{
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
std::vector<RimSummaryCaseCollection*> summaryCaseCollections;
|
||||
project->descendantsIncludingThisOfType( summaryCaseCollections );
|
||||
for ( auto summaryCaseCollection : summaryCaseCollections )
|
||||
{
|
||||
if ( summaryCaseCollection->isEnsemble() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( summaryCaseCollection->name(), summaryCaseCollection ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_summaryAddressUiField )
|
||||
{
|
||||
if ( m_ensemble )
|
||||
{
|
||||
RimEnsembleCurveSet::appendOptionItemsForSummaryAddresses( &options, m_ensemble );
|
||||
}
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_timeStep )
|
||||
{
|
||||
QString dateTimeFormat = RiaApplication::instance()->preferences()->dateTimeFormat();
|
||||
if ( m_ensemble )
|
||||
{
|
||||
std::set<time_t> allTimeSteps = allAvailableTimeSteps();
|
||||
for ( time_t timeStep : allTimeSteps )
|
||||
{
|
||||
QDateTime dateTime = QDateTime::fromTime_t( timeStep );
|
||||
QString timestepString = dateTime.toString( Qt::ISODate );
|
||||
options.push_back( caf::PdmOptionItemInfo( timestepString, dateTime ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<time_t> RimAbstractCorrelationPlot::allAvailableTimeSteps()
|
||||
{
|
||||
std::set<time_t> timeStepUnion;
|
||||
|
||||
for ( RimSummaryCase* sumCase : m_ensemble->allSummaryCases() )
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = sumCase->summaryReader()->timeSteps( m_summaryAddress->address() );
|
||||
|
||||
for ( time_t t : timeSteps )
|
||||
{
|
||||
timeStepUnion.insert( t );
|
||||
}
|
||||
}
|
||||
|
||||
return timeStepUnion;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimAbstractCorrelationPlot::viewWidget()
|
||||
{
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAbstractCorrelationPlot::deleteViewWidget()
|
||||
{
|
||||
cleanupBeforeClose();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RimAbstractCorrelationPlot::snapshotWindowContent()
|
||||
{
|
||||
QImage image;
|
||||
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
QPixmap pix = m_plotWidget->grab();
|
||||
image = pix.toImage();
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimAbstractCorrelationPlot::applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
||||
int oldFontSize,
|
||||
int fontSize,
|
||||
bool forceChange /*= false */ )
|
||||
{
|
||||
bool anyChange = false;
|
||||
|
||||
return anyChange;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimAbstractCorrelationPlot::description() const
|
||||
{
|
||||
return m_description();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlotWidget* RimAbstractCorrelationPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ )
|
||||
{
|
||||
if ( !m_plotWidget )
|
||||
{
|
||||
m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
|
||||
// updatePlotTitle();
|
||||
}
|
||||
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlotWidget* RimAbstractCorrelationPlot::viewer()
|
||||
{
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAbstractCorrelationPlot::detachAllCurves()
|
||||
{
|
||||
if ( m_plotWidget ) m_plotWidget->detachItems();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAbstractCorrelationPlot::updateLegend()
|
||||
{
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
m_plotWidget->insertLegend( nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAbstractCorrelationPlot::cleanupBeforeClose()
|
||||
{
|
||||
detachAllCurves();
|
||||
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
m_plotWidget->setParent( nullptr );
|
||||
delete m_plotWidget;
|
||||
m_plotWidget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
time_t RimAbstractCorrelationPlot::timeDiff( time_t lhs, time_t rhs )
|
||||
{
|
||||
if ( lhs >= rhs )
|
||||
{
|
||||
return lhs - rhs;
|
||||
}
|
||||
return rhs - lhs;
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RifEclipseSummaryAddressQMetaType.h"
|
||||
|
||||
#include "RimPlot.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
class RimSummaryAddress;
|
||||
|
||||
class RimAbstractCorrelationPlot : public RimPlot
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimAbstractCorrelationPlot();
|
||||
~RimAbstractCorrelationPlot() override;
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
|
||||
std::set<time_t> allAvailableTimeSteps();
|
||||
|
||||
// RimViewWindow overrides
|
||||
QWidget* viewWidget() override;
|
||||
void deleteViewWidget() override;
|
||||
void zoomAll() override {}
|
||||
QImage snapshotWindowContent() override;
|
||||
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
||||
int oldFontSize,
|
||||
int fontSize,
|
||||
bool forceChange = false ) override;
|
||||
|
||||
// RimPlotWindow overrides
|
||||
QString description() const override;
|
||||
void doUpdateLayout() override {}
|
||||
|
||||
// RimPlot Overrides
|
||||
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
|
||||
RiuQwtPlotWidget* viewer() override;
|
||||
|
||||
void detachAllCurves() override;
|
||||
void reattachAllCurves() override {}
|
||||
void doRemoveFromCollection() override {}
|
||||
void updateZoomInQwt() override {}
|
||||
void updateZoomFromQwt() override {}
|
||||
void setAutoScaleXEnabled( bool enabled ) override {}
|
||||
void setAutoScaleYEnabled( bool enabled ) override {}
|
||||
void updateLegend() override;
|
||||
|
||||
QString asciiDataForPlotExport() const override { return ""; }
|
||||
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override { return nullptr; }
|
||||
|
||||
void cleanupBeforeClose();
|
||||
virtual void updatePlotTitle() = 0;
|
||||
|
||||
static time_t timeDiff( time_t lhs, time_t rhs );
|
||||
|
||||
protected:
|
||||
QPointer<RiuQwtPlotWidget> m_plotWidget;
|
||||
|
||||
// Fields
|
||||
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble;
|
||||
caf::PdmChildField<RimSummaryAddress*> m_summaryAddress;
|
||||
caf::PdmField<RifEclipseSummaryAddress> m_summaryAddressUiField;
|
||||
caf::PdmField<bool> m_pushButtonSelectSummaryAddress;
|
||||
caf::PdmField<QDateTime> m_timeStep;
|
||||
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<bool> m_useAutoPlotTitle;
|
||||
caf::PdmField<QString> m_description;
|
||||
};
|
@ -19,13 +19,11 @@
|
||||
#include "RimCorrelationPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaStatisticsTools.h"
|
||||
#include "RiuGroupedBarChartBuilder.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuSummaryVectorSelectionDialog.h"
|
||||
#include "RiuQwtPlotWidget.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
@ -34,20 +32,12 @@
|
||||
#include "RimPlotAxisProperties.h"
|
||||
#include "RimPlotAxisPropertiesInterface.h"
|
||||
#include "RimPlotDataFilterCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryPlotAxisFormatter.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
#include "qwt_column_symbol.h"
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_painter.h"
|
||||
#include "qwt_scale_draw.h"
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
@ -70,38 +60,14 @@ CAF_PDM_SOURCE_INIT( RimCorrelationPlot, "CorrelationPlot" );
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCorrelationPlot::RimCorrelationPlot()
|
||||
: RimPlot()
|
||||
: RimAbstractCorrelationPlot()
|
||||
{
|
||||
CAF_PDM_InitObject( "Correlation Plot", ":/CorrelationPlot16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_ensemble, "Ensemble", "Ensemble", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryAddressUiField, "SelectedVariableDisplayVar", "Vector", "", "", "" );
|
||||
m_summaryAddressUiField.xmlCapability()->disableIO();
|
||||
m_summaryAddressUiField.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryAddress, "SummaryAddress", "Summary Address", "", "", "" );
|
||||
m_summaryAddress.uiCapability()->setUiHidden( true );
|
||||
m_summaryAddress.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_pushButtonSelectSummaryAddress, "SelectAddress", "", "", "", "" );
|
||||
caf::PdmUiPushButtonEditor::configureEditorForField( &m_pushButtonSelectSummaryAddress );
|
||||
m_pushButtonSelectSummaryAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
m_pushButtonSelectSummaryAddress = false;
|
||||
|
||||
m_summaryAddress = new RimSummaryAddress;
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_timeStep, "TimeStep", "Time Step", "", "", "" );
|
||||
m_timeStep.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_correlationFactor, "CorrelationFactor", "Correlation Factor", "", "", "" );
|
||||
m_correlationFactor.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
CAF_PDM_InitField( &m_showAbsoluteValues, "CorrelationAbsValues", true, "Show Absolute Values", "", "", "" );
|
||||
CAF_PDM_InitField( &m_sortByAbsoluteValues, "CorrelationAbsSorting", true, "Sort by Absolute Values", "", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" );
|
||||
CAF_PDM_InitField( &m_useAutoPlotTitle, "AutoTitle", true, "Automatic Plot Title", "", "", "" );
|
||||
CAF_PDM_InitField( &m_description, "PlotTitle", QString( "Correlation Plot" ), "Custom Plot Title", "", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -121,50 +87,13 @@ void RimCorrelationPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
RimPlot::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
if ( changedField == &m_pushButtonSelectSummaryAddress )
|
||||
{
|
||||
RiuSummaryVectorSelectionDialog dlg( nullptr );
|
||||
RimSummaryCaseCollection* candidateEnsemble = m_ensemble;
|
||||
RifEclipseSummaryAddress candicateAddress = m_summaryAddress->address();
|
||||
|
||||
dlg.hideSummaryCases();
|
||||
dlg.setEnsembleAndAddress( candidateEnsemble, candicateAddress );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
auto curveSelection = dlg.curveSelection();
|
||||
if ( !curveSelection.empty() )
|
||||
{
|
||||
m_summaryAddress->setAddress( curveSelection[0].summaryAddress() );
|
||||
|
||||
this->loadDataAndUpdate();
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
m_pushButtonSelectSummaryAddress = false;
|
||||
}
|
||||
else if ( changedField == &m_timeStep )
|
||||
RimAbstractCorrelationPlot::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
if ( changedField == &m_correlationFactor || changedField == &m_showAbsoluteValues ||
|
||||
changedField == &m_sortByAbsoluteValues )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
else if ( changedField == &m_ensemble )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
else if ( changedField == &m_correlationFactor || changedField == &m_showAbsoluteValues ||
|
||||
changedField == &m_sortByAbsoluteValues )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
else if ( changedField == &m_showPlotTitle || changedField == &m_useAutoPlotTitle || changedField == &m_description )
|
||||
{
|
||||
this->updatePlotTitle();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -172,6 +101,14 @@ void RimCorrelationPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
caf::PdmUiGroup* correlationGroup = uiOrdering.addNewGroup( "Correlation Factor Settings" );
|
||||
correlationGroup->add( &m_correlationFactor );
|
||||
correlationGroup->add( &m_showAbsoluteValues );
|
||||
if ( !m_showAbsoluteValues() )
|
||||
{
|
||||
correlationGroup->add( &m_sortByAbsoluteValues );
|
||||
}
|
||||
|
||||
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector" );
|
||||
curveDataGroup->add( &m_ensemble );
|
||||
curveDataGroup->add( &m_summaryAddressUiField );
|
||||
@ -179,12 +116,6 @@ void RimCorrelationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
|
||||
curveDataGroup->add( &m_timeStep );
|
||||
|
||||
caf::PdmUiGroup* plotGroup = uiOrdering.addNewGroup( "Plot Settings" );
|
||||
plotGroup->add( &m_correlationFactor );
|
||||
plotGroup->add( &m_showAbsoluteValues );
|
||||
if ( !m_showAbsoluteValues() )
|
||||
{
|
||||
plotGroup->add( &m_sortByAbsoluteValues );
|
||||
}
|
||||
plotGroup->add( &m_showPlotTitle );
|
||||
plotGroup->add( &m_useAutoPlotTitle );
|
||||
plotGroup->add( &m_description );
|
||||
@ -192,107 +123,18 @@ void RimCorrelationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
||||
if ( attrib )
|
||||
{
|
||||
attrib->m_buttonText = "...";
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimCorrelationPlot::userDescriptionField()
|
||||
{
|
||||
return &m_description;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimCorrelationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options = RimPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
|
||||
if ( fieldNeedingOptions == &m_ensemble )
|
||||
{
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
std::vector<RimSummaryCaseCollection*> summaryCaseCollections;
|
||||
project->descendantsIncludingThisOfType( summaryCaseCollections );
|
||||
for ( auto summaryCaseCollection : summaryCaseCollections )
|
||||
{
|
||||
if ( summaryCaseCollection->isEnsemble() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( summaryCaseCollection->name(), summaryCaseCollection ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_summaryAddressUiField )
|
||||
{
|
||||
if ( m_ensemble )
|
||||
{
|
||||
RimEnsembleCurveSet::appendOptionItemsForSummaryAddresses( &options, m_ensemble );
|
||||
}
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_timeStep )
|
||||
{
|
||||
QString dateTimeFormat = RiaApplication::instance()->preferences()->dateTimeFormat();
|
||||
if ( m_ensemble )
|
||||
{
|
||||
std::set<time_t> allTimeSteps = allAvailableTimeSteps();
|
||||
for ( time_t timeStep : allTimeSteps )
|
||||
{
|
||||
QDateTime dateTime = QDateTime::fromTime_t( timeStep );
|
||||
options.push_back( caf::PdmOptionItemInfo( dateTime.toString( dateTimeFormat ), dateTime ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
QList<caf::PdmOptionItemInfo> options =
|
||||
RimAbstractCorrelationPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<time_t> RimCorrelationPlot::allAvailableTimeSteps()
|
||||
{
|
||||
std::set<time_t> timeStepUnion;
|
||||
|
||||
for ( RimSummaryCase* sumCase : m_ensemble->allSummaryCases() )
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = sumCase->summaryReader()->timeSteps( m_summaryAddress->address() );
|
||||
|
||||
for ( time_t t : timeSteps )
|
||||
{
|
||||
timeStepUnion.insert( t );
|
||||
}
|
||||
}
|
||||
|
||||
return timeStepUnion;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimCorrelationPlot::viewWidget()
|
||||
{
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlot::deleteViewWidget()
|
||||
{
|
||||
cleanupBeforeClose();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -323,73 +165,6 @@ void RimCorrelationPlot::onLoadDataAndUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RimCorrelationPlot::snapshotWindowContent()
|
||||
{
|
||||
QImage image;
|
||||
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
QPixmap pix = m_plotWidget->grab();
|
||||
image = pix.toImage();
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCorrelationPlot::applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
||||
int oldFontSize,
|
||||
int fontSize,
|
||||
bool forceChange /*= false */ )
|
||||
{
|
||||
bool anyChange = false;
|
||||
|
||||
return anyChange;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCorrelationPlot::description() const
|
||||
{
|
||||
return m_description();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlotWidget* RimCorrelationPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ )
|
||||
{
|
||||
if ( !m_plotWidget )
|
||||
{
|
||||
m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
|
||||
// updatePlotTitle();
|
||||
}
|
||||
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlotWidget* RimCorrelationPlot::viewer()
|
||||
{
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlot::detachAllCurves()
|
||||
{
|
||||
if ( m_plotWidget ) m_plotWidget->detachItems();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -397,10 +172,13 @@ void RimCorrelationPlot::updateAxes()
|
||||
{
|
||||
if ( !m_plotWidget ) return;
|
||||
|
||||
m_plotWidget->setAxisTitle( QwtPlot::yLeft, "Parameter" );
|
||||
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Parameter" );
|
||||
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
|
||||
m_plotWidget->setAxisTitle( QwtPlot::xBottom, "Pearson Correlation Coefficient" );
|
||||
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 11, 11, false, Qt::AlignCenter );
|
||||
|
||||
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Pearson Correlation Coefficient" );
|
||||
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
|
||||
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, 11, 11, false, Qt::AlignCenter );
|
||||
if ( m_showAbsoluteValues )
|
||||
{
|
||||
m_plotWidget->setAxisRange( QwtPlot::xBottom, 0.0, 1.0 );
|
||||
@ -411,28 +189,6 @@ void RimCorrelationPlot::updateAxes()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlot::onAxisSelected( int axis, bool toggle )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlot::cleanupBeforeClose()
|
||||
{
|
||||
detachAllCurves();
|
||||
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
m_plotWidget->setParent( nullptr );
|
||||
delete m_plotWidget;
|
||||
m_plotWidget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -467,7 +223,7 @@ void RimCorrelationPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chart
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( m_summaryAddress->address() );
|
||||
for ( size_t i = 0; i < timeSteps.size(); ++i )
|
||||
{
|
||||
if ( timeSteps[i] >= selectedTimestep && timeSteps[i] - selectedTimestep < selectedTimestep - closestTimeStep )
|
||||
if ( timeDiff( timeSteps[i], selectedTimestep ) < timeDiff( selectedTimestep, closestTimeStep ) )
|
||||
{
|
||||
closestValue = values[i];
|
||||
closestTimeStep = timeSteps[i];
|
||||
@ -504,7 +260,7 @@ void RimCorrelationPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chart
|
||||
correlationResults.push_back( std::make_pair( parameterValuesPair.first, correlation ) );
|
||||
}
|
||||
|
||||
QString timestepString = m_timeStep().toString( RiaApplication::instance()->preferences()->dateTimeFormat() );
|
||||
QString timestepString = m_timeStep().toString( Qt::ISODate );
|
||||
|
||||
for ( auto parameterCorrPair : correlationResults )
|
||||
{
|
||||
@ -528,5 +284,5 @@ void RimCorrelationPlot::updatePlotTitle()
|
||||
.arg( QString::fromStdString( m_summaryAddressUiField().uiText() ) );
|
||||
}
|
||||
m_plotWidget->setPlotTitle( m_description );
|
||||
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle );
|
||||
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && isMdiWindow() );
|
||||
}
|
||||
|
@ -18,14 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
#include "RifEclipseSummaryAddressQMetaType.h"
|
||||
|
||||
#include "RimPlot.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include "RimAbstractCorrelationPlot.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
@ -36,7 +30,7 @@ class RiuGroupedBarChartBuilder;
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimCorrelationPlot : public RimPlot
|
||||
class RimCorrelationPlot : public RimAbstractCorrelationPlot
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@ -57,68 +51,20 @@ private:
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
|
||||
std::set<time_t> allAvailableTimeSteps();
|
||||
void onLoadDataAndUpdate() override;
|
||||
|
||||
// RimViewWindow overrides
|
||||
QWidget* viewWidget() override;
|
||||
void deleteViewWidget() override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void zoomAll() override {}
|
||||
QImage snapshotWindowContent() override;
|
||||
bool applyFontSize( RiaDefines::FontSettingType fontSettingType,
|
||||
int oldFontSize,
|
||||
int fontSize,
|
||||
bool forceChange = false ) override;
|
||||
|
||||
// RimPlotWindow overrides
|
||||
QString description() const override;
|
||||
void doUpdateLayout() override {}
|
||||
|
||||
// RimPlot Overrides
|
||||
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
|
||||
RiuQwtPlotWidget* viewer() override;
|
||||
|
||||
void detachAllCurves() override;
|
||||
void reattachAllCurves() override {}
|
||||
void doRemoveFromCollection() override {}
|
||||
void updateAxes() override;
|
||||
void onAxisSelected( int axis, bool toggle ) override;
|
||||
void updateZoomInQwt() override {}
|
||||
void updateZoomFromQwt() override {}
|
||||
void setAutoScaleXEnabled( bool enabled ) override {}
|
||||
void setAutoScaleYEnabled( bool enabled ) override {}
|
||||
void updateLegend() override{};
|
||||
|
||||
QString asciiDataForPlotExport() const override { return ""; }
|
||||
caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override { return nullptr; }
|
||||
|
||||
// Private methods
|
||||
void cleanupBeforeClose();
|
||||
void addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBuilder );
|
||||
void updatePlotTitle();
|
||||
void updatePlotTitle() override;
|
||||
|
||||
private:
|
||||
QPointer<RiuQwtPlotWidget> m_plotWidget;
|
||||
|
||||
// Fields
|
||||
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble;
|
||||
caf::PdmChildField<RimSummaryAddress*> m_summaryAddress;
|
||||
caf::PdmField<RifEclipseSummaryAddress> m_summaryAddressUiField;
|
||||
caf::PdmField<bool> m_pushButtonSelectSummaryAddress;
|
||||
caf::PdmField<QDateTime> m_timeStep;
|
||||
caf::PdmField<CorrelationFactorEnum> m_correlationFactor;
|
||||
caf::PdmField<bool> m_showAbsoluteValues;
|
||||
caf::PdmField<bool> m_sortByAbsoluteValues;
|
||||
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<bool> m_useAutoPlotTitle;
|
||||
caf::PdmField<QString> m_description;
|
||||
caf::PdmField<CorrelationFactorEnum> m_correlationFactor;
|
||||
caf::PdmField<bool> m_showAbsoluteValues;
|
||||
caf::PdmField<bool> m_sortByAbsoluteValues;
|
||||
};
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "RimCorrelationPlotCollection.h"
|
||||
|
||||
#include "RimCorrelationPlot.h"
|
||||
#include "RimParameterResultCrossPlot.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimCorrelationPlotCollection, "CorrelationPlotCollection" );
|
||||
|
||||
@ -57,26 +58,26 @@ RimCorrelationPlot* RimCorrelationPlotCollection::createCorrelationPlot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlotCollection::updateSummaryNameHasChanged()
|
||||
RimParameterResultCrossPlot* RimCorrelationPlotCollection::createParameterResultCrossPlot()
|
||||
{
|
||||
for ( RimCorrelationPlot* plot : m_correlationPlots )
|
||||
{
|
||||
plot->loadDataAndUpdate();
|
||||
}
|
||||
RimParameterResultCrossPlot* plot = new RimParameterResultCrossPlot;
|
||||
plot->setAsPlotMdiWindow();
|
||||
m_correlationPlots.push_back( plot );
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlotCollection::removeSummaryPlot( RimCorrelationPlot* CorrelationPlot )
|
||||
void RimCorrelationPlotCollection::removePlot( RimAbstractCorrelationPlot* correlationPlot )
|
||||
{
|
||||
m_correlationPlots.removeChildObject( CorrelationPlot );
|
||||
m_correlationPlots.removeChildObject( correlationPlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimCorrelationPlot*> RimCorrelationPlotCollection::plots()
|
||||
std::vector<RimAbstractCorrelationPlot*> RimCorrelationPlotCollection::plots()
|
||||
{
|
||||
return m_correlationPlots.childObjects();
|
||||
}
|
||||
|
@ -21,7 +21,9 @@
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class RimAbstractCorrelationPlot;
|
||||
class RimCorrelationPlot;
|
||||
class RimParameterResultCrossPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -35,14 +37,14 @@ public:
|
||||
RimCorrelationPlotCollection();
|
||||
~RimCorrelationPlotCollection() override;
|
||||
|
||||
RimCorrelationPlot* createCorrelationPlot();
|
||||
void updateSummaryNameHasChanged();
|
||||
void removeSummaryPlot( RimCorrelationPlot* CorrelationPlot );
|
||||
RimCorrelationPlot* createCorrelationPlot();
|
||||
RimParameterResultCrossPlot* createParameterResultCrossPlot();
|
||||
void removePlot( RimAbstractCorrelationPlot* CorrelationPlot );
|
||||
|
||||
std::vector<RimCorrelationPlot*> plots();
|
||||
std::vector<RimAbstractCorrelationPlot*> plots();
|
||||
|
||||
void deleteAllChildObjects();
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimCorrelationPlot*> m_correlationPlots;
|
||||
caf::PdmChildArrayField<RimAbstractCorrelationPlot*> m_correlationPlots;
|
||||
};
|
||||
|
@ -0,0 +1,250 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimParameterResultCrossPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaStatisticsTools.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuSummaryVectorSelectionDialog.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RimDerivedSummaryCase.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimPlotAxisProperties.h"
|
||||
#include "RimPlotAxisPropertiesInterface.h"
|
||||
#include "RimPlotDataFilterCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryPlotAxisFormatter.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimParameterResultCrossPlot, "ParameterResultCrossPlot" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimParameterResultCrossPlot::RimParameterResultCrossPlot()
|
||||
: RimAbstractCorrelationPlot()
|
||||
{
|
||||
CAF_PDM_InitObject( "ParameterResultCross Plot", ":/ParameterResultCrossPlot16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter", "", "", "" );
|
||||
m_ensembleParameter.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimParameterResultCrossPlot::~RimParameterResultCrossPlot()
|
||||
{
|
||||
removeMdiWindowFromMdiArea();
|
||||
cleanupBeforeClose();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimParameterResultCrossPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
RimAbstractCorrelationPlot::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
if ( changedField == &m_ensembleParameter )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimParameterResultCrossPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector" );
|
||||
curveDataGroup->add( &m_ensemble );
|
||||
curveDataGroup->add( &m_summaryAddressUiField );
|
||||
curveDataGroup->add( &m_pushButtonSelectSummaryAddress, { false, 1, 0 } );
|
||||
curveDataGroup->add( &m_timeStep );
|
||||
|
||||
caf::PdmUiGroup* crossPlotGroup = uiOrdering.addNewGroup( "Cross Plot Parameters" );
|
||||
crossPlotGroup->add( &m_ensembleParameter );
|
||||
|
||||
caf::PdmUiGroup* plotGroup = uiOrdering.addNewGroup( "Plot Settings" );
|
||||
plotGroup->add( &m_showPlotTitle );
|
||||
plotGroup->add( &m_useAutoPlotTitle );
|
||||
plotGroup->add( &m_description );
|
||||
m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle() );
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RimParameterResultCrossPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options =
|
||||
RimAbstractCorrelationPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
|
||||
if ( fieldNeedingOptions == &m_ensembleParameter )
|
||||
{
|
||||
if ( m_ensemble )
|
||||
{
|
||||
for ( const auto& param : m_ensemble->variationSortedEnsembleParameters() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( param.uiName(), param.name ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimParameterResultCrossPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
updateMdiWindowVisibility();
|
||||
|
||||
m_summaryAddressUiField = m_summaryAddress->address();
|
||||
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
m_plotWidget->insertLegend( nullptr );
|
||||
m_plotWidget->updateLegend();
|
||||
|
||||
createPoints();
|
||||
|
||||
this->updateAxes();
|
||||
this->updatePlotTitle();
|
||||
m_plotWidget->scheduleReplot();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimParameterResultCrossPlot::updateAxes()
|
||||
{
|
||||
if ( !m_plotWidget ) return;
|
||||
|
||||
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, QString::fromStdString( m_summaryAddressUiField().uiText() ) );
|
||||
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
|
||||
m_plotWidget->setAxisAutoScale( QwtPlot::yLeft, true );
|
||||
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 11, 11, false, Qt::AlignCenter );
|
||||
|
||||
m_plotWidget->setAxisTitleText( QwtPlot::xBottom, m_ensembleParameter );
|
||||
m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true );
|
||||
m_plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
|
||||
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::xBottom, 11, 11, false, Qt::AlignCenter );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimParameterResultCrossPlot::createPoints()
|
||||
{
|
||||
time_t selectedTimestep = m_timeStep().toTime_t();
|
||||
|
||||
if ( !m_ensemble ) return;
|
||||
|
||||
if ( !m_summaryAddress ) return;
|
||||
|
||||
EnsembleParameter ensembleParameter = m_ensemble->ensembleParameter( m_ensembleParameter );
|
||||
if ( !( ensembleParameter.isNumeric() && ensembleParameter.isValid() ) ) return;
|
||||
|
||||
for ( size_t caseIdx = 0u; caseIdx < m_ensemble->allSummaryCases().size(); ++caseIdx )
|
||||
{
|
||||
std::vector<double> caseValuesAtTimestep;
|
||||
std::vector<double> parameterValues;
|
||||
|
||||
auto summaryCase = m_ensemble->allSummaryCases()[caseIdx];
|
||||
|
||||
RifSummaryReaderInterface* reader = summaryCase->summaryReader();
|
||||
if ( !reader ) continue;
|
||||
|
||||
if ( !summaryCase->caseRealizationParameters() ) continue;
|
||||
|
||||
std::vector<double> values;
|
||||
|
||||
double closestValue = std::numeric_limits<double>::infinity();
|
||||
time_t closestTimeStep = 0;
|
||||
if ( reader->values( m_summaryAddress->address(), &values ) )
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( m_summaryAddress->address() );
|
||||
for ( size_t i = 0; i < timeSteps.size(); ++i )
|
||||
{
|
||||
if ( timeDiff( timeSteps[i], selectedTimestep ) < timeDiff( selectedTimestep, closestTimeStep ) )
|
||||
{
|
||||
closestValue = values[i];
|
||||
closestTimeStep = timeSteps[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( closestValue != std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
caseValuesAtTimestep.push_back( closestValue );
|
||||
double paramValue = ensembleParameter.values[caseIdx].toDouble();
|
||||
parameterValues.push_back( paramValue );
|
||||
|
||||
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve;
|
||||
plotCurve->setSamplesFromXValuesAndYValues( parameterValues, caseValuesAtTimestep, false );
|
||||
plotCurve->setAppearance( RiuQwtPlotCurve::STYLE_NONE,
|
||||
RiuQwtPlotCurve::INTERPOLATION_POINT_TO_POINT,
|
||||
0,
|
||||
QColor( Qt::red ) );
|
||||
RiuQwtSymbol* symbol = new RiuQwtSymbol( RiuQwtSymbol::SYMBOL_ELLIPSE, "" );
|
||||
symbol->setSize( 12, 12 );
|
||||
symbol->setColor( QColor( Qt::red ) );
|
||||
plotCurve->setSymbol( symbol );
|
||||
plotCurve->attach( m_plotWidget );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimParameterResultCrossPlot::updatePlotTitle()
|
||||
{
|
||||
if ( m_useAutoPlotTitle )
|
||||
{
|
||||
m_description = QString( "Cross Plot %1 x %2" )
|
||||
.arg( m_ensembleParameter )
|
||||
.arg( QString::fromStdString( m_summaryAddressUiField().uiText() ) );
|
||||
}
|
||||
m_plotWidget->setPlotTitle( m_description );
|
||||
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && isMdiWindow() );
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimAbstractCorrelationPlot.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimParameterResultCrossPlot : public RimAbstractCorrelationPlot
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimParameterResultCrossPlot();
|
||||
~RimParameterResultCrossPlot() override;
|
||||
|
||||
private:
|
||||
// Overridden PDM methods
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
|
||||
void onLoadDataAndUpdate() override;
|
||||
|
||||
void updateAxes() override;
|
||||
|
||||
// Private methods
|
||||
void updatePlotTitle() override;
|
||||
void createPoints();
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_ensembleParameter;
|
||||
};
|
@ -87,6 +87,7 @@
|
||||
#include "RimMultiPlot.h"
|
||||
#include "RimMultiPlotCollection.h"
|
||||
#include "RimObservedSummaryData.h"
|
||||
#include "RimParameterResultCrossPlot.h"
|
||||
#include "RimPerforationCollection.h"
|
||||
#include "RimPerforationInterval.h"
|
||||
#include "RimPlotDataFilterCollection.h"
|
||||
@ -529,11 +530,16 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
else if ( dynamic_cast<RimCorrelationPlotCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicNewCorrelationPlotFeature";
|
||||
menuBuilder << "RicNewParameterResultCrossPlotFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimCorrelationPlot*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicNewCorrelationPlotFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimParameterResultCrossPlot*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicNewParameterResultCrossPlotFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimPlotDataFilterCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicNewPlotDataFilterFeature";
|
||||
|
@ -103,7 +103,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void onPlotSelected( bool toggle );
|
||||
virtual void onAxisSelected( int axis, bool toggle ) = 0;
|
||||
virtual void onAxisSelected( int axis, bool toggle ) {}
|
||||
void onCurveSelected( QwtPlotCurve* curve, bool toggle );
|
||||
void onViewerDestroyed();
|
||||
void onKeyPressEvent( QKeyEvent* event );
|
||||
|
@ -173,23 +173,27 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
|
||||
subTitle->setVisible( false );
|
||||
m_subTitles.insert( static_cast<int>( index ), subTitle );
|
||||
|
||||
RiuQwtPlotLegend* legend = new RiuQwtPlotLegend( this );
|
||||
int legendColumns = 1;
|
||||
if ( m_plotDefinition->legendsHorizontal() )
|
||||
RiuQwtPlotLegend* legend = nullptr;
|
||||
if ( plotWidget->legend() )
|
||||
{
|
||||
legendColumns = 0; // unlimited
|
||||
}
|
||||
legend->setMaxColumns( legendColumns );
|
||||
legend->horizontalScrollBar()->setVisible( false );
|
||||
legend->verticalScrollBar()->setVisible( false );
|
||||
legend->connect( plotWidget,
|
||||
SIGNAL( legendDataChanged( const QVariant&, const QList<QwtLegendData>& ) ),
|
||||
SLOT( updateLegend( const QVariant&, const QList<QwtLegendData>& ) ) );
|
||||
QObject::connect( legend, SIGNAL( legendUpdated() ), this, SLOT( onLegendUpdated() ) );
|
||||
legend = new RiuQwtPlotLegend( this );
|
||||
int legendColumns = 1;
|
||||
if ( m_plotDefinition->legendsHorizontal() )
|
||||
{
|
||||
legendColumns = 0; // unlimited
|
||||
}
|
||||
legend->setMaxColumns( legendColumns );
|
||||
legend->horizontalScrollBar()->setVisible( false );
|
||||
legend->verticalScrollBar()->setVisible( false );
|
||||
legend->connect( plotWidget,
|
||||
SIGNAL( legendDataChanged( const QVariant&, const QList<QwtLegendData>& ) ),
|
||||
SLOT( updateLegend( const QVariant&, const QList<QwtLegendData>& ) ) );
|
||||
QObject::connect( legend, SIGNAL( legendUpdated() ), this, SLOT( onLegendUpdated() ) );
|
||||
|
||||
legend->contentsWidget()->layout()->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
|
||||
legend->setVisible( false );
|
||||
plotWidget->updateLegend();
|
||||
legend->contentsWidget()->layout()->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
|
||||
legend->setVisible( false );
|
||||
plotWidget->updateLegend();
|
||||
}
|
||||
m_legends.insert( static_cast<int>( index ), legend );
|
||||
|
||||
scheduleUpdate();
|
||||
@ -209,9 +213,12 @@ void RiuMultiPlotPage::removePlot( RiuQwtPlotWidget* plotWidget )
|
||||
plotWidget->setParent( nullptr );
|
||||
|
||||
RiuQwtPlotLegend* legend = m_legends[plotWidgetIdx];
|
||||
legend->setParent( nullptr );
|
||||
m_legends.removeAt( plotWidgetIdx );
|
||||
delete legend;
|
||||
if ( legend )
|
||||
{
|
||||
legend->setParent( nullptr );
|
||||
m_legends.removeAt( plotWidgetIdx );
|
||||
delete legend;
|
||||
}
|
||||
|
||||
QLabel* subTitle = m_subTitles[plotWidgetIdx];
|
||||
subTitle->setParent( nullptr );
|
||||
@ -367,8 +374,11 @@ void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
|
||||
|
||||
for ( auto legend : legendsForVisiblePlots() )
|
||||
{
|
||||
QPoint renderOffset = m_plotWidgetFrame->mapToParent( legend->frameGeometry().topLeft() ) - marginOffset;
|
||||
legend->render( painter, renderOffset );
|
||||
if ( legend )
|
||||
{
|
||||
QPoint renderOffset = m_plotWidgetFrame->mapToParent( legend->frameGeometry().topLeft() ) - marginOffset;
|
||||
legend->render( painter, renderOffset );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto plotWidget : visiblePlotWidgets() )
|
||||
@ -604,7 +614,10 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
|
||||
std::tie( row, column ) = findAvailableRowAndColumn( row, column, colSpan, rowAndColumnCount.second );
|
||||
|
||||
m_gridLayout->addWidget( subTitles[visibleIndex], 3 * row, column, 1, colSpan );
|
||||
m_gridLayout->addWidget( legends[visibleIndex], 3 * row + 1, column, 1, colSpan, Qt::AlignHCenter | Qt::AlignBottom );
|
||||
if ( legends[visibleIndex] )
|
||||
{
|
||||
m_gridLayout->addWidget( legends[visibleIndex], 3 * row + 1, column, 1, colSpan, Qt::AlignHCenter | Qt::AlignBottom );
|
||||
}
|
||||
m_gridLayout->addWidget( plotWidgets[visibleIndex], 3 * row + 2, column, 1 + ( rowSpan - 1 ) * 3, colSpan );
|
||||
|
||||
subTitles[visibleIndex]->setVisible( m_showSubTitles );
|
||||
@ -614,24 +627,26 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
|
||||
|
||||
plotWidgets[visibleIndex]->show();
|
||||
|
||||
if ( m_plotDefinition->legendsVisible() )
|
||||
if ( legends[visibleIndex] )
|
||||
{
|
||||
int legendColumns = 1;
|
||||
if ( m_plotDefinition->legendsHorizontal() )
|
||||
if ( m_plotDefinition->legendsVisible() )
|
||||
{
|
||||
legendColumns = 0; // unlimited
|
||||
int legendColumns = 1;
|
||||
if ( m_plotDefinition->legendsHorizontal() )
|
||||
{
|
||||
legendColumns = 0; // unlimited
|
||||
}
|
||||
legends[visibleIndex]->setMaxColumns( legendColumns );
|
||||
QFont legendFont = legends[visibleIndex]->font();
|
||||
legendFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( m_plotDefinition->legendFontSize() ) );
|
||||
legends[visibleIndex]->setFont( legendFont );
|
||||
legends[visibleIndex]->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
legends[visibleIndex]->hide();
|
||||
}
|
||||
legends[visibleIndex]->setMaxColumns( legendColumns );
|
||||
QFont legendFont = legends[visibleIndex]->font();
|
||||
legendFont.setPixelSize( RiaFontCache::pointSizeToPixelSize( m_plotDefinition->legendFontSize() ) );
|
||||
legends[visibleIndex]->setFont( legendFont );
|
||||
legends[visibleIndex]->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
legends[visibleIndex]->hide();
|
||||
}
|
||||
|
||||
// Set basic row and column stretches
|
||||
for ( int r = row; r < row + rowSpan; ++r )
|
||||
{
|
||||
@ -677,7 +692,10 @@ int RiuMultiPlotPage::alignCanvasTops()
|
||||
{
|
||||
int row = visibleIndex / rowAndColumnCount.second;
|
||||
plotWidgets[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] );
|
||||
legends[visibleIndex]->adjustSize();
|
||||
if ( legends[visibleIndex] )
|
||||
{
|
||||
legends[visibleIndex]->adjustSize();
|
||||
}
|
||||
}
|
||||
return maxExtents[0];
|
||||
}
|
||||
@ -692,7 +710,10 @@ void RiuMultiPlotPage::clearGridLayout()
|
||||
for ( int tIdx = 0; tIdx < m_plotWidgets.size(); ++tIdx )
|
||||
{
|
||||
m_gridLayout->removeWidget( m_subTitles[tIdx] );
|
||||
m_gridLayout->removeWidget( m_legends[tIdx] );
|
||||
if ( m_legends[tIdx] )
|
||||
{
|
||||
m_gridLayout->removeWidget( m_legends[tIdx] );
|
||||
}
|
||||
m_gridLayout->removeWidget( m_plotWidgets[tIdx] );
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ void RiuQwtPlotWidget::setLegendVisible( bool visible )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QwtInterval RiuQwtPlotWidget::axisRange( QwtPlot::Axis axis )
|
||||
QwtInterval RiuQwtPlotWidget::axisRange( QwtPlot::Axis axis ) const
|
||||
{
|
||||
return axisScaleDiv( axis ).interval();
|
||||
}
|
||||
@ -403,6 +403,8 @@ double RiuQwtPlotWidget::minorTickInterval( QwtPlot::Axis axis ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuQwtPlotWidget::axisExtent( QwtPlot::Axis axis ) const
|
||||
{
|
||||
if ( std::abs( axisRange( axis ).maxValue() - axisRange( axis ).minValue() ) < 1.0e-14 ) return 0;
|
||||
|
||||
int lineExtent = 0;
|
||||
|
||||
if ( this->axisScaleDraw( axis )->hasComponent( QwtAbstractScaleDraw::Ticks ) )
|
||||
@ -1027,7 +1029,7 @@ void RiuQwtPlotWidget::highlightCurve( const QwtPlotCurve* closestCurve )
|
||||
symbol->setPen( blendedSymbolLineColor, symbol->pen().width(), symbol->pen().style() );
|
||||
}
|
||||
}
|
||||
CurveColors curveColors = {curveColor, symbolColor, symbolLineColor};
|
||||
CurveColors curveColors = { curveColor, symbolColor, symbolLineColor };
|
||||
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
|
||||
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
|
||||
m_originalZValues.insert( std::make_pair( plotCurve, zValue ) );
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
void setLegendFontSize( int fontSize );
|
||||
void setLegendVisible( bool visible );
|
||||
|
||||
QwtInterval axisRange( QwtPlot::Axis axis );
|
||||
QwtInterval axisRange( QwtPlot::Axis axis ) const;
|
||||
void setAxisRange( QwtPlot::Axis axis, double min, double max );
|
||||
|
||||
void setAxisInverted( QwtPlot::Axis axis );
|
||||
|
@ -0,0 +1,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObjectCapability.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiObjectViewerCapability : public PdmObjectCapability
|
||||
{
|
||||
public:
|
||||
virtual int id() const = 0;
|
||||
virtual void createViewWidget() = 0;
|
||||
virtual void zoomAll() = 0;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user