mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2170 Summary Cross Plot : Add keyboard modifiers to source stepping
This commit is contained in:
parent
04a80864b1
commit
c0109361ef
@ -35,6 +35,8 @@
|
||||
|
||||
#include "cafPdmUiTreeViewEditor.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryCurveCollection, "RimSummaryCurveCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -319,6 +321,72 @@ QString RimSummaryCurveCollection::compileAutoPlotTitle() const
|
||||
return title;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveCollection::handleKeyPressEvent(QKeyEvent* keyEvent)
|
||||
{
|
||||
if (!keyEvent) return;
|
||||
|
||||
RimSummaryPlotSourceStepping* sourceStepping = nullptr;
|
||||
{
|
||||
RimSummaryCrossPlot* summaryCrossPlot = nullptr;
|
||||
this->firstAncestorOrThisOfType(summaryCrossPlot);
|
||||
|
||||
if (summaryCrossPlot)
|
||||
{
|
||||
sourceStepping = m_unionSourceStepping();
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceStepping = m_ySourceStepping();
|
||||
}
|
||||
}
|
||||
|
||||
if (keyEvent->key() == Qt::Key_PageUp)
|
||||
{
|
||||
if (keyEvent->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
sourceStepping->applyPrevCase();
|
||||
|
||||
keyEvent->accept();
|
||||
}
|
||||
else if (keyEvent->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
sourceStepping->applyPrevOtherIdentifier();
|
||||
|
||||
keyEvent->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceStepping->applyPrevQuantity();
|
||||
|
||||
keyEvent->accept();
|
||||
}
|
||||
}
|
||||
else if (keyEvent->key() == Qt::Key_PageDown)
|
||||
{
|
||||
if (keyEvent->modifiers() & Qt::ShiftModifier)
|
||||
{
|
||||
sourceStepping->applyNextCase();
|
||||
|
||||
keyEvent->accept();
|
||||
}
|
||||
else if (keyEvent->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
sourceStepping->applyNextOtherIdentifier();
|
||||
|
||||
keyEvent->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceStepping->applyNextQuantity();
|
||||
|
||||
keyEvent->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -30,6 +30,7 @@ class QwtPlotCurve;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryPlotSourceStepping;
|
||||
class QKeyEvent;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -66,6 +67,8 @@ public:
|
||||
|
||||
QString compileAutoPlotTitle() const;
|
||||
|
||||
void handleKeyPressEvent(QKeyEvent* keyEvent);
|
||||
|
||||
private:
|
||||
caf::PdmFieldHandle* objectToggleField();
|
||||
virtual void defineObjectEditorAttribute(QString uiConfigName,
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiItem.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
@ -69,6 +70,107 @@ void RimSummaryPlotSourceStepping::setSourceSteppingType(SourceSteppingType sour
|
||||
m_sourceSteppingType = sourceSteppingType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyNextCase()
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
|
||||
auto summaryCases = proj->allSummaryCases();
|
||||
if (summaryCases.size() < 1)
|
||||
return;
|
||||
|
||||
auto currentCase = std::find(summaryCases.begin(), summaryCases.end(), m_summaryCase());
|
||||
|
||||
if (currentCase != summaryCases.end())
|
||||
{
|
||||
currentCase++;
|
||||
if (currentCase != summaryCases.end())
|
||||
{
|
||||
m_summaryCase = *currentCase;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_summaryCase = summaryCases[0];
|
||||
}
|
||||
|
||||
fieldChangedByUi(&m_summaryCase, QVariant(), QVariant());
|
||||
m_summaryCase.uiCapability()->updateConnectedEditors();
|
||||
|
||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(curveCollection);
|
||||
|
||||
curveCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyPrevCase()
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
|
||||
auto summaryCases = proj->allSummaryCases();
|
||||
if (summaryCases.size() < 1)
|
||||
return;
|
||||
|
||||
auto currentCase = std::find(summaryCases.begin(), summaryCases.end(), m_summaryCase());
|
||||
|
||||
if (currentCase != summaryCases.end() && currentCase != summaryCases.begin())
|
||||
{
|
||||
currentCase--;
|
||||
m_summaryCase = *currentCase;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_summaryCase = summaryCases[0];
|
||||
}
|
||||
|
||||
fieldChangedByUi(&m_summaryCase, QVariant(), QVariant());
|
||||
m_summaryCase.uiCapability()->updateConnectedEditors();
|
||||
|
||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(curveCollection);
|
||||
|
||||
curveCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyNextQuantity()
|
||||
{
|
||||
modifyCurrentIndex(&m_quantity, 1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyPrevQuantity()
|
||||
{
|
||||
modifyCurrentIndex(&m_quantity, -1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyNextOtherIdentifier()
|
||||
{
|
||||
caf::PdmValueField* valueField = valueFieldToModify();
|
||||
modifyCurrentIndex(valueField, 1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyPrevOtherIdentifier()
|
||||
{
|
||||
caf::PdmValueField* valueField = valueFieldToModify();
|
||||
modifyCurrentIndex(valueField, -1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -611,7 +713,7 @@ caf::PdmFieldHandle* RimSummaryPlotSourceStepping::fieldToModify()
|
||||
|
||||
if (analyzer.wellGroupNames().size() == 1)
|
||||
{
|
||||
return &m_wellName;
|
||||
return &m_wellGroupName;
|
||||
}
|
||||
|
||||
if (analyzer.regionNumbers().size() == 1)
|
||||
@ -750,6 +852,51 @@ RiaSummaryCurveAnalyzer* RimSummaryPlotSourceStepping::analyzerForReader(RifSumm
|
||||
return &m_curveAnalyzerForReader.second;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::modifyCurrentIndex(caf::PdmValueField* valueField, int indexOffset)
|
||||
{
|
||||
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)
|
||||
{
|
||||
currentIndex = 0;
|
||||
}
|
||||
|
||||
int nextIndex = currentIndex + indexOffset;
|
||||
if (nextIndex < options.size() && nextIndex > -1)
|
||||
{
|
||||
auto optionValue = options[nextIndex].value();
|
||||
|
||||
QVariant currentValue = valueField->toQVariant();
|
||||
|
||||
valueField->setFromQVariant(optionValue);
|
||||
|
||||
valueField->uiCapability()->notifyFieldChanged(currentValue, optionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -760,5 +907,26 @@ void RimSummaryPlotSourceStepping::defineEditorAttribute(const caf::PdmFieldHand
|
||||
if (myAttr)
|
||||
{
|
||||
myAttr->showPreviousAndNextButtons = true;
|
||||
|
||||
QString modifierText;
|
||||
|
||||
if (field == &m_summaryCase)
|
||||
{
|
||||
modifierText = ("(Shift+");
|
||||
}
|
||||
else if (field == &m_wellName || field == &m_wellGroupName || field == &m_region)
|
||||
{
|
||||
modifierText = ("(Ctrl+");
|
||||
}
|
||||
else if (field == &m_quantity)
|
||||
{
|
||||
modifierText = ("(");
|
||||
}
|
||||
|
||||
if (!modifierText.isEmpty())
|
||||
{
|
||||
myAttr->nextButtonText = "Next " + modifierText + "PgDown)";
|
||||
myAttr->prevButtonText = "Previous " + modifierText + "PgUp)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,15 @@ public:
|
||||
|
||||
void setSourceSteppingType(SourceSteppingType sourceSteppingType);
|
||||
|
||||
void applyNextCase();
|
||||
void applyPrevCase();
|
||||
|
||||
void applyNextQuantity();
|
||||
void applyPrevQuantity();
|
||||
|
||||
void applyNextOtherIdentifier();
|
||||
void applyPrevOtherIdentifier();
|
||||
|
||||
void applyNextIdentifier();
|
||||
void applyPreviousIdentifier();
|
||||
|
||||
@ -85,6 +94,8 @@ private:
|
||||
|
||||
RiaSummaryCurveAnalyzer* analyzerForReader(RifSummaryReaderInterface* reader);
|
||||
|
||||
void modifyCurrentIndex(caf::PdmValueField* valueField, int indexOffset);
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
|
||||
caf::PdmField<QString> m_wellName;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "RimContextCommandBuilder.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
@ -186,24 +187,10 @@ void RiuSummaryQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::keyPressEvent(QKeyEvent* keyEvent)
|
||||
{
|
||||
if (keyEvent->key() == Qt::Key_PageUp)
|
||||
if (m_plotDefinition && m_plotDefinition->summaryCurveCollection())
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->applyPreviousIdentifier();
|
||||
}
|
||||
|
||||
keyEvent->accept();
|
||||
}
|
||||
|
||||
if (keyEvent->key() == Qt::Key_PageDown)
|
||||
{
|
||||
if (m_plotDefinition)
|
||||
{
|
||||
m_plotDefinition->applyNextIdentifier();
|
||||
}
|
||||
|
||||
keyEvent->accept();
|
||||
RimSummaryCurveCollection* curveColl = m_plotDefinition->summaryCurveCollection();
|
||||
curveColl->handleKeyPressEvent(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,17 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
{
|
||||
m_nextItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown));
|
||||
}
|
||||
|
||||
// Update button texts
|
||||
if (!attributes.nextButtonText.isEmpty())
|
||||
{
|
||||
m_nextItemButton->setToolTip(attributes.nextButtonText);
|
||||
}
|
||||
|
||||
if (!attributes.prevButtonText.isEmpty())
|
||||
{
|
||||
m_previousItemButton->setToolTip(attributes.prevButtonText);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -65,6 +65,9 @@ public:
|
||||
public:
|
||||
bool adjustWidthToContents;
|
||||
bool showPreviousAndNextButtons;
|
||||
|
||||
QString nextButtonText;
|
||||
QString prevButtonText;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user