mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8838 from OPM/datasource_steppingtoolbar
Add simplified data source stepping control in toolbar
This commit is contained in:
parent
571011c2bd
commit
0f5d949af0
@ -34,39 +34,15 @@ bool RimSummaryPlotControls::handleKeyEvents( RimSummaryPlotSourceStepping* srcS
|
||||
|
||||
bool bHandled = false;
|
||||
|
||||
if ( keyEvent->key() == Qt::Key_Left )
|
||||
if ( keyEvent->key() == Qt::Key_Up )
|
||||
{
|
||||
srcStepping->applyPrevOtherIdentifier();
|
||||
keyEvent->accept();
|
||||
bHandled = true;
|
||||
}
|
||||
else if ( keyEvent->key() == Qt::Key_Right )
|
||||
{
|
||||
srcStepping->applyNextOtherIdentifier();
|
||||
keyEvent->accept();
|
||||
bHandled = true;
|
||||
}
|
||||
else if ( keyEvent->key() == Qt::Key_PageDown )
|
||||
{
|
||||
srcStepping->applyNextCase();
|
||||
keyEvent->accept();
|
||||
bHandled = true;
|
||||
}
|
||||
else if ( keyEvent->key() == Qt::Key_PageUp )
|
||||
{
|
||||
srcStepping->applyPrevCase();
|
||||
keyEvent->accept();
|
||||
bHandled = true;
|
||||
}
|
||||
else if ( keyEvent->key() == Qt::Key_Up )
|
||||
{
|
||||
srcStepping->applyPrevQuantity();
|
||||
srcStepping->applyPrevStep();
|
||||
keyEvent->accept();
|
||||
bHandled = true;
|
||||
}
|
||||
else if ( keyEvent->key() == Qt::Key_Down )
|
||||
{
|
||||
srcStepping->applyNextQuantity();
|
||||
srcStepping->applyNextStep();
|
||||
keyEvent->accept();
|
||||
bHandled = true;
|
||||
}
|
||||
@ -77,7 +53,7 @@ bool RimSummaryPlotControls::handleKeyEvents( RimSummaryPlotSourceStepping* srcS
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlotControls::quantityNextKeyText()
|
||||
QString RimSummaryPlotControls::nextStepKeyText()
|
||||
{
|
||||
return QString( "Ctrl-Down" );
|
||||
}
|
||||
@ -85,39 +61,7 @@ QString RimSummaryPlotControls::quantityNextKeyText()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlotControls::quantityPrevKeyText()
|
||||
QString RimSummaryPlotControls::prevStepKeyText()
|
||||
{
|
||||
return QString( "Ctrl-Up" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlotControls::caseNextKeyText()
|
||||
{
|
||||
return QString( "Ctrl-PgDown" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlotControls::casePrevKeyText()
|
||||
{
|
||||
return QString( "Ctrl-PgUp" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlotControls::otherNextKeyText()
|
||||
{
|
||||
return QString( "Ctrl-Right" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlotControls::otherPrevKeyText()
|
||||
{
|
||||
return QString( "Ctrl-Left" );
|
||||
}
|
||||
|
@ -28,12 +28,8 @@ class RimSummaryPlotControls
|
||||
public:
|
||||
static bool handleKeyEvents( RimSummaryPlotSourceStepping* srcStepping, QKeyEvent* keyEvent );
|
||||
|
||||
static QString quantityNextKeyText();
|
||||
static QString quantityPrevKeyText();
|
||||
static QString caseNextKeyText();
|
||||
static QString casePrevKeyText();
|
||||
static QString otherNextKeyText();
|
||||
static QString otherPrevKeyText();
|
||||
static QString nextStepKeyText();
|
||||
static QString prevStepKeyText();
|
||||
|
||||
private:
|
||||
RimSummaryPlotControls() = default;
|
||||
|
@ -42,9 +42,26 @@
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiItem.h"
|
||||
#include "cafPdmUiLabelEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiToolBarEditor.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template <>
|
||||
void AppEnum<RimSummaryPlotSourceStepping::SourceSteppingDimension>::setUp()
|
||||
{
|
||||
addItem( RimSummaryPlotSourceStepping::SourceSteppingDimension::QUANTITY, "QUANTITY", "Quantity" );
|
||||
addItem( RimSummaryPlotSourceStepping::SourceSteppingDimension::WELL, "WELL", "Well" );
|
||||
addItem( RimSummaryPlotSourceStepping::SourceSteppingDimension::SUMMARY_CASE, "SUMMARY_CASE", "Summary Case" );
|
||||
addItem( RimSummaryPlotSourceStepping::SourceSteppingDimension::ENSEMBLE, "ENSEMBLE", "Ensemble" );
|
||||
addItem( RimSummaryPlotSourceStepping::SourceSteppingDimension::GROUP, "GROUP", "Group" );
|
||||
addItem( RimSummaryPlotSourceStepping::SourceSteppingDimension::REGION, "REGION", "Region" );
|
||||
addItem( RimSummaryPlotSourceStepping::SourceSteppingDimension::BLOCK, "BLOCK", "Block" );
|
||||
setDefault( RimSummaryPlotSourceStepping::SourceSteppingDimension::QUANTITY );
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSummaryPlotSourceStepping, "RimSummaryCurveCollectionModifier" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -55,6 +72,8 @@ RimSummaryPlotSourceStepping::RimSummaryPlotSourceStepping()
|
||||
{
|
||||
CAF_PDM_InitObject( "Summary Curves Modifier" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_stepDimension, "StepDimension", "Step Dimension" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryCase, "CurveCase", "Case" );
|
||||
|
||||
CAF_PDM_InitField( &m_includeEnsembleCasesForCaseStepping,
|
||||
@ -78,6 +97,10 @@ RimSummaryPlotSourceStepping::RimSummaryPlotSourceStepping()
|
||||
m_placeholderForLabel = "No common identifiers detected";
|
||||
m_placeholderForLabel.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
|
||||
m_placeholderForLabel.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
CAF_PDM_InitField( &m_indexLabel, "IndexLabel", QString( "Step By" ), "Step By" );
|
||||
m_indexLabel.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );
|
||||
m_indexLabel.xmlCapability()->disableIO();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -99,45 +122,7 @@ void RimSummaryPlotSourceStepping::setSourceSteppingObject( caf::PdmObject* sour
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyNextCase()
|
||||
{
|
||||
modifyCurrentIndex( &m_summaryCase, 1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyPrevCase()
|
||||
{
|
||||
modifyCurrentIndex( &m_summaryCase, -1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyNextQuantity()
|
||||
{
|
||||
if ( !m_quantity.uiCapability()->isUiHidden() )
|
||||
{
|
||||
modifyCurrentIndex( &m_quantity, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyPrevQuantity()
|
||||
{
|
||||
if ( !m_quantity.uiCapability()->isUiHidden() )
|
||||
{
|
||||
modifyCurrentIndex( &m_quantity, -1 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyNextOtherIdentifier()
|
||||
void RimSummaryPlotSourceStepping::applyNextStep()
|
||||
{
|
||||
caf::PdmValueField* valueField = fieldToModify();
|
||||
if ( !valueField ) return;
|
||||
@ -148,7 +133,7 @@ void RimSummaryPlotSourceStepping::applyNextOtherIdentifier()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::applyPrevOtherIdentifier()
|
||||
void RimSummaryPlotSourceStepping::applyPrevStep()
|
||||
{
|
||||
caf::PdmValueField* valueField = fieldToModify();
|
||||
if ( !valueField ) return;
|
||||
@ -161,8 +146,7 @@ void RimSummaryPlotSourceStepping::applyPrevOtherIdentifier()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::fieldsToShowInToolbar()
|
||||
{
|
||||
bool fieldsForToolbar = true;
|
||||
return activeFieldsForDataSourceStepping( fieldsForToolbar );
|
||||
return toolbarFieldsForDataSourceStepping();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -170,8 +154,7 @@ std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::fieldsToShowInTo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlotSourceStepping::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
bool fieldsForToolbar = false;
|
||||
auto visible = activeFieldsForDataSourceStepping( fieldsForToolbar );
|
||||
auto visible = activeFieldsForDataSourceStepping();
|
||||
if ( visible.empty() )
|
||||
{
|
||||
uiOrdering.add( &m_placeholderForLabel );
|
||||
@ -194,12 +177,12 @@ QList<caf::PdmOptionItemInfo>
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_includeEnsembleCasesForCaseStepping )
|
||||
if ( ( fieldNeedingOptions == &m_includeEnsembleCasesForCaseStepping ) || ( fieldNeedingOptions == &m_stepDimension ) )
|
||||
{
|
||||
return caf::PdmObject::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
|
||||
}
|
||||
|
||||
if ( fieldNeedingOptions == &m_placeholderForLabel )
|
||||
if ( ( fieldNeedingOptions == &m_placeholderForLabel ) || ( fieldNeedingOptions == &m_indexLabel ) )
|
||||
{
|
||||
return options;
|
||||
}
|
||||
@ -381,6 +364,13 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
std::vector<RimSummaryCurve*> curves;
|
||||
if ( dataSourceSteppingObject() ) curves = dataSourceSteppingObject()->allCurves( m_sourceSteppingType );
|
||||
|
||||
if ( changedField == &m_stepDimension )
|
||||
{
|
||||
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
|
||||
mainPlotWindow->updateMultiPlotToolBar();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( changedField == &m_includeEnsembleCasesForCaseStepping )
|
||||
{
|
||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||
@ -606,37 +596,41 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify()
|
||||
{
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
analyzer.appendAddresses( addressesForCurvesInPlot() );
|
||||
|
||||
if ( analyzer.wellNames().size() == 1 )
|
||||
switch ( m_stepDimension() )
|
||||
{
|
||||
return &m_wellName;
|
||||
}
|
||||
case SourceSteppingDimension::SUMMARY_CASE:
|
||||
return &m_summaryCase;
|
||||
break;
|
||||
|
||||
if ( analyzer.groupNames().size() == 1 )
|
||||
{
|
||||
return &m_groupName;
|
||||
}
|
||||
case SourceSteppingDimension::ENSEMBLE:
|
||||
return &m_ensemble;
|
||||
|
||||
if ( analyzer.regionNumbers().size() == 1 )
|
||||
{
|
||||
return &m_region;
|
||||
}
|
||||
case SourceSteppingDimension::WELL:
|
||||
return &m_wellName;
|
||||
|
||||
if ( analyzer.blocks().size() == 1 )
|
||||
{
|
||||
return &m_cellBlock;
|
||||
}
|
||||
case SourceSteppingDimension::GROUP:
|
||||
return &m_groupName;
|
||||
|
||||
if ( analyzer.wellNames().size() == 1 )
|
||||
{
|
||||
auto wellName = *( analyzer.wellNames().begin() );
|
||||
case SourceSteppingDimension::REGION:
|
||||
return &m_region;
|
||||
|
||||
if ( analyzer.wellSegmentNumbers( wellName ).size() == 1 )
|
||||
{
|
||||
case SourceSteppingDimension::QUANTITY:
|
||||
return &m_quantity;
|
||||
|
||||
case SourceSteppingDimension::BLOCK:
|
||||
return &m_cellBlock;
|
||||
|
||||
case SourceSteppingDimension::SEGMENT:
|
||||
return &m_segment;
|
||||
}
|
||||
|
||||
case SourceSteppingDimension::COMPLETION:
|
||||
return &m_completion;
|
||||
|
||||
case SourceSteppingDimension::AQUIFER:
|
||||
return &m_aquifer;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -748,13 +742,15 @@ std::set<RimSummaryCase*> RimSummaryPlotSourceStepping::summaryCasesCurveCollect
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::activeFieldsForDataSourceStepping( bool toolbarFields )
|
||||
std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::activeFieldsForDataSourceStepping()
|
||||
{
|
||||
RimProject* proj = RimProject::current();
|
||||
if ( !proj ) return {};
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
|
||||
fields.push_back( &m_stepDimension );
|
||||
|
||||
auto sumCases = summaryCasesCurveCollection();
|
||||
if ( sumCases.size() == 1 )
|
||||
{
|
||||
@ -763,7 +759,7 @@ std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::activeFieldsForD
|
||||
m_summaryCase = *( sumCases.begin() );
|
||||
|
||||
fields.push_back( &m_summaryCase );
|
||||
if ( !toolbarFields ) fields.push_back( &m_includeEnsembleCasesForCaseStepping );
|
||||
fields.push_back( &m_includeEnsembleCasesForCaseStepping );
|
||||
}
|
||||
}
|
||||
|
||||
@ -988,33 +984,21 @@ void RimSummaryPlotSourceStepping::defineEditorAttribute( const caf::PdmFieldHan
|
||||
caf::PdmUiComboBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiComboBoxEditorAttribute*>( attribute );
|
||||
if ( myAttr )
|
||||
{
|
||||
myAttr->showPreviousAndNextButtons = true;
|
||||
myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" );
|
||||
myAttr->previousIcon = QIcon( ":/ComboBoxUp.svg" );
|
||||
|
||||
QString nextText;
|
||||
QString prevText;
|
||||
|
||||
if ( field == &m_summaryCase )
|
||||
if ( field == &m_stepDimension )
|
||||
{
|
||||
nextText = RimSummaryPlotControls::caseNextKeyText();
|
||||
prevText = RimSummaryPlotControls::casePrevKeyText();
|
||||
myAttr->showPreviousAndNextButtons = false;
|
||||
}
|
||||
else if ( field == &m_wellName || field == &m_groupName || field == &m_region )
|
||||
{
|
||||
nextText = RimSummaryPlotControls::otherNextKeyText();
|
||||
prevText = RimSummaryPlotControls::otherPrevKeyText();
|
||||
}
|
||||
else if ( field == &m_quantity )
|
||||
{
|
||||
nextText = RimSummaryPlotControls::quantityNextKeyText();
|
||||
prevText = RimSummaryPlotControls::quantityPrevKeyText();
|
||||
}
|
||||
|
||||
if ( !nextText.isEmpty() )
|
||||
else
|
||||
{
|
||||
QString nextText = RimSummaryPlotControls::nextStepKeyText();
|
||||
QString prevText = RimSummaryPlotControls::prevStepKeyText();
|
||||
myAttr->nextButtonText = "Next (" + nextText + ")";
|
||||
myAttr->prevButtonText = "Previous (" + prevText + ")";
|
||||
|
||||
myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" );
|
||||
myAttr->previousIcon = QIcon( ":/ComboBoxUp.svg" );
|
||||
|
||||
myAttr->showPreviousAndNextButtons = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1023,3 +1007,18 @@ void RimSummaryPlotSourceStepping::defineEditorAttribute( const caf::PdmFieldHan
|
||||
myAttr->minimumWidth = 120;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::toolbarFieldsForDataSourceStepping()
|
||||
{
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
fields.push_back( &m_indexLabel );
|
||||
fields.push_back( &m_stepDimension );
|
||||
|
||||
caf::PdmFieldHandle* field = fieldToModify();
|
||||
if ( field != nullptr ) fields.push_back( field );
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
@ -42,20 +42,29 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum class SourceSteppingDimension
|
||||
{
|
||||
SUMMARY_CASE,
|
||||
ENSEMBLE,
|
||||
WELL,
|
||||
GROUP,
|
||||
REGION,
|
||||
QUANTITY,
|
||||
BLOCK,
|
||||
SEGMENT,
|
||||
COMPLETION,
|
||||
AQUIFER
|
||||
};
|
||||
|
||||
public:
|
||||
RimSummaryPlotSourceStepping();
|
||||
|
||||
void setSourceSteppingType( RimSummaryDataSourceStepping::Axis sourceSteppingType );
|
||||
void setSourceSteppingObject( caf::PdmObject* sourceObject );
|
||||
|
||||
void applyNextCase();
|
||||
void applyPrevCase();
|
||||
|
||||
void applyNextQuantity();
|
||||
void applyPrevQuantity();
|
||||
|
||||
void applyNextOtherIdentifier();
|
||||
void applyPrevOtherIdentifier();
|
||||
void applyNextStep();
|
||||
void applyPrevStep();
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
|
||||
|
||||
@ -78,9 +87,11 @@ private:
|
||||
|
||||
std::set<RifEclipseSummaryAddress> addressesForCurvesInPlot() const;
|
||||
std::set<RimSummaryCase*> summaryCasesCurveCollection() const;
|
||||
std::vector<caf::PdmFieldHandle*> activeFieldsForDataSourceStepping( bool toolbarFields );
|
||||
std::set<RimSummaryCaseCollection*> ensembleCollection() const;
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> activeFieldsForDataSourceStepping();
|
||||
std::vector<caf::PdmFieldHandle*> toolbarFieldsForDataSourceStepping();
|
||||
|
||||
bool isXAxisStepping() const;
|
||||
bool isYAxisStepping() const;
|
||||
|
||||
@ -93,6 +104,9 @@ private:
|
||||
private:
|
||||
caf::PdmPointer<caf::PdmObject> m_objectForSourceStepping;
|
||||
|
||||
caf::PdmField<QString> m_indexLabel;
|
||||
caf::PdmField<caf::AppEnum<SourceSteppingDimension>> m_stepDimension;
|
||||
|
||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
|
||||
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble;
|
||||
|
||||
|
@ -183,8 +183,11 @@ void PdmUiToolBarEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
}
|
||||
}
|
||||
|
||||
CAF_ASSERT( m_fields.size() == m_fieldViews.size() );
|
||||
CAF_ASSERT( static_cast<int>( m_fields.size() ) == m_actions.size() );
|
||||
// CAF_ASSERT( m_fields.size() == m_fieldViews.size() );
|
||||
if ( static_cast<int>( m_fields.size() ) != m_actions.size() ) return;
|
||||
|
||||
// CAF_ASSERT( static_cast<int>( m_fields.size() ) == m_actions.size() );
|
||||
if ( static_cast<int>( m_fields.size() ) != m_actions.size() ) return;
|
||||
|
||||
for ( size_t i = 0; i < m_fields.size(); i++ )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user