(#436) Moved LAS file related code to new class RigWellLogFile

This commit is contained in:
Pål Hagen 2015-09-15 18:07:53 +02:00
parent d99c5daee1
commit a79bce6ea4
7 changed files with 224 additions and 75 deletions

View File

@ -27,6 +27,7 @@
#include "RimProject.h"
#include "RimMainPlotCollection.h"
#include "RimWellLogPlotCollection.h"
#include "RigWellLogFile.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
@ -81,12 +82,17 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked)
cvf::Color3f curveColor = curveColorFromIndex(curveIdx);
curve->setColor(curveColor);
curve->setDescription(wellLog->name());
curve->setCurveData(lasFileInfo->logValues(wellLog->name()), lasFileInfo->depthValues());
RigWellLogFile* wellLogFile = lasFileInfo->wellLogFile();
curve->setCurveData(wellLogFile->values(wellLog->name()), wellLogFile->depthValues());
curve->updatePlotData();
}
}
plot->setVisibleDepthRangeFromContents();
RiaApplication::instance()->project()->updateConnectedEditors();
}

View File

@ -22,9 +22,8 @@
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "well.hpp"
#include "RigWellLogFile.h"
#include <QString>
#include <QStringList>
#include <QFileInfo>
@ -54,6 +53,8 @@ RimWellLasFileInfo::RimWellLasFileInfo()
CAF_PDM_InitFieldNoDefault(&m_lasFileLogs, "WellLASFileLogs", "", "", "", "");
m_lasFileLogs.uiCapability()->setUiHidden(true);
m_lasFileLogs.xmlCapability()->setIOWritable(false);
m_wellLogFile = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -61,7 +62,6 @@ RimWellLasFileInfo::RimWellLasFileInfo()
//--------------------------------------------------------------------------------------------------
RimWellLasFileInfo::~RimWellLasFileInfo()
{
close();
}
//--------------------------------------------------------------------------------------------------
@ -77,38 +77,23 @@ void RimWellLasFileInfo::setFileName(const QString& fileName)
//--------------------------------------------------------------------------------------------------
bool RimWellLasFileInfo::readFile()
{
close();
int wellFormat = NRLib::Well::LAS;
NRLib::Well* well = NRLib::Well::ReadWell(m_fileName().toStdString(), wellFormat);
if (!well)
if (!m_wellLogFile.p())
{
m_wellLogFile = new RigWellLogFile;
}
if (!m_wellLogFile->open(m_fileName))
{
// TODO: Error handling
return false;
}
m_wellName = QString::fromStdString(well->GetWellName());
m_wellName = m_wellLogFile->wellName();
m_name = QFileInfo(m_fileName).fileName();
QStringList wellLogNames;
m_lasFileLogs.deleteAllChildObjects();
const std::map<std::string, std::vector<double> >& contLogs = well->GetContLog();
std::vector<std::string> contLogNames;
std::map<std::string, std::vector<double> >::const_iterator itCL;
for (itCL = contLogs.begin(); itCL != contLogs.end(); itCL++)
{
wellLogNames.append(QString::fromStdString(itCL->first));
}
const std::map<std::string, std::vector<int> >& discLogs = well->GetDiscLog();
std::vector<std::string> discLogNames;
std::map<std::string, std::vector<int> >::const_iterator itDL;
for (itDL = discLogs.begin(); itDL != discLogs.end(); itDL++)
{
wellLogNames.append(QString::fromStdString(itDL->first));
}
for (size_t logIdx = 0; logIdx < wellLogNames.size(); logIdx++)
QStringList wellLogNames = m_wellLogFile->wellLogNames();
for (int logIdx = 0; logIdx < wellLogNames.size(); logIdx++)
{
RimWellLog* wellLog = new RimWellLog();
wellLog->setName(wellLogNames[logIdx]);
@ -117,7 +102,6 @@ bool RimWellLasFileInfo::readFile()
RimWellPath* wellPath;
firstAnchestorOrThisOfType(wellPath);
if (wellPath)
{
if (wellPath->filepath().isEmpty())
@ -126,20 +110,9 @@ bool RimWellLasFileInfo::readFile()
}
}
delete well;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLasFileInfo::close()
{
m_lasFileLogs.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -147,29 +120,3 @@ QString RimWellLasFileInfo::wellName() const
{
return m_wellName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimWellLasFileInfo::depthValues() const
{
return logValues("DEPT");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimWellLasFileInfo::logValues(const QString& logName) const
{
std::vector<double> values;
int wellFormat = NRLib::Well::LAS;
NRLib::Well* well = NRLib::Well::ReadWell(m_fileName().toStdString(), wellFormat);
if (well)
{
values = well->GetContLog(logName.toStdString());
delete well;
}
return values;
}

View File

@ -23,10 +23,13 @@
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"
#include "RigWellLogFile.h"
#include "cvfBase.h"
class RimWellLog;
class QString;
class QString;
//==================================================================================================
///
@ -46,16 +49,14 @@ public:
QString wellName() const;
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; }
std::vector<double> depthValues() const;
std::vector<double> logValues(const QString& logName) const;
RigWellLogFile* wellLogFile() { return m_wellLogFile.p(); }
private:
void close();
caf::PdmChildArrayField<RimWellLog*> m_lasFileLogs;
private:
caf::PdmField<QString> m_wellName;
caf::PdmField<QString> m_fileName;
caf::PdmField<QString> m_name;
cvf::ref<RigWellLogFile> m_wellLogFile;
caf::PdmField<QString> m_wellName;
caf::PdmField<QString> m_fileName;
caf::PdmField<QString> m_name;
};

View File

@ -35,6 +35,7 @@ ${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h
${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.h
${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.h
${CEE_CURRENT_LIST_DIR}RigWellLogFile.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -64,6 +65,7 @@ ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp
${CEE_CURRENT_LIST_DIR}RigNativeStatCalc.cpp
${CEE_CURRENT_LIST_DIR}RigMultipleDatasetStatCalc.cpp
${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -19,6 +19,7 @@ include_directories(
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface
${ResInsight_SOURCE_DIR}/ApplicationCode/ProjectDataModel
${ResInsight_SOURCE_DIR}/ThirdParty
${ResInsight_SOURCE_DIR}/ThirdParty/NRLib/nrlib/well
#${ResInsight_SOURCE_DIR}/Fwk/AppFwk/cafProjectDataModel
@ -68,6 +69,8 @@ set( LINK_LIBRARIES
ecl_well
ert_util
NRLib
${QT_LIBRARIES}
)

View File

@ -0,0 +1,134 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigWellLogFile.h"
#include "well.hpp"
#include <QString>
#include <QFileInfo>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellLogFile::RigWellLogFile()
: cvf::Object()
{
m_wellLogFile = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellLogFile::~RigWellLogFile()
{
close();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigWellLogFile::open(const QString& fileName)
{
close();
int wellFormat = NRLib::Well::LAS;
NRLib::Well* well = NRLib::Well::ReadWell(fileName.toStdString(), wellFormat);
if (!well)
{
// TODO: Error handling
return false;
}
QStringList wellLogNames;
const std::map<std::string, std::vector<double> >& contLogs = well->GetContLog();
std::vector<std::string> contLogNames;
std::map<std::string, std::vector<double> >::const_iterator itCL;
for (itCL = contLogs.begin(); itCL != contLogs.end(); itCL++)
{
wellLogNames.append(QString::fromStdString(itCL->first));
}
// TODO: Possibly handle discrete logs
// const std::map<std::string, std::vector<int> >& discLogs = well->GetDiscLog();
// std::vector<std::string> discLogNames;
// std::map<std::string, std::vector<int> >::const_iterator itDL;
// for (itDL = discLogs.begin(); itDL != discLogs.end(); itDL++)
// {
// wellLogNames.append(QString::fromStdString(itDL->first));
// }
m_wellLogNames = wellLogNames;
m_wellLogFile = well;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellLogFile::close()
{
if (m_wellLogFile)
{
delete m_wellLogFile;
m_wellLogFile = NULL;
}
m_wellLogNames.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigWellLogFile::wellName() const
{
CVF_ASSERT(m_wellLogFile);
return QString::fromStdString(m_wellLogFile->GetWellName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RigWellLogFile::wellLogNames() const
{
return m_wellLogNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigWellLogFile::depthValues() const
{
return values("DEPT");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigWellLogFile::values(const QString& name) const
{
// TODO: Possibly handle discrete logs
CVF_ASSERT(m_wellLogFile);
return m_wellLogFile->GetContLog(name.toStdString());
}

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- 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 "cvfBase.h"
#include "cvfObject.h"
#include <QStringList>
#include <vector>
namespace NRLib
{
class Well;
}
//==================================================================================================
///
//==================================================================================================
class RigWellLogFile : public cvf::Object
{
public:
RigWellLogFile();
virtual ~RigWellLogFile();
bool open(const QString& fileName);
QString wellName() const;
QStringList wellLogNames() const;
std::vector<double> depthValues() const;
std::vector<double> values(const QString& name) const;
private:
void close();
NRLib::Well* m_wellLogFile;
QStringList m_wellLogNames;
};