diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index a09f017929..803132e0ec 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFile.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCsvFile.h + ${CMAKE_CURRENT_LIST_DIR}/RimWellLog.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannel.h @@ -40,6 +41,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogLasFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCsvFile.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellLog.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileUtil.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogChannel.cpp diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp new file mode 100644 index 0000000000..8340a6371a --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp @@ -0,0 +1,88 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimWellLog.h" + +#include "RimFileWellPath.h" +#include "RimTools.h" +#include "RimWellLogChannel.h" + +#include "RiaFieldHandleTools.h" +#include "RiaQDateTimeTools.h" + +#include "cafPdmUiDateEditor.h" + +#include + +CAF_PDM_ABSTRACT_SOURCE_INIT( RimWellLog, "WellLog" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QDateTime RimWellLog::DEFAULT_DATE_TIME = RiaQDateTimeTools::createUtcDateTime( QDate( 1900, 1, 1 ) ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLog::RimWellLog() +{ + CAF_PDM_InitObject( "Well File Info", ":/LasFile16x16.png" ); + + CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date" ); + + CAF_PDM_InitFieldNoDefault( &m_wellLogChannelNames, "WellLogFileChannels", "" ); + RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_wellLogChannelNames ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellLog::wellLogChannels() const +{ + return m_wellLogChannelNames.childrenByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDateTime RimWellLog::date() const +{ + return m_date; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLog::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + if ( changedField == &m_date ) + { + // Due to a possible bug in QDateEdit/PdmUiDateEditor, convert m_date to a QDateTime having UTC timespec + m_date = RiaQDateTimeTools::createUtcDateTime( m_date().date(), m_date().time() ); + } +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLog::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) +{ + if ( caf::PdmUiDateEditorAttribute* attrib = dynamic_cast( attribute ) ) + { + attrib->dateFormat = RiaQDateTimeTools::dateFormatString(); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h new file mode 100644 index 0000000000..0a899326a6 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.h @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include +#include + +class RimWellLogChannel; +class RimWellPath; + +class RigWellLogData; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLog : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLog(); + + virtual std::vector wellLogChannels() const; + + virtual QString wellName() const = 0; + virtual QString name() const = 0; + virtual RigWellLogData* wellLogData() = 0; + + virtual QDateTime date() const; + + virtual std::vector> + findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) = 0; + + const static QDateTime DEFAULT_DATE_TIME; + +protected: + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + + caf::PdmChildArrayField m_wellLogChannelNames; + caf::PdmField m_date; +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp index 198a2741d3..6c0435711d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp @@ -18,24 +18,10 @@ #include "RimWellLogFile.h" -#include "RimFileWellPath.h" -#include "RimTools.h" -#include "RimWellLogChannel.h" - -#include "RiaFieldHandleTools.h" -#include "RiaQDateTimeTools.h" - -#include "cafPdmUiDateEditor.h" - #include CAF_PDM_ABSTRACT_SOURCE_INIT( RimWellLogFile, "WellLogFileInterface" ); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const QDateTime RimWellLogFile::DEFAULT_DATE_TIME = RiaQDateTimeTools::createUtcDateTime( QDate( 1900, 1, 1 ) ); - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -45,11 +31,6 @@ RimWellLogFile::RimWellLogFile() CAF_PDM_InitFieldNoDefault( &m_fileName, "FileName", "Filename" ); m_fileName.uiCapability()->setUiReadOnly( true ); - - CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date" ); - - CAF_PDM_InitFieldNoDefault( &m_wellLogChannelNames, "WellLogFileChannels", "" ); - RiaFieldHandleTools::disableWriteAndSetFieldHidden( &m_wellLogChannelNames ); } //-------------------------------------------------------------------------------------------------- @@ -57,7 +38,6 @@ RimWellLogFile::RimWellLogFile() //-------------------------------------------------------------------------------------------------- RimWellLogFile::~RimWellLogFile() { - m_wellLogChannelNames.deleteChildren(); } //-------------------------------------------------------------------------------------------------- @@ -76,45 +56,18 @@ QString RimWellLogFile::fileName() const return m_fileName().path(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimWellLogFile::wellLogChannels() const -{ - std::vector channels; - for ( const auto& channel : m_wellLogChannelNames ) - { - channels.push_back( channel ); - } - return channels; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QDateTime RimWellLogFile::date() const -{ - return m_date; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogFile::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) { - if ( changedField == &m_date ) - { - // Due to a possible bug in QDateEdit/PdmUiDateEditor, convert m_date to a QDateTime having UTC timespec - m_date = RiaQDateTimeTools::createUtcDateTime( m_date().date(), m_date().time() ); - } + RimWellLog::fieldChangedByUi( changedField, oldValue, newValue ); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogFile::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { - if ( caf::PdmUiDateEditorAttribute* attrib = dynamic_cast( attribute ) ) - { - attrib->dateFormat = RiaQDateTimeTools::dateFormatString(); - } + RimWellLog::defineEditorAttribute( field, uiConfigName, attribute ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h index 44b7b57127..7cb19f1a06 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.h @@ -22,19 +22,15 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include #include -class RimWellLogChannel; -class RimWellPath; - -class RigWellLogData; +#include "RimWellLog.h" //================================================================================================== /// /// //================================================================================================== -class RimWellLogFile : public caf::PdmObject +class RimWellLogFile : public RimWellLog { CAF_PDM_HEADER_INIT; @@ -42,27 +38,14 @@ public: RimWellLogFile(); ~RimWellLogFile() override; - virtual void setFileName( const QString& fileName ); - virtual QString fileName() const; - virtual std::vector wellLogChannels() const; + virtual void setFileName( const QString& fileName ); + virtual QString fileName() const; - virtual QString wellName() const = 0; - virtual QString name() const = 0; - virtual bool readFile( QString* errorMessage ) = 0; - virtual RigWellLogData* wellLogData() = 0; - - virtual QDateTime date() const; - - virtual std::vector> - findMdAndChannelValuesForWellPath( const RimWellPath& wellPath, const QString& channelName, QString* unitString = nullptr ) = 0; - - const static QDateTime DEFAULT_DATE_TIME; + virtual bool readFile( QString* errorMessage ) = 0; protected: void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - caf::PdmChildArrayField m_wellLogChannelNames; - caf::PdmField m_fileName; - caf::PdmField m_date; + caf::PdmField m_fileName; };