diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimKeywordEvent.cpp b/ApplicationLibCode/ProjectDataModel/WellEvents/RimKeywordEvent.cpp index 899834c1f2..84a683aa27 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimKeywordEvent.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimKeywordEvent.cpp @@ -27,6 +27,7 @@ #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiOrdering.h" +#include "cafPdmUiTableViewEditor.h" #include "cafPdmUiTreeOrdering.h" CAF_PDM_SOURCE_INIT( RimKeywordEvent, "KeywordEvent" ); @@ -40,6 +41,12 @@ RimKeywordEvent::RimKeywordEvent() CAF_PDM_InitScriptableField( &m_keywordName, "KeywordName", QString(), "Keyword Name" ); CAF_PDM_InitFieldNoDefault( &m_items, "Items", "Items" ); + m_items.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); + m_items.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::TOP ); + m_items.uiCapability()->setAttribute( caf::PdmUiTableViewEditor::Keys::RESIZE_POLICY, + static_cast( caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FILL_CONTAINER ) ); + m_items.uiCapability()->setAttribute( caf::PdmUiTableViewEditor::Keys::ALWAYS_ENFORCE_RESIZE_POLICY, true ); + m_items.uiCapability()->setAttribute( caf::PdmUiTableViewEditor::Keys::MINIMUM_HEIGHT, 200 ); setDeletable( true ); } @@ -148,8 +155,12 @@ std::optional RimKeywordEvent::generateDeckKeyword( const QStr //-------------------------------------------------------------------------------------------------- void RimKeywordEvent::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { + // Schedule-level keyword events are not tied to a well, so the inherited well path field is not shown + uiOrdering.add( &m_eventDate ); uiOrdering.add( &m_keywordName ); uiOrdering.add( &m_items ); + + uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- @@ -157,5 +168,7 @@ void RimKeywordEvent::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering //-------------------------------------------------------------------------------------------------- void RimKeywordEvent::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) { - uiTreeOrdering.add( &m_items ); + setUiName( QString( "%1 %2" ).arg( m_keywordName() ).arg( m_eventDate().toString( "yyyy-MM-dd" ) ) ); + + uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEvent.cpp b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEvent.cpp index 166dd2a45b..c4356f935f 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEvent.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEvent.cpp @@ -18,12 +18,30 @@ #include "RimWellEvent.h" +#include "RimTools.h" #include "RimWellPath.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiDateEditor.h" +namespace caf +{ +template <> +void AppEnum::setUp() +{ + addItem( RimWellEvent::EventType::PERF, "PERF", "Perforation" ); + addItem( RimWellEvent::EventType::VALVE, "VALVE", "Valve" ); + addItem( RimWellEvent::EventType::TUBING, "TUBING", "Tubing" ); + addItem( RimWellEvent::EventType::WSTATE, "WSTATE", "Well State" ); + addItem( RimWellEvent::EventType::WTYPE, "WTYPE", "Well Type" ); + addItem( RimWellEvent::EventType::WCONTROL, "WCONTROL", "Well Control" ); + addItem( RimWellEvent::EventType::KEYWORD, "KEYWORD", "Well Keyword" ); + addItem( RimWellEvent::EventType::SCHEDULE_KEYWORD, "SCHEDULE_KEYWORD", "Schedule Keyword" ); + setDefault( RimWellEvent::EventType::PERF ); +} +} // namespace caf + CAF_PDM_ABSTRACT_SOURCE_INIT( RimWellEvent, "WellEvent" ); //-------------------------------------------------------------------------------------------------- @@ -96,3 +114,18 @@ void RimWellEvent::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& u uiOrdering.add( &m_wellPath ); uiOrdering.add( &m_eventDate ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimWellEvent::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + + if ( fieldNeedingOptions == &m_wellPath ) + { + RimTools::wellPathOptionItems( &options ); + } + + return options; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEvent.h b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEvent.h index 7b63f7e4ad..cce6cdb8ce 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEvent.h +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEvent.h @@ -64,9 +64,16 @@ public: virtual QString generateScheduleKeyword( const QString& wellName ) const = 0; protected: - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; protected: caf::PdmField m_eventDate; caf::PdmPtrField m_wellPath; }; + +namespace caf +{ +template <> +void caf::AppEnum::setUp(); +} // namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeyword.cpp b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeyword.cpp index 3c0e727f4d..556609cd29 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeyword.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeyword.cpp @@ -27,6 +27,7 @@ #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiOrdering.h" +#include "cafPdmUiTableViewEditor.h" #include "cafPdmUiTreeOrdering.h" CAF_PDM_SOURCE_INIT( RimWellEventKeyword, "WellEventKeyword" ); @@ -40,6 +41,12 @@ RimWellEventKeyword::RimWellEventKeyword() CAF_PDM_InitScriptableField( &m_keywordName, "KeywordName", QString(), "Keyword Name" ); CAF_PDM_InitFieldNoDefault( &m_items, "Items", "Items" ); + m_items.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); + m_items.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::TOP ); + m_items.uiCapability()->setAttribute( caf::PdmUiTableViewEditor::Keys::RESIZE_POLICY, + static_cast( caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FILL_CONTAINER ) ); + m_items.uiCapability()->setAttribute( caf::PdmUiTableViewEditor::Keys::ALWAYS_ENFORCE_RESIZE_POLICY, true ); + m_items.uiCapability()->setAttribute( caf::PdmUiTableViewEditor::Keys::MINIMUM_HEIGHT, 200 ); setDeletable( true ); } @@ -148,8 +155,12 @@ std::optional RimWellEventKeyword::generateDeckKeyword( const //-------------------------------------------------------------------------------------------------- void RimWellEventKeyword::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { + RimWellEvent::defineUiOrdering( uiConfigName, uiOrdering ); + uiOrdering.add( &m_keywordName ); uiOrdering.add( &m_items ); + + uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- @@ -157,5 +168,7 @@ void RimWellEventKeyword::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde //-------------------------------------------------------------------------------------------------- void RimWellEventKeyword::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) { - uiTreeOrdering.add( &m_items ); + setUiName( QString( "%1 %2 [%3]" ).arg( m_keywordName() ).arg( m_eventDate().toString( "yyyy-MM-dd" ) ).arg( wellName() ) ); + + uiTreeOrdering.skipRemainingChildren( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeywordItem.cpp b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeywordItem.cpp index 1d96470aeb..414ff36387 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeywordItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeywordItem.cpp @@ -18,6 +18,8 @@ #include "RimWellEventKeywordItem.h" +#include "cafPdmUiOrdering.h" + CAF_PDM_SOURCE_INIT( RimWellEventKeywordItem, "RimWellEventKeywordItem" ); //-------------------------------------------------------------------------------------------------- @@ -28,10 +30,20 @@ RimWellEventKeywordItem::RimWellEventKeywordItem() CAF_PDM_InitObject( "Keyword Item", "" ); CAF_PDM_InitFieldNoDefault( &m_itemName, "ItemName", "Item Name" ); + m_itemName.uiCapability()->setUiReadOnly( true ); CAF_PDM_InitFieldNoDefault( &m_itemType, "ItemType", "Type" ); + m_itemType.uiCapability()->setUiReadOnly( true ); CAF_PDM_InitFieldNoDefault( &m_stringValue, "StringValue", "String Value" ); + m_stringValue.uiCapability()->setUiHidden( true ); CAF_PDM_InitFieldNoDefault( &m_intValue, "IntValue", "Integer Value" ); + m_intValue.uiCapability()->setUiHidden( true ); CAF_PDM_InitFieldNoDefault( &m_doubleValue, "DoubleValue", "Double Value" ); + m_doubleValue.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_valueForUi, "ValueForUi", "Value" ); + m_valueForUi.registerGetMethod( this, &RimWellEventKeywordItem::valueForUi ); + m_valueForUi.registerSetMethod( this, &RimWellEventKeywordItem::setValueForUi ); + m_valueForUi.xmlCapability()->disableIO(); } //-------------------------------------------------------------------------------------------------- @@ -96,6 +108,7 @@ void RimWellEventKeywordItem::setStringValue( const QString& value ) { m_itemType = ItemType::STRING; m_stringValue = value; + updateValueFieldReadOnlyState(); } //-------------------------------------------------------------------------------------------------- @@ -105,6 +118,7 @@ void RimWellEventKeywordItem::setIntValue( int value ) { m_itemType = ItemType::INTEGER; m_intValue = value; + updateValueFieldReadOnlyState(); } //-------------------------------------------------------------------------------------------------- @@ -114,6 +128,7 @@ void RimWellEventKeywordItem::setDoubleValue( double value ) { m_itemType = ItemType::DOUBLE; m_doubleValue = value; + updateValueFieldReadOnlyState(); } //-------------------------------------------------------------------------------------------------- @@ -122,6 +137,83 @@ void RimWellEventKeywordItem::setDoubleValue( double value ) void RimWellEventKeywordItem::setFlag() { m_itemType = ItemType::FLAG; + updateValueFieldReadOnlyState(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellEventKeywordItem::valueForUi() const +{ + switch ( m_itemType() ) + { + case ItemType::STRING: + return m_stringValue(); + case ItemType::INTEGER: + return QString::number( m_intValue() ); + case ItemType::DOUBLE: + return QString::number( m_doubleValue() ); + case ItemType::FLAG: + default: + return {}; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellEventKeywordItem::setValueForUi( const QString& value ) +{ + switch ( m_itemType() ) + { + case ItemType::STRING: + m_stringValue = value; + break; + case ItemType::INTEGER: + { + bool ok = false; + int intValue = value.toInt( &ok ); + if ( ok ) m_intValue = intValue; + break; + } + case ItemType::DOUBLE: + { + bool ok = false; + double doubleValue = value.toDouble( &ok ); + if ( ok ) m_doubleValue = doubleValue; + break; + } + case ItemType::FLAG: + default: + break; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellEventKeywordItem::updateValueFieldReadOnlyState() +{ + m_valueForUi.uiCapability()->setUiReadOnly( m_itemType() == ItemType::FLAG ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellEventKeywordItem::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_itemName ); + uiOrdering.add( &m_itemType ); + uiOrdering.add( &m_valueForUi ); + uiOrdering.skipRemainingFields(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellEventKeywordItem::initAfterRead() +{ + updateValueFieldReadOnlyState(); } namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeywordItem.h b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeywordItem.h index 7d1426512f..abd473c590 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeywordItem.h +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventKeywordItem.h @@ -21,6 +21,7 @@ #include "cafAppEnum.h" #include "cafPdmField.h" #include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" #include @@ -59,12 +60,22 @@ public: void setDoubleValue( double value ); void setFlag(); +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void initAfterRead() override; + +private: + QString valueForUi() const; + void setValueForUi( const QString& value ); + void updateValueFieldReadOnlyState(); + private: caf::PdmField m_itemName; caf::PdmField> m_itemType; caf::PdmField m_stringValue; caf::PdmField m_intValue; caf::PdmField m_doubleValue; + caf::PdmProxyValueField m_valueForUi; }; namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventTimeline.cpp b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventTimeline.cpp index 9fea8b101d..dad65c6f3d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventTimeline.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventTimeline.cpp @@ -47,6 +47,7 @@ #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiTreeOrdering.h" +#include "cafPdmUiTreeSelectionEditor.h" #include #include @@ -62,6 +63,23 @@ RimWellEventTimeline::RimWellEventTimeline() CAF_PDM_InitScriptableObject( "Well Event Timeline", "", "", "WellEventTimeline" ); CAF_PDM_InitScriptableFieldNoDefault( &m_events, "Events", "Events" ); + + CAF_PDM_InitFieldNoDefault( &m_sortBy, "SortBy", "Sort By" ); + CAF_PDM_InitField( &m_sortDescending, "SortDescending", false, "Descending" ); + + CAF_PDM_InitFieldNoDefault( &m_wellPathFilter, "WellPathFilter", "Wells" ); + m_wellPathFilter.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + m_wellPathFilter.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::TOP ); + + CAF_PDM_InitFieldNoDefault( &m_eventTypeFilter, "EventTypeFilter", "Event Types" ); + m_eventTypeFilter.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); + m_eventTypeFilter.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::TOP ); + + CAF_PDM_InitField( &m_filterByStartDate, "FilterByStartDate", false, "Filter by Start Date" ); + CAF_PDM_InitField( &m_startDateFilter, "StartDateFilter", QDateTime::currentDateTime(), "Start Date" ); + + CAF_PDM_InitField( &m_filterByEndDate, "FilterByEndDate", false, "Filter by End Date" ); + CAF_PDM_InitField( &m_endDateFilter, "EndDateFilter", QDateTime::currentDateTime(), "End Date" ); } //-------------------------------------------------------------------------------------------------- @@ -612,23 +630,151 @@ bool RimWellEventTimeline::applyValveEvent( const RimWellEventValve& event, RimW return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellEventTimeline::filteredAndSortedEventsForUi() const +{ + std::vector filteredEvents; + + std::set wellPathFilter( m_wellPathFilter.begin(), m_wellPathFilter.end() ); + + std::set eventTypeFilter; + for ( const auto& eventType : m_eventTypeFilter() ) + { + eventTypeFilter.insert( eventType.value() ); + } + + for ( auto* event : events() ) + { + // Events without a well (schedule-level keywords) are hidden when a well filter is active + if ( !wellPathFilter.empty() && !wellPathFilter.contains( event->wellPath() ) ) continue; + if ( !eventTypeFilter.empty() && !eventTypeFilter.contains( event->eventType() ) ) continue; + if ( m_filterByStartDate() && event->eventDate() < m_startDateFilter() ) continue; + if ( m_filterByEndDate() && event->eventDate() > m_endDateFilter() ) continue; + + filteredEvents.push_back( event ); + } + + auto compareEvents = [this]( const RimWellEvent* a, const RimWellEvent* b ) + { + switch ( m_sortBy() ) + { + case SortMode::WELL: + if ( a->wellName() != b->wellName() ) return a->wellName() < b->wellName(); + break; + case SortMode::TYPE: + if ( a->eventType() != b->eventType() ) return a->eventType() < b->eventType(); + break; + case SortMode::DATE: + default: + break; + } + return a->eventDate() < b->eventDate(); + }; + std::stable_sort( filteredEvents.begin(), filteredEvents.end(), compareEvents ); + + if ( m_sortDescending() ) + { + std::reverse( filteredEvents.begin(), filteredEvents.end() ); + } + + return filteredEvents; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellEventTimeline::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + auto sortGroup = uiOrdering.addNewGroup( "Sorting" ); + sortGroup->add( &m_sortBy ); + sortGroup->add( &m_sortDescending ); + + auto filterGroup = uiOrdering.addNewGroup( "Filter" ); + filterGroup->add( &m_wellPathFilter ); + filterGroup->add( &m_eventTypeFilter ); + filterGroup->add( &m_filterByStartDate ); + filterGroup->add( &m_startDateFilter ); + m_startDateFilter.uiCapability()->setUiReadOnly( !m_filterByStartDate() ); + filterGroup->add( &m_filterByEndDate ); + filterGroup->add( &m_endDateFilter ); + m_endDateFilter.uiCapability()->setUiReadOnly( !m_filterByEndDate() ); + + uiOrdering.skipRemainingFields(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellEventTimeline::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) { - setUiName( QString( "Event Timeline (%1 events)" ).arg( m_events.size() ) ); + std::vector visibleEvents = filteredAndSortedEventsForUi(); - // Sort events by date for display - std::vector sortedEvents = events(); - std::sort( sortedEvents.begin(), - sortedEvents.end(), - []( const RimWellEvent* a, const RimWellEvent* b ) { return a->eventDate() < b->eventDate(); } ); + if ( visibleEvents.size() != m_events.size() ) + { + setUiName( QString( "Event Timeline (%1 of %2 events)" ).arg( visibleEvents.size() ).arg( m_events.size() ) ); + } + else + { + setUiName( QString( "Event Timeline (%1 events)" ).arg( m_events.size() ) ); + } - for ( auto* event : sortedEvents ) + for ( auto* event : visibleEvents ) { uiTreeOrdering.add( event ); } uiTreeOrdering.skipRemainingChildren(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellEventTimeline::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_sortBy || changedField == &m_sortDescending || changedField == &m_wellPathFilter || + changedField == &m_eventTypeFilter || changedField == &m_filterByStartDate || changedField == &m_startDateFilter || + changedField == &m_filterByEndDate || changedField == &m_endDateFilter ) + { + updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimWellEventTimeline::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) +{ + QList options; + + if ( fieldNeedingOptions == &m_wellPathFilter ) + { + for ( auto* wellPath : getWellPathsWithEvents() ) + { + options.push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath, false ) ); + } + } + else if ( fieldNeedingOptions == &m_eventTypeFilter ) + { + for ( size_t i = 0; i < caf::AppEnum::size(); i++ ) + { + options.push_back( caf::PdmOptionItemInfo( caf::AppEnum::uiTextFromIndex( i ), + caf::AppEnum::fromIndex( i ) ) ); + } + } + + return options; +} + +namespace caf +{ +template <> +void AppEnum::setUp() +{ + addItem( RimWellEventTimeline::SortMode::DATE, "DATE", "Date" ); + addItem( RimWellEventTimeline::SortMode::WELL, "WELL", "Well" ); + addItem( RimWellEventTimeline::SortMode::TYPE, "TYPE", "Type" ); + setDefault( RimWellEventTimeline::SortMode::DATE ); +} +} // namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventTimeline.h b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventTimeline.h index 5c8859d1f6..1d88fb985f 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventTimeline.h +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventTimeline.h @@ -20,8 +20,10 @@ #include "RimWellEvent.h" +#include "cafAppEnum.h" #include "cafPdmChildArrayField.h" #include "cafPdmObject.h" +#include "cafPdmPtrArrayField.h" #include #include @@ -47,6 +49,13 @@ class RimWellEventTimeline : public caf::PdmObject CAF_PDM_HEADER_INIT; public: + enum class SortMode + { + DATE, + WELL, + TYPE + }; + RimWellEventTimeline(); ~RimWellEventTimeline() override; @@ -90,7 +99,10 @@ public: QDateTime lastAppliedTimestamp() const; protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; private: bool applyEvent( RimWellPathCollection* wellPathCollection, RimWellEvent* event ); @@ -99,6 +111,23 @@ private: bool applyPerfEvent( const RimWellEventPerf& event, RimWellPath& wellPath ); bool applyValveEvent( const RimWellEventValve& event, RimWellPath& wellPath ); + std::vector filteredAndSortedEventsForUi() const; + caf::PdmChildArrayField m_events; QDateTime m_lastAppliedTimestamp; + + caf::PdmField> m_sortBy; + caf::PdmField m_sortDescending; + caf::PdmPtrArrayField m_wellPathFilter; + caf::PdmField>> m_eventTypeFilter; + caf::PdmField m_filterByStartDate; + caf::PdmField m_startDateFilter; + caf::PdmField m_filterByEndDate; + caf::PdmField m_endDateFilter; }; + +namespace caf +{ +template <> +void caf::AppEnum::setUp(); +} // namespace caf diff --git a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventValve.cpp b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventValve.cpp index 645c2b3f5e..9b422a8177 100644 --- a/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventValve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellEvents/RimWellEventValve.cpp @@ -338,7 +338,7 @@ void RimWellEventValve::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrde //-------------------------------------------------------------------------------------------------- QList RimWellEventValve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - QList options; + QList options = RimWellEvent::calculateValueOptions( fieldNeedingOptions ); if ( fieldNeedingOptions == &m_valveTemplate ) {