///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "RiaDefines.h" #include "Summary/RiaSummaryDefines.h" #include "cafPdmUiTreeAttributes.h" #include "RifEclipseSummaryAddress.h" #include "RigEnsembleParameter.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmProxyValueField.h" #include #include #include #include class RimSummaryCase; class RimSummaryAddressCollection; class RiaSummaryAddressAnalyzer; class RimSummaryEnsembleParameterCollection; //================================================================================================== /// //================================================================================================== class RimSummaryEnsemble : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: caf::Signal<> caseNameChanged; caf::Signal caseRemoved; public: RimSummaryEnsemble(); ~RimSummaryEnsemble() override; void removeCase( RimSummaryCase* summaryCase, bool notifyChange = true ); void addCase( RimSummaryCase* summaryCase, bool notifyChange = true ); void replaceCases( const std::vector& summaryCases, bool notifyChange = true ); virtual void reloadCases(); virtual std::vector allSummaryCases() const; RimSummaryCase* firstSummaryCase() const; QString name() const; void setNameTemplate( const QString& name ); void setAutoName( bool autoName ); virtual void updateName( const std::set& existingEnsembleNames ); void setUsePathKey1( bool useKey1 ); void setUsePathKey2( bool useKey2 ); virtual std::pair nameKeys() const; virtual QString nameTemplateText() const; void setGroupingMode( RiaDefines::EnsembleGroupingMode groupingMode ); RiaDefines::EnsembleGroupingMode groupingMode() const; bool isEnsemble() const; void setAsEnsemble( bool isEnsemble ); virtual std::set ensembleSummaryAddresses() const; virtual std::set ensembleTimeSteps() const; // Hint that these addresses are about to be read, given before the curves pull their values. Sources that // fetch data remotely can use it to load everything in one go instead of one blocking request per address. // Data is still loaded on demand, so this is an optimization only: not calling it changes nothing but speed. virtual void prefetchSummaryData( const std::vector& resultAddresses ) {} // Whether any of these addresses is being loaded right now, for sources that load without waiting. A plot // asks about the addresses of its own curves, so it can say it is still waiting for data. virtual bool isSummaryDataPending( const std::vector& resultAddresses ) const { return false; } void setEnsembleId( int ensembleId ); int ensembleId() const; bool hasEnsembleParameters() const; std::vector variationSortedEnsembleParameters( bool excludeNoVariation = false ) const; std::vector> correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address ) const; std::vector> correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address, time_t selectedTimeStep ) const; std::vector> parameterCorrelations( const RifEclipseSummaryAddress& address, time_t selectedTimeStep, const std::vector& selectedParameters = {}, const std::set& selectedCases = {} ) const; std::vector> parameterCorrelationsAllTimeSteps( const RifEclipseSummaryAddress& address, const std::vector& selectedParameters = {} ) const; RigEnsembleParameter ensembleParameter( const QString& paramName ) const; void calculateEnsembleParametersIntersectionHash(); void loadDataAndUpdate(); static bool validateEnsembleCases( const std::vector cases ); bool operator<( const RimSummaryEnsemble& rhs ) const; RiaDefines::EclipseUnitSystem unitSystem() const; void onCalculationUpdated(); void onSummaryVectorsChanged(); void updateReferringCurveSets(); void updateReferringCurveSetsZoomAll(); void clearReferringCurveSets(); RiaSummaryAddressAnalyzer* addressAnalyzer(); void computeMinMax( const RifEclipseSummaryAddress& address ); void setMinMax( const RifEclipseSummaryAddress& address, double min, double max ); std::pair minMax( const RifEclipseSummaryAddress& address ); virtual void cleanupBeforeDelete(); bool includeInAutoReload() const; protected: virtual void onLoadDataAndUpdate(); // Add a case without notifying the delta ensembles depending on this ensemble. Used when the caller is itself the // owner of the dependency update, as is the case when a delta ensemble rebuilds its derived cases. void addCaseWithoutDependencyUpdate( RimSummaryCase* summaryCase ); void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void buildMetaData(); void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; bool isAutoNameChecked() const; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void initAfterRead() override; void buildChildNodes(); private: caf::PdmFieldHandle* userDescriptionField() override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; std::vector treeItemTags() override; QString nameAndItemCount() const; void updateIcon(); void updateReferringCurveSets( bool doZoomAll ); void onCaseNameChanged( const SignalEmitter* emitter ); void clearChildNodes(); QString ensembleDescription() const; protected: caf::PdmChildArrayField m_cases; caf::PdmField m_name; caf::PdmField m_includeInAutoReload; private: caf::PdmField m_nameTemplateString; caf::PdmField m_autoName; caf::PdmField m_useKey1; caf::PdmField m_useKey2; caf::PdmProxyValueField m_ensembleDescription; caf::PdmField> m_groupingMode; caf::PdmProxyValueField m_nameAndItemCount; caf::PdmField m_isEnsemble; caf::PdmChildField m_dataVectorFolders; caf::PdmChildField m_ensembleParameters; caf::PdmField m_ensembleId; mutable std::vector m_cachedSortedEnsembleParameters; std::unique_ptr m_analyzer; std::map> m_minMaxValues; };