Merge dev into main before release

This commit is contained in:
Magne Sjaastad
2024-09-25 09:11:12 +02:00
committed by GitHub
925 changed files with 29510 additions and 13490 deletions

12
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"

View File

@@ -34,7 +34,7 @@ jobs:
sudo apt-get install --option="APT::Acquire::Retries=3" libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev
- name: Install Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
with:
version: ${{ matrix.qtver }}
dir: "${{ github.workspace }}/Qt/"

View File

@@ -9,9 +9,9 @@ on:
- cron: '0 1 * * *'
env:
BUILD_TYPE: Release
BUILDCACHE_VERSION: 0.27.6
BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir
BUILDCACHE_ACCURACY: SLOPPY
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
@@ -23,45 +23,49 @@ jobs:
strategy:
fail-fast: false
matrix:
build_type: [Release]
config:
- {
name: "Windows Latest MSVC",
os: windows-2022,
cc: "cl",
cxx: "cl",
vcpkg-response-file: vcpkg_x64-windows.txt,
vcpkg-triplet: x64-windows,
build-python-module: true,
execute-unit-tests: true,
execute-pytests: true,
unity-build: true,
publish-to-pypi: false,
vcpkg-bootstrap: bootstrap-vcpkg.bat,
vcpkg-triplet: x64-windows-release,
qt-version: 5.12.12,
}
- {
name: "Ubuntu 20.04 gcc",
os: ubuntu-20.04,
name: "Ubuntu 22.04 gcc",
os: ubuntu-22.04,
cc: "gcc",
cxx: "g++",
vcpkg-response-file: vcpkg_x64-linux.txt,
vcpkg-triplet: x64-linux,
build-python-module: true,
execute-unit-tests: true,
execute-pytests: true,
unity-build: false,
publish-to-pypi: true,
vcpkg-bootstrap: bootstrap-vcpkg.sh,
vcpkg-triplet: x64-linux-release,
qt-version: 5.12.12,
}
- {
name: "Ubuntu 22.04 clang-16",
os: ubuntu-22.04,
cc: "clang-16",
cxx: "clang++-16",
vcpkg-response-file: vcpkg_x64-linux.txt,
vcpkg-triplet: x64-linux,
build-python-module: true,
execute-unit-tests: true,
execute-pytests: false,
unity-build: false,
publish-to-pypi: false,
vcpkg-bootstrap: bootstrap-vcpkg.sh,
vcpkg-triplet: x64-linux-release,
qt-version: 5.12.12,
}
steps:
- name: Checkout
@@ -72,7 +76,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.11"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
@@ -107,8 +111,7 @@ jobs:
set(buildcache_suffix "linux.tar.gz")
endif()
set(buildcache_version $ENV{BUILDCACHE_VERSION})
set(buildcache_url "https://github.com/mbitsnbites/buildcache/releases/download/v${buildcache_version}/buildcache-${buildcache_suffix}")
set(buildcache_url "https://gitlab.com/bits-n-bites/buildcache/-/releases/permalink/latest/downloads/buildcache-${buildcache_suffix}")
file(DOWNLOAD "${buildcache_url}" ./buildcache.zip)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./buildcache.zip)
@@ -170,74 +173,51 @@ jobs:
sudo ./llvm.sh 16 all
- name: Install Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
with:
version: 5.12.12
version: ${{ matrix.config.qt-version }}
dir: "${{ github.workspace }}/Qt/"
cache: true
modules: "qtnetworkauth"
- name: Restore from cache and install vcpkg
uses: lukka/run-vcpkg@v7
id: runvcpkg
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}"
vcpkgDirectory:
"${{ github.workspace }}/ThirdParty/vcpkg"
appendedCacheKey: ${{ matrix.config.os }}-${{ matrix.config.cxx }}-cache-key-v2
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Cache dynamic version of OpenSSL (Linux)
if: contains( matrix.config.os, 'ubuntu_disabled')
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux-dynamic
key: ${{ matrix.config.os }}-vcpkg-x64-linux-dynamic_v05
- name: Install dynamic version of OpenSSL (Linux)
if: contains( matrix.config.os, 'ubuntu')
- name: vcpkg bootstrap
run: |
$VCPKG_ROOT/vcpkg install --overlay-triplets=${{ github.workspace }}/ThirdParty/vcpkg-custom-triplets --triplet x64-linux-dynamic openssl
ThirdParty/vcpkg/${{ matrix.config.vcpkg-bootstrap }}
- name: Configure
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
shell: bash
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
run: >
cmake -S . -B cmakebuild
-DVCPKG_BUILD_TYPE=release
-DVCPKG_TARGET_TRIPLET=${{ matrix.config.vcpkg-triplet }}
-DCMAKE_INSTALL_PREFIX=cmakebuild/install
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DRESINSIGHT_QT5_BUNDLE_LIBRARIES=true
-DRESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true
-DRESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true
-DRESINSIGHT_ENABLE_PRECOMPILED_HEADERS=false
-DRESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }}
-DRESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }}
-DRESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
-DRESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true
-DRESINSIGHT_ENABLE_HDF5=false
-DRESINSIGHT_BUILD_LIBS_FROM_SOURCE=false
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
-G Ninja
execute_process(
COMMAND cmake
-S .
-B cmakebuild
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-D CMAKE_INSTALL_PREFIX=cmakebuild/install
-D RESINSIGHT_BUNDLE_OPENSSL=true
-D RESINSIGHT_QT5_BUNDLE_LIBRARIES=true
-D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true
-D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true
-D RESINSIGHT_ENABLE_PRECOMPILED_HEADERS=false
-D RESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }}
-D RESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }}
-D RESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
-D RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true
-D RESINSIGHT_ENABLE_HDF5=false
-D RESINSIGHT_BUILD_LIBS_FROM_SOURCE=false
-D CMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
-G Ninja
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Build
shell: cmake -P {0}
run: |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
execute_process(
COMMAND cmake --build cmakebuild --target install
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
cmake --build cmakebuild --target install
- name: Stats for buildcache
run: ${{ github.workspace }}/buildcache/bin/buildcache -s
@@ -272,12 +252,14 @@ jobs:
with:
name: python-distribution
path: GrpcInterface/Python/dist
retention-days: 5
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ResInsight-${{ matrix.config.name }}
path: ${{ runner.workspace }}/ResInsight/cmakebuild/install
retention-days: 5
pypi-publish:
name: Upload release to PyPI
@@ -307,5 +289,5 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
# uncomment the two lines below to publish to test PyPi
# with:
# repository-url: https://test.pypi.org/legacy/
# repository-url: https://test.pypi.org/legacy/

View File

@@ -1,207 +0,0 @@
name: ResInsight Manual gRPC Paths
on:
workflow_dispatch:
schedule:
# Once every night
- cron: "0 1 * * * "
env:
NINJA_VERSION: 1.9.0
BUILD_TYPE: Release
BUILDCACHE_VERSION: 0.23.0
BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir
jobs:
ResInsight-x64-buildcache:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu 20.04",
os: ubuntu-20.04,
cc: "gcc",
cxx: "g++",
vcpkg-response-file: vcpkg_x64-linux.txt,
vcpkg-triplet: x64-linux,
cmake-toolchain: "ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake",
}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Download Ninja
uses: seanmiddleditch/gha-setup-ninja@master
with:
version: ${{ env.NINJA_VERSION }}
- name: Download buildcache
id: buildcache-download
shell: cmake -P {0}
run: |
if ("${{ runner.os }}" STREQUAL "Windows")
set(buildcache_suffix "win-msvc.zip")
elseif ("${{ runner.os }}" STREQUAL "Linux")
set(buildcache_suffix "linux.tar.gz")
endif()
set(buildcache_version $ENV{BUILDCACHE_VERSION})
set(buildcache_url "https://github.com/mbitsnbites/buildcache/releases/download/v${buildcache_version}/buildcache-${buildcache_suffix}")
file(DOWNLOAD "${buildcache_url}" ./buildcache.zip)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./buildcache.zip)
if (NOT "${{ runner.os }}" STREQUAL "Windows")
execute_process(
COMMAND chmod +x buildcache/bin/buildcache
)
endif()
- name: Prepare cache timestamp
id: cache_timestamp_string
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d" UTC)
message("::set-output name=timestamp::${current_date}")
- name: Cache Buildcache
id: cache-buildcache
uses: actions/cache@v2
with:
path: ${{ env.BUILDCACHE_DIR }}
key: ${{ matrix.config.name }}-cache-v02-${{ steps.cache_timestamp_string.outputs.timestamp }}
- name: Create Folder for buildcache
run: New-Item ${{ env.BUILDCACHE_DIR }} -ItemType "directory" -Force
shell: pwsh
- name: Add buildcache to system path
run: echo "${{github.workspace}}/buildcache/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
shell: pwsh
- name: Cache Qt
id: cache-qt
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/Qt/
key: ${{ matrix.config.os }}-QtCache-5-12-12
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: 5.12.12
modules: qtscript qtcharts
dir: "${{ github.workspace }}/Qt/"
cached: ${{ steps.cache-qt.outputs.cache-hit }}
- name: Install Linux dependencies
if: "contains( matrix.config.os, 'ubuntu')"
run: sudo apt-get install libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev
- name: Get Python executable path
id: python-path
run: echo "::set-output name=PYTHON_EXECUTABLE::$(python -c 'import sys; import pathlib; print (pathlib.PurePath(sys.executable).as_posix())')"
- name: Print Python path
run: echo ${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
- name: Set vcpkg's response file path used as part of cache's key.
uses: lukka/set-shell-env@master
with:
VCPKGRESPONSEFILE: ${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}
- name: Run vcpkg
uses: lukka/run-vcpkg@v5
id: runvcpkg
with:
vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}"
vcpkgDirectory:
"${{ github.workspace }}/ThirdParty/vcpkg"
# Ensure the cache key changes any time the content of the response file changes.
appendedCacheKey: ${{ hashFiles(env.VCPKGRESPONSEFILE) }}
- name: Configure
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND "${{ matrix.config.environment_script }}" && set
OUTPUT_FILE environment_script_output.txt
)
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
execute_process(
COMMAND cmake
-S .
-B cmakebuild
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-D CMAKE_INSTALL_PREFIX=cmakebuild/install
-D RESINSIGHT_ENABLE_UNITY_BUILD=true
-D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true
-D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true
-D RESINSIGHT_ENABLE_GRPC=true
-D Eigen3_DIR=${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux/share/eigen3
-D Boost_INCLUDE_DIR=${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux/include
-D RESINSIGHT_GRPC_INSTALL_PREFIX=${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux
-D RESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
-D RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true
-D VCPKG_AUTO_INSTALL=false
-G Ninja
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Build
shell: cmake -P {0}
run: |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
execute_process(
COMMAND cmake --build cmakebuild --target install
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Stats for buildcache
run: ${{ github.workspace }}/buildcache/bin/buildcache -s
- name: Run Unit Tests
shell: bash
run: |
cmakebuild/ApplicationExeCode/ResInsight --unittest
- name: Run pytest
env:
RESINSIGHT_EXECUTABLE: ${{ runner.workspace }}/ResInsight/cmakebuild/ApplicationExeCode/ResInsight
run: |
cd GrpcInterface/Python/rips
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pytest --console
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ResInsight-${{ matrix.config.name }}
path: ${{ runner.workspace }}/ResInsight/cmakebuild/install

View File

@@ -44,7 +44,7 @@ jobs:
make -j 4
make install
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python
@@ -90,7 +90,7 @@ jobs:
ls
- name: Upload artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ResInsight
path: ./cmakebuild/packages

View File

@@ -12,7 +12,7 @@ jobs:
steps:
- name: Check for broken links
id: link-report
uses: celinekurpershoek/link-checker@v1.0.1
uses: celinekurpershoek/link-checker@v1.0.2
with:
# Required:
url: 'https://resinsight.org/'

View File

@@ -36,7 +36,7 @@ jobs:
cd Fwk/AppFwk
find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | grep -v gtest | xargs clang-format-15 -i
git diff
- uses: peter-evans/create-pull-request@v6
- uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Fixes by clang-format"

View File

@@ -12,23 +12,13 @@ on:
# Once every night
- cron: "0 1 * * *"
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
jobs:
ResInsight-x64-buildcache:
runs-on: ${{ matrix.config.os }}
ResInsight-clang-tidy:
runs-on: ubuntu-22.04
continue-on-error: true
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu 22.04",
os: ubuntu-22.04,
cc: "gcc",
cxx: "g++",
vcpkg-response-file: vcpkg_x64-linux.txt,
vcpkg-triplet: x64-linux,
cmake-toolchain: "ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake",
}
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -36,33 +26,35 @@ jobs:
submodules: true
- name: Install Linux dependencies
if: ${{contains( matrix.config.os, 'ubuntu') }}
run: |
sudo apt-get update --option="APT::Acquire::Retries=3"
sudo apt-get install --option="APT::Acquire::Retries=3" libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev
sudo apt-get install clang-tidy-15 clang-format-15
- name: Install Qt
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
with:
version: 5.12.12
modules: qtscript
dir: "${{ github.workspace }}/Qt/"
cache: true
modules: "qtnetworkauth"
- name: Run vcpkg
uses: lukka/run-vcpkg@v7
id: runvcpkg
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}"
vcpkgDirectory:
"${{ github.workspace }}/ThirdParty/vcpkg"
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: vcpkg bootstrap
run: ThirdParty/vcpkg/bootstrap-vcpkg.sh
- name: Create compile commands and run clang-tidy
# https://clang.llvm.org/extra/doxygen/run-clang-tidy_8py_source.html
run: |
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=${{ matrix.config.cmake-toolchain }} -DRESINSIGHT_USE_OPENMP=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
cmake -DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux-release -DRESINSIGHT_USE_OPENMP=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
mv compile_commands.json compile_commands_original.json
python ../scripts/fix_json_database.py compile_commands_original.json >> compile_commands.json
- name: Run clang-tidy and apply fixes, clang-format after fixes
@@ -76,7 +68,7 @@ jobs:
find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | xargs clang-format-15 -i
cd ../GrpcInterface
find -name '*.h' -o -name '*.cpp' -o -name '*.inl' | xargs clang-format-15 -i
- uses: peter-evans/create-pull-request@v6
- uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Fixes by clang-tidy"

View File

@@ -9,7 +9,7 @@ jobs:
permissions:
issues: write
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({

View File

@@ -32,7 +32,7 @@ jobs:
cd ..
git diff
- uses: peter-evans/create-pull-request@v6
- uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Fixes by cmake-format"

View File

@@ -15,7 +15,7 @@ jobs:
pip install black
cd GrpcInterface
black .
- uses: peter-evans/create-pull-request@v6
- uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Python code linting changes detected by black"

View File

@@ -11,7 +11,7 @@ jobs:
- uses: sobolevn/misspell-fixer-action@master
with:
options: "-rsvnuR ApplicationLibCode/"
- uses: peter-evans/create-pull-request@v6
- uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Fixes by misspell-fixer"

44
.github/workflows/update-submodules.yml vendored Normal file
View File

@@ -0,0 +1,44 @@
name: Update Submodules
on:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
update-submodules:
runs-on: ubuntu-latest
strategy:
matrix:
submodule:
- tomlplusplus
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Update submodules to latest release
id: git-change-job
run: |
cd ThirdParty/${{ matrix.submodule }}
git fetch --tags
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
if [ -n "$latest_tag" ]; then
git checkout $latest_tag
echo "LATEST_TAG=$latest_tag" >> "$GITHUB_OUTPUT"
else
echo "Empty tag detected in ${{ matrix.submodule }}. Nothing to do."
fi
- name: Create PR
# The generated PR does not have any tests. Close and reopen the PR to activate tests.
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update ${{ matrix.submodule }} to ${{ steps.git-change-job.outputs.LATEST_TAG }}"
title: "Update ${{ matrix.submodule }} to ${{ steps.git-change-job.outputs.LATEST_TAG }}"
branch: ci-update-${{ matrix.submodule }}
branch-suffix: random

6
.gitmodules vendored
View File

@@ -4,9 +4,6 @@
[submodule "ThirdParty/vcpkg"]
path = ThirdParty/vcpkg
url = https://github.com/microsoft/vcpkg
[submodule "ThirdParty/fast_float"]
path = ThirdParty/fast_float
url = https://github.com/fastfloat/fast_float
[submodule "ThirdParty/custom-opm-common/opm-common"]
path = ThirdParty/custom-opm-common/opm-common
url = https://github.com/CeetronSolutions/opm-common
@@ -25,6 +22,3 @@
[submodule "ThirdParty/qtadvanceddocking"]
path = ThirdParty/qtadvanceddocking
url = https://github.com/CeetronSolutions/qtadvanceddocking.git
[submodule "ThirdParty/spdlog"]
path = ThirdParty/spdlog
url = https://github.com/gabime/spdlog.git

View File

@@ -28,23 +28,27 @@ if(Qt5Core_FOUND)
Gui
OpenGL
Network
NetworkAuth
Widgets
Xml
Concurrent
PrintSupport
Svg
Sql
OPTIONAL_COMPONENTS Charts
)
set(QT_LIBRARIES
Qt5::Core
Qt5::Gui
Qt5::Network
Qt5::NetworkAuth
Qt5::OpenGL
Qt5::Widgets
Qt5::Xml
Qt5::Concurrent
Qt5::PrintSupport
Qt5::Svg
Qt5::Sql
)
if(Qt5Charts_FOUND)
list(APPEND QT_LIBRARIES Qt5::Charts)
@@ -298,12 +302,7 @@ set(UNITY_EXCLUDE_FILES
# forever is used as variable name, and this symbol is defined by Qt and
# used in precompiled headers
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
qrc_cafAnimControl.cpp
qrc_ResInsight.cpp
qrc_cafCommandFeatures.cpp
# Exclude files including opm-common
ProjectDataModel/RimVfpTableExtractor.cpp
ProjectDataModel/RimVfpPlot.cpp
qrc_cafAnimControl.cpp qrc_ResInsight.cpp qrc_cafCommandFeatures.cpp
)
if(RESINSIGHT_ENABLE_UNITY_BUILD)
@@ -484,6 +483,13 @@ if(RESINSIGHT_PRIVATE_INSTALL)
OPTIONAL
)
# Required sql driver
install(
FILES ${QT_PLUGIN_PATH}/sqldrivers/libqsqlite.so
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/sqldrivers/
OPTIONAL
)
install(FILES qt.conf DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/)
endif(RESINSIGHT_QT5_BUNDLE_LIBRARIES)
@@ -662,50 +668,6 @@ else(RESINSIGHT_PRIVATE_INSTALL)
)
endif(RESINSIGHT_PRIVATE_INSTALL)
# OpenSSL
option(RESINSIGHT_BUNDLE_OPENSSL "Bundle the OpenSSL binary library files" OFF)
mark_as_advanced(FORCE RESINSIGHT_BUNDLE_OPENSSL)
if(RESINSIGHT_BUNDLE_OPENSSL)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
find_package(OpenSSL)
if(OPENSSL_FOUND)
message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
set(OPENSSL_BIN_DIR ${OPENSSL_INCLUDE_DIR})
string(REPLACE "include" "bin" OPENSSL_BIN_DIR ${OPENSSL_BIN_DIR})
message("OpenSSL binary dir: ${OPENSSL_BIN_DIR}")
install(FILES ${OPENSSL_BIN_DIR}/libcrypto-3-x64.dll
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}
)
install(FILES ${OPENSSL_BIN_DIR}/libssl-3-x64.dll
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}
)
endif(OPENSSL_FOUND)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# Assumes that OpenSSL is installed by ./vcpkg install
# --overlay-triplets=custom-triplets --triplet x64-linux-dynamic openssl
set(OPENSSL_BIN_DIR
${CMAKE_SOURCE_DIR}/ThirdParty/vcpkg/installed/x64-linux-dynamic/lib
)
message("OpenSSL binary dir: ${OPENSSL_BIN_DIR}")
install(FILES ${OPENSSL_BIN_DIR}/libcrypto.so
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}
)
install(FILES ${OPENSSL_BIN_DIR}/libcrypto.so.3
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}
)
install(FILES ${OPENSSL_BIN_DIR}/libssl.so
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}
)
install(FILES ${OPENSSL_BIN_DIR}/libssl.so.3
DESTINATION ${RESINSIGHT_INSTALL_FOLDER}
)
endif()
endif(RESINSIGHT_BUNDLE_OPENSSL)
# ##############################################################################
# Installation packaging
# ##############################################################################
@@ -742,10 +704,6 @@ if(NOT ${OCTAVE_VERSION_STRING} EQUAL "")
)
endif()
if(RESINSIGHT_BUNDLE_OPENSSL AND OPENSSL_FOUND)
set(RESINSIGHT_PACKAGE_NAME "${RESINSIGHT_PACKAGE_NAME}_openssl")
endif()
# Append el5 when compiled on RHEL5 and el6 if compiled on RHEL6
if(NOT "${RESINSIGHT_RHEL_SYSTEM_NAME}" STREQUAL "")
set(RESINSIGHT_PACKAGE_NAME

View File

@@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs>
<style>.canvas{fill: none; opacity: 0;}.light-lightblue-10{fill: #0077a0; opacity: 0.1;}.light-lightblue{fill: #0077a0; opacity: 1;}</style>
</defs>
<title>IconLightCloud</title>
<g id="canvas" class="canvas">
<path class="canvas" d="M16,16H0V0H16Z" />
</g>
<g id="level-1">
<path class="light-lightblue-10" d="M14.518,9.25A2.239,2.239,0,0,1,12.3,11.5H4.562a3.125,3.125,0,0,1,0-6.25,2.939,2.939,0,0,1,.8.109A3.492,3.492,0,0,1,11.937,7H12.3A2.239,2.239,0,0,1,14.518,9.25Z" />
<path class="light-lightblue" d="M8.43,3ZM15,9.25A2.73,2.73,0,0,1,12.3,12H4.561a3.626,3.626,0,0,1,0-7.25,3.471,3.471,0,0,1,.567.047,3.963,3.963,0,0,1,7.255,1.7A2.732,2.732,0,0,1,15,9.25Zm-.982,0A1.735,1.735,0,0,0,12.3,7.5h-.859V7.063A3.037,3.037,0,0,0,8.43,4,3.005,3.005,0,0,0,5.622,5.988,2.521,2.521,0,0,0,4.561,5.75a2.625,2.625,0,0,0,0,5.25H12.3A1.735,1.735,0,0,0,14.018,9.25Z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 968 B

View File

@@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<defs>
<style>.canvas{fill: none; opacity: 0;}.light-lightblue-10{fill: #0077a0; opacity: 0.1;}.light-lightblue{fill: #0077a0; opacity: 1;}.light-blue{fill: #005dba; opacity: 1;}.light-defaultgrey-10{fill: #212121; opacity: 0.1;}.light-defaultgrey{fill: #212121; opacity: 1;}</style>
</defs>
<title>IconLightCloudBlobs</title>
<g id="canvas">
<path class="canvas" d="M16,16H0V0H16Z" />
</g>
<g id="level-1">
<path class="light-lightblue-10" d="M12.263,6.5h-.325l-.5-.492A3.048,3.048,0,0,0,8.43,3,3,3,0,0,0,5.8,4.6l-.575.244a2.452,2.452,0,0,0-.661-.091A2.631,2.631,0,0,0,3.582,9.8a.724.724,0,0,0,.317.116l-.586.843A3.508,3.508,0,0,0,4.562,11H7V8L8,7h4l.383.076.353.147.325.216.912.913c0-.034.009-.067.009-.1A1.737,1.737,0,0,0,12.263,6.5ZM4.2,9.966c.16.018.338.029.528.034H4.562A2.194,2.194,0,0,1,4.2,9.966Z" />
<path class="light-lightblue" d="M14.982,8.25a2.685,2.685,0,0,1-.208,1.008l-.213-.319-.588-.587c0-.034.009-.067.009-.1a1.748,1.748,0,0,0-1.1-1.627l0,0-.053-.022c-.042-.015-.084-.028-.127-.04a1.7,1.7,0,0,0-.278-.046.753.753,0,0,1-.083-.011c-.027,0-.052-.008-.078-.008h-.814V6.063c0-.016,0-.031,0-.047l-.008-.008A3.048,3.048,0,0,0,8.437,3c-.015,0-.03,0-.044,0a2.921,2.921,0,0,0-.378.03c-.079.012-.156.031-.234.049-.057.013-.114.025-.169.042a2.72,2.72,0,0,0-.271.1c-.036.014-.071.028-.106.044a3.138,3.138,0,0,0-.282.146l-.066.041a3.055,3.055,0,0,0-.283.2l-.029.025a3.073,3.073,0,0,0-.759.921l-.007,0a3.03,3.03,0,0,0-.177.388,2.659,2.659,0,0,0-.44-.152,2.515,2.515,0,0,0-.623-.085c-.067,0-.131.013-.2.018-.087.007-.175.012-.26.027-.029.007-.057.015-.086.021a2.5,2.5,0,0,0-.323.094h0c-.03.011-.059.024-.088.037l0-.008A2.637,2.637,0,0,0,3.582,9.8a2.6,2.6,0,0,0,.328.1l-.6.857c-.043-.017-.09-.024-.132-.042A3.629,3.629,0,0,1,3.975,3.81l.016,0a3.484,3.484,0,0,1,.37-.036c.068,0,.132-.021.2-.021h.017a3.557,3.557,0,0,1,.537.043A3.986,3.986,0,0,1,8.43,2h.017a4.047,4.047,0,0,1,3.97,3.5l.013,0a2.666,2.666,0,0,1,.468.068l.026.007a2.779,2.779,0,0,1,.51.18l0,.008A2.755,2.755,0,0,1,14.982,8.25Z" />
<path class="light-blue" d="M7.039,12.146v.708L5.1,14.8l-.707-.707L5.479,13H2.5V12H5.479L4.388,10.909,5.1,10.2Z" />
<path class="light-defaultgrey-10" d="M13.5,14.5h-5v-6H12L13.5,10Z" />
<path class="light-defaultgrey" d="M13.854,9.646l-1.5-1.5L12,8H8.5L8,8.5v6l.5.5h5l.5-.5V10ZM9,14V9h3v1h1v4Z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -287,6 +287,9 @@
<file>regression-curve.svg</file>
<file>padlock.svg</file>
<file>warning.svg</file>
<file>cloud-and-server.svg</file>
<file>Cloud.svg</file>
<file>CloudBlobs.svg</file>
</qresource>
<qresource prefix="/Shader">
<file>fs_CellFace.glsl</file>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21.254 17.528A4.165 4.165 0 0 0 17.094 14a4.22 4.22 0 0 0-3.685 2.137 1.717 1.717 0 0 0-.534-.092 1.67 1.67 0 0 0-1.556 1.04A2.996 2.996 0 0 0 12 23h8.018A2.918 2.918 0 0 0 23 20.136a2.858 2.858 0 0 0-1.746-2.608zM19.994 22h-7.54l-.46-.003a1.995 1.995 0 0 1-.448-3.938l.506-.118.195-.481a.67.67 0 0 1 .628-.415.734.734 0 0 1 .225.043l.777.252.402-.711A3.231 3.231 0 0 1 17.094 15a3.18 3.18 0 0 1 3.17 2.67l.08.552.51.223A1.863 1.863 0 0 1 22 20.137 1.916 1.916 0 0 1 19.995 22zM11.5 2C6.78 2 2 3.03 2 5v12.58c0 1.64 2.676 2.695 6 3.123v-1.006c-3.16-.426-5-1.381-5-2.118v-6.248C4.643 12.429 8.082 13 11.5 13s6.857-.57 8.5-1.67v2.568a5.22 5.22 0 0 1 1 .856V5c0-1.97-4.78-3-9.5-3zM20 9.848C20 10.726 16.689 12 11.5 12S3 10.726 3 9.848V6.41C4.643 7.457 8.082 8 11.5 8s6.857-.543 8.5-1.589zM11.5 7C6 7 3 5.679 3 5s3-2 8.5-2S20 4.321 20 5s-3 2-8.5 2z"/><path fill="none" d="M0 0h24v24H0z"/></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -181,7 +181,7 @@ int main( int argc, char* argv[] )
if ( file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
QTextStream out( &file );
out << portNumber << endl;
out << portNumber << "\n";
}
file.close();

View File

@@ -1,5 +1,5 @@
---
Checks: '-*,modernize-use-override,modernize-deprecated-headers,modernize-use-using,bugprone-bool-pointer-implicit-conversion,bugprone-parent-virtual-call,bugprone-redundant-branch-condition,bugprone-suspicious-semicolon,bugprone-suspicious-string-compare,modernize-redundant-void-arg,readability-static-accessed-through-instance,readability-simplify-boolean-expr,readability-container-size-empty'
Checks: '-*,modernize-use-override,modernize-deprecated-headers,modernize-use-using,modernize-make-unique,modernize-make-shared,bugprone-bool-pointer-implicit-conversion,bugprone-parent-virtual-call,bugprone-redundant-branch-condition,bugprone-suspicious-semicolon,bugprone-suspicious-string-compare,modernize-redundant-void-arg,readability-static-accessed-through-instance,readability-simplify-boolean-expr,readability-container-size-empty'
WarningsAsErrors: ''
HeaderFilterRegex: 'ApplicationLibCode/*.*$'
FormatStyle: 'file'

View File

@@ -715,3 +715,33 @@ THE SOFTWARE.
-- NOTE: Third party dependency used by this software --
This software depends on the fmt lib (MIT License),
and users must comply to its license: https://raw.githubusercontent.com/fmtlib/fmt/master/LICENSE
===============================================================================
Notice for type-lite
===============================================================================
https://github.com/martinmoene/type-lite/blob/master/LICENSE.txt
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -35,4 +35,6 @@
#define RESINSIGHT_PYTHON_VERSION "@Python3_VERSION@"
#define RESINSIGHT_GIT_HASH "@RESINSIGHT_GIT_HASH@"
#define RESINSIGHT_GIT_HASH "@RESINSIGHT_GIT_HASH@"
#define RESINSIGHT_BUILD_SYSTEM_ID "@RESINSIGHT_BUILD_SYSTEM_ID@"

View File

@@ -8,7 +8,10 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGrid.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.h
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSumo.h
${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h
${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.h
@@ -33,6 +36,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaCloudDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h
)
@@ -47,7 +52,10 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGrid.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSystem.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesOsdu.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSumo.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.cpp
@@ -72,6 +80,8 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaCloudDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp
)

View File

@@ -17,24 +17,28 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaApplication.h"
#include "RiaArgumentParser.h"
#include "Cloud/RiaConnectorTools.h"
#include "Cloud/RiaOsduConnector.h"
#include "Cloud/RiaSumoConnector.h"
#include "Cloud/RiaSumoDefines.h"
#include "RiaOsduDefines.h"
#include "RiaBaseDefs.h"
#include "RiaFilePathTools.h"
#include "RiaFontCache.h"
#include "RiaGuiApplication.h"
#include "RiaImportEclipseCaseTools.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaPreferencesSumo.h"
#include "RiaPreferencesSystem.h"
#include "RiaProjectModifier.h"
#include "RiaRegressionTestRunner.h"
#include "RiaSocketServer.h"
#include "RiaTextStringTools.h"
#include "RiaVersionInfo.h"
#include "RiaViewRedrawScheduler.h"
#include "RiaWellNameComparer.h"
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
#include "HoloLensCommands/RicHoloLensSessionManager.h"
#include "RicImportGeneralDataFeature.h"
#include "RicfCommandFileExecutor.h"
#include "RicfCommandObject.h"
@@ -43,31 +47,37 @@
#include "Polygons/RimPolygonCollection.h"
#include "Rim2dIntersectionViewCollection.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationInViewCollection.h"
#include "RimAnnotationTextAppearance.h"
#include "RimCellFilterCollection.h"
#include "RimCommandObject.h"
#include "RimCommandRouter.h"
#include "RimCompletionTemplateCollection.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCaseEnsemble.h"
#include "RimEclipseView.h"
#include "RimEclipseViewCollection.h"
#include "RimEnsembleWellLogsCollection.h"
#include "RimFaultReactivationModelCollection.h"
#include "RimFileWellPath.h"
#include "RimFileWellPathDataLoader.h"
#include "RimFormationNamesCollection.h"
#include "RimFractureTemplateCollection.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechModels.h"
#include "RimGeoMechView.h"
#include "RimGridCalculationCollection.h"
#include "RimGridSummaryCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimMainPlotCollection.h"
#include "RimModeledWellPath.h"
#include "RimModeledWellPathDataLoader.h"
#include "RimObservedDataCollection.h"
#include "RimObservedFmuRftData.h"
#include "RimObservedSummaryData.h"
#include "RimOilField.h"
#include "RimOsduWellLog.h"
#include "RimOsduWellLogDataLoader.h"
#include "RimOsduWellPath.h"
#include "RimOsduWellPathDataLoader.h"
#include "RimPlotWindow.h"
#include "RimProject.h"
#include "RimScriptCollection.h"
@@ -81,23 +91,26 @@
#include "RimStimPlanModelCollection.h"
#include "RimSummaryCalculationCollection.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryEnsemble.h"
#include "RimSurfaceCollection.h"
#include "RimTextAnnotation.h"
#include "RimTextAnnotationInView.h"
#include "RimViewLinker.h"
#include "RimViewLinkerCollection.h"
#include "RimWellLogFile.h"
#include "RimWellLogFileDataLoader.h"
#include "RimWellLogLasFile.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellPathFracture.h"
#include "VerticalFlowPerformance/RimVfpDataCollection.h"
#include "VerticalFlowPerformance/RimVfpPlotCollection.h"
#include "Riu3DMainWindowTools.h"
#include "RiuGuiTheme.h"
#include "RiuMainWindow.h"
#include "RiuViewer.h"
#include "RiuViewerCommands.h"
#include "cafDataLoadController.h"
#include "cafPdmCodeGenerator.h"
#include "cafPdmDataValueField.h"
#include "cafPdmDefaultObjectFactory.h"
@@ -111,14 +124,8 @@
#include "cafUiProcess.h"
#include "cafUtils.h"
#include "cvfProgramOptions.h"
#include "cvfqtUtils.h"
#include <QCoreApplication>
#include <QDir>
#include <QFileInfo>
#include <iostream>
#include <memory>
#ifdef WIN32
@@ -168,6 +175,8 @@ RiaApplication::RiaApplication()
setLastUsedDialogDirectory( "MULTICASEIMPORT", "/" );
m_commandRouter = std::make_unique<RimCommandRouter>();
m_osduConnector = nullptr;
m_sumoConnector = nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -178,6 +187,16 @@ RiaApplication::~RiaApplication()
RiaFontCache::clear();
caf::SelectionManager::instance()->setPdmRootObject( nullptr );
m_project.reset();
delete m_osduConnector.data();
m_osduConnector.clear();
m_osduConnector = nullptr;
delete m_sumoConnector.data();
m_sumoConnector.clear();
m_sumoConnector = nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -459,8 +478,9 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
return false;
}
m_project->fileName = fullPathProjectFileName;
m_project->setFileName( fullPathProjectFileName );
m_project->readFile();
m_project->updatesAfterProjectFileIsRead();
// Apply any modifications to the loaded project before we go ahead and load actual data
if ( projectModifier )
@@ -491,6 +511,11 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
return true;
}
// At this point, all the file paths variables are replaced and all file paths updated to the new location. This will enable use of file
// paths in initAfterRead().
m_project->resolveReferencesRecursively();
m_project->initAfterReadRecursively();
// Migrate all RimGridCases to RimFileSummaryCase
RimGridSummaryCase_obsolete::convertGridCasesToSummaryFileCases( m_project.get() );
@@ -537,8 +562,17 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
}
// Initialize well paths
oilField->wellPathCollection->loadDataAndUpdate();
if ( !oilField->wellPathCollection->loadDataAndUpdate() )
{
// Opening well path was cancelled or failed: close project.
closeProject();
m_project = std::make_unique<RimProject>();
onProjectOpened();
return true;
}
oilField->ensembleWellLogsCollection->loadDataAndUpdate();
oilField->vfpDataCollection->loadDataAndUpdate();
// Initialize seismic data
auto& seisDataColl = oilField->seismicDataCollection();
@@ -553,6 +587,10 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
{
RimMainPlotCollection* mainPlotColl = RimMainPlotCollection::current();
mainPlotColl->ensureDefaultFlowPlotsAreCreated();
// RimVfpTable are not presisted in the project file, and are created in vfpDataCollection->loadDataAndUpdate(). Existing VFP
// plots will have references to RimVfpTables. Call resolveReferencesRecursively() to update the references to RimVfpTable objects.
mainPlotColl->vfpPlotCollection()->resolveReferencesRecursively();
}
for ( RimOilField* oilField : m_project->oilFields )
@@ -677,6 +715,20 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
}
}
// Load all grid ensemble views
{
auto gridCaseEnsembles = m_project->activeOilField()->analysisModels()->caseEnsembles.childrenByType();
for ( auto gridCaseEnsemble : gridCaseEnsembles )
{
auto views = gridCaseEnsemble->viewCollection()->views();
for ( auto view : views )
{
view->loadDataAndUpdate();
}
}
}
if ( m_project->viewLinkerCollection() && m_project->viewLinkerCollection()->viewLinker() )
{
m_project->viewLinkerCollection()->viewLinker()->updateOverrides();
@@ -690,10 +742,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
}
{
std::vector<Rim3dView*> views;
m_project->allViews( views );
for ( auto view : views )
for ( auto view : m_project->allViews() )
{
if ( auto eclipseView = dynamic_cast<RimEclipseView*>( view ) )
{
@@ -723,8 +772,6 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
sumCaseGroup->loadDataAndUpdate();
}
oilField->annotationCollection()->loadDataAndUpdate();
for ( auto well : oilField->wellPathCollection()->allWellPaths() )
{
for ( auto stimPlan : well->stimPlanModelCollection()->allStimPlanModels() )
@@ -800,7 +847,7 @@ bool RiaApplication::saveProjectAs( const QString& fileName, gsl::not_null<QStri
{
CAF_ASSERT( m_project );
// Make sure we always store path with forward slash to avoid issues when opening the project file on Linux
m_project->fileName = RiaFilePathTools::toInternalSeparator( fileName );
m_project->setFileName( RiaFilePathTools::toInternalSeparator( fileName ) );
onProjectBeingSaved();
@@ -1072,7 +1119,7 @@ QStringList RiaApplication::octaveArguments() const
QStringList arguments;
arguments.append( "--path" );
arguments << QApplication::applicationDirPath();
arguments << QCoreApplication::applicationDirPath();
if ( !m_preferences->octaveShowHeaderInfoWhenExecutingScripts() )
{
@@ -1100,9 +1147,9 @@ QProcessEnvironment RiaApplication::octaveProcessEnvironment() const
QString pathString = penv.value( "PATH", "" );
if ( pathString == "" )
pathString = QApplication::applicationDirPath() + "\\octave_plugin_dependencies";
pathString = QCoreApplication::applicationDirPath() + "\\octave_plugin_dependencies";
else
pathString = QApplication::applicationDirPath() + "\\octave_plugin_dependencies" + ";" + pathString;
pathString = QCoreApplication::applicationDirPath() + "\\octave_plugin_dependencies" + ";" + pathString;
penv.insert( "PATH", pathString );
#else
@@ -1110,9 +1157,9 @@ QProcessEnvironment RiaApplication::octaveProcessEnvironment() const
QString ldPath = penv.value( "LD_LIBRARY_PATH", "" );
if ( ldPath == "" )
ldPath = QApplication::applicationDirPath();
ldPath = QCoreApplication::applicationDirPath();
else
ldPath = QApplication::applicationDirPath() + ":" + ldPath;
ldPath = QCoreApplication::applicationDirPath() + ":" + ldPath;
penv.insert( "LD_LIBRARY_PATH", ldPath );
#endif
@@ -1510,6 +1557,59 @@ cvf::Font* RiaApplication::defaultWellLabelFont()
return m_defaultWellLabelFont.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
auto readCloudConfigFiles = []( RiaPreferences* preferences )
{
if ( preferences == nullptr ) return;
// Check multiple locations for configuration files. The first valid configuration file is used. Currently, using Qt5 the ResInsight
// binary file is stored at the root of the installation folder. When moving to Qt6, we will probably use sub folders /bin /lib and
// others. Support both one and two search levels to support Qt6.
//
// home_folder/.resinsight/*_config.json
// location_of_resinsight_executable/../share/cloud_services/*_config.json
// location_of_resinsight_executable/../../share/cloud_services/*_config.json
//
{
QStringList osduFilePathCandidates;
osduFilePathCandidates << QDir::homePath() + "/.resinsight/osdu_config.json";
osduFilePathCandidates << QCoreApplication::applicationDirPath() + "/../share/cloud_services/osdu_config.json";
osduFilePathCandidates << QCoreApplication::applicationDirPath() + "/../../share/cloud_services/osdu_config.json";
for ( const auto& osduFileCandidate : osduFilePathCandidates )
{
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( osduFileCandidate );
if ( !keyValuePairs.empty() )
{
preferences->osduPreferences()->setData( keyValuePairs );
preferences->osduPreferences()->setFieldsReadOnly();
break;
}
}
}
{
QStringList sumoFilePathCandidates;
sumoFilePathCandidates << QDir::homePath() + "/.resinsight/sumo_config.json";
sumoFilePathCandidates << QCoreApplication::applicationDirPath() + "/../share/cloud_services/sumo_config.json";
sumoFilePathCandidates << QCoreApplication::applicationDirPath() + "/../../share/cloud_services/sumo_config.json";
for ( const auto& sumoFileCandidate : sumoFilePathCandidates )
{
auto keyValuePairs = RiaConnectorTools::readKeyValuePairs( sumoFileCandidate );
if ( !keyValuePairs.empty() )
{
preferences->sumoPreferences()->setData( keyValuePairs );
preferences->sumoPreferences()->setFieldsReadOnly();
break;
}
}
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1526,6 +1626,10 @@ void RiaApplication::initialize()
m_project->setPlotTemplateFolders( m_preferences->plotTemplateFolders() );
caf::SelectionManager::instance()->setPdmRootObject( project() );
initializeDataLoadController();
readCloudConfigFiles( m_preferences.get() );
}
//--------------------------------------------------------------------------------------------------
@@ -1682,3 +1786,90 @@ bool RiaApplication::generateCode( const QString& fileName, gsl::not_null<QStrin
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaOsduConnector* RiaApplication::makeOsduConnector()
{
if ( m_osduConnector ) return m_osduConnector;
if ( !QSslSocket::supportsSsl() )
{
QString errMsg = "SSL support is not available. ";
#ifdef Q_OS_WIN
errMsg +=
"Make sure that the SSL libraries are available (on Windows platform, they are called 'libcrypto*.dll' and 'libssl*.dll').";
#endif
RiaLogging::errorInMessageBox( nullptr, "OSDU Service Connection", errMsg );
return nullptr;
}
RiaPreferencesOsdu* osduPreferences = preferences()->osduPreferences();
const QString server = osduPreferences->server();
const QString dataPartitionId = osduPreferences->dataPartitionId();
const QString authority = osduPreferences->authority();
const QString scopes = osduPreferences->scopes();
const QString clientId = osduPreferences->clientId();
const unsigned int port = 35327;
m_osduConnector = new RiaOsduConnector( RiuMainWindow::instance(), server, dataPartitionId, authority, scopes, clientId, port );
m_osduConnector->setTokenDataFilePath( RiaOsduDefines::tokenPath() );
m_osduConnector->importTokenFromFile();
return m_osduConnector;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSumoConnector* RiaApplication::makeSumoConnector()
{
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
{
return nullptr;
}
if ( !m_sumoConnector )
{
auto sumoPrefs = preferences()->sumoPreferences();
const QString server = sumoPrefs->server();
const QString authority = sumoPrefs->authority();
const QString scopes = sumoPrefs->scopes();
const QString clientId = sumoPrefs->clientId();
const unsigned int port = 53527;
m_sumoConnector = new RiaSumoConnector( RiuMainWindow::instance(), server, authority, scopes, clientId, port );
m_sumoConnector->setTokenDataFilePath( RiaSumoDefines::tokenPath() );
m_sumoConnector->importTokenFromFile();
}
return m_sumoConnector;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::initializeDataLoadController()
{
caf::DataLoadController* dataLoadController = caf::DataLoadController::instance();
const QString wellPathGeometryKeyword = "WELL_PATH_GEOMETRY";
dataLoadController->registerDataLoader( RimFileWellPath::classKeywordStatic(),
wellPathGeometryKeyword,
std::make_unique<RimFileWellPathDataLoader>() );
dataLoadController->registerDataLoader( RimOsduWellPath::classKeywordStatic(),
wellPathGeometryKeyword,
std::make_unique<RimOsduWellPathDataLoader>() );
dataLoadController->registerDataLoader( RimModeledWellPath::classKeywordStatic(),
wellPathGeometryKeyword,
std::make_unique<RimModeledWellPathDataLoader>() );
const QString wellLogKeyword = "WELL_LOG";
dataLoadController->registerDataLoader( RimWellLogLasFile::classKeywordStatic(),
wellLogKeyword,
std::make_unique<RimWellLogFileDataLoader>() );
dataLoadController->registerDataLoader( RimWellLogFile::classKeywordStatic(), wellLogKeyword, std::make_unique<RimWellLogFileDataLoader>() );
dataLoadController->registerDataLoader( RimOsduWellLog::classKeywordStatic(), wellLogKeyword, std::make_unique<RimOsduWellLogDataLoader>() );
}

View File

@@ -68,6 +68,8 @@ class RiuMainWindowBase;
class RiuPlotMainWindow;
class RiuRecentFileActionProvider;
class RiaArgumentParser;
class RiaOsduConnector;
class RiaSumoConnector;
namespace caf
{
@@ -182,8 +184,6 @@ public:
void executeCommandObjects();
void waitUntilCommandObjectsHasBeenProcessed();
int launchUnitTests();
const QString startDir() const;
void setStartDir( const QString& startDir );
@@ -200,6 +200,9 @@ public:
virtual void addToRecentFiles( const QString& fileName ) {}
virtual void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) = 0;
RiaOsduConnector* makeOsduConnector();
RiaSumoConnector* makeSumoConnector();
protected:
// Protected implementation specific overrides
virtual void invokeProcessEvents( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) = 0;
@@ -224,6 +227,8 @@ protected:
bool generateCode( const QString& outputPath, gsl::not_null<QString*> errMsg );
protected:
void initializeDataLoadController();
cvf::ref<cvf::Font> m_defaultSceneFont;
cvf::ref<cvf::Font> m_defaultAnnotationFont;
cvf::ref<cvf::Font> m_defaultWellLabelFont;
@@ -254,5 +259,7 @@ protected:
bool m_runningWorkerProcess;
private:
static RiaApplication* s_riaApplication;
static RiaApplication* s_riaApplication;
QPointer<RiaOsduConnector> m_osduConnector;
QPointer<RiaSumoConnector> m_sumoConnector;
};

View File

@@ -1,7 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
// Copyright (C) 2024- 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
@@ -17,29 +16,28 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellLogFileChannel.h"
#include "RiaFieldHandleTools.h"
#include <QString>
CAF_PDM_SOURCE_INIT( RimWellLogFileChannel, "WellLogFileChannel" );
#include "RiaCloudDefines.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogFileChannel::RimWellLogFileChannel()
QString RiaCloudDefines::contentTypeJson()
{
CAF_PDM_InitObject( "Well Log File Channel" );
CAF_PDM_InitFieldNoDefault( &m_name, "Name", "" );
RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_name );
return "application/json";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogFileChannel::setName( const QString& name )
QString RiaCloudDefines::contentTypeParquet()
{
m_name = name;
return "application/x-parquet";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaCloudDefines::requestTokenTimeoutMillis()
{
return 120 * 1000;
}

View File

@@ -0,0 +1,28 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
namespace RiaCloudDefines
{
QString contentTypeJson();
QString contentTypeParquet();
int requestTokenTimeoutMillis();
}; // namespace RiaCloudDefines

View File

@@ -20,6 +20,7 @@
#include "RiaArgumentParser.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "RiaPreferencesGrid.h"
#include "RiaProjectModifier.h"
#include "RiaSocketServer.h"
#include "RiaVersionInfo.h"
@@ -161,6 +162,13 @@ RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::n
setStartDir( cvfqt::Utils::toQString( o.value( 0 ) ) );
}
if ( cvf::Option o = progOpt->option( "egridReader" ) )
{
CVF_ASSERT( o.valueCount() == 1 );
std::string readerName = o.value( 0 ).toLower().toStdString();
m_preferences->gridPreferences()->setGridModelReaderOverride( readerName );
}
QString projectFileName;
if ( progOpt->hasOption( "last" ) )

View File

@@ -19,7 +19,7 @@
#include "RiaCurveSetDefinition.h"
#include "RifSummaryReaderInterface.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryEnsemble.h"
//--------------------------------------------------------------------------------------------------
///
@@ -32,7 +32,7 @@ RiaCurveSetDefinition::RiaCurveSetDefinition()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaCurveSetDefinition::RiaCurveSetDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddress )
RiaCurveSetDefinition::RiaCurveSetDefinition( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& summaryAddress )
: m_ensemble( ensemble )
, m_summaryAddress( summaryAddress )
{
@@ -41,7 +41,7 @@ RiaCurveSetDefinition::RiaCurveSetDefinition( RimSummaryCaseCollection* ensemble
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCaseCollection* RiaCurveSetDefinition::ensemble() const
RimSummaryEnsemble* RiaCurveSetDefinition::ensemble() const
{
return m_ensemble;
}

View File

@@ -25,7 +25,7 @@
#include <utility>
#include <vector>
class RimSummaryCaseCollection;
class RimSummaryEnsemble;
//==================================================================================================
///
@@ -34,14 +34,14 @@ class RiaCurveSetDefinition
{
public:
RiaCurveSetDefinition();
explicit RiaCurveSetDefinition( RimSummaryCaseCollection* emsemble, const RifEclipseSummaryAddress& summaryAddress );
explicit RiaCurveSetDefinition( RimSummaryEnsemble* emsemble, const RifEclipseSummaryAddress& summaryAddress );
RimSummaryCaseCollection* ensemble() const;
RimSummaryEnsemble* ensemble() const;
const RifEclipseSummaryAddress& summaryAddress() const;
bool operator<( const RiaCurveSetDefinition& other ) const;
private:
RimSummaryCaseCollection* m_ensemble;
RifEclipseSummaryAddress m_summaryAddress;
RimSummaryEnsemble* m_ensemble;
RifEclipseSummaryAddress m_summaryAddress;
};

View File

@@ -65,10 +65,10 @@ void caf::AppEnum<RiaDefines::DepthUnitType>::setUp()
template <>
void caf::AppEnum<RiaDefines::GridModelReader>::setUp()
{
addItem( RiaDefines::GridModelReader::LIBECL, "LIBECL", "libecl" );
addItem( RiaDefines::GridModelReader::RESDATA, "RESDATA", "resdata", { "LIBECL" } );
addItem( RiaDefines::GridModelReader::OPM_COMMON, "OPM_COMMON", "opm-common (beta)" );
setDefault( RiaDefines::GridModelReader::LIBECL );
setDefault( RiaDefines::GridModelReader::RESDATA );
}
template <>
@@ -374,3 +374,11 @@ std::vector<double> RiaDefines::viewScaleOptions()
{
return { 0.005, 0.01, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 50.0 };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::betaFeaturePostfix()
{
return " [BETA]";
}

View File

@@ -172,8 +172,9 @@ enum class GridCaseAxis
enum class GridModelReader
{
LIBECL,
OPM_COMMON
RESDATA,
OPM_COMMON,
NOT_SET
};
enum class ThemeEnum
@@ -251,6 +252,8 @@ enum class ItemIn3dView
ALL = 0b00000011
};
QString betaFeaturePostfix();
}; // namespace RiaDefines
// Activate bit mask operators at global scope

View File

@@ -31,7 +31,7 @@ template <typename T>
class AppEnum;
}
class RimSummaryCaseCollection;
class RimSummaryEnsemble;
//==================================================================================================
///

View File

@@ -30,6 +30,7 @@
#include "RiaLogging.h"
#include "RiaPlotWindowRedrawScheduler.h"
#include "RiaPreferences.h"
#include "RiaPreferencesGrid.h"
#include "RiaPreferencesSystem.h"
#include "RiaProjectModifier.h"
#include "RiaRegressionTestRunner.h"
@@ -76,8 +77,8 @@
#include "RimSimWellInViewCollection.h"
#include "RimStimPlanColors.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryEnsemble.h"
#include "RimSummaryPlot.h"
#include "RimTextAnnotation.h"
#include "RimTextAnnotationInView.h"
@@ -189,7 +190,10 @@ RiaGuiApplication::RiaGuiApplication( int& argc, char** argv )
//--------------------------------------------------------------------------------------------------
RiaGuiApplication::~RiaGuiApplication()
{
delete m_mainWindow.data();
m_mainWindow.clear();
m_mainPlotWindow.reset();
}
//--------------------------------------------------------------------------------------------------
@@ -521,6 +525,13 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n
setStartDir( cvfqt::Utils::toQString( o.value( 0 ) ) );
}
if ( cvf::Option o = progOpt->option( "egridReader" ) )
{
CVF_ASSERT( o.valueCount() == 1 );
std::string readerName = o.value( 0 ).toLower().toStdString();
m_preferences->gridPreferences()->setGridModelReaderOverride( readerName );
}
if ( cvf::Option o = progOpt->option( "size" ) )
{
int width = o.safeValue( 0 ).toInt( -1 );

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
// Copyright (C) 2024- 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
@@ -16,68 +16,55 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimOilRegionEntry.h"
#include "RimOilFieldEntry.h"
#include "RiaOsduDefines.h"
CAF_PDM_SOURCE_INIT( RimOilRegionEntry, "RimOilRegionEntry" );
#include <QDir>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimOilRegionEntry::RimOilRegionEntry()
QString RiaOsduDefines::osduFieldKind()
{
CAF_PDM_InitObject( "OilRegionEntry" );
CAF_PDM_InitFieldNoDefault( &name, "OilRegionEntry", "OilRegionEntry" );
CAF_PDM_InitFieldNoDefault( &fields, "Fields", "" );
CAF_PDM_InitField( &selected, "Selected", false, "Selected" );
return "osdu:wks:master-data--Field:1.0.0";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimOilRegionEntry::~RimOilRegionEntry()
QString RiaOsduDefines::osduWellKind()
{
fields.deleteChildren();
return "osdu:wks:master-data--Well:1.*.*";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimOilRegionEntry::userDescriptionField()
QString RiaOsduDefines::osduWellboreKind()
{
return &name;
return "osdu:wks:master-data--Wellbore:1.*.*";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimOilRegionEntry::objectToggleField()
QString RiaOsduDefines::osduWellboreTrajectoryKind()
{
return &selected;
return "osdu:wks:work-product-component--WellboreTrajectory:1.*.*";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOilRegionEntry::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
QString RiaOsduDefines::osduWellLogKind()
{
if ( &selected == changedField )
{
updateState();
}
return "osdu:wks:work-product-component--WellLog:1.*.*";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOilRegionEntry::updateState()
QString RiaOsduDefines::tokenPath()
{
for ( size_t i = 0; i < fields.size(); i++ )
{
fields[i]->setUiReadOnly( !selected );
fields[i]->updateEnabledState();
}
QString homePath = QDir::homePath();
return homePath + "/.resinsight/osdu_token.json";
}

View File

@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
namespace RiaOsduDefines
{
QString osduFieldKind();
QString osduWellKind();
QString osduWellboreKind();
QString osduWellboreTrajectoryKind();
QString osduWellLogKind();
QString tokenPath();
}; // namespace RiaOsduDefines

View File

@@ -23,13 +23,15 @@
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaLogging.h"
#include "RiaPreferencesGeoMech.h"
#include "RiaPreferencesGrid.h"
#include "RiaPreferencesSummary.h"
#include "RiaPreferencesSumo.h"
#include "RiaPreferencesSystem.h"
#include "RiaQDateTimeTools.h"
#include "RiaValidRegExpValidator.h"
#include "RifReaderSettings.h"
#include "RiuGuiTheme.h"
#include "cafPdmFieldCvfColor.h"
@@ -143,8 +145,7 @@ RiaPreferences::RiaPreferences()
CAF_PDM_InitField( &m_loggerFlushInterval, "loggerFlushInterval", 500, "Logging Flush Interval [ms]" );
CAF_PDM_InitField( &m_loggerTrapSignalAndFlush, "loggerTrapSignalAndFlush", false, "Trap SIGNAL and Flush File Logs" );
CAF_PDM_InitField( &ssihubAddress, "ssihubAddress", QString( "http://" ), "SSIHUB Address" );
ssihubAddress.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
CAF_PDM_InitField( &m_storeBackupOfProjectFile, "storeBackupOfProjectFile", true, "Store Backup of Project Files" );
CAF_PDM_InitFieldNoDefault( &m_defaultMeshModeType, "defaultMeshModeType", "Show Grid Lines" );
CAF_PDM_InitField( &defaultGridLineColors, "defaultGridLineColors", RiaColorTables::defaultGridLineColor(), "Mesh Color" );
@@ -190,18 +191,6 @@ RiaPreferences::RiaPreferences()
CAF_PDM_InitFieldNoDefault( &lastUsedProjectFileName, "lastUsedProjectFileName", "Last Used Project File" );
lastUsedProjectFileName.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &autocomputeDepthRelatedProperties,
"autocomputeDepth",
true,
"Compute DEPTH Related Properties",
"",
"DEPTH, DX, DY, DZ, TOP, BOTTOM",
"" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &autocomputeDepthRelatedProperties );
CAF_PDM_InitField( &loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &loadAndShowSoil );
CAF_PDM_InitField( &holoLensDisableCertificateVerification,
"holoLensDisableCertificateVerification",
false,
@@ -210,10 +199,6 @@ RiaPreferences::RiaPreferences()
CAF_PDM_InitField( &csvTextExportFieldSeparator, "csvTextExportFieldSeparator", QString( "," ), "CSV Text Export Field Separator" );
CAF_PDM_InitFieldNoDefault( &m_gridModelReader, "gridModelReader", "Grid Model Reader" );
CAF_PDM_InitFieldNoDefault( &m_readerSettings, "readerSettings", "Reader Settings" );
m_readerSettings = new RifReaderSettings;
CAF_PDM_InitFieldNoDefault( &m_dateFormat, "dateFormat", "Date Format" );
m_dateFormat.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
m_dateFormat = RiaQDateTimeTools::supportedDateFormats().front();
@@ -275,11 +260,20 @@ RiaPreferences::RiaPreferences()
CAF_PDM_InitFieldNoDefault( &m_summaryPreferences, "summaryPreferences", "summaryPreferences" );
m_summaryPreferences = new RiaPreferencesSummary;
CAF_PDM_InitFieldNoDefault( &m_gridPreferences, "gridPreferences", "gridPreferences" );
m_gridPreferences = new RiaPreferencesGrid();
CAF_PDM_InitFieldNoDefault( &m_geoMechPreferences, "geoMechPreferences", "geoMechPreferences" );
m_geoMechPreferences = new RiaPreferencesGeoMech;
CAF_PDM_InitFieldNoDefault( &m_systemPreferences, "systemPreferences", "systemPreferences" );
m_systemPreferences = new RiaPreferencesSystem;
CAF_PDM_InitFieldNoDefault( &m_osduPreferences, "osduPreferences", "osduPreferences" );
m_osduPreferences = new RiaPreferencesOsdu;
CAF_PDM_InitFieldNoDefault( &m_sumoPreferences, "sumoPreferences", "sumoPreferences" );
m_sumoPreferences = new RiaPreferencesSumo;
}
//--------------------------------------------------------------------------------------------------
@@ -287,7 +281,6 @@ RiaPreferences::RiaPreferences()
//--------------------------------------------------------------------------------------------------
RiaPreferences::~RiaPreferences()
{
delete m_readerSettings;
}
//--------------------------------------------------------------------------------------------------
@@ -303,7 +296,6 @@ RiaPreferences* RiaPreferences::current()
//--------------------------------------------------------------------------------------------------
void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
m_readerSettings->defineEditorAttribute( field, uiConfigName, attribute );
m_summaryPreferences->defineEditorAttribute( field, uiConfigName, attribute );
{
@@ -379,20 +371,21 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
viewsGroup->add( &m_showInfoBox );
viewsGroup->add( &m_showGridBox, { .newRow = false, .totalColumnSpan = 1 } );
caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging and Backup" );
loggingGroup->add( &m_storeBackupOfProjectFile );
loggingGroup->add( &m_loggerFilename );
loggingGroup->add( &m_loggerFlushInterval );
loggingGroup->add( &m_loggerTrapSignalAndFlush );
m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup( "Other" );
otherGroup->add( &ssihubAddress );
otherGroup->add( &holoLensDisableCertificateVerification );
otherGroup->add( &m_useUndoRedo );
}
else if ( uiConfigName == RiaPreferences::tabNameGrid() )
{
uiOrdering.add( &m_gridModelReader );
caf::PdmUiGroup* newCaseBehaviourGroup = uiOrdering.addNewGroup( "Behavior When Loading Data" );
newCaseBehaviourGroup->add( &autocomputeDepthRelatedProperties );
newCaseBehaviourGroup->add( &loadAndShowSoil );
m_readerSettings->uiOrdering( uiConfigName, *newCaseBehaviourGroup );
m_gridPreferences()->appendItems( uiOrdering );
}
else if ( uiConfigName == RiaPreferences::tabNameSummary() )
{
@@ -481,12 +474,13 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
otherGroup->add( &m_gridCalculationExpressionFolder );
otherGroup->add( &m_summaryCalculationExpressionFolder );
caf::PdmUiGroup* loggingGroup = uiOrdering.addNewGroup( "Logging" );
loggingGroup->add( &m_loggerFilename );
loggingGroup->add( &m_loggerFlushInterval );
loggingGroup->add( &m_loggerTrapSignalAndFlush );
m_loggerTrapSignalAndFlush.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
m_loggerFlushInterval.uiCapability()->setUiReadOnly( !m_loggerFilename().first );
caf::PdmUiGroup* osduGroup = uiOrdering.addNewGroup( "OSDU" );
osduGroup->setCollapsedByDefault();
m_osduPreferences()->uiOrdering( uiConfigName, *osduGroup );
caf::PdmUiGroup* sumoGroup = uiOrdering.addNewGroup( "SUMO" );
sumoGroup->setCollapsedByDefault();
m_sumoPreferences()->uiOrdering( uiConfigName, *sumoGroup );
}
else if ( RiaApplication::enableDevelopmentFeatures() && uiConfigName == RiaPreferences::tabNameSystem() )
{
@@ -664,22 +658,6 @@ QStringList RiaPreferences::tabNames()
return names;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RifReaderSettings* RiaPreferences::readerSettings() const
{
return m_readerSettings;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaDefines::GridModelReader RiaPreferences::gridModelReader() const
{
return m_gridModelReader();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1005,6 +983,14 @@ bool RiaPreferences::loggerTrapSignalAndFlush() const
return m_loggerTrapSignalAndFlush();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferences::storeBackupOfProjectFiles() const
{
return m_storeBackupOfProjectFile();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1029,6 +1015,22 @@ RiaPreferencesGeoMech* RiaPreferences::geoMechPreferences() const
return m_geoMechPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesOsdu* RiaPreferences::osduPreferences() const
{
return m_osduPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesSumo* RiaPreferences::sumoPreferences() const
{
return m_sumoPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1036,3 +1038,11 @@ bool RiaPreferences::enableFaultsByDefault() const
{
return m_enableFaultsByDefault;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesGrid* RiaPreferences::gridPreferences() const
{
return m_gridPreferences();
}

View File

@@ -24,6 +24,7 @@
#include "RiaDateTimeDefines.h"
#include "RiaDefines.h"
#include "RiaFontCache.h"
#include "RiaPreferencesOsdu.h"
#include "cafAppEnum.h"
#include "cafPdmChildField.h"
@@ -38,11 +39,14 @@
#include <QStringList>
#include <map>
#include <string>
class RifReaderSettings;
class RiaPreferencesSummary;
class RiaPreferencesGeoMech;
class RiaPreferencesSystem;
class RiaPreferencesOsdu;
class RiaPreferencesGrid;
class RiaPreferencesSumo;
//--------------------------------------------------------------------------------------------------
///
@@ -55,7 +59,6 @@ public:
using FontSizeEnum = RiaFontCache::FontSizeEnum;
using PageSizeEnum = caf::AppEnum<QPageSize::PageSizeId>;
using PageOrientationEnum = caf::AppEnum<QPageLayout::Orientation>;
using GridModelEnum = caf::AppEnum<RiaDefines::GridModelReader>;
bool enableFaultsByDefault() const;
@@ -67,9 +70,6 @@ public:
QStringList tabNames();
const RifReaderSettings* readerSettings() const;
RiaDefines::GridModelReader gridModelReader() const;
bool useUndoRedo() const;
const QString& dateFormat() const;
@@ -124,10 +124,14 @@ public:
QString loggerFilename() const;
int loggerFlushInterval() const;
bool loggerTrapSignalAndFlush() const;
bool storeBackupOfProjectFiles() const;
RiaPreferencesGeoMech* geoMechPreferences() const;
RiaPreferencesSummary* summaryPreferences() const;
RiaPreferencesSystem* systemPreferences() const;
RiaPreferencesOsdu* osduPreferences() const;
RiaPreferencesSumo* sumoPreferences() const;
RiaPreferencesGrid* gridPreferences() const;
public:
caf::PdmField<bool> enableGrpcServer;
@@ -137,8 +141,6 @@ public:
caf::PdmField<QString> scriptEditorExecutable;
caf::PdmField<bool> showPythonDebugInfo;
caf::PdmField<QString> ssihubAddress;
caf::PdmField<cvf::Color3f> defaultGridLineColors;
caf::PdmField<cvf::Color3f> defaultFaultGridLineColors;
caf::PdmField<cvf::Color3f> defaultViewerBackgroundColor;
@@ -151,9 +153,6 @@ public:
caf::PdmField<QString> lastUsedProjectFileName;
caf::PdmField<bool> autocomputeDepthRelatedProperties;
caf::PdmField<bool> loadAndShowSoil;
caf::PdmField<bool> holoLensDisableCertificateVerification;
caf::PdmField<QString> csvTextExportFieldSeparator;
@@ -177,9 +176,6 @@ private:
static double defaultMarginSize( QPageSize::PageSizeId pageSizeId );
private:
caf::PdmField<GridModelEnum> m_gridModelReader;
caf::PdmChildField<RifReaderSettings*> m_readerSettings;
caf::PdmField<QString> m_dateFormat;
caf::PdmField<QString> m_timeFormat;
@@ -219,12 +215,17 @@ private:
caf::PdmField<int> m_loggerFlushInterval;
caf::PdmField<bool> m_loggerTrapSignalAndFlush;
caf::PdmField<bool> m_storeBackupOfProjectFile;
// Surface Import
caf::PdmField<double> m_surfaceImportResamplingDistance;
// Well Path Import
caf::PdmField<QString> m_multiLateralWellPattern;
// Grid import
caf::PdmChildField<RiaPreferencesGrid*> m_gridPreferences;
// GeoMech things
caf::PdmChildField<RiaPreferencesGeoMech*> m_geoMechPreferences;
@@ -234,6 +235,10 @@ private:
// System settings
caf::PdmChildField<RiaPreferencesSystem*> m_systemPreferences;
// Osdu settings
caf::PdmChildField<RiaPreferencesOsdu*> m_osduPreferences;
caf::PdmChildField<RiaPreferencesSumo*> m_sumoPreferences;
// 3d view
caf::PdmField<caf::AppEnum<RiaDefines::MeshModeType>> m_defaultMeshModeType;
caf::PdmField<caf::AppEnum<RiaDefines::RINavigationPolicy>> m_navigationPolicy;

View File

@@ -0,0 +1,318 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 - 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaPreferencesGrid.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
#include "cafPdmUiCheckBoxEditor.h"
CAF_PDM_SOURCE_INIT( RiaPreferencesGrid, "RifReaderSettings" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesGrid::RiaPreferencesGrid()
: m_gridModelReaderOverride( RiaDefines::GridModelReader::NOT_SET )
{
CAF_PDM_InitObject( "RiaPreferencesGrid" );
CAF_PDM_InitFieldNoDefault( &m_gridModelReader, "gridModelReader", "Model Reader" );
m_gridModelReader = RiaDefines::GridModelReader::RESDATA;
CAF_PDM_InitField( &m_importFaults, "importFaults", true, "Import Faults" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_importFaults );
CAF_PDM_InitField( &m_importNNCs, "importSimulationNNCs", true, "Import NNCs" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_importNNCs );
CAF_PDM_InitField( &m_includeInactiveCellsInFaultGeometry,
"includeInactiveCellsInFaultGeometry",
false,
"Include Inactive Cells in Fault Geometry" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_includeInactiveCellsInFaultGeometry );
CAF_PDM_InitField( &m_importAdvancedMswData, "importAdvancedMswData", true, "Import Advanced MSW Data" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_importAdvancedMswData );
CAF_PDM_InitField( &m_useResultIndexFile,
"useResultIndexFile",
false,
"Use Result Index File",
"",
"After import of a result file, store index data in an index file in the same folder as the "
"result file.\n"
"Import of result data if a result index file is present, will reduce file parsing "
"significantly.",
"" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useResultIndexFile );
CAF_PDM_InitField( &m_skipWellData, "skipWellData", false, "Skip Import of Simulation Well Data" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_skipWellData );
CAF_PDM_InitField( &m_includeFileAbsolutePathPrefix,
"includeFileAbsolutePathPrefix",
QString(),
"Include File Absolute Path Prefix",
"",
"Path used to prefix absolute UNIX paths in include statements on Windows, used when searching "
"for FAULTS and EQUIL",
"" );
CAF_PDM_InitField( &m_autoComputeDepthRelatedProperties,
"autocomputeDepth",
true,
"Compute DEPTH Related Properties",
"",
"DEPTH, DX, DY, DZ, TOP, BOTTOM",
"" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_autoComputeDepthRelatedProperties );
CAF_PDM_InitField( &m_loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_loadAndShowSoil );
CAF_PDM_InitField( &m_onlyLoadActiveCells, "onlyLoadActiveCells", false, "Only Load Active Cell Geometry (Experimental)" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_onlyLoadActiveCells );
CAF_PDM_InitField( &m_invalidateLongThinCells, "invalidateLongThinCells", false, "Skip Long, Thin Cells" );
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_invalidateLongThinCells );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesGrid* RiaPreferencesGrid::current()
{
return RiaApplication::instance()->preferences()->gridPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPreferencesGrid::appendItems( caf::PdmUiOrdering& uiOrdering )
{
auto newCBGroup = uiOrdering.addNewGroup( "Behavior When Loading Data" );
newCBGroup->add( &m_autoComputeDepthRelatedProperties );
newCBGroup->add( &m_loadAndShowSoil );
newCBGroup->add( &m_invalidateLongThinCells );
auto faultGrp = uiOrdering.addNewGroup( "Fault Import" );
faultGrp->add( &m_importFaults );
faultGrp->add( &m_includeInactiveCellsInFaultGeometry );
#ifdef WIN32
faultGrp->add( &m_includeFileAbsolutePathPrefix );
#endif
faultGrp->add( &m_importNNCs );
auto wellGrp = uiOrdering.addNewGroup( "Well Import" );
wellGrp->add( &m_skipWellData );
wellGrp->add( &m_importAdvancedMswData );
if ( m_gridModelReaderOverride == RiaDefines::GridModelReader::NOT_SET )
{
auto egridGrp = uiOrdering.addNewGroup( "EGRID Settings" );
egridGrp->add( &m_gridModelReader );
}
auto resdataGrp = uiOrdering.addNewGroup( "ResData Reader Settings" );
resdataGrp->add( &m_useResultIndexFile );
// TODO: Disabled for the 2024.09 release, enable after release
// auto opmcGrp = uiOrdering.addNewGroup( "OPM Common Reader Settings" );
// opmcGrp->add( &m_onlyLoadActiveCells );
const bool setFaultImportSettingsReadOnly = !importFaults();
m_includeInactiveCellsInFaultGeometry.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly );
m_includeFileAbsolutePathPrefix.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly );
m_importNNCs.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderSettings RiaPreferencesGrid::gridOnlyReaderSettings()
{
RifReaderSettings rs{
// Disable as much as possible
false, // import faults
false, // import NNCs
false, // includeInactiveCellsInFaultGeometry
false, // importAdvancedMswData
false, // useResultIndexFile
true, // skipWellData
false, // import summary data
"", // include prefix,
false, // only active cells
true // ignore long thin cells
};
return rs;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderSettings RiaPreferencesGrid::readerSettings()
{
RifReaderSettings rs{ m_importFaults,
m_importNNCs,
m_includeInactiveCellsInFaultGeometry,
m_importAdvancedMswData,
m_useResultIndexFile,
m_skipWellData,
true, // import summary data
m_includeFileAbsolutePathPrefix,
onlyLoadActiveCells(),
m_invalidateLongThinCells };
return rs;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::importFaults() const
{
return m_importFaults;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::importNNCs() const
{
return m_importNNCs;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::includeInactiveCellsInFaultGeometry() const
{
return m_includeInactiveCellsInFaultGeometry;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::importAdvancedMswData() const
{
return m_importAdvancedMswData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesGrid::includeFileAbsolutePathPrefix() const
{
return m_includeFileAbsolutePathPrefix;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::useResultIndexFile() const
{
return m_useResultIndexFile;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::skipWellData() const
{
return m_skipWellData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::loadAndShowSoil() const
{
return m_loadAndShowSoil;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::autoComputeDepthRelatedProperties() const
{
return m_autoComputeDepthRelatedProperties;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::onlyLoadActiveCells() const
{
return false;
// return m_onlyLoadActiveCells;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferencesGrid::invalidateLongThinCells() const
{
return m_invalidateLongThinCells;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaDefines::GridModelReader RiaPreferencesGrid::gridModelReader() const
{
if ( m_gridModelReaderOverride != RiaDefines::GridModelReader::NOT_SET )
{
return m_gridModelReaderOverride;
}
return m_gridModelReader();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPreferencesGrid::setGridModelReaderOverride( const std::string& readerName )
{
RiaDefines::GridModelReader readerType = RiaDefines::GridModelReader::NOT_SET;
if ( readerName == "opm_common" )
{
readerType = RiaDefines::GridModelReader::OPM_COMMON;
}
else if ( readerName == "resdata" )
{
readerType = RiaDefines::GridModelReader::RESDATA;
}
else
{
RiaLogging::warning( QString::fromStdString( "Unknown EGRID reader type specified on command line: " + readerName ) );
return;
}
if ( readerType != RiaDefines::GridModelReader::NOT_SET )
{
RiaLogging::info( QString::fromStdString( "Using EGRID reader: " + readerName ) );
}
m_gridModelReaderOverride = readerType;
}

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RiaDefines.h"
#include "RifReaderSettings.h"
#include <QString>
//==================================================================================================
///
///
//==================================================================================================
class RiaPreferencesGrid : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
using GridModelEnum = caf::AppEnum<RiaDefines::GridModelReader>;
public:
RiaPreferencesGrid();
static RiaPreferencesGrid* current();
static RifReaderSettings gridOnlyReaderSettings();
RifReaderSettings readerSettings();
bool importFaults() const;
bool importNNCs() const;
bool includeInactiveCellsInFaultGeometry() const;
bool importAdvancedMswData() const;
QString includeFileAbsolutePathPrefix() const;
bool useResultIndexFile() const;
bool skipWellData() const;
bool loadAndShowSoil() const;
bool autoComputeDepthRelatedProperties() const;
bool onlyLoadActiveCells() const;
bool invalidateLongThinCells() const;
RiaDefines::GridModelReader gridModelReader() const;
void setGridModelReaderOverride( const std::string& readerName );
void appendItems( caf::PdmUiOrdering& uiOrdering );
private:
caf::PdmField<GridModelEnum> m_gridModelReader;
RiaDefines::GridModelReader m_gridModelReaderOverride;
caf::PdmField<bool> m_importFaults;
caf::PdmField<bool> m_importNNCs;
caf::PdmField<bool> m_includeInactiveCellsInFaultGeometry;
caf::PdmField<bool> m_importAdvancedMswData;
caf::PdmField<QString> m_includeFileAbsolutePathPrefix;
caf::PdmField<bool> m_useResultIndexFile;
caf::PdmField<bool> m_skipWellData;
caf::PdmField<bool> m_autoComputeDepthRelatedProperties;
caf::PdmField<bool> m_loadAndShowSoil;
caf::PdmField<bool> m_onlyLoadActiveCells;
caf::PdmField<bool> m_invalidateLongThinCells;
};

View File

@@ -0,0 +1,126 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RiaPreferencesOsdu.h"
CAF_PDM_SOURCE_INIT( RiaPreferencesOsdu, "RiaPreferencesOsdu" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesOsdu::RiaPreferencesOsdu()
{
CAF_PDM_InitFieldNoDefault( &m_server, "server", "Server" );
CAF_PDM_InitFieldNoDefault( &m_dataPartitionId, "dataPartitionId", "Data Partition Id" );
CAF_PDM_InitFieldNoDefault( &m_authority, "authority", "Authority" );
CAF_PDM_InitFieldNoDefault( &m_scopes, "scopes", "Scopes" );
CAF_PDM_InitFieldNoDefault( &m_clientId, "clientId", "Client Id" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaPreferencesOsdu* RiaPreferencesOsdu::current()
{
return RiaApplication::instance()->preferences()->osduPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPreferencesOsdu::setData( const std::map<QString, QString>& keyValuePairs )
{
for ( const auto& [key, value] : keyValuePairs )
{
if ( key == "server" )
{
m_server = value;
}
else if ( key == "dataPartitionId" )
{
m_dataPartitionId = value;
}
else if ( key == "authority" )
{
m_authority = value;
}
else if ( key == "scopes" )
{
m_scopes = value;
}
else if ( key == "clientId" )
{
m_clientId = value;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPreferencesOsdu::setFieldsReadOnly()
{
m_server.uiCapability()->setUiReadOnly( true );
m_dataPartitionId.uiCapability()->setUiReadOnly( true );
m_authority.uiCapability()->setUiReadOnly( true );
m_scopes.uiCapability()->setUiReadOnly( true );
m_clientId.uiCapability()->setUiReadOnly( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::server() const
{
return m_server;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::dataPartitionId() const
{
return m_dataPartitionId;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::authority() const
{
return m_authority;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::scopes() const
{
return m_scopes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesOsdu::clientId() const
{
return m_clientId;
}

View File

@@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RiaPreferencesOsdu : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RiaPreferencesOsdu();
static RiaPreferencesOsdu* current();
void setData( const std::map<QString, QString>& keyValuePairs );
void setFieldsReadOnly();
QString server() const;
QString dataPartitionId() const;
QString authority() const;
QString scopes() const;
QString clientId() const;
private:
caf::PdmField<QString> m_server;
caf::PdmField<QString> m_dataPartitionId;
caf::PdmField<QString> m_authority;
caf::PdmField<QString> m_scopes;
caf::PdmField<QString> m_clientId;
};

View File

@@ -57,7 +57,7 @@ void RiaPreferencesSummary::SummaryHistoryCurveStyleModeType::setUp()
template <>
void RiaPreferencesSummary::SummaryReaderModeType::setUp()
{
addItem( RiaPreferencesSummary::SummaryReaderMode::LIBECL, "LIBECL", "UNSMRY (libecl)" );
addItem( RiaPreferencesSummary::SummaryReaderMode::RESDATA, "RESDATA", "UNSMRY (resdata)", { "LIBECL" } );
addItem( RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON, "HDF5_OPM_COMMON", "h5 (HDF5)" );
addItem( RiaPreferencesSummary::SummaryReaderMode::OPM_COMMON, "OPM_COMMON", "ESMRY (opm-common)" );
setDefault( RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON );
@@ -471,7 +471,7 @@ QList<caf::PdmOptionItemInfo> RiaPreferencesSummary::calculateValueOptions( cons
#ifdef USE_HDF5
availableModes.push_back( SummaryReaderMode::HDF5_OPM_COMMON );
#endif // USE_HDF5
availableModes.push_back( SummaryReaderMode::LIBECL );
availableModes.push_back( SummaryReaderMode::RESDATA );
availableModes.push_back( SummaryReaderMode::OPM_COMMON );
for ( auto enumValue : availableModes )

View File

@@ -42,7 +42,7 @@ class RiaPreferencesSummary : public caf::PdmObject
public:
enum class SummaryReaderMode
{
LIBECL,
RESDATA,
OPM_COMMON,
HDF5_OPM_COMMON
};

View File

@@ -1,8 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
// Copyright (C) 2024 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
@@ -18,110 +16,97 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimOilFieldEntry.h"
#include "RimWellPathImport.h"
#include "RiaApplication.h"
#include "RifJsonEncodeDecode.h"
#include "RiaPreferences.h"
#include "RiaPreferencesSumo.h"
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QMap>
CAF_PDM_SOURCE_INIT( RimOilFieldEntry, "RimOilFieldEntry" );
CAF_PDM_SOURCE_INIT( RiaPreferencesSumo, "RiaPreferencesSumo" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimOilFieldEntry::RimOilFieldEntry()
RiaPreferencesSumo::RiaPreferencesSumo()
{
CAF_PDM_InitObject( "OilFieldEntry" );
CAF_PDM_InitFieldNoDefault( &name, "OilFieldName", "Oil Field Name" );
CAF_PDM_InitFieldNoDefault( &edmId, "EdmId", "Edm ID" );
CAF_PDM_InitField( &selected, "Selected", false, "Selected" );
CAF_PDM_InitFieldNoDefault( &wellsFilePath, "wellsFilePath", "Wells File Path" );
CAF_PDM_InitFieldNoDefault( &wells, "Wells", "" );
wells.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_server, "server", "Server" );
CAF_PDM_InitFieldNoDefault( &m_authority, "authority", "Authority" );
CAF_PDM_InitFieldNoDefault( &m_scopes, "scopes", "Scopes" );
CAF_PDM_InitFieldNoDefault( &m_clientId, "clientId", "Client Id" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimOilFieldEntry::~RimOilFieldEntry()
RiaPreferencesSumo* RiaPreferencesSumo::current()
{
wells.deleteChildren();
return RiaApplication::instance()->preferences()->sumoPreferences();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimOilFieldEntry::userDescriptionField()
void RiaPreferencesSumo::setData( const std::map<QString, QString>& keyValuePairs )
{
return &name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimOilFieldEntry::objectToggleField()
{
return &selected;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOilFieldEntry::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &selected )
for ( const auto& [key, value] : keyValuePairs )
{
updateEnabledState();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOilFieldEntry::initAfterRead()
{
updateEnabledState();
updateUiIconFromToggleField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimOilFieldEntry::updateEnabledState()
{
bool wellsReadOnly = !selected;
if ( isUiReadOnly() )
{
wellsReadOnly = true;
}
for ( size_t i = 0; i < wells.size(); i++ )
{
wells[i]->setUiReadOnly( wellsReadOnly );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathEntry* RimOilFieldEntry::find( const QString& entryName, RimWellPathEntry::WellTypeEnum wellPathType )
{
for ( size_t i = 0; i < wells.size(); i++ )
{
RimWellPathEntry* wellPathEntry = wells[i];
if ( wellPathEntry->name == entryName && wellPathEntry->wellPathType == wellPathType )
if ( key == "server" )
{
return wellPathEntry;
m_server = value;
}
else if ( key == "authority" )
{
m_authority = value;
}
else if ( key == "scopes" )
{
m_scopes = value;
}
else if ( key == "clientId" )
{
m_clientId = value;
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaPreferencesSumo::setFieldsReadOnly()
{
m_server.uiCapability()->setUiReadOnly( true );
m_authority.uiCapability()->setUiReadOnly( true );
m_scopes.uiCapability()->setUiReadOnly( true );
m_clientId.uiCapability()->setUiReadOnly( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSumo::server() const
{
return m_server;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSumo::authority() const
{
return m_authority;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSumo::scopes() const
{
return m_scopes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSumo::clientId() const
{
return m_clientId;
}

View File

@@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RiaPreferencesSumo : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RiaPreferencesSumo();
static RiaPreferencesSumo* current();
void setData( const std::map<QString, QString>& keyValuePairs );
void setFieldsReadOnly();
QString server() const;
QString authority() const;
QString scopes() const;
QString clientId() const;
private:
caf::PdmField<QString> m_server;
caf::PdmField<QString> m_authority;
caf::PdmField<QString> m_scopes;
caf::PdmField<QString> m_clientId;
};

View File

@@ -102,9 +102,12 @@ bool RiaResultNames::isFlowResultWithBothPosAndNegValues( const QString& resultN
//--------------------------------------------------------------------------------------------------
bool RiaResultNames::isCategoryResult( const QString& resultName )
{
static std::set<QString> excludedResultNames = { "FIPOIL", "FIPGAS", "FIPWAT" };
// Identify and mark some FIP-results as non-category result.
// This includes statistics results FIPOIL_MEAN, FIPOIL_P90, SFIP* and RFIP*.
if ( excludedResultNames.find( resultName.toUpper() ) != excludedResultNames.end() ) return false;
if ( resultName.contains( "FIPOIL", Qt::CaseInsensitive ) ) return false;
if ( resultName.contains( "FIPGAS", Qt::CaseInsensitive ) ) return false;
if ( resultName.contains( "FIPWAT", Qt::CaseInsensitive ) ) return false;
if ( resultName.endsWith( "NUM", Qt::CaseInsensitive ) ) return true;
if ( resultName.startsWith( "FIP", Qt::CaseInsensitive ) ) return true;

View File

@@ -19,6 +19,14 @@
#include "RiaRftDefines.h"
#include "cafAppEnum.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaDefines::isSegmentResult( const QString& resultName )
{
return resultName.startsWith( "SEG" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -51,6 +59,78 @@ QString RiaDefines::segmentNumberResultName()
return "SEGMENTNUMBER";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaDefines::isSegmentConnectionResult( const QString& resultName )
{
return resultName.startsWith( "CON" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::segmentConnectionTvdDepthResultName()
{
return "CONDEPTH";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaDefines::segmentConnectionEndDepthResultName()
{
return "CONLENEN";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaDefines::segmentConnectionStartDepthResultName()
{
return "CONLENST";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaDefines::segmentConnectionBranchNoResultName()
{
return "CONBRNO";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::segmentConnectionMeasuredDepthResultName()
{
return "SegmentConnectionMeasuredDepth";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaDefines::segmentConnectionIPos()
{
return "CONIPOS";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaDefines::segmentConnectionJPos()
{
return "CONJPOS";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaDefines::segmentConnectionKPos()
{
return "CONKPOS";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -22,11 +22,22 @@
namespace RiaDefines
{
bool isSegmentResult( const QString& resultName );
QString segmentStartDepthResultName();
QString segmentEndDepthResultName();
QString segmentTvdDepthResultName();
QString segmentNumberResultName();
bool isSegmentConnectionResult( const QString& resultName );
QString segmentConnectionTvdDepthResultName();
std::string segmentConnectionEndDepthResultName();
std::string segmentConnectionStartDepthResultName();
std::string segmentConnectionBranchNoResultName();
QString segmentConnectionMeasuredDepthResultName();
std::string segmentConnectionIPos();
std::string segmentConnectionJPos();
std::string segmentConnectionKPos();
QString allBranches();
QString segmentBranchNumberResultName();

View File

@@ -57,8 +57,8 @@ const QDateTime& RiaRftPltCurveDefinition::timeStep() const
//--------------------------------------------------------------------------------------------------
auto RiaRftPltCurveDefinition::operator<=>( const RiaRftPltCurveDefinition& other ) const -> std::strong_ordering
{
RimSummaryCaseCollection* thisEnsemble = m_curveAddress.ensemble();
RimSummaryCaseCollection* otherEnsemble = other.m_curveAddress.ensemble();
RimSummaryEnsemble* thisEnsemble = m_curveAddress.ensemble();
RimSummaryEnsemble* otherEnsemble = other.m_curveAddress.ensemble();
if ( ( thisEnsemble && !otherEnsemble ) || ( !thisEnsemble && otherEnsemble ) )
{
@@ -72,7 +72,7 @@ auto RiaRftPltCurveDefinition::operator<=>( const RiaRftPltCurveDefinition& othe
{
if ( m_wellName == other.m_wellName )
{
return m_timeStep.toTime_t() <=> other.m_timeStep.toTime_t();
return m_timeStep.toMSecsSinceEpoch() <=> other.m_timeStep.toMSecsSinceEpoch();
}
return m_wellName.toStdString() <=> other.m_wellName.toStdString();
}

View File

@@ -19,8 +19,7 @@
#pragma once
#include <QString>
class QStringList;
#include <QStringList>
//--------------------------------------------------------------------------------------------------
///

View File

@@ -23,7 +23,7 @@
#include "RifSummaryReaderInterface.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryEnsemble.h"
#include "cafAssert.h"
@@ -57,7 +57,7 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCase*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddressY )
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& summaryAddressY )
: m_summaryCaseY( nullptr )
, m_summaryAddressY( summaryAddressY )
, m_summaryCaseX( nullptr )
@@ -70,7 +70,7 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress )
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryEnsemble* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress )
: m_summaryCaseY( nullptr )
, m_summaryAddressY( summaryCurveAddress.summaryAddressY() )
, m_summaryCaseX( nullptr )
@@ -91,7 +91,7 @@ RimSummaryCase* RiaSummaryCurveDefinition::summaryCaseY() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const
RimSummaryEnsemble* RiaSummaryCurveDefinition::ensemble() const
{
return m_ensemble;
}
@@ -99,7 +99,7 @@ RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::setEnsemble( RimSummaryCaseCollection* ensemble )
void RiaSummaryCurveDefinition::setEnsemble( RimSummaryEnsemble* ensemble )
{
m_ensemble = ensemble;
}

View File

@@ -29,7 +29,7 @@
#include <gsl/gsl>
class RimSummaryCase;
class RimSummaryCaseCollection;
class RimSummaryEnsemble;
class RiaSummaryCurveAddress;
//==================================================================================================
@@ -40,12 +40,12 @@ class RiaSummaryCurveDefinition
public:
RiaSummaryCurveDefinition();
explicit RiaSummaryCurveDefinition( RimSummaryCase* summaryCaseY, const RifEclipseSummaryAddress& summaryAddressY, bool isEnsembleCurve );
explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddressY );
explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress );
explicit RiaSummaryCurveDefinition( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& summaryAddressY );
explicit RiaSummaryCurveDefinition( RimSummaryEnsemble* ensemble, const RiaSummaryCurveAddress& summaryCurveAddress );
// X and Y Axis
RimSummaryCaseCollection* ensemble() const;
void setEnsemble( RimSummaryCaseCollection* ensemble );
RimSummaryEnsemble* ensemble() const;
void setEnsemble( RimSummaryEnsemble* ensemble );
// Y Axis
RimSummaryCase* summaryCaseY() const;
@@ -74,12 +74,12 @@ public:
static QString curveDefinitionText( const QString& caseName, const RifEclipseSummaryAddress& summaryAddress );
private:
RimSummaryCase* m_summaryCaseY;
RifEclipseSummaryAddress m_summaryAddressY;
RimSummaryCase* m_summaryCaseX;
RifEclipseSummaryAddress m_summaryAddressX;
RimSummaryCaseCollection* m_ensemble;
bool m_isEnsembleCurve;
RimSummaryCase* m_summaryCaseY;
RifEclipseSummaryAddress m_summaryAddressY;
RimSummaryCase* m_summaryCaseX;
RifEclipseSummaryAddress m_summaryAddressX;
RimSummaryEnsemble* m_ensemble;
bool m_isEnsembleCurve;
};
class RiaSummaryCurveDefinitionAnalyser
@@ -88,8 +88,8 @@ public:
RiaSummaryCurveDefinitionAnalyser() = default;
void setCurveDefinitions( const std::vector<RiaSummaryCurveDefinition>& curveDefs );
std::set<RimSummaryCase*> m_singleSummaryCases; // All summary cases used
std::set<RimSummaryCaseCollection*> m_ensembles; // All the ensembles referenced by the summary cases
std::set<RimSummaryCase*> m_singleSummaryCases; // All summary cases used
std::set<RimSummaryEnsemble*> m_ensembles; // All the ensembles referenced by the summary cases
std::set<RifEclipseSummaryAddress> m_summaryAdresses;
std::set<std::string> m_vectorNames;

View File

@@ -28,6 +28,15 @@ void caf::AppEnum<RiaDefines::HorizontalAxisType>::setUp()
addItem( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR, "SUMMARY_VECTOR", "Summary Vector" );
setDefault( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR );
}
template <>
void caf::AppEnum<RiaDefines::SummaryCurveTypeMode>::setUp()
{
addItem( RiaDefines::SummaryCurveTypeMode::AUTO, "AUTO", "Auto" );
addItem( RiaDefines::SummaryCurveTypeMode::CUSTOM, "CUSTOM", "Custom" );
setDefault( RiaDefines::SummaryCurveTypeMode::AUTO );
}
} // namespace caf
//--------------------------------------------------------------------------------------------------

View File

@@ -35,6 +35,12 @@ enum class HorizontalAxisType
SUMMARY_VECTOR
};
enum class SummaryCurveTypeMode
{
AUTO,
CUSTOM
};
QString summaryField();
QString summaryAquifer();
QString summaryNetwork();

View File

@@ -18,7 +18,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaInterpolationTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryAddressAnalyzer.h
${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.h
@@ -54,6 +54,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaNumericalTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTextTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaFileLogger.h
${CMAKE_CURRENT_LIST_DIR}/RiaProjectBackupTools.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -76,7 +77,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaInterpolationTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryAddressAnalyzer.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.cpp
@@ -105,6 +106,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaNumericalTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTextTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaFileLogger.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaProjectBackupTools.cpp
)
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})

View File

@@ -0,0 +1,30 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaCloudConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiaOAuthHttpServerReplyHandler.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaCloudConnector.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSumoDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaConnectorTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOAuthHttpServerReplyHandler.cpp
)
list(
APPEND
QT_MOC_HEADERS
${CMAKE_CURRENT_LIST_DIR}/RiaCloudConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiaSumoConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduConnector.h
${CMAKE_CURRENT_LIST_DIR}/RiaOAuthHttpServerReplyHandler.h
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})

View File

@@ -0,0 +1,285 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaCloudConnector.h"
#include "RiaCloudDefines.h"
#include "RiaConnectorTools.h"
#include "RiaLogging.h"
#include "RiaOAuthHttpServerReplyHandler.h"
#include <QDateTime>
#include <QDesktopServices>
#include <QEventLoop>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QTimer>
#include <QUrlQuery>
#include <QtNetworkAuth/QOAuth2AuthorizationCodeFlow>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaCloudConnector::RiaCloudConnector( QObject* parent,
const QString& server,
const QString& authority,
const QString& scopes,
const QString& clientId,
unsigned int port )
: QObject( parent )
, m_server( server )
, m_authority( authority )
, m_scopes( scopes )
, m_clientId( clientId )
{
m_authCodeFlow = new QOAuth2AuthorizationCodeFlow( this );
m_networkAccessManager = new QNetworkAccessManager( this );
m_authCodeFlow->setNetworkAccessManager( m_networkAccessManager );
RiaLogging::debug( "SSL BUILD VERSION: " + QSslSocket::sslLibraryBuildVersionString() );
RiaLogging::debug( "SSL VERSION STRING: " + QSslSocket::sslLibraryVersionString() );
RiaLogging::debug( "Cloud config:" );
RiaLogging::debug( " server: '" + server + "'" );
RiaLogging::debug( " authority: '" + authority + "'" );
RiaLogging::debug( " scopes: '" + scopes + "'" );
RiaLogging::debug( " client id: '" + clientId + "'" );
connect( m_authCodeFlow,
&QOAuth2AuthorizationCodeFlow::authorizeWithBrowser,
[]( QUrl url )
{
RiaLogging::info( "Authorize with url: " + url.toString() );
QUrlQuery query( url );
url.setQuery( query );
QDesktopServices::openUrl( url );
} );
QString authUrl = constructAuthUrl( m_authority );
m_authCodeFlow->setAuthorizationUrl( QUrl( authUrl ) );
QString tokenUrl = constructTokenUrl( m_authority );
m_authCodeFlow->setAccessTokenUrl( QUrl( tokenUrl ) );
// App key
m_authCodeFlow->setClientIdentifier( m_clientId );
m_authCodeFlow->setScope( m_scopes );
auto replyHandler = new RiaOAuthHttpServerReplyHandler( port, this );
m_authCodeFlow->setReplyHandler( replyHandler );
RiaLogging::debug( "Server callback: " + replyHandler->callback() );
connect( m_authCodeFlow, SIGNAL( granted() ), this, SLOT( accessGranted() ) );
connect( m_authCodeFlow,
SIGNAL( error( const QString&, const QString&, const QUrl& ) ),
this,
SLOT( errorReceived( const QString&, const QString&, const QUrl& ) ) );
connect( m_authCodeFlow,
SIGNAL( authorizationCallbackReceived( const QVariantMap& ) ),
this,
SLOT( authorizationCallbackReceived( const QVariantMap& ) ) );
connect( m_authCodeFlow,
&QOAuth2AuthorizationCodeFlow::tokenChanged,
this,
[&]( const QString& token )
{
RiaLogging::debug( "Access token changed." );
exportTokenToFile();
} );
connect( m_authCodeFlow,
&QOAuth2AuthorizationCodeFlow::refreshTokenChanged,
this,
[&]( const QString& refreshToken )
{
RiaLogging::debug( "Refresh token changed." );
exportTokenToFile();
} );
connect( m_authCodeFlow,
&QOAuth2AuthorizationCodeFlow::expirationAtChanged,
this,
[&]( const QDateTime& expiration )
{
RiaLogging::debug( QString( "Access token expiration changed: %1" ).arg( expiration.toString() ) );
exportTokenToFile();
} );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaCloudConnector::~RiaCloudConnector()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::accessGranted()
{
QString currentToken = m_authCodeFlow->token();
emit tokenReady( currentToken );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri )
{
RiaLogging::debug( "Cloud Error Received: " + error + ". Description: " + errorDescription );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::authorizationCallbackReceived( const QVariantMap& data )
{
RiaLogging::debug( "Authorization callback received:" );
for ( const auto& [key, value] : data.toStdMap() )
{
RiaLogging::debug( " Key: " + key + " Value: " + value.toString() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::requestFailed( const QAbstractOAuth::Error error )
{
RiaLogging::error( "Request failed: " );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::requestToken()
{
if ( token().isEmpty() )
{
RiaLogging::debug( "No valid access token found." );
if ( !m_authCodeFlow->refreshToken().isEmpty() )
{
RiaLogging::info( "Refreshing access token with refresh token." );
m_authCodeFlow->refreshAccessToken();
}
else
{
RiaLogging::info( "Requesting token." );
m_authCodeFlow->grant();
}
}
else
{
RiaLogging::debug( "Has token: skipping token request." );
emit accessGranted();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaCloudConnector::token() const
{
QString currentToken = m_authCodeFlow->token();
QDateTime expiration = m_authCodeFlow->expirationAt();
if ( !currentToken.isEmpty() && expiration.isValid() && expiration > QDateTime::currentDateTime() )
{
return currentToken;
}
else
{
return QString();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::exportTokenToFile()
{
QString tokenDataJson = RiaConnectorTools::tokenDataAsJson( m_authCodeFlow );
RiaConnectorTools::writeTokenData( m_tokenDataFilePath, tokenDataJson );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::importTokenFromFile()
{
auto tokenDataJson = RiaConnectorTools::readStringFromFile( m_tokenDataFilePath );
if ( !tokenDataJson.isEmpty() )
{
RiaConnectorTools::initializeTokenDataFromJson( m_authCodeFlow, tokenDataJson );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::setTokenDataFilePath( const QString& filePath )
{
m_tokenDataFilePath = filePath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaCloudConnector::constructAuthUrl( const QString& authority )
{
return authority + "/oauth2/v2.0/authorize";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaCloudConnector::constructTokenUrl( const QString& authority )
{
return authority + "/oauth2/v2.0/token";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaCloudConnector::requestTokenBlocking()
{
QString currentToken = token();
if ( !currentToken.isEmpty() ) return currentToken;
QTimer timer;
timer.setSingleShot( true );
QEventLoop loop;
connect( this, SIGNAL( tokenReady( const QString& ) ), &loop, SLOT( quit() ) );
connect( &timer, SIGNAL( timeout() ), &loop, SLOT( quit() ) );
requestToken();
timer.start( RiaCloudDefines::requestTokenTimeoutMillis() );
loop.exec( QEventLoop::ProcessEventsFlag::ExcludeUserInputEvents );
return m_authCodeFlow->token();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaCloudConnector::server() const
{
return m_server;
}

View File

@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QObject>
#include <QtNetworkAuth/QAbstractOAuth>
class QNetworkAccessManager;
class QOAuth2AuthorizationCodeFlow;
//==================================================================================================
///
//==================================================================================================
class RiaCloudConnector : public QObject
{
Q_OBJECT
public:
RiaCloudConnector( QObject* parent,
const QString& server,
const QString& authority,
const QString& scopes,
const QString& clientId,
unsigned int port );
~RiaCloudConnector() override;
QString token() const;
void importTokenFromFile();
void exportTokenToFile();
void setTokenDataFilePath( const QString& filePath );
QString server() const;
QString requestTokenBlocking();
public slots:
void requestToken();
void requestFailed( const QAbstractOAuth::Error error );
signals:
void tokenReady( const QString& token );
private slots:
void errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri );
void authorizationCallbackReceived( const QVariantMap& data );
void accessGranted();
protected:
static QString constructAuthUrl( const QString& authority );
static QString constructTokenUrl( const QString& authority );
QOAuth2AuthorizationCodeFlow* m_authCodeFlow;
QNetworkAccessManager* m_networkAccessManager;
const QString m_server;
const QString m_authority;
const QString m_scopes;
const QString m_clientId;
QString m_tokenDataFilePath;
};

View File

@@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaConnectorTools.h"
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonDocument>
#include <QJsonObject>
#include <QTextStream>
#include <QtNetworkAuth/QOAuth2AuthorizationCodeFlow>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaConnectorTools::tokenDataAsJson( QOAuth2AuthorizationCodeFlow* authCodeFlow )
{
QJsonObject obj;
obj.insert( "token", authCodeFlow->token() );
obj.insert( "refreshToken", authCodeFlow->refreshToken() );
if ( authCodeFlow->expirationAt().isValid() )
{
obj.insert( "expiration", authCodeFlow->expirationAt().toSecsSinceEpoch() );
}
QJsonDocument doc( obj );
return doc.toJson( QJsonDocument::Indented );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaConnectorTools::initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlow* authCodeFlow, const QString& tokenDataJson )
{
QJsonDocument doc = QJsonDocument::fromJson( tokenDataJson.toUtf8() );
QJsonObject obj = doc.object();
if ( obj.contains( "expiration" ) && obj.contains( "token" ) )
{
quint64 secondsSinceEpoch = obj["expiration"].toVariant().toULongLong();
QDateTime expiration = QDateTime::fromSecsSinceEpoch( secondsSinceEpoch );
if ( expiration.isValid() && expiration > QDateTime::currentDateTime() )
{
authCodeFlow->setToken( obj["token"].toString() );
}
}
authCodeFlow->setRefreshToken( obj["refreshToken"].toString() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaConnectorTools::writeTokenData( const QString& filePath, const QString& tokenDataJson )
{
QFile file( filePath );
// Ensure the directory exists (create it if it doesn't)
QString dirPath = QFileInfo( file ).absolutePath();
QDir dir( dirPath );
if ( !dir.exists() )
{
dir.mkpath( dirPath );
}
if ( file.open( QIODevice::WriteOnly ) )
{
QTextStream stream( &file );
stream << tokenDataJson;
file.close();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaConnectorTools::readStringFromFile( const QString& filePath )
{
QFile file( filePath );
if ( file.open( QIODevice::ReadOnly ) )
{
QTextStream stream( &file );
QString result = stream.readAll();
file.close();
return result;
}
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<QString, QString> RiaConnectorTools::readKeyValuePairs( const QString& filePath )
{
auto content = readStringFromFile( filePath );
QJsonDocument doc = QJsonDocument::fromJson( content.toUtf8() );
QJsonObject obj = doc.object();
std::map<QString, QString> keyValuePairs;
for ( auto it = obj.begin(); it != obj.end(); ++it )
{
keyValuePairs[it.key()] = it.value().toString();
}
return keyValuePairs;
}

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
#include <map>
class QOAuth2AuthorizationCodeFlow;
namespace RiaConnectorTools
{
QString tokenDataAsJson( QOAuth2AuthorizationCodeFlow* authCodeFlow );
void initializeTokenDataFromJson( QOAuth2AuthorizationCodeFlow* authCodeFlow, const QString& tokenDataJson );
void writeTokenData( const QString& filePath, const QString& tokenDataJson );
QString readStringFromFile( const QString& filePath );
std::map<QString, QString> readKeyValuePairs( const QString& filePath );
} // namespace RiaConnectorTools

View File

@@ -0,0 +1,24 @@
#include "RiaOAuthHttpServerReplyHandler.h"
#include <QString>
#include <QUrl>
#include <QtNetworkAuth/QAbstractOAuth>
#include <QtNetworkAuth/QOAuthHttpServerReplyHandler>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaOAuthHttpServerReplyHandler::RiaOAuthHttpServerReplyHandler( quint16 port, QObject* parent )
: QOAuthHttpServerReplyHandler( port, parent )
, m_port( port )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaOAuthHttpServerReplyHandler::callback() const
{
const QUrl url( QString::fromLatin1( "http://localhost:%1/" ).arg( m_port ) );
return url.toString( QUrl::EncodeDelimiters );
}

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QObject>
#include <QString>
#include <QtNetworkAuth/QOAuthHttpServerReplyHandler>
//==================================================================================================
///
//==================================================================================================
class RiaOAuthHttpServerReplyHandler : public QOAuthHttpServerReplyHandler
{
Q_OBJECT
public:
RiaOAuthHttpServerReplyHandler( quint16 port, QObject* parent );
QString callback() const override;
private:
quint16 m_port;
};

View File

@@ -0,0 +1,813 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaOsduConnector.h"
#include "RiaCloudDefines.h"
#include "RiaLogging.h"
#include "RiaOsduDefines.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <limits>
#include "cafAssert.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaOsduConnector::RiaOsduConnector( QObject* parent,
const QString& server,
const QString& dataPartitionId,
const QString& authority,
const QString& scopes,
const QString& clientId,
unsigned int port )
: RiaCloudConnector( parent, server, authority, scopes, clientId, port )
, m_dataPartitionId( dataPartitionId )
{
connect( this,
SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ),
this,
SLOT( parquetDownloadComplete( const QByteArray&, const QString&, const QString& ) ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaOsduConnector::~RiaOsduConnector()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::clearCachedData()
{
QMutexLocker lock( &m_mutex );
m_fields.clear();
m_wells.clear();
m_wellbores.clear();
m_wellboreTrajectories.clear();
m_wellLogs.clear();
m_parquetData.clear();
m_parquetErrors.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestFieldsByName( const QString& token, const QString& fieldName )
{
requestFieldsByName( m_server, m_dataPartitionId, token, fieldName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestFieldsByName( const QString& fieldName )
{
requestFieldsByName( token(), fieldName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName )
{
std::map<QString, QString> params;
params["kind"] = RiaOsduDefines::osduFieldKind();
params["limit"] = "10000";
params["query"] = "data.FieldName:" + fieldName;
auto reply = makeSearchRequest( params, server, dataPartitionId, token );
connect( reply,
&QNetworkReply::finished,
[this, reply, fieldName]()
{
if ( reply->error() == QNetworkReply::NoError )
{
parseFields( reply );
}
else
{
QString errorMessage =
QString( "Download failed for fields by name (%1). Error: %2" ).arg( fieldName ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
}
} );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellsByFieldId( const QString& fieldId )
{
requestWellsByFieldId( m_server, m_dataPartitionId, token(), fieldId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId )
{
std::map<QString, QString> params;
params["kind"] = RiaOsduDefines::osduWellKind();
params["limit"] = "10000";
params["query"] = QString( "nested(data.GeoContexts, (FieldID:\"%1\"))" ).arg( fieldId );
auto reply = makeSearchRequest( params, server, dataPartitionId, token );
connect( reply,
&QNetworkReply::finished,
[this, reply, fieldId]()
{
if ( reply->error() == QNetworkReply::NoError )
{
parseWells( reply );
}
else
{
QString errorMessage =
QString( "Request failed for wells for field (%1). Error: %2" ).arg( fieldId ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
}
} );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellboresByWellId( const QString& wellId )
{
requestWellboresByWellId( m_server, m_dataPartitionId, token(), wellId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId )
{
std::map<QString, QString> params;
params["kind"] = RiaOsduDefines::osduWellboreKind();
params["limit"] = "10000";
params["query"] = "data.WellID: \"" + wellId + "\"";
auto reply = makeSearchRequest( params, server, dataPartitionId, token );
connect( reply,
&QNetworkReply::finished,
[this, reply, wellId]()
{
if ( reply->error() == QNetworkReply::NoError )
{
parseWellbores( reply, wellId );
}
else
{
QString errorMessage =
QString( "Request failed for wellbores for well (%1). Error: %2" ).arg( wellId ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
}
} );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<OsduWellLog> RiaOsduConnector::requestWellLogsByWellboreIdBlocking( const QString& wellboreId )
{
QString token = requestTokenBlocking();
QEventLoop loop;
connect( this, SIGNAL( wellLogsFinished( const QString& ) ), &loop, SLOT( quit() ) );
requestWellLogsByWellboreId( m_server, m_dataPartitionId, token, wellboreId );
loop.exec();
return m_wellLogs[wellboreId];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellLogsByWellboreId( const QString& wellboreId )
{
requestWellLogsByWellboreId( m_server, m_dataPartitionId, token(), wellboreId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellLogsByWellboreId( const QString& server,
const QString& dataPartitionId,
const QString& token,
const QString& wellboreId )
{
std::map<QString, QString> params;
params["kind"] = RiaOsduDefines::osduWellLogKind();
params["limit"] = "10000";
params["query"] = "data.WellboreID: \"" + wellboreId + "\"";
auto reply = makeSearchRequest( params, server, dataPartitionId, token );
connect( reply,
&QNetworkReply::finished,
[this, reply, wellboreId]()
{
if ( reply->error() == QNetworkReply::NoError )
{
parseWellLogs( reply, wellboreId );
}
else
{
QString errorMessage =
QString( "Request failed for well logs by wellbore (%1). Error: %2" ).arg( wellboreId ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
}
} );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& wellboreId )
{
requestWellboreTrajectoryByWellboreId( m_server, m_dataPartitionId, token(), wellboreId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellboreTrajectoryByWellboreId( const QString& server,
const QString& dataPartitionId,
const QString& token,
const QString& wellboreId )
{
std::map<QString, QString> params;
params["kind"] = RiaOsduDefines::osduWellboreTrajectoryKind();
params["limit"] = "10000";
params["query"] = "data.WellboreID: \"" + wellboreId + "\"";
auto reply = makeSearchRequest( params, server, dataPartitionId, token );
connect( reply,
&QNetworkReply::finished,
[this, reply, wellboreId]()
{
if ( reply->error() == QNetworkReply::NoError )
{
parseWellTrajectory( reply, wellboreId );
}
else
{
QString errorMessage =
QString( "Request failed for well trajectory by wellbore (%1). Error: %2" ).arg( wellboreId ).arg( reply->errorString() );
RiaLogging::error( errorMessage );
}
} );
}
//--------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------
QString RiaOsduConnector::constructSearchUrl( const QString& server )
{
return server + "/api/search/v2/query";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaOsduConnector::constructFileDownloadUrl( const QString& server, const QString& fileId )
{
return server + "/api/file/v2/files/" + fileId + "/downloadURL";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaOsduConnector::constructWellLogDownloadUrl( const QString& server, const QString& wellLogId )
{
return server + "/api/os-wellbore-ddms/ddms/v3/welllogs/" + wellLogId + "/data";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaOsduConnector::constructWellboreTrajectoriesDownloadUrl( const QString& server, const QString& wellboreTrajectoryId )
{
return server + "/api/os-wellbore-ddms/ddms/v3/wellboretrajectories/" + wellboreTrajectoryId + "/data";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QNetworkReply* RiaOsduConnector::makeSearchRequest( const std::map<QString, QString>& parameters,
const QString& server,
const QString& dataPartitionId,
const QString& token )
{
QNetworkRequest networkRequest;
networkRequest.setUrl( QUrl( constructSearchUrl( server ) ) );
addStandardHeader( networkRequest, token, dataPartitionId, RiaCloudDefines::contentTypeJson() );
QJsonObject obj;
for ( auto [key, value] : parameters )
{
obj.insert( key, value );
}
QJsonDocument doc( obj );
QString strJson( doc.toJson( QJsonDocument::Compact ) );
auto reply = m_networkAccessManager->post( networkRequest, strJson.toUtf8() );
return reply;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::parseFields( QNetworkReply* reply )
{
QByteArray result = reply->readAll();
reply->deleteLater();
if ( reply->error() == QNetworkReply::NoError )
{
QJsonDocument doc = QJsonDocument::fromJson( result );
QJsonObject jsonObj = doc.object();
QJsonArray resultsArray = jsonObj["results"].toArray();
{
QMutexLocker lock( &m_mutex );
m_fields.clear();
for ( const QJsonValue& value : resultsArray )
{
QJsonObject resultObj = value.toObject();
QString id = resultObj["id"].toString();
QString kind = resultObj["kind"].toString();
QString fieldName = resultObj["data"].toObject()["FieldName"].toString();
m_fields.push_back( OsduField{ id, kind, fieldName } );
}
RiaLogging::debug( QString( "Found %1 fields." ).arg( m_fields.size() ) );
}
emit fieldsFinished();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::parseWells( QNetworkReply* reply )
{
QByteArray result = reply->readAll();
reply->deleteLater();
if ( reply->error() == QNetworkReply::NoError )
{
QJsonDocument doc = QJsonDocument::fromJson( result );
QJsonObject jsonObj = doc.object();
QJsonArray resultsArray = jsonObj["results"].toArray();
{
QMutexLocker lock( &m_mutex );
m_wells.clear();
for ( const QJsonValue& value : resultsArray )
{
QJsonObject resultObj = value.toObject();
QString id = resultObj["id"].toString();
QString kind = resultObj["kind"].toString();
QString name = resultObj["data"].toObject()["FacilityName"].toString();
m_wells.push_back( OsduWell{ id, kind, name } );
}
}
emit wellsFinished();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::parseWellbores( QNetworkReply* reply, const QString& wellId )
{
QByteArray result = reply->readAll();
reply->deleteLater();
if ( reply->error() == QNetworkReply::NoError )
{
QJsonDocument doc = QJsonDocument::fromJson( result );
QJsonObject jsonObj = doc.object();
QJsonArray resultsArray = jsonObj["results"].toArray();
{
QMutexLocker lock( &m_mutex );
m_wellbores[wellId].clear();
for ( const QJsonValue& value : resultsArray )
{
QJsonObject resultObj = value.toObject();
QString id = resultObj["id"].toString();
QString kind = resultObj["kind"].toString();
QString name = resultObj["data"].toObject()["FacilityName"].toString();
// Extract datum elevation. The DefaultVerticalMeasurementID is probably the datum elevation needed.
// Default to 0.0 if nothing is found, but finding nothing is suspicious.
double datumElevation = std::numeric_limits<double>::infinity();
QString defaultVerticalMeasurementId = resultObj["data"].toObject()["DefaultVerticalMeasurementID"].toString();
QJsonArray verticalMeasurementsArray = resultObj["data"].toObject()["VerticalMeasurements"].toArray();
for ( const QJsonValue& vma : verticalMeasurementsArray )
{
QString verticalMeasurementId = vma["VerticalMeasurementID"].toString();
if ( verticalMeasurementId == defaultVerticalMeasurementId )
{
double verticalMeasurement = vma["VerticalMeasurement"].toDouble( 0.0 );
datumElevation = verticalMeasurement;
}
}
if ( std::isinf( datumElevation ) )
{
RiaLogging::warning( QString( "Missing datum elevation for well bore '%1'. Id: %2" ).arg( name ).arg( id ) );
datumElevation = 0.0;
}
m_wellbores[wellId].push_back( OsduWellbore{ id, kind, name, wellId, datumElevation } );
}
}
emit wellboresFinished( wellId );
}
else
{
RiaLogging::error( "Failed to download well with id " + wellId + ": " + reply->errorString() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::parseWellTrajectory( QNetworkReply* reply, const QString& wellboreId )
{
QByteArray result = reply->readAll();
reply->deleteLater();
if ( reply->error() == QNetworkReply::NoError )
{
QJsonDocument doc = QJsonDocument::fromJson( result );
QJsonObject jsonObj = doc.object();
QJsonArray resultsArray = jsonObj["results"].toArray();
{
QMutexLocker lock( &m_mutex );
m_wellboreTrajectories[wellboreId].clear();
for ( const QJsonValue& value : resultsArray )
{
QJsonObject resultObj = value.toObject();
QString id = resultObj["id"].toString();
QString kind = resultObj["kind"].toString();
m_wellboreTrajectories[wellboreId].push_back( OsduWellboreTrajectory{ id, kind, wellboreId } );
}
}
emit wellboreTrajectoryFinished( wellboreId, resultsArray.size(), "" );
}
else
{
emit wellboreTrajectoryFinished( wellboreId, 0, "Failed to download: " + reply->errorString() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::parseWellLogs( QNetworkReply* reply, const QString& wellboreId )
{
QByteArray result = reply->readAll();
reply->deleteLater();
if ( reply->error() == QNetworkReply::NoError )
{
QJsonDocument doc = QJsonDocument::fromJson( result );
QJsonObject jsonObj = doc.object();
QJsonArray resultsArray = jsonObj["results"].toArray();
{
QMutexLocker lock( &m_mutex );
m_wellLogs[wellboreId].clear();
for ( const QJsonValue& value : resultsArray )
{
QJsonObject resultObj = value.toObject();
QString id = resultObj["id"].toString();
QString kind = resultObj["kind"].toString();
QJsonObject dataObj = resultObj["data"].toObject();
QString name = dataObj["Name"].toString();
QString description = dataObj["Description"].toString();
double samplingStart = dataObj["SamplingStart"].toDouble( std::numeric_limits<double>::infinity() );
double samplingStop = dataObj["SamplingStop"].toDouble( std::numeric_limits<double>::infinity() );
QJsonArray curvesArray = dataObj["Curves"].toArray();
RiaLogging::debug( QString( "Curves for '%1':" ).arg( id ) );
std::vector<OsduWellLogChannel> channels;
for ( const QJsonValue& curve : curvesArray )
{
QString mnemonic = curve["Mnemonic"].toString();
QString curveId = curve["CurveID"].toString();
QString curveDescription = curve["CurveDescription"].toString();
double curveBaseDepth = curve["BaseDepth"].toDouble( std::numeric_limits<double>::infinity() );
double curveTopDepth = curve["TopDepth"].toDouble( std::numeric_limits<double>::infinity() );
QString interpreterName = curve["InterpreterName"].toString();
QString quality = curve["CurveQuality"].toString();
QString unit = curve["CurveUnit"].toString();
QString depthUnit = curve["DepthUnit"].toString();
RiaLogging::debug(
QString( "%1: '%2' (%3 - %4)" ).arg( curveId ).arg( curveDescription ).arg( curveTopDepth ).arg( curveBaseDepth ) );
channels.push_back( OsduWellLogChannel{ .id = curveId,
.mnemonic = mnemonic,
.description = curveDescription,
.topDepth = curveTopDepth,
.baseDepth = curveBaseDepth,
.interpreterName = interpreterName,
.quality = quality,
.unit = unit,
.depthUnit = depthUnit } );
}
m_wellLogs[wellboreId].push_back( OsduWellLog{ .id = id,
.kind = kind,
.name = name,
.description = description,
.samplingStart = samplingStart,
.samplingStop = samplingStop,
.wellboreId = wellboreId,
.channels = channels } );
}
}
emit wellLogsFinished( wellboreId );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::addStandardHeader( QNetworkRequest& networkRequest,
const QString& token,
const QString& dataPartitionId,
const QString& contentType )
{
networkRequest.setHeader( QNetworkRequest::ContentTypeHeader, contentType );
networkRequest.setRawHeader( "Authorization", "Bearer " + token.toUtf8() );
networkRequest.setRawHeader( QByteArray( "Data-Partition-Id" ), dataPartitionId.toUtf8() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QNetworkReply*
RiaOsduConnector::makeDownloadRequest( const QString& url, const QString& dataPartitionId, const QString& token, const QString& contentType )
{
QNetworkRequest networkRequest;
networkRequest.setUrl( QUrl( url ) );
addStandardHeader( networkRequest, token, dataPartitionId, contentType );
auto reply = m_networkAccessManager->get( networkRequest );
return reply;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaOsduConnector::dataPartition() const
{
return m_dataPartitionId;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<OsduField> RiaOsduConnector::fields() const
{
QMutexLocker lock( &m_mutex );
return m_fields;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<OsduWell> RiaOsduConnector::wells() const
{
QMutexLocker lock( &m_mutex );
return m_wells;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<OsduWellLog> RiaOsduConnector::wellLogs( const QString& wellboreId ) const
{
QMutexLocker lock( &m_mutex );
auto it = m_wellLogs.find( wellboreId );
if ( it != m_wellLogs.end() ) return it->second;
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<OsduWellbore> RiaOsduConnector::wellbores( const QString& wellId ) const
{
QMutexLocker lock( &m_mutex );
auto it = m_wellbores.find( wellId );
if ( it != m_wellbores.end() ) return it->second;
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaOsduConnector::wellIdForWellboreId( const QString& wellboreId ) const
{
auto findWellIdForWellboreId = []( const std::vector<OsduWellbore>& wellbores, const QString& wellboreId )
{
auto it = std::find_if( wellbores.begin(), wellbores.end(), [wellboreId]( const OsduWellbore& w ) { return w.id == wellboreId; } );
if ( it != wellbores.end() ) return it->wellId;
return QString();
};
QMutexLocker lock( &m_mutex );
for ( auto [wellId, wellbores] : m_wellbores )
{
if ( auto res = findWellIdForWellboreId( wellbores, wellboreId ); !res.isEmpty() )
{
return wellId;
}
}
return QString();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<OsduWellboreTrajectory> RiaOsduConnector::wellboreTrajectories( const QString& wellboreId ) const
{
QMutexLocker lock( &m_mutex );
auto it = m_wellboreTrajectories.find( wellboreId );
if ( it != m_wellboreTrajectories.end() ) return it->second;
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId )
{
QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId );
RiaLogging::debug( "Wellbore trajectory URL: " + url );
requestParquetDataByUrl( url, wellboreTrajectoryId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestWellLogParquetDataById( const QString& wellLogId )
{
QString url = constructWellLogDownloadUrl( m_server, wellLogId );
RiaLogging::debug( "Well log URL: " + url );
requestParquetDataByUrl( url, wellLogId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestParquetDataByUrl( const QString& url, const QString& id )
{
requestParquetData( url, m_dataPartitionId, token(), id );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<QByteArray, QString> RiaOsduConnector::requestWellboreTrajectoryParquetDataByIdBlocking( const QString& wellboreTrajectoryId )
{
QString url = constructWellboreTrajectoriesDownloadUrl( m_server, wellboreTrajectoryId );
RiaLogging::debug( "Wellbore trajectory URL: " + url );
return requestParquetDataByUrlBlocking( url, wellboreTrajectoryId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<QByteArray, QString> RiaOsduConnector::requestWellLogParquetDataByIdBlocking( const QString& wellLogId )
{
QString url = constructWellLogDownloadUrl( m_server, wellLogId );
RiaLogging::debug( "Well log URL: " + url );
return requestParquetDataByUrlBlocking( url, wellLogId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<QByteArray, QString> RiaOsduConnector::requestParquetDataByUrlBlocking( const QString& url, const QString& id )
{
QString token = requestTokenBlocking();
QEventLoop loop;
connect( this, SIGNAL( parquetDownloadFinished( const QByteArray&, const QString&, const QString& ) ), &loop, SLOT( quit() ) );
requestParquetData( url, m_dataPartitionId, token, id );
loop.exec();
QMutexLocker lock( &m_mutex );
return { m_parquetData[id], m_parquetErrors[id] };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token, const QString& id )
{
RiaLogging::info( "Requesting download of parquet from: " + url );
auto reply = makeDownloadRequest( url, dataPartitionId, token, RiaCloudDefines::contentTypeParquet() );
m_repliesMutex.lock();
m_replies[id] = reply;
m_repliesMutex.unlock();
connect( reply,
&QNetworkReply::finished,
[this, reply, url, id]()
{
if ( reply->error() == QNetworkReply::NoError )
{
QByteArray contents = reply->readAll();
RiaLogging::info( QString( "Download succeeded: %1 bytes." ).arg( contents.length() ) );
emit parquetDownloadFinished( contents, "", id );
}
else
{
QString errorMessage = "Request failed: " + url + " failed." + reply->errorString();
RiaLogging::error( errorMessage );
emit parquetDownloadFinished( QByteArray(), errorMessage, id );
}
} );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::parquetDownloadComplete( const QByteArray& contents, const QString& errorMessage, const QString& id )
{
CAF_ASSERT( !id.isEmpty() );
QMutexLocker lock( &m_mutex );
m_parquetData[id] = contents;
m_parquetErrors[id] = errorMessage;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaOsduConnector::cancelRequestForId( const QString& id )
{
QMutexLocker lock( &m_repliesMutex );
auto it = m_replies.find( id );
if ( it != m_replies.end() )
{
if ( !it->second.isNull() )
{
it->second->abort();
}
}
}

View File

@@ -0,0 +1,187 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiaCloudConnector.h"
#include <QtCore>
#include <QNetworkAccessManager>
#include <QtNetworkAuth/QOAuth2AuthorizationCodeFlow>
#include <map>
struct OsduField
{
QString id;
QString kind;
QString name;
};
struct OsduWell
{
QString id;
QString kind;
QString name;
};
struct OsduWellbore
{
QString id;
QString kind;
QString name;
QString wellId;
double datumElevation;
};
struct OsduWellboreTrajectory
{
QString id;
QString kind;
QString wellboreId;
};
struct OsduWellLogChannel
{
QString id;
QString mnemonic;
QString description;
double topDepth;
double baseDepth;
QString interpreterName;
QString quality;
QString unit;
QString depthUnit;
};
struct OsduWellLog
{
QString id;
QString kind;
QString name;
QString description;
double samplingStart;
double samplingStop;
QString wellboreId;
std::vector<OsduWellLogChannel> channels;
};
//==================================================================================================
///
//==================================================================================================
class RiaOsduConnector : public RiaCloudConnector
{
Q_OBJECT
public:
RiaOsduConnector( QObject* parent,
const QString& server,
const QString& dataParitionId,
const QString& authority,
const QString& scopes,
const QString& clientId,
unsigned int port );
~RiaOsduConnector() override;
void requestFieldsByName( const QString& fieldName );
void requestWellsByFieldId( const QString& fieldId );
void requestWellboresByWellId( const QString& wellId );
void requestWellboreTrajectoryByWellboreId( const QString& wellboreId );
void requestWellLogsByWellboreId( const QString& wellboreId );
std::vector<OsduWellLog> requestWellLogsByWellboreIdBlocking( const QString& wellboreId );
void requestWellLogParquetDataById( const QString& wellLogId );
void requestWellboreTrajectoryParquetDataById( const QString& wellboreTrajectoryId );
std::pair<QByteArray, QString> requestWellLogParquetDataByIdBlocking( const QString& wellLogId );
std::pair<QByteArray, QString> requestWellboreTrajectoryParquetDataByIdBlocking( const QString& wellboreTrajectoryId );
QString wellIdForWellboreId( const QString& wellboreId ) const;
void cancelRequestForId( const QString& id );
void clearCachedData();
QString dataPartition() const;
std::vector<OsduField> fields() const;
std::vector<OsduWell> wells() const;
std::vector<OsduWellbore> wellbores( const QString& wellId ) const;
std::vector<OsduWellboreTrajectory> wellboreTrajectories( const QString& wellboreId ) const;
std::vector<OsduWellLog> wellLogs( const QString& wellboreId ) const;
public slots:
void parseFields( QNetworkReply* reply );
void parseWells( QNetworkReply* reply );
void parseWellbores( QNetworkReply* reply, const QString& wellId );
void parseWellTrajectory( QNetworkReply* reply, const QString& wellboreId );
void parseWellLogs( QNetworkReply* reply, const QString& wellboreId );
void parquetDownloadComplete( const QByteArray&, const QString& url, const QString& id );
signals:
void parquetDownloadFinished( const QByteArray& contents, const QString& url, const QString& id );
void fieldsFinished();
void wellsFinished();
void wellboresFinished( const QString& wellId );
void wellboreTrajectoryFinished( const QString& wellboreId, int numTrajectories, const QString& errorMessage );
void wellLogsFinished( const QString& wellboreId );
private slots:
void requestParquetData( const QString& url, const QString& dataPartitionId, const QString& token, const QString& id );
private:
void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& dataPartitionId, const QString& contentType );
QNetworkReply* makeSearchRequest( const std::map<QString, QString>& parameters,
const QString& server,
const QString& dataPartitionId,
const QString& token );
QNetworkReply* makeDownloadRequest( const QString& url, const QString& dataPartitionId, const QString& token, const QString& contentType );
void requestFieldsByName( const QString& token, const QString& fieldName );
void requestFieldsByName( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldName );
void requestWellsByFieldId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& fieldId );
void requestWellboresByWellId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellId );
void requestWellboreTrajectoryByWellboreId( const QString& server,
const QString& dataPartitionId,
const QString& token,
const QString& wellboreId );
void requestWellLogsByWellboreId( const QString& server, const QString& dataPartitionId, const QString& token, const QString& wellboreId );
static QString constructSearchUrl( const QString& server );
static QString constructFileDownloadUrl( const QString& server, const QString& fileId );
static QString constructWellLogDownloadUrl( const QString& server, const QString& wellLogId );
static QString constructWellboreTrajectoriesDownloadUrl( const QString& server, const QString& wellboreTrajectoryId );
std::pair<QByteArray, QString> requestParquetDataByUrlBlocking( const QString& url, const QString& id );
void requestParquetDataByUrl( const QString& url, const QString& id );
const QString m_dataPartitionId;
mutable QMutex m_mutex;
mutable QMutex m_repliesMutex;
std::vector<OsduField> m_fields;
std::vector<OsduWell> m_wells;
std::map<QString, std::vector<OsduWellbore>> m_wellbores;
std::map<QString, std::vector<OsduWellboreTrajectory>> m_wellboreTrajectories;
std::map<QString, std::vector<OsduWellLog>> m_wellLogs;
std::map<QString, QByteArray> m_parquetData;
std::map<QString, QString> m_parquetErrors;
std::map<QString, QPointer<QNetworkReply>> m_replies;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,162 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiaCloudConnector.h"
#include "RiaSumoDefines.h"
#include <QByteArray>
#include <QNetworkAccessManager>
#include <QtNetworkAuth/QOAuth2AuthorizationCodeFlow>
#include <map>
class QEventLoop;
using SumoObjectId = QString;
struct SumoAsset
{
SumoAssetId assetId;
QString kind;
QString name;
};
struct SumoCase
{
SumoCaseId caseId;
QString kind;
QString name;
};
struct SumoRedirect
{
SumoObjectId objectId;
QString blobName;
QString url;
QString redirectBaseUri;
QString redirectAuth;
QByteArray contents;
};
struct SumoEnsemble
{
SumoCaseId caseId;
QString name;
};
//==================================================================================================
///
//==================================================================================================
class RiaSumoConnector : public RiaCloudConnector
{
Q_OBJECT
public:
RiaSumoConnector( QObject* parent,
const QString& server,
const QString& authority,
const QString& scopes,
const QString& clientId,
unsigned int port );
~RiaSumoConnector() override;
void requestAssets();
void requestAssetsBlocking();
void requestCasesForField( const QString& fieldName );
void requestCasesForFieldBlocking( const QString& fieldName );
void requestEnsembleByCasesId( const SumoCaseId& caseId );
void requestEnsembleByCasesIdBlocking( const SumoCaseId& caseId );
void requestVectorNamesForEnsemble( const SumoCaseId& caseId, const QString& ensembleName );
void requestVectorNamesForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName );
void requestRealizationIdsForEnsemble( const SumoCaseId& caseId, const QString& ensembleName );
void requestRealizationIdsForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName );
void requestParametersBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName );
void requestParametersBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName );
QByteArray requestParametersParquetDataBlocking( const SumoCaseId& caseId, const QString& ensembleName );
void requestBlobIdForEnsemble( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName );
void requestBlobIdForEnsembleBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName );
void requestBlobDownload( const QString& blobId );
void requestBlobByRedirectUri( const QString& blobId, const QString& redirectUri );
QByteArray requestParquetDataBlocking( const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName );
std::vector<SumoAsset> assets() const;
std::vector<SumoCase> cases() const;
std::vector<QString> ensembleNamesForCase( const SumoCaseId& caseId ) const;
std::vector<QString> vectorNames() const;
std::vector<QString> realizationIds() const;
std::vector<QString> blobUrls() const;
std::vector<SumoRedirect> blobContents() const;
public slots:
void parseAssets( QNetworkReply* reply );
void parseEnsembleNames( QNetworkReply* reply, const SumoCaseId& caseId );
void parseCases( QNetworkReply* reply );
void parseVectorNames( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName );
void parseRealizationNumbers( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName );
void parseBlobIds( QNetworkReply* reply, const SumoCaseId& caseId, const QString& ensembleName, const QString& vectorName, bool isParameters );
void requestFailed( const QAbstractOAuth::Error error );
void parquetDownloadComplete( const QString& blobId, const QByteArray&, const QString& url );
signals:
void fileDownloadFinished( const QString& fileId, const QString& filePath );
void casesFinished();
void wellsFinished();
void wellboresFinished( const QString& wellId );
void wellboreTrajectoryFinished( const QString& wellboreId );
void parquetDownloadFinished( const QByteArray& contents, const QString& url );
void ensembleNamesFinished();
void vectorNamesFinished();
void blobIdFinished();
void assetsFinished();
void realizationIdsFinished();
private:
void addStandardHeader( QNetworkRequest& networkRequest, const QString& token, const QString& contentType );
QNetworkReply* makeRequest( const std::map<QString, QString>& parameters, const QString& server, const QString& token );
QNetworkReply* makeDownloadRequest( const QString& url, const QString& token, const QString& contentType );
void requestParquetData( const QString& url, const QString& token );
static QString constructSearchUrl( const QString& server );
static QString constructDownloadUrl( const QString& server, const QString& blobId );
void wrapAndCallNetworkRequest( std::function<void()> requestCallable, const QMetaMethod& signalMethod );
private:
std::vector<SumoAsset> m_assets;
std::vector<SumoCase> m_cases;
std::vector<QString> m_vectorNames;
std::vector<QString> m_realizationIds;
std::vector<SumoEnsemble> m_ensembleNames;
std::vector<QString> m_blobUrl;
std::vector<SumoRedirect> m_redirectInfo;
};

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor ASA
// Copyright (C) 2024- 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
@@ -16,24 +16,23 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimPolylinesFromFileAnnotationInView.h"
#include "RimPolylinesFromFileAnnotation.h"
#include "RiaSumoDefines.h"
CAF_PDM_SOURCE_INIT( RimPolylinesFromFileAnnotationInView, "RimPolylinesFromFileAnnotationInView" );
#include <QDir>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolylinesFromFileAnnotationInView::RimPolylinesFromFileAnnotationInView()
QString RiaSumoDefines::tokenPath()
{
CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png" );
QString homePath = QDir::homePath();
return homePath + "/.resinsight/sumo_token.json";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolylinesFromFileAnnotationInView::RimPolylinesFromFileAnnotationInView( RimPolylinesFromFileAnnotation* sourceAnnotation )
: RimPolylinesAnnotationInView( sourceAnnotation )
int RiaSumoDefines::requestTimeoutMillis()
{
CAF_PDM_InitObject( "PolyLines Annotation", ":/PolylinesFromFile16x16.png" );
return 10 * 1000;
}

View File

@@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "nonstd/type.hpp"
#include <QString>
using SumoAssetId = nonstd::ordered<QString, struct sumo_asset_tag>;
using SumoCaseId = nonstd::ordered<QString, struct sumo_case_tag>;
namespace RiaSumoDefines
{
QString tokenPath();
int requestTimeoutMillis();
}; // namespace RiaSumoDefines

View File

@@ -135,6 +135,11 @@ bool RiaArgumentParser::parseArguments( cvf::ProgramOptions* progOpt )
progOpt->registerOption( "version", "", "Display the application version string" );
progOpt->registerOption( "openplotwindow", "", "Open the 2D plot window. By default, the 3D window is displayed." );
progOpt->registerOption( "egridReader",
"<readerName>",
"Select the reader type used to access EGRID files, valid values are RESDATA or OPM_COMMON",
cvf::ProgramOptions::SINGLE_VALUE );
progOpt->setOptionPrefix( cvf::ProgramOptions::DOUBLE_DASH );
QStringList arguments = QCoreApplication::arguments();

View File

@@ -549,6 +549,25 @@ const caf::ColorTable& RiaColorTables::heatMapPaletteColors()
return colorTable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const caf::ColorTable& RiaColorTables::curveSetPaletteColors()
{
static std::vector<cvf::Color3ub> colors{
cvf::Color3ub( 255, 131, 140 ), // Old pink
cvf::Color3ub( 210, 176, 112 ), // Light Brown
cvf::Color3ub( 140, 171, 238 ), // Light gray blue
cvf::Color3ub( 130, 255, 120 ), // Light green
cvf::Color3ub( 255, 64, 236 ), // Magenta
cvf::Color3ub( 101, 132, 96 ), // Dark green
};
static caf::ColorTable colorTable = caf::ColorTable( colors );
return colorTable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -63,6 +63,7 @@ public:
static const caf::ColorTable& waterAndRockPaletteColors();
static const caf::ColorTable& correlationPaletteColors();
static const caf::ColorTable& heatMapPaletteColors();
static const caf::ColorTable& curveSetPaletteColors();
static cvf::Color3f undefinedCellColor();

View File

@@ -25,7 +25,7 @@
#include "RimCaseDisplayNameTools.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryEnsemble.h"
#include "cafAppEnum.h"

View File

@@ -259,7 +259,7 @@ void addToPathTree( PathNode* node, QStringList pathComponents, const QString& f
}
}
node->children.push_back( std::unique_ptr<PathNode>( new PathNode( pathComponent, node ) ) );
node->children.push_back( std::make_unique<PathNode>( pathComponent, node ) );
addToPathTree( node->children.back().get(), pathComponents, fileName );
}
else
@@ -335,7 +335,7 @@ std::map<QString, QStringList> RiaFilePathTools::keyPathComponentsForEachFilePat
allComponents[fileName] = pathComponentsForFile;
}
auto topNode = std::unique_ptr<PathNode>( new PathNode( "", nullptr ) );
auto topNode = std::make_unique<PathNode>( "", nullptr );
for ( auto keyComponentsPair : allComponents )
{

View File

@@ -26,6 +26,7 @@
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RiaPreferencesGrid.h"
#include "RifEclipseSummaryTools.h"
#include "RifReaderSettings.h"
@@ -48,10 +49,10 @@
#include "RimProject.h"
#include "RimRoffCase.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryEnsemble.h"
#include "RimSummaryPlot.h"
#include "RimWellLogRftCurve.h"
@@ -68,11 +69,20 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fileNames,
bool createView,
FileCaseIdMap* openedFilesOut,
bool noDialog,
std::shared_ptr<RifReaderSettings> readerSettings )
bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fileNames, bool createView, FileCaseIdMap* openedFilesOut, bool noDialog )
{
RifReaderSettings rs = RiaPreferencesGrid::current()->readerSettings();
return openEclipseCasesFromFile( fileNames, createView, openedFilesOut, noDialog, rs );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fileNames,
bool createView,
FileCaseIdMap* openedFilesOut,
bool noDialog,
RifReaderSettings& readerSettings )
{
RimProject* project = RimProject::current();
if ( !project ) return false;
@@ -100,16 +110,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
RimMainPlotCollection::current()->ensureDefaultFlowPlotsAreCreated();
}
// The default value for summary case import is true, but we use the state from RifReaderSettings if defined
//
// TODO:
// Refactor RifReaderSettings, separate the data structure sent to reader from the data structure in
// preferences. See RifReaderSettings::createGridOnlyReaderSettings() for the only use of importSummaryData flag
//
bool importSummaryCases = true;
if ( readerSettings ) importSummaryCases = readerSettings->importSummaryData;
if ( importSummaryCases && !summaryFileInfos.empty() )
if ( readerSettings.importSummaryData && !summaryFileInfos.empty() )
{
RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection()
: nullptr;
@@ -120,11 +121,11 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
for ( RimSummaryCase* newSumCase : candidateCases )
{
RimSummaryCaseCollection* existingCollection = nullptr;
RimSummaryEnsemble* existingCollection = nullptr;
auto existingSummaryCase = sumCaseColl->findTopLevelSummaryCaseFromFileName( newSumCase->summaryHeaderFilename() );
if ( existingSummaryCase )
{
existingCollection = existingSummaryCase->firstAncestorOrThisOfType<RimSummaryCaseCollection>();
existingCollection = existingSummaryCase->firstAncestorOrThisOfType<RimSummaryEnsemble>();
// Replace file summary case pointers in Rft Curves
auto rftCurves = existingSummaryCase->objectsWithReferringPtrFieldsOfType<RimWellLogRftCurve>();
@@ -228,7 +229,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaImportEclipseCaseTools::openEclipseCaseFromFile( const QString& fileName, bool createView, std::shared_ptr<RifReaderSettings> readerSettings )
int RiaImportEclipseCaseTools::openEclipseCaseFromFile( const QString& fileName, bool createView, RifReaderSettings& readerSettings )
{
if ( !caf::Utils::fileExists( fileName ) ) return -1;
@@ -243,9 +244,10 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilter( const QString
{
if ( !caf::Utils::fileExists( fileName ) ) return false;
bool showTimeStepFilter = true;
bool createView = true;
return RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( fileName, showTimeStepFilter, createView, nullptr ) >= 0;
bool showTimeStepFilter = true;
bool createView = true;
RifReaderSettings rs = RiaPreferencesGrid::current()->readerSettings();
return RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( fileName, showTimeStepFilter, createView, rs ) >= 0;
}
//--------------------------------------------------------------------------------------------------
@@ -318,18 +320,19 @@ std::vector<int> RiaImportEclipseCaseTools::openEclipseInputCasesFromFileNames(
//--------------------------------------------------------------------------------------------------
bool RiaImportEclipseCaseTools::openMockModel( const QString& name )
{
bool showTimeStepFilter = false;
bool createView = true;
return RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( name, showTimeStepFilter, createView, nullptr );
bool showTimeStepFilter = false;
bool createView = true;
RifReaderSettings rs = RiaPreferencesGrid::current()->readerSettings();
return RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( name, showTimeStepFilter, createView, rs );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QString& fileName,
bool showTimeStepFilter,
bool createView,
std::shared_ptr<RifReaderSettings> readerSettings )
int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QString& fileName,
bool showTimeStepFilter,
bool createView,
RifReaderSettings& readerSettings )
{
RimProject* project = RimProject::current();
if ( !project ) return -1;

View File

@@ -18,17 +18,19 @@
#pragma once
#include <QStringList>
#include "RifReaderSettings.h"
#include <map>
#include <memory>
#include <utility>
#include <vector>
class QString;
class QStringList;
class RimIdenticalGridCaseGroup;
class RimRoffCase;
class RifReaderSettings;
//==================================================================================================
///
@@ -39,11 +41,13 @@ public:
using CaseFileNameAndId = std::pair<QString, int>;
using FileCaseIdMap = std::map<QString, int>;
static bool openEclipseCasesFromFile( const QStringList& fileNames,
bool createView,
FileCaseIdMap* openedFilesOut,
bool noDialog,
std::shared_ptr<RifReaderSettings> readerSettings = nullptr );
static bool openEclipseCasesFromFile( const QStringList& fileNames, bool createView, FileCaseIdMap* openedFilesOut, bool noDialog );
static bool openEclipseCasesFromFile( const QStringList& fileNames,
bool createView,
FileCaseIdMap* openedFilesOut,
bool noDialog,
RifReaderSettings& readerSettings );
static bool openEclipseCaseShowTimeStepFilter( const QString& fileName );
@@ -54,7 +58,7 @@ public:
static bool addEclipseCases( const QStringList& fileNames, RimIdenticalGridCaseGroup** resultingCaseGroup = nullptr );
static int openEclipseCaseFromFile( const QString& fileName, bool createView, std::shared_ptr<RifReaderSettings> readerSettings = nullptr );
static int openEclipseCaseFromFile( const QString& fileName, bool createView, RifReaderSettings& readerSettings );
static std::vector<int> openRoffCasesFromFileNames( const QStringList& fileNames, bool createDefaultView );
static RimRoffCase* openRoffCaseFromFileName( const QString& fileName, bool createDefaultView );
@@ -62,8 +66,8 @@ public:
static bool openEmFilesFromFileNames( const QStringList& fileNames, bool createDefaultView, std::vector<int>& createdCaseIds );
private:
static int openEclipseCaseShowTimeStepFilterImpl( const QString& fileName,
bool showTimeStepFilter,
bool createView,
std::shared_ptr<RifReaderSettings> readerSettings );
static int openEclipseCaseShowTimeStepFilterImpl( const QString& fileName,
bool showTimeStepFilter,
bool createView,
RifReaderSettings& readerSettings );
};

View File

@@ -76,7 +76,7 @@ double RiaInterpolationTools::linear( const std::vector<double>& x, const std::v
{
return extrapolateClosestValue( x, y, value );
}
else if ( extrapolationMode == ExtrapolationMode::TREND )
else if ( extrapolationMode == ExtrapolationMode::TREND && x.size() >= 2 )
{
return extrapolate( x, y, value );
}
@@ -103,7 +103,25 @@ double RiaInterpolationTools::linear( const std::vector<double>& x, const std::v
//--------------------------------------------------------------------------------------------------
double RiaInterpolationTools::extrapolate( const std::vector<double>& x, const std::vector<double>& y, double value )
{
return y[0] + ( value - x[0] ) / ( x[1] - x[0] ) * ( y[1] - y[0] );
CAF_ASSERT( x.size() == y.size() );
CAF_ASSERT( x.size() >= 2 && "Need at least two points for extrapolation" );
if ( value <= x[0] )
return extrapolate( x[0], y[0], x[1], y[1], value );
else
{
size_t lastIndex = x.size() - 1;
size_t secondLastIndex = x.size() - 2;
return extrapolate( x[secondLastIndex], y[secondLastIndex], x[lastIndex], y[lastIndex], value );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaInterpolationTools::extrapolate( double x0, double y0, double x1, double y1, double value )
{
return y0 + ( value - x0 ) / ( x1 - x0 ) * ( y1 - y0 );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -47,5 +47,7 @@ private:
static int findNextDataPoint( const std::vector<double>& values, int index );
static int findPreviousDataPoint( const std::vector<double>& values, int index );
static double extrapolate( const std::vector<double>& x, const std::vector<double>& y, double value );
static double extrapolate( double x0, double y0, double x1, double y1, double value );
static double extrapolateClosestValue( const std::vector<double>& x, const std::vector<double>& y, double value );
};

View File

@@ -0,0 +1,140 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaProjectBackupTools.h"
#include "RiaLogging.h"
#include <QDateTime>
#include <QVariant>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>
namespace RiaProjectBackupTools
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool createTableIfNeeded()
{
QSqlQuery query;
if ( !query.exec( "CREATE TABLE IF NOT EXISTS file_versions ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"timestamp DATETIME,"
"content TEXT)" ) )
{
QString txt = "Error creating table:" + query.lastError().text();
RiaLogging::error( txt );
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool insertContent( const QString& content )
{
QSqlQuery query;
query.prepare( "INSERT INTO file_versions (timestamp, content) "
"VALUES (:timestamp, :content)" );
query.bindValue( ":timestamp", QDateTime::currentDateTime() );
query.bindValue( ":content", content );
if ( !query.exec() )
{
QString txt = "Error saving file content to database:" + query.lastError().text();
RiaLogging::error( txt );
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool deleteOldRecords( int maximumRecordCount )
{
QSqlQuery countQuery( "SELECT COUNT(*) FROM file_versions" );
if ( !countQuery.exec() || !countQuery.next() )
{
RiaLogging::error( "Error counting records: " + countQuery.lastError().text() );
return false;
}
int count = countQuery.value( 0 ).toInt();
int recordsToDelete = count - maximumRecordCount;
if ( recordsToDelete <= 0 ) return true;
QSqlQuery query;
query.prepare( "DELETE FROM file_versions WHERE id IN (SELECT id FROM file_versions ORDER BY timestamp ASC LIMIT :limit)" );
query.bindValue( ":limit", recordsToDelete );
if ( !query.exec() )
{
QString txt = "Error deleting old records:" + query.lastError().text();
RiaLogging::error( txt );
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool appendTextToDatabase( const QString& databaseFilePath, int maximumRecordCount, const QString& content )
{
const QString databaseType = "QSQLITE";
if ( !QSqlDatabase::isDriverAvailable( databaseType ) )
{
RiaLogging::error( "sqlite database is not available." );
return false;
}
// Try to open the SQLITE database
QSqlDatabase db = QSqlDatabase::database();
if ( !db.isValid() || !db.open() )
{
RiaLogging::info( "Adding database" );
// Add the SQLITE database, and it it required to do this once per session. The database will be available during the lifetime of
// the application, and can be accessed using QSqlDatabase::database()
db = QSqlDatabase::addDatabase( databaseType );
}
if ( !db.open() )
{
QString txt = "Error opening database:" + db.lastError().text();
RiaLogging::error( txt );
return false;
}
// Set the file name for the database. The database will be created if it does not exist.
db.setDatabaseName( databaseFilePath );
if ( !createTableIfNeeded() ) return false;
if ( !deleteOldRecords( maximumRecordCount ) ) return false;
if ( !insertContent( content ) ) return false;
return true;
}
} // namespace RiaProjectBackupTools

View File

@@ -0,0 +1,29 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
//==================================================================================================
//
//==================================================================================================
namespace RiaProjectBackupTools
{
bool appendTextToDatabase( const QString& databaseFilePath, int maximumRecordCount, const QString& content );
} // namespace RiaProjectBackupTools

View File

@@ -16,51 +16,47 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaProjectFileVersionTools.h"
#include "RiaProjectFileTools.h"
#include <QStringList>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaProjectFileVersionTools::isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& projectFileVersion )
bool RiaProjectFileTools::isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& projectFileVersion )
{
int candidateMajorVersion = 0;
int candidateMinorVersion = 0;
int candidatePatchNumber = -1;
int candidateDevelopmentId = -1;
RiaProjectFileVersionTools::decodeVersionString( candidateProjectFileVersion,
&candidateMajorVersion,
&candidateMinorVersion,
&candidatePatchNumber,
&candidateDevelopmentId );
RiaProjectFileTools::decodeVersionString( candidateProjectFileVersion,
&candidateMajorVersion,
&candidateMinorVersion,
&candidatePatchNumber,
&candidateDevelopmentId );
int majorVersion = 0;
int minorVersion = 0;
int patchNumber = -1;
int developmentId = -1;
RiaProjectFileVersionTools::decodeVersionString( projectFileVersion, &majorVersion, &minorVersion, &patchNumber, &developmentId );
RiaProjectFileTools::decodeVersionString( projectFileVersion, &majorVersion, &minorVersion, &patchNumber, &developmentId );
return RiaProjectFileVersionTools::isCandidateNewerThanOther( candidateMajorVersion,
candidateMinorVersion,
candidatePatchNumber,
candidateDevelopmentId,
majorVersion,
minorVersion,
patchNumber,
developmentId );
return RiaProjectFileTools::isCandidateNewerThanOther( candidateMajorVersion,
candidateMinorVersion,
candidatePatchNumber,
candidateDevelopmentId,
majorVersion,
minorVersion,
patchNumber,
developmentId );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFileVersion,
int* majorVersion,
int* minorVersion,
int* patch,
int* developmentId )
void RiaProjectFileTools::decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId )
{
if ( projectFileVersion.isEmpty() ) return;
@@ -79,7 +75,7 @@ void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFile
if ( subStrings.size() > 2 )
{
QString candidate = subStrings[2];
QString candidateDigitsOnly = RiaProjectFileVersionTools::stringOfDigits( candidate );
QString candidateDigitsOnly = RiaProjectFileTools::stringOfDigits( candidate );
*patch = candidateDigitsOnly.toInt();
}
@@ -87,7 +83,7 @@ void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFile
if ( subStrings.size() > 3 )
{
QString candidate = subStrings.back();
QString candidateDigitsOnly = RiaProjectFileVersionTools::stringOfDigits( candidate );
QString candidateDigitsOnly = RiaProjectFileTools::stringOfDigits( candidate );
*developmentId = candidateDigitsOnly.toInt();
}
@@ -96,14 +92,14 @@ void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFile
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaProjectFileVersionTools::isCandidateNewerThanOther( int candidateMajorVersion,
int candidateMinorVersion,
int candidatePatchNumber,
int candidateDevelopmentId,
int otherMajorVersion,
int otherMinorVersion,
int otherPatchNumber,
int otherDevelopmentId )
bool RiaProjectFileTools::isCandidateNewerThanOther( int candidateMajorVersion,
int candidateMinorVersion,
int candidatePatchNumber,
int candidateDevelopmentId,
int otherMajorVersion,
int otherMinorVersion,
int otherPatchNumber,
int otherDevelopmentId )
{
if ( candidateMajorVersion != otherMajorVersion )
{
@@ -137,7 +133,7 @@ bool RiaProjectFileVersionTools::isCandidateNewerThanOther( int candidateMajorVe
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaProjectFileVersionTools::stringOfDigits( const QString& string )
QString RiaProjectFileTools::stringOfDigits( const QString& string )
{
QString digitsOnly;

View File

@@ -18,12 +18,17 @@
#pragma once
#include "cafPdmField.h"
#include "cafPdmObjectHandle.h"
#include <QString>
#include <vector>
//==================================================================================================
//
//==================================================================================================
class RiaProjectFileVersionTools
class RiaProjectFileTools
{
public:
static bool isCandidateVersionNewerThanOther( const QString& candidateProjectFileVersion, const QString& otherProjectFileVersion );
@@ -31,6 +36,39 @@ public:
// Public to be able to unit test function, not intended to be used
static void decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId );
template <typename T>
static void fieldContentsByType( const caf::PdmObjectHandle* object, std::vector<T*>& fieldContents )
{
if ( !object ) return;
std::vector<caf::PdmFieldHandle*> allFieldsInObject = object->fields();
std::vector<caf::PdmObjectHandle*> children;
for ( const auto& field : allFieldsInObject )
{
caf::PdmField<T>* typedField = dynamic_cast<caf::PdmField<T>*>( field );
if ( typedField ) fieldContents.push_back( &typedField->v() );
caf::PdmField<std::vector<T>>* typedFieldInVector = dynamic_cast<caf::PdmField<std::vector<T>>*>( field );
if ( typedFieldInVector )
{
for ( T& typedFieldFromVector : typedFieldInVector->v() )
{
fieldContents.push_back( &typedFieldFromVector );
}
}
auto other = field->children();
children.insert( children.end(), other.begin(), other.end() );
}
for ( const auto& child : children )
{
fieldContentsByType( child, fieldContents );
}
}
private:
static bool isCandidateNewerThanOther( int candidateMajorVersion,
int candidateMinorVersion,

View File

@@ -201,12 +201,12 @@ QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, RiaDefines::Da
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RiaQDateTimeTools::createDateTime( const QDate& date )
QDateTime RiaQDateTimeTools::createDateTime( const QDate& date, Qt::TimeSpec timeSpec /*= Qt::LocalTime*/ )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
return date.startOfDay();
return date.startOfDay( timeSpec );
#else
return QDateTime( date, QTime( 0, 0 ) );
return QDateTime( date, QTime( 0, 0 ), timeSpec );
#endif
}

View File

@@ -58,7 +58,7 @@ public:
static QDateTime addPeriod( const QDateTime& dt, RiaDefines::DateTimePeriod period );
static QDateTime subtractPeriod( const QDateTime& dt, RiaDefines::DateTimePeriod period );
static QDateTime createDateTime( const QDate& date );
static QDateTime createDateTime( const QDate& date, Qt::TimeSpec timeSpec = Qt::LocalTime );
static QDateTime epoch();

View File

@@ -49,7 +49,7 @@ QString RiaRegressionTextTools::generateRegressionText( const regression::Polyno
bool isFirst = true;
std::vector<double> coeffs = reg.coeffisients();
QStringList parts;
for ( size_t i = 0; i < coeffs.size(); i++ )
for ( int i = static_cast<int>( coeffs.size() ) - 1; i >= 0; i-- )
{
double coeff = coeffs[i];
// Skip zero coeffs

View File

@@ -19,7 +19,7 @@
#include "RiaStdStringTools.h"
#include "RiaLogging.h"
#include "fast_float/include/fast_float/fast_float.h"
#include "fast_float/fast_float.h"
#include <QString>
@@ -32,7 +32,7 @@ const std::string WHITESPACE = " \n\r\t\f\v";
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaStdStringTools::leftTrimString( const std::string& s )
std::string_view RiaStdStringTools::leftTrimString( std::string_view s )
{
size_t start = s.find_first_not_of( WHITESPACE );
return ( start == std::string::npos ) ? "" : s.substr( start );
@@ -41,7 +41,7 @@ std::string RiaStdStringTools::leftTrimString( const std::string& s )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaStdStringTools::rightTrimString( const std::string& s )
std::string_view RiaStdStringTools::rightTrimString( std::string_view s )
{
size_t end = s.find_last_not_of( WHITESPACE );
return ( end == std::string::npos ) ? "" : s.substr( 0, end + 1 );
@@ -50,7 +50,7 @@ std::string RiaStdStringTools::rightTrimString( const std::string& s )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaStdStringTools::trimString( const std::string& s )
std::string_view RiaStdStringTools::trimString( std::string_view s )
{
return rightTrimString( leftTrimString( s ) );
}
@@ -87,42 +87,24 @@ bool RiaStdStringTools::isNumber( const std::string& s, char decimalPoint )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int16_t RiaStdStringTools::toInt16( const std::string& s )
int16_t RiaStdStringTools::toInt16( std::string_view s )
{
return (int16_t)toInt( s );
}
//--------------------------------------------------------------------------------------------------
///
/// Convert a string to an integer. If the string is not a valid integer, the function returns -1.
/// For best performance, use toInt( const std::string_view& s, int& value );
//--------------------------------------------------------------------------------------------------
int RiaStdStringTools::toInt( const std::string& s )
int RiaStdStringTools::toInt( std::string_view s )
{
int intValue = -1;
try
{
intValue = std::stoi( s );
}
catch ( ... )
{
}
toInt( s, intValue );
return intValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaStdStringTools::toDouble( const std::string& s )
{
double doubleValue = -1.0;
char* end;
doubleValue = std::strtod( s.data(), &end );
return doubleValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -164,8 +146,11 @@ std::string RiaStdStringTools::formatThousandGrouping( long value )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaStdStringTools::toDouble( const std::string_view& s, double& value )
bool RiaStdStringTools::toDouble( std::string_view s, double& value )
{
s.remove_prefix( std::min( s.find_first_not_of( " " ), s.size() ) );
// NB! Note that we use fast_float:: here, and not std::
auto resultObject = fast_float::from_chars( s.data(), s.data() + s.size(), value );
return ( resultObject.ec == std::errc() );
@@ -174,8 +159,10 @@ bool RiaStdStringTools::toDouble( const std::string_view& s, double& value )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaStdStringTools::toInt( const std::string_view& s, int& value )
bool RiaStdStringTools::toInt( std::string_view s, int& value )
{
s.remove_prefix( std::min( s.find_first_not_of( " " ), s.size() ) );
auto resultObject = std::from_chars( s.data(), s.data() + s.size(), value );
return ( resultObject.ec == std::errc() );
@@ -184,9 +171,9 @@ bool RiaStdStringTools::toInt( const std::string_view& s, int& value )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaStdStringTools::toUpper( const std::string& s )
std::string RiaStdStringTools::toUpper( std::string_view s )
{
auto strCopy( s );
std::string strCopy( s );
std::transform( strCopy.begin(), strCopy.end(), strCopy.begin(), []( unsigned char c ) { return std::toupper( c ); } );
return strCopy;
@@ -419,3 +406,51 @@ std::set<int> RiaStdStringTools::valuesFromRangeSelection( const std::string& s,
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaStdStringTools::formatRangeSelection( const std::vector<int>& values )
{
if ( values.empty() ) return "";
std::vector<int> sortedNums = values;
std::sort( sortedNums.begin(), sortedNums.end() );
std::ostringstream result;
int start = sortedNums[0];
int end = sortedNums[0];
for ( size_t i = 1; i < sortedNums.size(); ++i )
{
if ( sortedNums[i] == end + 1 )
{
end = sortedNums[i];
}
else
{
if ( start == end )
{
result << start;
}
else
{
result << start << "-" << end;
}
result << ", ";
start = sortedNums[i];
end = sortedNums[i];
}
}
if ( start == end )
{
result << start;
}
else
{
result << start << "-" << end;
}
return result.str();
}

View File

@@ -31,26 +31,25 @@
class RiaStdStringTools
{
public:
static std::string trimString( const std::string& s );
static std::string rightTrimString( const std::string& s );
static std::string leftTrimString( const std::string& s );
static std::string removeWhitespace( const std::string& line );
static std::string_view trimString( std::string_view s );
static std::string_view rightTrimString( std::string_view s );
static std::string_view leftTrimString( std::string_view s );
static std::string removeWhitespace( const std::string& line );
static bool isNumber( const std::string& s, char decimalPoint );
static int16_t toInt16( const std::string& s );
static int toInt( const std::string& s );
static double toDouble( const std::string& s );
static int16_t toInt16( std::string_view s );
static int toInt( std::string_view s );
static bool containsAlphabetic( const std::string& s );
static bool startsWithAlphabetic( const std::string& s );
static std::string formatThousandGrouping( long value );
// Conversion using fastest known approach
static bool toDouble( const std::string_view& s, double& value );
static bool toInt( const std::string_view& s, int& value );
static bool toDouble( std::string_view s, double& value );
static bool toInt( std::string_view s, int& value );
static std::string toUpper( const std::string& s );
static std::string toUpper( std::string_view s );
static bool endsWith( const std::string& mainStr, const std::string& toMatch );
@@ -68,6 +67,9 @@ public:
// The input "-3,5-8,10-", min:1, max:12 will produce {1, 2, 3, 5, 6, 7, 8, 10, 11, 12}
static std::set<int> valuesFromRangeSelection( const std::string& s, int minimumValue, int maximumValue );
// Create a string from a set of values. {1, 2, 3, 5, 6, 7, 8, 10, 11, 12} will be converted to "1, 2, 3, 5-8, 10-12"
static std::string formatRangeSelection( const std::vector<int>& values );
private:
template <class Container>
static void splitByDelimiter( const std::string& str, Container& cont, char delimiter = ' ' );

View File

@@ -29,8 +29,8 @@
#include "RimMainPlotCollection.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryEnsemble.h"
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
@@ -142,7 +142,7 @@ void RiaSummaryStringTools::splitUsingDataSourceNames( const QStringList& filter
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryCaseCollection*>> RiaSummaryStringTools::allDataSourcesInProject()
std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryEnsemble*>> RiaSummaryStringTools::allDataSourcesInProject()
{
auto sumCaseMainColl = RiaSummaryTools::summaryCaseMainCollection();
if ( !sumCaseMainColl ) return { {}, {} };
@@ -156,11 +156,11 @@ std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryCaseCollection*>>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryCaseCollection*>>
std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryEnsemble*>>
RiaSummaryStringTools::dataSourcesMatchingFilters( const QStringList& dataSourceFilters )
{
std::vector<RimSummaryCase*> matchingSummaryCases;
std::vector<RimSummaryCaseCollection*> matchingEnsembles;
std::vector<RimSummaryCase*> matchingSummaryCases;
std::vector<RimSummaryEnsemble*> matchingEnsembles;
auto [allSummaryCases, allEnsembles] = allDataSourcesInProject();
@@ -223,8 +223,8 @@ QStringList RiaSummaryStringTools::splitIntoWords( const QString& text )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RiaSummaryStringTools::dataSourceNames( const std::vector<RimSummaryCase*>& summaryCases,
const std::vector<RimSummaryCaseCollection*>& ensembles )
QStringList RiaSummaryStringTools::dataSourceNames( const std::vector<RimSummaryCase*>& summaryCases,
const std::vector<RimSummaryEnsemble*>& ensembles )
{
QStringList names;
for ( const auto& summaryCase : summaryCases )

View File

@@ -18,15 +18,16 @@
#pragma once
#include <QStringList>
#include <set>
#include <vector>
class RimSummaryCase;
class RifEclipseSummaryAddress;
class RimSummaryCaseCollection;
class RimSummaryEnsemble;
class QString;
class QStringList;
//==================================================================================================
//
@@ -41,14 +42,13 @@ public:
static std::pair<QStringList, QStringList> splitIntoAddressAndDataSourceFilters( const QString& filter );
static std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryCaseCollection*>> allDataSourcesInProject();
static std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryCaseCollection*>>
static std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryEnsemble*>> allDataSourcesInProject();
static std::pair<std::vector<RimSummaryCase*>, std::vector<RimSummaryEnsemble*>>
dataSourcesMatchingFilters( const QStringList& dataSourceFilters );
static QStringList splitIntoWords( const QString& text );
static QStringList dataSourceNames( const std::vector<RimSummaryCase*>& summaryCases,
const std::vector<RimSummaryCaseCollection*>& ensembles );
static QStringList dataSourceNames( const std::vector<RimSummaryCase*>& summaryCases, const std::vector<RimSummaryEnsemble*>& ensembles );
static std::set<RifEclipseSummaryAddress> computeFilteredAddresses( const QStringList& textFilters,
const std::set<RifEclipseSummaryAddress>& sourceAddresses,

View File

@@ -32,9 +32,9 @@
#include "RimSummaryCalculationCollection.h"
#include "RimSummaryCalculationVariable.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryEnsemble.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryMultiPlotCollection.h"
#include "RimSummaryPlot.h"
@@ -175,7 +175,7 @@ RimSummaryTableCollection* RiaSummaryTools::parentSummaryTableCollection( caf::P
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaSummaryTools::hasAccumulatedData( const RifEclipseSummaryAddress& address )
RifEclipseSummaryAddressDefines::CurveType RiaSummaryTools::identifyCurveType( const RifEclipseSummaryAddress& address )
{
if ( address.isCalculated() )
{
@@ -187,15 +187,16 @@ bool RiaSummaryTools::hasAccumulatedData( const RifEclipseSummaryAddress& addres
{
if ( !variableAddress.hasAccumulatedData() )
{
return false;
return RifEclipseSummaryAddressDefines::CurveType::RATE;
}
}
// All the variables are accumulated
return true;
return RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED;
}
return address.hasAccumulatedData();
return address.hasAccumulatedData() ? RifEclipseSummaryAddressDefines::CurveType::ACCUMULATED
: RifEclipseSummaryAddressDefines::CurveType::RATE;
}
//--------------------------------------------------------------------------------------------------
@@ -231,11 +232,27 @@ std::pair<std::vector<time_t>, std::vector<double>> RiaSummaryTools::resampledVa
const std::vector<time_t>& timeSteps,
const std::vector<double>& values,
RiaDefines::DateTimePeriod period )
{
// NB! The curve type can be overridden by the user, so there might be a discrepancy between the curve type and the curve type derived
// from the address
// See RimSummaryCurve::curveType()
return resampledValuesForPeriod( RiaSummaryTools::identifyCurveType( address ), timeSteps, values, period );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<std::vector<time_t>, std::vector<double>>
RiaSummaryTools::resampledValuesForPeriod( RifEclipseSummaryAddressDefines::CurveType accumulatedOrRate,
const std::vector<time_t>& timeSteps,
const std::vector<double>& values,
RiaDefines::DateTimePeriod period )
{
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( values, timeSteps );
if ( RiaSummaryTools::hasAccumulatedData( address ) )
if ( accumulatedOrRate == CurveType::ACCUMULATED )
{
resampler.resampleAndComputePeriodEndValues( period );
}
@@ -268,7 +285,7 @@ RimSummaryCase* RiaSummaryTools::summaryCaseById( int caseId )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCaseCollection* RiaSummaryTools::ensembleById( int ensembleId )
RimSummaryEnsemble* RiaSummaryTools::ensembleById( int ensembleId )
{
auto ensembles = RimProject::current()->summaryGroups();
@@ -393,3 +410,23 @@ void RiaSummaryTools::reloadSummaryCase( RimSummaryCase* summaryCase )
multiPlot->updatePlotTitles();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryTools::reloadSummaryEnsemble( RimSummaryEnsemble* ensemble )
{
RimSummaryMultiPlotCollection* summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection();
for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() )
{
for ( RimSummaryPlot* summaryPlot : multiPlot->summaryPlots() )
{
summaryPlot->loadDataAndUpdate();
// Consider to make the zoom optional
summaryPlot->zoomAll();
}
multiPlot->updatePlotTitles();
}
}

View File

@@ -19,9 +19,13 @@
#pragma once
#include "RiaDateTimeDefines.h"
#include "RifEclipseSummaryAddressDefines.h"
#include "RimObservedDataCollection.h"
#include <QString>
#include <QStringList>
#include <vector>
@@ -31,15 +35,13 @@ class RimSummaryMultiPlot;
class RimSummaryMultiPlotCollection;
class RimSummaryCaseMainCollection;
class RimSummaryCase;
class RimSummaryCaseCollection;
class RimSummaryEnsemble;
class RimSummaryTable;
class RimSummaryTableCollection;
class RimObservedDataCollection;
class RimSummaryCurve;
class RimUserDefinedCalculation;
class QStringList;
namespace caf
{
class PdmObject;
@@ -67,18 +69,24 @@ public:
static RimSummaryTable* parentSummaryTable( caf::PdmObject* object );
static RimSummaryTableCollection* parentSummaryTableCollection( caf::PdmObject* object );
static bool hasAccumulatedData( const RifEclipseSummaryAddress& address );
static void getSummaryCasesAndAddressesForCalculation( int id,
std::vector<RimSummaryCase*>& cases,
std::vector<RifEclipseSummaryAddress>& addresses );
static RifEclipseSummaryAddressDefines::CurveType identifyCurveType( const RifEclipseSummaryAddress& address );
static void getSummaryCasesAndAddressesForCalculation( int id,
std::vector<RimSummaryCase*>& cases,
std::vector<RifEclipseSummaryAddress>& addresses );
static std::pair<std::vector<time_t>, std::vector<double>> resampledValuesForPeriod( const RifEclipseSummaryAddress& address,
const std::vector<time_t>& timeSteps,
const std::vector<double>& values,
RiaDefines::DateTimePeriod period );
static RimSummaryCase* summaryCaseById( int caseId );
static RimSummaryCaseCollection* ensembleById( int ensembleId );
static std::pair<std::vector<time_t>, std::vector<double>>
resampledValuesForPeriod( RifEclipseSummaryAddressDefines::CurveType accumulatedOrRate,
const std::vector<time_t>& timeSteps,
const std::vector<double>& values,
RiaDefines::DateTimePeriod period );
static RimSummaryCase* summaryCaseById( int caseId );
static RimSummaryEnsemble* ensembleById( int ensembleId );
static QList<caf::PdmOptionItemInfo> optionsForAllSummaryCases();
static QList<caf::PdmOptionItemInfo> optionsForSummaryCases( const std::vector<RimSummaryCase*>& cases );
@@ -87,6 +95,7 @@ public:
static void copyCurveAxisData( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve );
static void reloadSummaryCase( RimSummaryCase* summaryCase );
static void reloadSummaryEnsemble( RimSummaryEnsemble* ensemble );
private:
static void updateRequiredCalculatedCurves( RimSummaryCase* sourceSummaryCase );

View File

@@ -19,9 +19,9 @@
#pragma once
#include <QString>
#include <map>
#include <QStringList>
class QStringList;
#include <map>
//--------------------------------------------------------------------------------------------------
///

View File

@@ -32,23 +32,27 @@ if(Qt5Core_FOUND)
Gui
OpenGL
Network
NetworkAuth
Widgets
Xml
Concurrent
PrintSupport
Svg
Sql
OPTIONAL_COMPONENTS Charts
)
set(QT_LIBRARIES
Qt5::Core
Qt5::Gui
Qt5::Network
Qt5::NetworkAuth
Qt5::OpenGL
Qt5::Widgets
Qt5::Xml
Qt5::Concurrent
Qt5::PrintSupport
Qt5::Svg
Qt5::Sql
)
if(Qt5Charts_FOUND)
list(APPEND QT_LIBRARIES Qt5::Charts)
@@ -77,13 +81,6 @@ if(MSVC)
add_definitions(-D_USE_MATH_DEFINES)
endif()
# ##############################################################################
# Eigen
# ##############################################################################
if(RESINSIGHT_VCPKG_AUTO_INSTALL)
vcpkg_install(eigen3)
endif()
find_package(Eigen3 REQUIRED)
# ##############################################################################
@@ -96,6 +93,7 @@ list(
Application/CMakeLists_files.cmake
Application/Tools/CMakeLists_files.cmake
Application/Tools/WellPathTools/CMakeLists_files.cmake
Application/Tools/Cloud/CMakeLists_files.cmake
ReservoirDataModel/CMakeLists_files.cmake
ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake
ReservoirDataModel/Completions/CMakeLists_files.cmake
@@ -105,11 +103,13 @@ list(
ProjectDataModel/CMakeLists_files.cmake
ProjectDataModel/AnalysisPlots/CMakeLists_files.cmake
ProjectDataModel/CorrelationPlots/CMakeLists_files.cmake
ProjectDataModel/Cloud/CMakeLists_files.cmake
ProjectDataModel/Faults/CMakeLists_files.cmake
ProjectDataModel/GeoMech/CMakeLists_files.cmake
ProjectDataModel/GridCrossPlots/CMakeLists_files.cmake
ProjectDataModel/GridCrossPlots/CellFilters/CMakeLists_files.cmake
ProjectDataModel/Summary/CMakeLists_files.cmake
ProjectDataModel/Summary/Sumo/CMakeLists_files.cmake
ProjectDataModel/Flow/CMakeLists_files.cmake
ProjectDataModel/Annotations/CMakeLists_files.cmake
ProjectDataModel/Completions/CMakeLists_files.cmake
@@ -130,6 +130,7 @@ list(
ProjectDataModel/Tools/CMakeLists_files.cmake
ProjectDataModelCommands/CMakeLists_files.cmake
ProjectDataModelCommands/CommandRouter/CMakeLists_files.cmake
ProjectDataModel/VerticalFlowPerformance/CMakeLists_files.cmake
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
ModelVisualization/CMakeLists_files.cmake
ModelVisualization/Faults/CMakeLists_files.cmake
@@ -413,6 +414,11 @@ set(UNITY_EXCLUDE_FILES
# Exclude files including opm-common
ProjectDataModel/RimVfpTableExtractor.cpp
ProjectDataModel/RimVfpPlot.cpp
ProjectDataModel/RiaOpmParserTools.cpp
FileInterface/RifOsduWellPathReader.cpp
FileInterface/RifOsduWellLogReader.cpp
FileInterface/RifByteArrayArrowRandomAccessFile.cpp
FileInterface/RifArrowTools.cpp
)
if(RESINSIGHT_ENABLE_UNITY_BUILD)

View File

@@ -19,12 +19,13 @@
#pragma once
#include <QString>
#include <QStringList>
#include <vector>
class RimEclipseCase;
class RimEclipseView;
class RimWellPath;
class QStringList;
//==================================================================================================
//

View File

@@ -21,9 +21,12 @@
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferencesGrid.h"
#include "RicImportGeneralDataFeature.h"
#include "RifReaderSettings.h"
#include "cafPdmFieldScriptingCapability.h"
#include <QDir>
@@ -65,8 +68,8 @@ caf::PdmScriptResponse RicfLoadCase::execute()
absolutePath = startDir.absoluteFilePath( m_path );
}
std::shared_ptr<RifReaderSettings> readerSettings;
if ( m_gridOnly ) readerSettings = RifReaderSettings::createGridOnlyReaderSettings();
RifReaderSettings readerSettings = m_gridOnly ? RiaPreferencesGrid::current()->gridOnlyReaderSettings()
: RiaPreferencesGrid::current()->readerSettings();
bool createPlot = false;
bool createView = false;

View File

@@ -62,10 +62,10 @@ void RicNewAnalysisPlotFeature::onActionTriggered( bool isChecked )
CAF_ASSERT( !correlationPlotCollections.empty() );
analysisPlotColl = correlationPlotCollections.front();
EnsemblePlotParams params = userData.value<EnsemblePlotParams>();
RimSummaryCaseCollection* ensemble = params.ensemble;
QString quantityName = params.mainQuantityName;
std::time_t timeStep = params.timeStep;
EnsemblePlotParams params = userData.value<EnsemblePlotParams>();
RimSummaryEnsemble* ensemble = params.ensemble;
QString quantityName = params.mainQuantityName;
std::time_t timeStep = params.timeStep;
newPlot = analysisPlotColl->createAnalysisPlot( ensemble, quantityName, timeStep );
}

View File

@@ -1,18 +1,14 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportPolylinesAnnotationFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationIn3dViewFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateReachCircleAnnotationFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateUserDefinedPolylinesAnnotationFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicTextAnnotation3dEditor.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportPolylinesAnnotationFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationIn3dViewFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateReachCircleAnnotationFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateUserDefinedPolylinesAnnotationFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicTextAnnotation3dEditor.cpp
)

View File

@@ -1,89 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicCreateUserDefinedPolylinesAnnotationFeature.h"
#include "RiaColorTables.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationGroupCollection.h"
#include "RimAnnotationInViewCollection.h"
#include "RimAnnotationLineAppearance.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimReachCircleAnnotation.h"
#include "RimTextAnnotation.h"
#include "RimUserDefinedPolylinesAnnotation.h"
#include "RiuMainWindow.h"
#include <cafSelectionManagerTools.h>
#include <QAction>
CAF_CMD_SOURCE_INIT( RicCreateUserDefinedPolylinesAnnotationFeature, "RicCreateUserDefinedPolylinesAnnotationFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCreateUserDefinedPolylinesAnnotationFeature::isCommandEnabled() const
{
auto selObjs = caf::selectedObjectsByTypeStrict<RimAnnotationCollection*>();
auto selGroupColl = caf::selectedObjectsByTypeStrict<RimAnnotationGroupCollection*>();
return selObjs.size() == 1 || ( selGroupColl.size() == 1 && selGroupColl.front()->uiCapability()->uiName() ==
RimAnnotationGroupCollection::USED_DEFINED_POLYLINE_ANNOTATION_UI_NAME );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateUserDefinedPolylinesAnnotationFeature::onActionTriggered( bool isChecked )
{
auto coll = annotationCollection();
if ( coll )
{
auto newAnnotation = new RimUserDefinedPolylinesAnnotation();
auto newColor = RiaColorTables::categoryPaletteColors().cycledColor3f( coll->lineBasedAnnotationsCount() );
newAnnotation->appearance()->setColor( newColor );
newAnnotation->appearance()->setSphereColor( newColor );
newAnnotation->enablePicking( true );
coll->addAnnotation( newAnnotation );
coll->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem( newAnnotation );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateUserDefinedPolylinesAnnotationFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/Plus.png" ) );
actionToSetup->setText( "Create User Defined Polyline Annotation" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationCollection* RicCreateUserDefinedPolylinesAnnotationFeature::annotationCollection() const
{
auto project = RimProject::current();
auto oilField = project->activeOilField();
return oilField ? oilField->annotationCollection() : nullptr;
}

View File

@@ -1,100 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicImportPolylinesAnnotationFeature.h"
#include "RiaApplication.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationGroupCollection.h"
#include "RimOilField.h"
#include "RimPolylinesFromFileAnnotation.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h"
#include "RiuFileDialogTools.h"
#include <QAction>
#include <QFileInfo>
#include "cafSelectionManagerTools.h"
CAF_CMD_SOURCE_INIT( RicImportPolylinesAnnotationFeature, "RicImportPolylinesAnnotationFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicImportPolylinesAnnotationFeature::isCommandEnabled() const
{
auto selObjs = caf::selectedObjectsByTypeStrict<RimAnnotationCollection*>();
auto selGroupColl = caf::selectedObjectsByTypeStrict<RimAnnotationGroupCollection*>();
return selObjs.size() == 1 || ( selGroupColl.size() == 1 && selGroupColl.front()->uiCapability()->uiName() ==
RimAnnotationGroupCollection::POLYLINE_FROM_FILE_ANNOTATION_UI_NAME );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportPolylinesAnnotationFeature::onActionTriggered( bool isChecked )
{
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" );
QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
"Import Poly Lines Annotation",
defaultDir,
"Text Files (*.txt);;Polylines (*.dat);;All Files (*.*)" );
if ( fileNames.isEmpty() ) return;
// Remember the path to next time
app->setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( fileNames.last() ).absolutePath() );
// Find or create the AnnotationsCollection
RimProject* proj = RimProject::current();
RimAnnotationCollection* annotColl = proj->activeOilField()->annotationCollection();
if ( !annotColl )
{
annotColl = new RimAnnotationCollection;
proj->activeOilField()->annotationCollection = annotColl;
}
// For each file,
RimPolylinesFromFileAnnotation* lastCreatedOrUpdated = annotColl->importOrUpdatePolylinesFromFile( fileNames );
proj->activeOilField()->updateConnectedEditors();
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
annotColl->scheduleRedrawOfRelevantViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportPolylinesAnnotationFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/PolylinesFromFile16x16.png" ) );
actionToSetup->setText( "Import Poly Lines Annotation" );
}

Some files were not shown because too many files have changed in this diff Show More