///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 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 "cafPdmField.h" #include "cafPdmObject.h" #include class QDateTime; class RimEclipseResultCase; class RimGeoMechCase; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- class RimTimeStepFilter : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: enum TimeStepFilterTypeEnum { TS_ALL, TS_INTERVAL_DAYS, TS_INTERVAL_WEEKS, TS_INTERVAL_MONTHS, TS_INTERVAL_QUARTERS, TS_INTERVAL_YEARS }; public: RimTimeStepFilter(); void clearFilteredTimeSteps(); void setTimeStepsFromFile( const std::vector& timeSteps ); void setTimeStepsFromFile( const std::vector>& timeSteps ); std::vector filteredTimeSteps() const; bool updateFilteredTimeStepsFromUi(); static std::vector filteredTimeStepIndices( const std::vector& timeSteps, int firstTimeStep, int lastTimeStep, TimeStepFilterTypeEnum filterType, int interval ); void setReadOnlyLastFrame( bool onlyLast ); bool readOnlyLastFrame() const; protected: void initAfterRead() override; private: static QDateTime incrementDateTime( const QDateTime& dateTime, TimeStepFilterTypeEnum filterType, int interval ); std::vector> allTimeSteps() const; std::vector filteredTimeStepIndicesFromUi() const; void updateFieldVisibility(); RimEclipseResultCase* parentEclipseResultCase() const; RimGeoMechCase* parentGeoMechCase() const; // PDM overrides void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; private: caf::PdmField> m_filterType; caf::PdmField> m_filteredTimeSteps; caf::PdmField> m_filteredTimeStepsUi; caf::PdmField m_firstTimeStep; caf::PdmField m_lastTimeStep; caf::PdmField m_interval; caf::PdmField m_applyReloadOfCase; caf::PdmField m_dateFormat; caf::PdmField> m_timeStepNamesFromFile; caf::PdmField m_readOnlyLastFrame; };