///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2023- Equinor 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 #include #include #include #include namespace RimSummaryTableTools { // Struct for storing vector data struct VectorData { QString category; QString name; std::vector values; time_t firstTimeStep; time_t lastTimeStep; std::vector timeSteps; // Time step for each value }; // Value filter for table rows. Rows are kept if they have at least one value matching the filter. enum class ValueFilterType { NONE, ABOVE, BELOW, BETWEEN, OUTSIDE }; struct ValueFilter { ValueFilterType type = ValueFilterType::NONE; double lowerThreshold = 0.0; double upperThreshold = 0.0; }; // Struct for storing table data struct TableData { std::vector vectorDataCollection; std::set timeStepsUnion; double maxValue = 0.0; double minValue = 0.0; ValueFilter valueFilter; // Value range of all rows before the value filter is applied std::optional> unfilteredMinMax; QString unitName; }; // ABOVE: value > lowerThreshold // BELOW: value < upperThreshold // BETWEEN: lowerThreshold <= value <= upperThreshold // OUTSIDE: value < lowerThreshold or value > upperThreshold, used to exclude values in a range // NONE: value > 0 bool isValueMatchingFilter( double value, const ValueFilter& filter ); bool hasValueMatchingFilter( const std::vector& values, const ValueFilter& filter ); std::vector vectorsMatchingFilter( const std::vector& vectorDataCollection, const ValueFilter& filter ); void sortVectorDataOnDate( TableData& rTableData ); std::vector categoryNames( const std::vector& vectorDataCollection ); // Values of the vector for each of the given time steps. Time steps without a value are set to NaN. std::vector valuesForTimeSteps( const VectorData& vectorData, const std::set& timeSteps ); // Value filter equivalent to the threshold in older project files, which kept rows with at least one value equal to or above // the threshold ValueFilter valueFilterFromLegacyThreshold( double thresholdValue ); } // namespace RimSummaryTableTools