mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#861) Summary Plot : Add support for autogenerated plot name
This commit is contained in:
@@ -50,6 +50,7 @@ RimSummaryCurvesModifier::RimSummaryCurvesModifier()
|
||||
m_wellNameProxy.registerGetMethod(this, &RimSummaryCurvesModifier::wellName);
|
||||
m_wellNameProxy.registerSetMethod(this, &RimSummaryCurvesModifier::setWellName);
|
||||
m_wellNameProxy.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
|
||||
m_wellNameProxy.uiCapability()->setUiHidden(false);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
@@ -92,20 +93,20 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurvesModifier::calculateValueOptions(co
|
||||
std::set<QString> identifierTexts;
|
||||
|
||||
RifSummaryReaderInterface* reader = summaryReader();
|
||||
if (reader)
|
||||
{
|
||||
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
|
||||
|
||||
if (fieldNeedingOptions == &m_wellName || fieldNeedingOptions == &m_wellNameProxy)
|
||||
{
|
||||
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
|
||||
identifierTexts = findAvailableIdentifierTexts(allAddresses, RifEclipseSummaryAddress::SUMMARY_WELL);
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_region)
|
||||
{
|
||||
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
|
||||
identifierTexts = findAvailableIdentifierTexts(allAddresses, RifEclipseSummaryAddress::SUMMARY_REGION);
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_groupName)
|
||||
{
|
||||
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
|
||||
identifierTexts = findAvailableIdentifierTexts(allAddresses, RifEclipseSummaryAddress::SUMMARY_WELL_GROUP);
|
||||
}
|
||||
}
|
||||
@@ -193,9 +194,12 @@ void RimSummaryCurvesModifier::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
||||
for (auto curve : curveCollection->curves())
|
||||
{
|
||||
RifEclipseSummaryAddress adr = curve->summaryAddressY();
|
||||
adr.setWellName(m_wellName().toStdString());
|
||||
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_WELL)
|
||||
{
|
||||
adr.setWellName(m_wellName().toStdString());
|
||||
|
||||
curve->setSummaryAddressY(adr);
|
||||
curve->setSummaryAddressY(adr);
|
||||
}
|
||||
}
|
||||
|
||||
triggerLoadDataAndUpdate = true;
|
||||
@@ -205,9 +209,12 @@ void RimSummaryCurvesModifier::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
||||
for (auto curve : curveCollection->curves())
|
||||
{
|
||||
RifEclipseSummaryAddress adr = curve->summaryAddressY();
|
||||
adr.setRegion(m_region());
|
||||
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_REGION)
|
||||
{
|
||||
adr.setRegion(m_region());
|
||||
|
||||
curve->setSummaryAddressY(adr);
|
||||
curve->setSummaryAddressY(adr);
|
||||
}
|
||||
}
|
||||
|
||||
triggerLoadDataAndUpdate = true;
|
||||
@@ -217,9 +224,12 @@ void RimSummaryCurvesModifier::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
||||
for (auto curve : curveCollection->curves())
|
||||
{
|
||||
RifEclipseSummaryAddress adr = curve->summaryAddressY();
|
||||
adr.setWellGroupName(m_groupName().toStdString());
|
||||
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP)
|
||||
{
|
||||
adr.setWellGroupName(m_groupName().toStdString());
|
||||
|
||||
curve->setSummaryAddressY(adr);
|
||||
curve->setSummaryAddressY(adr);
|
||||
}
|
||||
}
|
||||
|
||||
triggerLoadDataAndUpdate = true;
|
||||
@@ -229,6 +239,9 @@ void RimSummaryCurvesModifier::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
||||
{
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(summaryPlot);
|
||||
|
||||
summaryPlot->updatePlotTitle();
|
||||
|
||||
summaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
@@ -247,8 +260,6 @@ void RimSummaryCurvesModifier::defineUiOrdering(QString uiConfigName, caf::PdmUi
|
||||
curveDefinitions.push_back(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY()));
|
||||
}
|
||||
|
||||
RiaSummaryCurveDefTools tools(curveDefinitions);
|
||||
|
||||
// m_summaryCase.uiCapability()->setUiReadOnly(true);
|
||||
// m_wellName.uiCapability()->setUiReadOnly(true);
|
||||
// m_groupName.uiCapability()->setUiReadOnly(true);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaSummaryCurveDefTools.h"
|
||||
|
||||
#include "RimAsciiDataCurve.h"
|
||||
#include "RimGridTimeHistoryCurve.h"
|
||||
@@ -40,16 +41,16 @@
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QRectF>
|
||||
|
||||
#include "qwt_abstract_legend.h"
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_plot_renderer.h"
|
||||
|
||||
#include "vector"
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <QRectF>
|
||||
|
||||
#include <set>
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryPlot, "SummaryPlot");
|
||||
@@ -61,12 +62,15 @@ RimSummaryPlot::RimSummaryPlot()
|
||||
{
|
||||
CAF_PDM_InitObject("Summary Plot", ":/SummaryPlotLight16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Summary Plot"), "Name", "", "", "");
|
||||
CAF_PDM_InitField(&m_userDefinedPlotTitle, "PlotDescription", QString("Summary Plot"), "Name", "", "", "");
|
||||
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Plot Title", "", "", "");
|
||||
m_showPlotTitle.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Legend", "", "", "");
|
||||
m_showLegend.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
|
||||
CAF_PDM_InitField(&m_isUsingAutoName, "IsUsingAutoName", false, "Auto Name", "", "", "");
|
||||
m_isUsingAutoName.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_curveFilters_OBSOLETE, "SummaryCurveFilters", "", "", "", "");
|
||||
m_curveFilters_OBSOLETE.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
@@ -497,6 +501,19 @@ RiuSummaryQwtPlot* RimSummaryPlot::qwtPlot() const
|
||||
return m_qwtPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::updatePlotTitle()
|
||||
{
|
||||
if (m_isUsingAutoName)
|
||||
{
|
||||
m_userDefinedPlotTitle = extractPlotTitleFromCurves();
|
||||
}
|
||||
|
||||
updateMdiWindowTitle();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1045,6 +1062,14 @@ void RimSummaryPlot::addAsciiDataCruve(RimAsciiDataCurve* curve)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimSummaryPlot::userDescriptionField()
|
||||
{
|
||||
return &m_userDefinedPlotTitle;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1052,11 +1077,12 @@ void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
|
||||
{
|
||||
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
|
||||
if (changedField == &m_userName ||
|
||||
if (changedField == &m_userDefinedPlotTitle ||
|
||||
changedField == &m_showPlotTitle ||
|
||||
changedField == &m_showLegend)
|
||||
changedField == &m_showLegend ||
|
||||
changedField == &m_isUsingAutoName)
|
||||
{
|
||||
updateMdiWindowTitle();
|
||||
updatePlotTitle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1115,7 +1141,12 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
updateMdiWindowVisibility();
|
||||
if (m_isUsingAutoName)
|
||||
{
|
||||
m_userDefinedPlotTitle = extractPlotTitleFromCurves();
|
||||
}
|
||||
|
||||
updateMdiWindowVisibility();
|
||||
|
||||
for (RimSummaryCurveFilter* curveFilter: m_curveFilters_OBSOLETE)
|
||||
{
|
||||
@@ -1190,6 +1221,42 @@ void RimSummaryPlot::setZoomIntervalsInQwtPlot()
|
||||
m_qwtPlot->setZoomWindow(left, right, time);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlot::extractPlotTitleFromCurves() const
|
||||
{
|
||||
RiaSummaryCurveDefTools nameHelper;
|
||||
|
||||
nameHelper.findIdentifiers(m_summaryCurveCollection());
|
||||
|
||||
auto quantities = nameHelper.quantities();
|
||||
auto wellNames = nameHelper.wellNames();
|
||||
auto wellGroupNames = nameHelper.wellGroupNames();
|
||||
auto regions = nameHelper.regionNumbers();
|
||||
|
||||
QString title;
|
||||
|
||||
if (wellNames.size() == 1)
|
||||
{
|
||||
title = "Well : " + QString::fromStdString(*(wellNames.begin()));
|
||||
}
|
||||
else if (wellGroupNames.size() == 1)
|
||||
{
|
||||
title = "Well Group : " + QString::fromStdString(*(wellGroupNames.begin()));
|
||||
}
|
||||
else if (regions.size() == 1)
|
||||
{
|
||||
title = "Region : " + QString::number(*(regions.begin()));
|
||||
}
|
||||
else if (quantities.size() == 1)
|
||||
{
|
||||
title = "Quantity : " + QString::fromStdString(*(quantities.begin()));
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1216,7 +1283,7 @@ void RimSummaryPlot::disableAutoZoom()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::setDescription(const QString& description)
|
||||
{
|
||||
m_userName = description;
|
||||
m_userDefinedPlotTitle = description;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1224,7 +1291,7 @@ void RimSummaryPlot::setDescription(const QString& description)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlot::description() const
|
||||
{
|
||||
return m_userName();
|
||||
return m_userDefinedPlotTitle();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1235,6 +1302,14 @@ void RimSummaryPlot::setShowDescription(bool showDescription)
|
||||
m_showPlotTitle = showDescription;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::enableAutoName(bool enable)
|
||||
{
|
||||
m_isUsingAutoName = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1243,6 +1318,24 @@ void RimSummaryPlot::setAsCrossPlot()
|
||||
m_isCrossPlot = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
uiOrdering.add(&m_isUsingAutoName);
|
||||
uiOrdering.add(&m_userDefinedPlotTitle);
|
||||
uiOrdering.add(&m_showPlotTitle);
|
||||
uiOrdering.add(&m_showLegend);
|
||||
|
||||
m_userDefinedPlotTitle.uiCapability()->setUiReadOnly(m_isUsingAutoName);
|
||||
|
||||
if (m_isUsingAutoName)
|
||||
{
|
||||
m_userDefinedPlotTitle = extractPlotTitleFromCurves();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1327,18 +1420,19 @@ void RimSummaryPlot::updateMdiWindowTitle()
|
||||
{
|
||||
if (m_qwtPlot)
|
||||
{
|
||||
m_qwtPlot->setWindowTitle(m_userName);
|
||||
QString plotTitle = description();
|
||||
|
||||
m_qwtPlot->setWindowTitle(plotTitle);
|
||||
|
||||
if (m_showPlotTitle)
|
||||
{
|
||||
m_qwtPlot->setTitle(m_userName);
|
||||
m_qwtPlot->setTitle(plotTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_qwtPlot->setTitle("");
|
||||
}
|
||||
|
||||
|
||||
if (m_showLegend)
|
||||
{
|
||||
// Will be released in plot destructor or when a new legend is set
|
||||
@@ -1446,7 +1540,9 @@ size_t RimSummaryPlot::curveCount() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
|
||||
{
|
||||
if (field == &m_showLegend || field == &m_showPlotTitle)
|
||||
if (field == &m_showLegend ||
|
||||
field == &m_showPlotTitle ||
|
||||
field == &m_isUsingAutoName)
|
||||
{
|
||||
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
void setDescription(const QString& description);
|
||||
QString description() const;
|
||||
void setShowDescription(bool showDescription);
|
||||
void enableAutoName(bool enable);
|
||||
|
||||
void addCurveAndUpdate(RimSummaryCurve* curve);
|
||||
void addCurveNoUpdate(RimSummaryCurve* curve);
|
||||
@@ -101,6 +102,8 @@ public:
|
||||
RimSummaryCurveCollection* summaryCurveCollection() const;
|
||||
RiuSummaryQwtPlot* qwtPlot() const;
|
||||
|
||||
void updatePlotTitle();
|
||||
|
||||
// RimViewWindow overrides
|
||||
public:
|
||||
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
@@ -112,16 +115,19 @@ private:
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual void onLoadDataAndUpdate() override;
|
||||
|
||||
virtual QImage snapshotWindowContent() override;
|
||||
|
||||
void setAsCrossPlot();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
std::vector<RimSummaryCurve*> visibleSummaryCurvesForAxis(RiaDefines::PlotAxis plotAxis) const;
|
||||
std::vector<RimGridTimeHistoryCurve*> visibleTimeHistoryCurvesForAxis(RiaDefines::PlotAxis plotAxis) const;
|
||||
@@ -136,10 +142,14 @@ private:
|
||||
void updateBottomXAxis();
|
||||
void setZoomIntervalsInQwtPlot();
|
||||
|
||||
QString extractPlotTitleFromCurves() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
caf::PdmField<QString> m_userName;
|
||||
|
||||
caf::PdmField<bool> m_isUsingAutoName;
|
||||
caf::PdmField<QString> m_userDefinedPlotTitle;
|
||||
|
||||
caf::PdmChildArrayField<RimGridTimeHistoryCurve*> m_gridTimeHistoryCurves;
|
||||
caf::PdmChildField<RimSummaryCurveCollection*> m_summaryCurveCollection;
|
||||
|
||||
@@ -42,6 +42,30 @@ RimSummaryPlotCollection::~RimSummaryPlotCollection()
|
||||
summaryPlots.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RimSummaryPlotCollection::createSummaryPlotAutoName()
|
||||
{
|
||||
RimSummaryPlot* plot = new RimSummaryPlot();
|
||||
plot->enableAutoName(true);
|
||||
summaryPlots.push_back(plot);
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RimSummaryPlotCollection::createNamedSummaryPlot(const QString& name)
|
||||
{
|
||||
RimSummaryPlot* plot = new RimSummaryPlot();
|
||||
summaryPlots.push_back(plot);
|
||||
plot->setDescription(name);
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -36,6 +36,9 @@ public:
|
||||
|
||||
caf::PdmChildArrayField<RimSummaryPlot*> summaryPlots;
|
||||
|
||||
RimSummaryPlot* createSummaryPlotAutoName();
|
||||
RimSummaryPlot* createNamedSummaryPlot(const QString& name);
|
||||
|
||||
void updateSummaryNameHasChanged();
|
||||
void summaryPlotItemInfos(QList<caf::PdmOptionItemInfo>* optionInfos) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user