#2179 Summary Plot : Change identifier using PgUp / PgDown

This commit is contained in:
Magne Sjaastad
2017-11-24 18:13:43 +01:00
parent e231685d4c
commit 0a8a67c2aa
8 changed files with 278 additions and 56 deletions

View File

@@ -231,6 +231,22 @@ void RimSummaryCurveCollection::setCurrentSummaryCurve(RimSummaryCurve* curve)
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::applyNextIdentifier()
{
m_curvesModifier->applyNextIdentifier();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryCurveCollection::applyPreviousIdentifier()
{
m_curvesModifier->applyPreviousIdentifier();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -60,6 +60,9 @@ public:
void setCurrentSummaryCurve(RimSummaryCurve* curve);
void applyNextIdentifier();
void applyPreviousIdentifier();
private:
caf::PdmFieldHandle* objectToggleField();
virtual void defineObjectEditorAttribute(QString uiConfigName,

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -514,6 +514,22 @@ void RimSummaryPlot::updatePlotTitle()
updateMdiWindowTitle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::applyNextIdentifier()
{
m_summaryCurveCollection->applyNextIdentifier();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::applyPreviousIdentifier()
{
m_summaryCurveCollection->applyPreviousIdentifier();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -104,6 +104,9 @@ public:
void updatePlotTitle();
void applyNextIdentifier();
void applyPreviousIdentifier();
// RimViewWindow overrides
public:
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;