mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2179 Summary Plot : Change identifier using PgUp / PgDown
This commit is contained in:
@@ -231,6 +231,22 @@ void RimSummaryCurveCollection::setCurrentSummaryCurve(RimSummaryCurve* curve)
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveCollection::applyNextIdentifier()
|
||||
{
|
||||
m_curvesModifier->applyNextIdentifier();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveCollection::applyPreviousIdentifier()
|
||||
{
|
||||
m_curvesModifier->applyPreviousIdentifier();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
|
||||
void setCurrentSummaryCurve(RimSummaryCurve* curve);
|
||||
|
||||
void applyNextIdentifier();
|
||||
void applyPreviousIdentifier();
|
||||
|
||||
private:
|
||||
caf::PdmFieldHandle* objectToggleField();
|
||||
virtual void defineObjectEditorAttribute(QString uiConfigName,
|
||||
|
||||
@@ -59,66 +59,118 @@ RimSummaryCurvesModifier::RimSummaryCurvesModifier()
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurvesModifier::applyNextIdentifier()
|
||||
{
|
||||
updateUiFromCurves();
|
||||
|
||||
caf::PdmValueField* valueField = nullptr;
|
||||
{
|
||||
auto identifierField = fieldToModify();
|
||||
|
||||
valueField = dynamic_cast<caf::PdmValueField*>(identifierField);
|
||||
}
|
||||
|
||||
if (valueField)
|
||||
{
|
||||
bool useOptionsOnly = true;
|
||||
QList<caf::PdmOptionItemInfo> options = calculateValueOptions(valueField, nullptr);
|
||||
if (options.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto uiVariant = valueField->uiCapability()->toUiBasedQVariant();
|
||||
|
||||
int currentIndex = -1;
|
||||
for (int i = 0; i < options.size(); i++)
|
||||
{
|
||||
if (uiVariant == options[i].optionUiText())
|
||||
{
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentIndex != -1)
|
||||
{
|
||||
int nextIndex = currentIndex + 1;
|
||||
if (nextIndex >= options.size() - 1)
|
||||
{
|
||||
nextIndex = 0;
|
||||
}
|
||||
|
||||
auto optionValue = options[nextIndex].value();
|
||||
|
||||
QVariant currentValue = valueField->toQVariant();
|
||||
|
||||
valueField->setFromQVariant(optionValue);
|
||||
|
||||
valueField->uiCapability()->notifyFieldChanged(currentValue, optionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurvesModifier::applyPreviousIdentifier()
|
||||
{
|
||||
updateUiFromCurves();
|
||||
|
||||
caf::PdmValueField* valueField = nullptr;
|
||||
{
|
||||
auto identifierField = fieldToModify();
|
||||
|
||||
valueField = dynamic_cast<caf::PdmValueField*>(identifierField);
|
||||
}
|
||||
|
||||
if (valueField)
|
||||
{
|
||||
bool useOptionsOnly = true;
|
||||
QList<caf::PdmOptionItemInfo> options = calculateValueOptions(valueField, nullptr);
|
||||
if (options.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto uiVariant = valueField->uiCapability()->toUiBasedQVariant();
|
||||
|
||||
int currentIndex = -1;
|
||||
for (int i = 0; i < options.size(); i++)
|
||||
{
|
||||
if (uiVariant == options[i].optionUiText())
|
||||
{
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentIndex != -1)
|
||||
{
|
||||
int nextIndex = currentIndex - 1;
|
||||
if (nextIndex < 0)
|
||||
{
|
||||
nextIndex = options.size() - 1;
|
||||
}
|
||||
|
||||
auto optionValue = options[nextIndex].value();
|
||||
|
||||
QVariant currentValue = valueField->toQVariant();
|
||||
|
||||
valueField->setFromQVariant(optionValue);
|
||||
|
||||
valueField->uiCapability()->notifyFieldChanged(currentValue, optionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurvesModifier::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(curveCollection);
|
||||
|
||||
RiaSummaryCurveAnalyzer analyzer;
|
||||
analyzer.analyzeCurves(curveCollection);
|
||||
|
||||
RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID;
|
||||
{
|
||||
if (analyzer.categories().size() == 1)
|
||||
{
|
||||
category = *(analyzer.categories().begin());
|
||||
}
|
||||
}
|
||||
|
||||
m_summaryCase.uiCapability()->setUiHidden(true);
|
||||
m_wellName.uiCapability()->setUiHidden(true);
|
||||
m_wellGroupName.uiCapability()->setUiHidden(true);
|
||||
m_region.uiCapability()->setUiHidden(true);
|
||||
m_quantity.uiCapability()->setUiHidden(true);
|
||||
|
||||
if (category != RifEclipseSummaryAddress::SUMMARY_INVALID)
|
||||
{
|
||||
if (analyzer.summaryCases().size() == 1)
|
||||
{
|
||||
m_summaryCase = *(analyzer.summaryCases().begin());
|
||||
m_summaryCase.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
|
||||
if (analyzer.wellNames().size() == 1)
|
||||
{
|
||||
QString txt = QString::fromStdString(*(analyzer.wellNames().begin()));
|
||||
m_wellName = txt;
|
||||
m_wellName.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
|
||||
if (analyzer.wellGroupNames().size() == 1)
|
||||
{
|
||||
QString txt = QString::fromStdString(*(analyzer.wellGroupNames().begin()));
|
||||
m_wellGroupName = txt;
|
||||
m_wellGroupName.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
|
||||
if (analyzer.regionNumbers().size() == 1)
|
||||
{
|
||||
m_region = *(analyzer.regionNumbers().begin());
|
||||
m_region.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
|
||||
if (analyzer.quantities().size() == 1)
|
||||
{
|
||||
QString txt = QString::fromStdString(*(analyzer.quantities().begin()));
|
||||
m_quantity = txt;
|
||||
m_quantity.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
}
|
||||
updateUiFromCurves();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -350,3 +402,104 @@ void RimSummaryCurvesModifier::setWellName(const QString& wellName)
|
||||
{
|
||||
m_wellName.setValueWithFieldChanged(wellName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurvesModifier::updateUiFromCurves()
|
||||
{
|
||||
m_summaryCase.uiCapability()->setUiHidden(true);
|
||||
m_wellName.uiCapability()->setUiHidden(true);
|
||||
m_wellGroupName.uiCapability()->setUiHidden(true);
|
||||
m_region.uiCapability()->setUiHidden(true);
|
||||
m_quantity.uiCapability()->setUiHidden(true);
|
||||
|
||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(curveCollection);
|
||||
|
||||
RiaSummaryCurveAnalyzer analyzer;
|
||||
analyzer.analyzeCurves(curveCollection);
|
||||
|
||||
if (analyzer.summaryCases().size() == 1)
|
||||
{
|
||||
m_summaryCase = *(analyzer.summaryCases().begin());
|
||||
m_summaryCase.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
|
||||
RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID;
|
||||
{
|
||||
if (analyzer.categories().size() == 1)
|
||||
{
|
||||
category = *(analyzer.categories().begin());
|
||||
}
|
||||
}
|
||||
|
||||
if (category != RifEclipseSummaryAddress::SUMMARY_INVALID)
|
||||
{
|
||||
if (analyzer.wellNames().size() == 1)
|
||||
{
|
||||
QString txt = QString::fromStdString(*(analyzer.wellNames().begin()));
|
||||
m_wellName = txt;
|
||||
m_wellName.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
|
||||
if (analyzer.wellGroupNames().size() == 1)
|
||||
{
|
||||
QString txt = QString::fromStdString(*(analyzer.wellGroupNames().begin()));
|
||||
m_wellGroupName = txt;
|
||||
m_wellGroupName.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
|
||||
if (analyzer.regionNumbers().size() == 1)
|
||||
{
|
||||
m_region = *(analyzer.regionNumbers().begin());
|
||||
m_region.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
|
||||
if (analyzer.quantities().size() == 1)
|
||||
{
|
||||
QString txt = QString::fromStdString(*(analyzer.quantities().begin()));
|
||||
m_quantity = txt;
|
||||
m_quantity.uiCapability()->setUiHidden(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimSummaryCurvesModifier::fieldToModify()
|
||||
{
|
||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(curveCollection);
|
||||
|
||||
RiaSummaryCurveAnalyzer analyzer;
|
||||
analyzer.analyzeCurves(curveCollection);
|
||||
|
||||
if (analyzer.wellNames().size() == 1)
|
||||
{
|
||||
return &m_wellName;
|
||||
}
|
||||
|
||||
if (analyzer.wellGroupNames().size() == 1)
|
||||
{
|
||||
return &m_wellName;
|
||||
}
|
||||
|
||||
if (analyzer.regionNumbers().size() == 1)
|
||||
{
|
||||
return &m_region;
|
||||
}
|
||||
|
||||
if (analyzer.quantities().size() == 1)
|
||||
{
|
||||
return &m_quantity;
|
||||
}
|
||||
|
||||
if (analyzer.summaryCases().size() == 1)
|
||||
{
|
||||
return &m_summaryCase;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@ class RimSummaryCurvesModifier : public caf::PdmObject
|
||||
public:
|
||||
RimSummaryCurvesModifier();
|
||||
|
||||
void applyNextIdentifier();
|
||||
void applyPreviousIdentifier();
|
||||
|
||||
private:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
@@ -52,6 +55,8 @@ private:
|
||||
RimSummaryCase* singleSummaryCase() const;
|
||||
QString wellName() const;
|
||||
void setWellName(const QString& wellName);
|
||||
void updateUiFromCurves();
|
||||
caf::PdmFieldHandle* fieldToModify();
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
|
||||
|
||||
@@ -514,6 +514,22 @@ void RimSummaryPlot::updatePlotTitle()
|
||||
updateMdiWindowTitle();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::applyNextIdentifier()
|
||||
{
|
||||
m_summaryCurveCollection->applyNextIdentifier();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::applyPreviousIdentifier()
|
||||
{
|
||||
m_summaryCurveCollection->applyPreviousIdentifier();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -104,6 +104,9 @@ public:
|
||||
|
||||
void updatePlotTitle();
|
||||
|
||||
void applyNextIdentifier();
|
||||
void applyPreviousIdentifier();
|
||||
|
||||
// RimViewWindow overrides
|
||||
public:
|
||||
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
|
||||
Reference in New Issue
Block a user