mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1948 PLT plot. Save editor selections to project file
This commit is contained in:
parent
f229ce5c23
commit
3ef2ec3f33
@ -68,8 +68,6 @@ private:
|
||||
caf::PdmPointer<RimWellLogFile> m_wellLogFile;
|
||||
};
|
||||
|
||||
//Q_DECLARE_METATYPE(RifWellRftAddress);
|
||||
|
||||
bool operator==(const RifWellRftAddress& addr1, const RifWellRftAddress& addr2);
|
||||
QTextStream& operator <<(QTextStream& str, const RifWellRftAddress& addr);
|
||||
QTextStream& operator >> (QTextStream& str, RifWellRftAddress& addr);
|
||||
|
@ -48,9 +48,16 @@ CAF_PDM_SOURCE_INIT(RimRftAddress, "RftAddress");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRftAddress::RimRftAddress()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault(&m_sourceType, "SourceType", "SourceType", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_eclCase, "EclipseCase", "EclipseCase", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_wellLogFile, "WellLogFile", "WellLogFile", "", "", "");
|
||||
InitPdmObject();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRftAddress::RimRftAddress(const RifWellRftAddress& addr)
|
||||
{
|
||||
InitPdmObject();
|
||||
setAddress(addr);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -72,3 +79,24 @@ RifWellRftAddress RimRftAddress::address() const
|
||||
RifWellRftAddress(m_sourceType(), m_eclCase()) :
|
||||
RifWellRftAddress(m_sourceType(), m_wellLogFile());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRftAddress::InitPdmObject()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault(&m_sourceType, "SourceType", "SourceType", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_eclCase, "EclipseCase", "EclipseCase", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_wellLogFile, "WellLogFile", "WellLogFile", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRftAddress& RimRftAddress::operator=(const RimRftAddress& other)
|
||||
{
|
||||
m_sourceType = other.m_sourceType();
|
||||
m_eclCase = other.m_eclCase();
|
||||
m_wellLogFile = other.m_wellLogFile();
|
||||
return *this;
|
||||
}
|
||||
|
@ -47,13 +47,17 @@ class RimRftAddress : public caf::PdmObject
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
|
||||
RimRftAddress();
|
||||
RimRftAddress(const RifWellRftAddress& addr);
|
||||
|
||||
void setAddress(const RifWellRftAddress& address);
|
||||
RifWellRftAddress address() const;
|
||||
|
||||
RimRftAddress& operator=(const RimRftAddress& other);
|
||||
|
||||
private:
|
||||
void InitPdmObject();
|
||||
|
||||
caf::PdmField<caf::AppEnum<RifWellRftAddress::SourceType> > m_sourceType;
|
||||
caf::PdmPtrField<RimEclipseCase*> m_eclCase;
|
||||
caf::PdmPtrField<RimWellLogFile*> m_wellLogFile;
|
||||
|
@ -104,10 +104,14 @@ RimWellPltPlot::RimWellPltPlot()
|
||||
CAF_PDM_InitFieldNoDefault(&m_wellName, "WellName", "WellName", "", "", "");
|
||||
CAF_PDM_InitField(&m_branchIndex, "BranchIndex", 0, "BranchIndex", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectedSources, "Sources", "Sources", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectedSources, "SourcesInternal", "SourcesInternal", "", "", "");
|
||||
m_selectedSources.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
||||
m_selectedSources.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
m_selectedSources.uiCapability()->setAutoAddingOptionFromValue(false);
|
||||
m_selectedSources.xmlCapability()->disableIO();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectedSourcesForIo, "Sources", "Sources", "", "", "");
|
||||
m_selectedSourcesForIo.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_selectedTimeSteps, "TimeSteps", "TimeSteps", "", "", "");
|
||||
m_selectedTimeSteps.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
||||
@ -118,8 +122,10 @@ RimWellPltPlot::RimWellPltPlot()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_phases, "Phases", "Phases", "", "", "");
|
||||
m_phases.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
||||
m_phases = std::vector<caf::AppEnum<FlowPhase>>({ FlowPhase::PHASE_OIL, FlowPhase::PHASE_GAS, FlowPhase::PHASE_WATER });
|
||||
|
||||
this->setAsPlotMdiWindow();
|
||||
m_doInitAfterLoad = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -253,7 +259,7 @@ void RimWellPltPlot::deleteViewWidget()
|
||||
void RimWellPltPlot::updateSelectedTimeStepsFromSelectedSources()
|
||||
{
|
||||
std::vector<QDateTime> newTimeStepsSelections;
|
||||
std::vector<RifWellRftAddress> selectedSourcesVector = selectedSources();
|
||||
std::vector<RifWellRftAddress> selectedSourcesVector = m_selectedSources();
|
||||
auto selectedSources = std::set<RifWellRftAddress>(selectedSourcesVector.begin(), selectedSourcesVector.end());
|
||||
|
||||
for (const QDateTime& timeStep : m_selectedTimeSteps())
|
||||
@ -386,35 +392,6 @@ std::vector<RimEclipseCase*> RimWellPltPlot::eclipseCases() const
|
||||
// syncCurvesFromUiSelection();
|
||||
//}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPltPlot::updateEditorsFromCurves()
|
||||
{
|
||||
// std::set<RifWellRftAddress> selectedSources;
|
||||
// std::set<QDateTime> selectedTimeSteps;
|
||||
// std::map<QDateTime, std::set<RifWellRftAddress>> selectedTimeStepsMap;
|
||||
//
|
||||
// for (const std::pair<RifWellRftAddress, QDateTime>& curveDef : curveDefsFromCurves())
|
||||
// {
|
||||
// if (curveDef.first.sourceType() == RftSourceType::OBSERVED)
|
||||
// selectedSources.insert(RifWellRftAddress(RftSourceType::OBSERVED));
|
||||
// else
|
||||
// selectedSources.insert(curveDef.first);
|
||||
//
|
||||
// auto newTimeStepMap = std::map<QDateTime, std::set<RifWellRftAddress>>
|
||||
// {
|
||||
// { curveDef.second, std::set<RifWellRftAddress> { curveDef.first} }
|
||||
// };
|
||||
// addTimeStepsToMap(selectedTimeStepsMap, newTimeStepMap);
|
||||
// selectedTimeSteps.insert(curveDef.second);
|
||||
// }
|
||||
//
|
||||
// m_selectedSources = std::vector<RifWellRftAddress>(selectedSources.begin(), selectedSources.end());
|
||||
// m_selectedTimeSteps = std::vector<QDateTime>(selectedTimeSteps.begin(), selectedTimeSteps.end());
|
||||
// addTimeStepsToMap(m_timeStepsToAddresses, selectedTimeStepsMap);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -989,6 +966,30 @@ std::vector<RifWellRftAddress> RimWellPltPlot::selectedSources() const
|
||||
return sources;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RifWellRftAddress> RimWellPltPlot::selectedSourcesAndTimeSteps() const
|
||||
{
|
||||
std::vector<RifWellRftAddress> sources;
|
||||
for (const RifWellRftAddress& addr : m_selectedSources())
|
||||
{
|
||||
if (addr.sourceType() == RifWellRftAddress::OBSERVED)
|
||||
{
|
||||
for (const QDateTime& timeStep : m_selectedTimeSteps())
|
||||
{
|
||||
for (const RifWellRftAddress& address : m_timeStepsToAddresses.at(timeStep))
|
||||
{
|
||||
sources.push_back(address);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
sources.push_back(addr);
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1194,7 +1195,6 @@ void RimWellPltPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
|
||||
plotTrack->removeCurve(curve);
|
||||
}
|
||||
m_timeStepsToAddresses.clear();
|
||||
updateEditorsFromCurves();
|
||||
}
|
||||
else if (changedField == &m_selectedSources)
|
||||
{
|
||||
@ -1240,12 +1240,6 @@ QImage RimWellPltPlot::snapshotWindowContent()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPltPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
//if (!m_selectedSourcesOrTimeStepsFieldsChanged)
|
||||
//{
|
||||
// updateEditorsFromCurves();
|
||||
//}
|
||||
//m_selectedSourcesOrTimeStepsFieldsChanged = false;
|
||||
|
||||
uiOrdering.add(&m_userName);
|
||||
uiOrdering.add(&m_wellName);
|
||||
|
||||
@ -1287,6 +1281,49 @@ void RimWellPltPlot::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPltPlot::initAfterRead()
|
||||
{
|
||||
RimViewWindow::initAfterRead();
|
||||
|
||||
// Postpone init until data has been loaded
|
||||
m_doInitAfterLoad = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPltPlot::setupBeforeSave()
|
||||
{
|
||||
m_selectedSourcesForIo.clear();
|
||||
for (const RifWellRftAddress& addr : selectedSourcesAndTimeSteps())
|
||||
{
|
||||
m_selectedSourcesForIo.push_back(new RimRftAddress(addr));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPltPlot::initAfterLoad()
|
||||
{
|
||||
std::set<RifWellRftAddress> selectedSources;
|
||||
for (RimRftAddress* addr : m_selectedSourcesForIo)
|
||||
{
|
||||
if (addr->address().sourceType() == RifWellRftAddress::OBSERVED)
|
||||
{
|
||||
selectedSources.insert(RifWellRftAddress(RifWellRftAddress::OBSERVED));
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedSources.insert(addr->address());
|
||||
}
|
||||
}
|
||||
m_selectedSources = std::vector<RifWellRftAddress>(selectedSources.begin(), selectedSources.end());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1456,9 +1493,15 @@ QString RimWellPltPlot::description() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPltPlot::loadDataAndUpdate()
|
||||
{
|
||||
if (m_doInitAfterLoad)
|
||||
{
|
||||
initAfterLoad();
|
||||
m_doInitAfterLoad = false;
|
||||
}
|
||||
|
||||
updateMdiWindowVisibility();
|
||||
syncCurvesFromUiSelection();
|
||||
m_wellLogPlot->loadDataAndUpdate();
|
||||
updateEditorsFromCurves();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -22,14 +22,15 @@
|
||||
#include "RimViewWindow.h"
|
||||
#include "RigFlowDiagResultAddress.h"
|
||||
|
||||
#include "RimRftAddress.h"
|
||||
#include "RifWellRftAddressQMetaType.h"
|
||||
#include "RimPlotCurve.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cvfCollection.h"
|
||||
#include "RimPlotCurve.h"
|
||||
|
||||
#include "RifWellRftAddress.h"
|
||||
#include "RifWellRftAddressQMetaType.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QDate>
|
||||
@ -114,15 +115,18 @@ protected:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
||||
|
||||
virtual void initAfterRead() override;
|
||||
virtual void setupBeforeSave() override;
|
||||
void initAfterLoad();
|
||||
|
||||
private:
|
||||
void addTimeStepToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
||||
static void addTimeStepToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
||||
const std::pair<QDateTime, std::set<RifWellRftAddress>>& timeStepToAdd);
|
||||
void addTimeStepsToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
||||
static void addTimeStepsToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
||||
const std::map<QDateTime, std::set<RifWellRftAddress>>& timeStepsToAdd);
|
||||
void calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>& options);
|
||||
void calculateValueOptionsForTimeSteps(const QString& wellName, QList<caf::PdmOptionItemInfo>& options);
|
||||
|
||||
void updateEditorsFromCurves();
|
||||
void updateWidgetTitleWindowTitle();
|
||||
|
||||
void syncCurvesFromUiSelection();
|
||||
@ -154,6 +158,7 @@ private:
|
||||
bool isOnlyGridSourcesSelected() const;
|
||||
bool isAnySourceAddressSelected(const std::set<RifWellRftAddress>& addresses) const;
|
||||
std::vector<RifWellRftAddress> selectedSources() const;
|
||||
std::vector<RifWellRftAddress> selectedSourcesAndTimeSteps() const;
|
||||
|
||||
// RimViewWindow overrides
|
||||
|
||||
@ -172,8 +177,10 @@ private:
|
||||
|
||||
caf::PdmField<QString> m_wellName;
|
||||
caf::PdmField<int> m_branchIndex;
|
||||
|
||||
caf::PdmField<std::vector<RifWellRftAddress>> m_selectedSources;
|
||||
|
||||
caf::PdmChildArrayField<RimRftAddress*> m_selectedSourcesForIo;
|
||||
|
||||
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;
|
||||
|
||||
QPointer<RiuWellPltPlot> m_wellLogPlotWidget;
|
||||
@ -184,4 +191,6 @@ private:
|
||||
|
||||
caf::PdmField<caf::AppEnum<FlowType>> m_phaseSelectionMode;
|
||||
caf::PdmField<std::vector<caf::AppEnum<FlowPhase>>> m_phases;
|
||||
|
||||
bool m_doInitAfterLoad;
|
||||
};
|
||||
|
@ -102,9 +102,9 @@ protected:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
private:
|
||||
void addTimeStepToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
||||
static void addTimeStepToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
||||
const std::pair<QDateTime, std::set<RifWellRftAddress>>& timeStepToAdd);
|
||||
void addTimeStepsToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
||||
static void addTimeStepsToMap(std::map<QDateTime, std::set<RifWellRftAddress>>& destMap,
|
||||
const std::map<QDateTime, std::set<RifWellRftAddress>>& timeStepsToAdd);
|
||||
void calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>& options);
|
||||
void calculateValueOptionsForTimeSteps(const QString& wellName, QList<caf::PdmOptionItemInfo>& options);
|
||||
|
Loading…
Reference in New Issue
Block a user