mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 23:46:00 -06:00
#8292 Add docking widget used to manage summary plots
This commit is contained in:
parent
7b1c780a77
commit
640b7406ec
@ -38,6 +38,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotFilterTextCurveSetEditor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimObjectiveFunction.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimObjectiveFunctionTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotManager.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@ -80,13 +81,16 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotFilterTextCurveSetEditor.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimObjectiveFunction.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimObjectiveFunctionTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotManager.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
|
||||
|
||||
list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h)
|
||||
list(APPEND QT_MOC_HEADERS ${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotManager.h
|
||||
)
|
||||
|
||||
source_group(
|
||||
"ProjectDataModel\\Summary"
|
||||
|
@ -0,0 +1,474 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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 "RimSummaryPlotManager.h"
|
||||
|
||||
#include "RiaStdStringTools.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
||||
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
#include "cafPdmUiLabelEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSummaryPlotManager, "RimSummaryPlotManager" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlotManager::RimSummaryPlotManager()
|
||||
{
|
||||
CAF_PDM_InitObject( "Summary Plot Manager" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryPlot, "SummaryPlot", "Summary Plot" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_curveFilterText, "CurveFilterText", "Curve Filter Text" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_curveCandidates, "CurveCandidates", "Candidates" );
|
||||
|
||||
CAF_PDM_InitField( &m_includeDiffCurves,
|
||||
"IncludeDiffCurves",
|
||||
true,
|
||||
"Include Difference Curves",
|
||||
"",
|
||||
"Difference between simulated and observed(history) curve",
|
||||
"" );
|
||||
m_includeDiffCurves.uiCapability()->setUiEditorTypeName( caf::PdmUiNativeCheckBoxEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_pushButtonReplace, "PushButtonReplace", "Replace (CTRL + Enter)" );
|
||||
m_pushButtonReplace.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
m_pushButtonReplace.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_pushButtonNewPlot, "PushButtonNewPlot", "New (Alt + Enter)" );
|
||||
m_pushButtonNewPlot.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
m_pushButtonNewPlot.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_pushButtonAppend, "PushButtonAppend", "Append (Shift + Enter)" );
|
||||
m_pushButtonAppend.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
m_pushButtonAppend.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_labelA, "LabelA", "" );
|
||||
m_labelA.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );
|
||||
m_labelA.xmlCapability()->disableIO();
|
||||
m_labelA.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_labelB, "LabelB", "" );
|
||||
m_labelB.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );
|
||||
m_labelB.xmlCapability()->disableIO();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
|
||||
{
|
||||
updateUiFromSelection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_curveFilterText || changedField == &m_includeDiffCurves )
|
||||
{
|
||||
updateCurveCandidates();
|
||||
}
|
||||
else if ( changedField == &m_pushButtonReplace )
|
||||
{
|
||||
replaceCurves();
|
||||
m_pushButtonReplace = false;
|
||||
}
|
||||
else if ( changedField == &m_pushButtonNewPlot )
|
||||
{
|
||||
createNewPlot();
|
||||
m_pushButtonNewPlot = false;
|
||||
}
|
||||
else if ( changedField == &m_pushButtonAppend )
|
||||
{
|
||||
appendCurves();
|
||||
m_pushButtonAppend = false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RimSummaryPlotManager::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
if ( fieldNeedingOptions == &m_summaryPlot )
|
||||
{
|
||||
auto coll = RiaSummaryTools::summaryPlotCollection();
|
||||
coll->summaryPlotItemInfos( &options );
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::updateCurveCandidates()
|
||||
{
|
||||
m_curveCandidates.value().clear();
|
||||
|
||||
if ( !m_summaryPlot ) return;
|
||||
|
||||
auto curves = m_summaryPlot->summaryAndEnsembleCurves();
|
||||
if ( curves.empty() ) return;
|
||||
|
||||
auto firstSource = curves.front()->summaryCaseY();
|
||||
if ( !firstSource ) return;
|
||||
|
||||
std::set<RifEclipseSummaryAddress> addressesFromSources = addressesForSource( firstSource );
|
||||
QStringList addressFilters = m_curveFilterText().split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
|
||||
|
||||
auto addresses = computeFilteredAddresses( addressFilters, addressesFromSources );
|
||||
|
||||
std::vector<QString> curveCandidates;
|
||||
for ( const auto& adr : addresses )
|
||||
{
|
||||
curveCandidates.push_back( QString::fromStdString( adr.uiText() ) );
|
||||
}
|
||||
|
||||
m_curveCandidates = curveCandidates;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress>
|
||||
RimSummaryPlotManager::computeFilteredAddresses( const QStringList& textFilters,
|
||||
const std::set<RifEclipseSummaryAddress>& sourceAddresses )
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> addresses;
|
||||
|
||||
std::vector<bool> usedFilters;
|
||||
RicSummaryPlotFeatureImpl::insertFilteredAddressesInSet( textFilters, sourceAddresses, &addresses, &usedFilters );
|
||||
|
||||
if ( m_includeDiffCurves ) return addresses;
|
||||
|
||||
const auto diffText = RifReaderEclipseSummary::differenceIdentifier();
|
||||
|
||||
std::set<RifEclipseSummaryAddress> addressesWithoutDiffVectors;
|
||||
for ( const auto& adr : addresses )
|
||||
{
|
||||
if ( RiaStdStringTools::endsWith( adr.quantityName(), diffText ) ) continue;
|
||||
|
||||
addressesWithoutDiffVectors.insert( adr );
|
||||
}
|
||||
|
||||
return addressesWithoutDiffVectors;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
{
|
||||
auto myAttr = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
{
|
||||
if ( field == &m_pushButtonReplace )
|
||||
{
|
||||
myAttr->m_buttonText = "Replace Curves \n(Ctrl + Enter)";
|
||||
}
|
||||
if ( field == &m_pushButtonNewPlot )
|
||||
{
|
||||
myAttr->m_buttonText = "Create New Plot \n(Alt + Enter)";
|
||||
}
|
||||
if ( field == &m_pushButtonAppend )
|
||||
{
|
||||
myAttr->m_buttonText = "Append Curves \n(Shift + Enter)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_summaryPlot );
|
||||
|
||||
// uiOrdering.add( &m_labelA );
|
||||
uiOrdering.add( &m_includeDiffCurves );
|
||||
|
||||
uiOrdering.add( &m_curveFilterText );
|
||||
uiOrdering.add( &m_curveCandidates );
|
||||
|
||||
uiOrdering.add( &m_labelB );
|
||||
uiOrdering.add( &m_pushButtonAppend, { false } );
|
||||
uiOrdering.add( &m_pushButtonReplace, { false } );
|
||||
uiOrdering.add( &m_pushButtonNewPlot, { false } );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::appendCurves()
|
||||
{
|
||||
RimSummaryPlot* destinationPlot = m_summaryPlot;
|
||||
|
||||
appendCurvesToPlot( destinationPlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::replaceCurves()
|
||||
{
|
||||
RimSummaryPlot* destinationPlot = m_summaryPlot;
|
||||
destinationPlot->deleteAllSummaryCurves();
|
||||
destinationPlot->ensembleCurveSetCollection()->deleteAllCurveSets();
|
||||
|
||||
appendCurvesToPlot( destinationPlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::createNewPlot()
|
||||
{
|
||||
RimSummaryPlot* destinationPlot = RiaSummaryTools::summaryPlotCollection()->createSummaryPlotWithAutoTitle();
|
||||
|
||||
appendCurvesToPlot( destinationPlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryPlotManager::eventFilter( QObject* obj, QEvent* event )
|
||||
{
|
||||
if ( event->type() == QEvent::KeyPress )
|
||||
{
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>( event );
|
||||
|
||||
if ( keyEvent && ( keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return ) )
|
||||
{
|
||||
auto mods = keyEvent->modifiers();
|
||||
|
||||
if ( mods & Qt::ShiftModifier )
|
||||
appendCurves();
|
||||
else if ( mods & Qt::ControlModifier )
|
||||
replaceCurves();
|
||||
else if ( mods & Qt::AltModifier )
|
||||
createNewPlot();
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter( obj, event );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryCaseCollection*>> RimSummaryPlotManager::dataSources() const
|
||||
{
|
||||
auto sumCaseMainColl = RiaSummaryTools::summaryCaseMainCollection();
|
||||
|
||||
auto summaryCases = sumCaseMainColl->topLevelSummaryCases();
|
||||
auto ensembles = sumCaseMainColl->summaryCaseCollections();
|
||||
|
||||
return { summaryCases, ensembles };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::updateUiFromSelection()
|
||||
{
|
||||
auto destinationObject = dynamic_cast<caf::PdmObjectHandle*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
if ( destinationObject ) destinationObject->firstAncestorOrThisOfType( summaryPlot );
|
||||
|
||||
if ( m_summaryPlot != summaryPlot )
|
||||
{
|
||||
m_summaryPlot = summaryPlot;
|
||||
updateConnectedEditors();
|
||||
updateCurveCandidates();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress> RimSummaryPlotManager::filteredAddresses()
|
||||
{
|
||||
auto [summaryCases, ensembles] = dataSources();
|
||||
|
||||
std::set<RifEclipseSummaryAddress> allAddressesFromSource;
|
||||
|
||||
if ( !summaryCases.empty() )
|
||||
{
|
||||
allAddressesFromSource = addressesForSource( summaryCases.front() );
|
||||
}
|
||||
else if ( !ensembles.empty() )
|
||||
{
|
||||
allAddressesFromSource = addressesForSource( ensembles.front() );
|
||||
}
|
||||
|
||||
if ( allAddressesFromSource.empty() ) return {};
|
||||
|
||||
QStringList allCurveAddressFilters = m_curveFilterText().split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
|
||||
|
||||
return computeFilteredAddresses( allCurveAddressFilters, allAddressesFromSource );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress> RimSummaryPlotManager::addressesForSource( caf::PdmObject* summarySource )
|
||||
{
|
||||
auto ensemble = dynamic_cast<RimSummaryCaseCollection*>( summarySource );
|
||||
if ( ensemble )
|
||||
{
|
||||
return ensemble->ensembleSummaryAddresses();
|
||||
}
|
||||
|
||||
auto sumCase = dynamic_cast<RimSummaryCase*>( summarySource );
|
||||
if ( sumCase )
|
||||
{
|
||||
auto reader = sumCase ? sumCase->summaryReader() : nullptr;
|
||||
if ( reader )
|
||||
{
|
||||
return reader->allResultAddresses();
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleCurveSet* RimSummaryPlotManager::createCurveSet( RimSummaryCaseCollection* ensemble,
|
||||
const RifEclipseSummaryAddress& addr )
|
||||
{
|
||||
auto curveSet = new RimEnsembleCurveSet();
|
||||
|
||||
curveSet->setSummaryCaseCollection( ensemble );
|
||||
curveSet->setSummaryAddress( addr );
|
||||
|
||||
return curveSet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurve* RimSummaryPlotManager::createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr )
|
||||
{
|
||||
auto curve = new RimSummaryCurve();
|
||||
|
||||
curve->setSummaryCaseY( summaryCase );
|
||||
curve->setSummaryAddressY( addr );
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::appendCurvesToPlot( RimSummaryPlot* summaryPlot,
|
||||
const std::set<RifEclipseSummaryAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles )
|
||||
{
|
||||
for ( const auto& addr : addresses )
|
||||
{
|
||||
for ( const auto ensemble : ensembles )
|
||||
{
|
||||
auto curveSet = createCurveSet( ensemble, addr );
|
||||
summaryPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
|
||||
}
|
||||
|
||||
for ( const auto summaryCase : summaryCases )
|
||||
{
|
||||
auto curve = createCurve( summaryCase, addr );
|
||||
|
||||
summaryPlot->addCurveNoUpdate( curve );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::appendCurvesToPlot( RimSummaryPlot* destinationPlot )
|
||||
{
|
||||
CAF_ASSERT( destinationPlot );
|
||||
|
||||
auto [summaryCases, ensembles] = dataSources();
|
||||
|
||||
std::set<RifEclipseSummaryAddress> filteredAddressesFromSource = filteredAddresses();
|
||||
appendCurvesToPlot( destinationPlot, filteredAddressesFromSource, summaryCases, ensembles );
|
||||
|
||||
destinationPlot->applyDefaultCurveAppearances();
|
||||
destinationPlot->loadDataAndUpdate();
|
||||
|
||||
RiaSummaryTools::summaryPlotCollection()->updateConnectedEditors();
|
||||
|
||||
setFocusToEditorWidget( m_curveFilterText.uiCapability() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotManager::setFocusToEditorWidget( caf::PdmUiFieldHandle* uiFieldHandle )
|
||||
{
|
||||
CAF_ASSERT( uiFieldHandle );
|
||||
|
||||
auto editors = uiFieldHandle->connectedEditors();
|
||||
if ( !editors.empty() )
|
||||
{
|
||||
auto fieldEditorHandle = dynamic_cast<caf::PdmUiFieldEditorHandle*>( editors.front() );
|
||||
if ( fieldEditorHandle && fieldEditorHandle->editorWidget() )
|
||||
{
|
||||
auto widget = fieldEditorHandle->editorWidget();
|
||||
|
||||
// If the dock widget is floating, activateWindow() must be called to make sure the top level widget has
|
||||
// focus before the editor widget is given focus
|
||||
widget->activateWindow();
|
||||
widget->setFocus();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafSelectionChangedReceiver.h"
|
||||
|
||||
class RifEclipseSummaryAddress;
|
||||
class RimSummaryPlot;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
class RimEnsembleCurveSet;
|
||||
class RimSummaryCurve;
|
||||
|
||||
class RimSummaryPlotManager : public QObject, public caf::PdmObject, public caf::SelectionChangedReceiver
|
||||
|
||||
{
|
||||
Q_OBJECT;
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimSummaryPlotManager();
|
||||
|
||||
private:
|
||||
void appendCurves();
|
||||
void replaceCurves();
|
||||
void createNewPlot();
|
||||
|
||||
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 defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
|
||||
|
||||
// Override eventFilter to be able to track key events from QDockWidget
|
||||
bool eventFilter( QObject* obj, QEvent* event ) override;
|
||||
|
||||
void updateCurveCandidates();
|
||||
|
||||
std::set<RifEclipseSummaryAddress> computeFilteredAddresses( const QStringList& textFilters,
|
||||
const std::set<RifEclipseSummaryAddress>& sourceAddresses );
|
||||
|
||||
std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryCaseCollection*>> dataSources() const;
|
||||
|
||||
void updateUiFromSelection();
|
||||
std::set<RifEclipseSummaryAddress> filteredAddresses();
|
||||
void appendCurvesToPlot( RimSummaryPlot* destinationPlot );
|
||||
|
||||
// Static helper functions
|
||||
static std::set<RifEclipseSummaryAddress> addressesForSource( caf::PdmObject* summarySource );
|
||||
|
||||
static RimEnsembleCurveSet* createCurveSet( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& addr );
|
||||
static RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr );
|
||||
|
||||
static void appendCurvesToPlot( RimSummaryPlot* summaryPlot,
|
||||
const std::set<RifEclipseSummaryAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles );
|
||||
|
||||
static void setFocusToEditorWidget( caf::PdmUiFieldHandle* uiFieldHandle );
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimSummaryPlot*> m_summaryPlot;
|
||||
|
||||
caf::PdmField<QString> m_curveFilterText;
|
||||
caf::PdmField<std::vector<QString>> m_curveCandidates;
|
||||
|
||||
caf::PdmField<bool> m_includeDiffCurves;
|
||||
|
||||
caf::PdmField<bool> m_pushButtonReplace;
|
||||
caf::PdmField<bool> m_pushButtonNewPlot;
|
||||
caf::PdmField<bool> m_pushButtonAppend;
|
||||
|
||||
caf::PdmField<QString> m_labelA;
|
||||
caf::PdmField<QString> m_labelB;
|
||||
};
|
@ -100,6 +100,14 @@ QString RiuDockWidgetTools::undoStackName()
|
||||
return "dockUndoStack";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuDockWidgetTools::summaryCurveManagerName()
|
||||
{
|
||||
return "dockSummaryCurveManager";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
static QString messagesName();
|
||||
static QString mohrsCirclePlotName();
|
||||
static QString undoStackName();
|
||||
static QString summaryCurveManagerName();
|
||||
|
||||
static QString plotMainWindowProjectTreeName();
|
||||
static QString plotMainWindowPropertyEditorName();
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimSummaryPlotFilterTextCurveSetEditor.h"
|
||||
#include "RimSummaryPlotManager.h"
|
||||
#include "RimViewWindow.h"
|
||||
#include "RimWellAllocationPlot.h"
|
||||
#include "RimWellLogCurveCommonDataSource.h"
|
||||
@ -105,6 +106,7 @@ RiuPlotMainWindow::RiuPlotMainWindow()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuPlotMainWindow::~RiuPlotMainWindow()
|
||||
{
|
||||
m_summaryCurveManagerView->showProperties( nullptr );
|
||||
setPdmRoot( nullptr );
|
||||
}
|
||||
|
||||
@ -499,6 +501,22 @@ void RiuPlotMainWindow::createDockPanels()
|
||||
dockWidget->hide();
|
||||
}
|
||||
|
||||
{
|
||||
QDockWidget* dockWidget = new QDockWidget( "Curve Manager", this );
|
||||
dockWidget->setObjectName( RiuDockWidgetTools::summaryCurveManagerName() );
|
||||
|
||||
m_summaryCurveManagerView = new caf::PdmUiPropertyView( dockWidget );
|
||||
|
||||
auto curveManager = std::make_unique<RimSummaryPlotManager>();
|
||||
m_summaryCurveManagerView->showProperties( curveManager.get() );
|
||||
m_summaryCurveManagerView->installEventFilter( curveManager.get() );
|
||||
m_summaryCurveManager = std::move( curveManager );
|
||||
|
||||
dockWidget->setWidget( m_summaryCurveManagerView );
|
||||
addDockWidget( Qt::BottomDockWidgetArea, dockWidget );
|
||||
dockWidget->hide();
|
||||
}
|
||||
|
||||
if ( m_undoView && RiaPreferences::current()->useUndoRedo() )
|
||||
{
|
||||
QDockWidget* dockWidget = new QDockWidget( "Undo Stack", this );
|
||||
|
@ -137,9 +137,11 @@ private:
|
||||
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;
|
||||
|
||||
caf::PdmUiPropertyView* m_pdmUiPropertyView;
|
||||
caf::PdmUiPropertyView* m_summaryCurveManagerView;
|
||||
|
||||
QPointer<RicSummaryPlotEditorDialog> m_summaryCurveCreatorDialog;
|
||||
QPointer<RicSummaryCurveCalculatorDialog> m_summaryCurveCalculatorDialog;
|
||||
std::unique_ptr<caf::PdmObject> m_summaryCurveManager;
|
||||
|
||||
std::vector<QWidget*> m_temporaryWidgets;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user