#2224 Well Formations: Make Reloading the csv file work

This commit is contained in:
Rebecca Cox 2017-12-06 12:01:15 +01:00
parent 4bef3abda8
commit 8608e00b35
10 changed files with 206 additions and 2 deletions

View File

@ -30,6 +30,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.h
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.h
${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.h
${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.h
${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.h
${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.h
${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.h
${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.h
@ -107,6 +108,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.cpp
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.cpp
${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.cpp
${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.cpp
${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.cpp

View File

@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicReloadWellPathFormationNamesFeature.h"
#include "RiaApplication.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicReloadWellPathFormationNamesFeature, "RicReloadWellPathFormationNamesFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicReloadWellPathFormationNamesFeature::isCommandEnabled()
{
std::vector<RimWellPath*> wellPaths;
caf::SelectionManager::instance()->objectsByType(&wellPaths);
std::vector<RimWellPathCollection*> wellPathCollection;
caf::SelectionManager::instance()->objectsByType(&wellPathCollection);
return (wellPaths.size() > 0 || wellPathCollection.size() > 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReloadWellPathFormationNamesFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellPath*> wellPaths;
caf::SelectionManager::instance()->objectsByType(&wellPaths);
std::vector<RimWellPathCollection*> wellPathCollections;
caf::SelectionManager::instance()->objectsByType(&wellPathCollections);
if (wellPaths.size() > 0)
{
RimWellPathCollection* wellPathCollection;
wellPaths[0]->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
wellPathCollection->reloadAllWellPathFormations();
}
else if (wellPathCollections.size() > 0)
{
wellPathCollections[0]->reloadAllWellPathFormations();
}
RimProject* project = RiaApplication::instance()->project();
if (project)
{
if (project->mainPlotCollection())
{
project->mainPlotCollection->updatePlotsWithFormations();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicReloadWellPathFormationNamesFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Reload All Well Picks");
actionToSetup->setIcon(QIcon(":/Refresh-32.png"));
}

View File

@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicReloadWellPathFormationNamesFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -36,6 +36,16 @@ cvf::ref<RigWellPathFormations> RifWellPathFormationsImporter::readWellPathForma
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigWellPathFormations> RifWellPathFormationsImporter::reloadWellPathFormations(const QString& formationFilePath, const QString& wellName)
{
m_fileNameToWellPathFormationMap.erase(formationFilePath);
return readWellPathFormations(formationFilePath, wellName);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -55,6 +65,25 @@ std::map<QString, cvf::ref<RigWellPathFormations>> RifWellPathFormationsImporter
return wellPathToFormationMap;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathFormationsImporter::reloadAllWellPathFormations()
{
std::vector<QString> allFilePaths;
for (auto it = m_fileNameToWellPathFormationMap.begin(); it != m_fileNameToWellPathFormationMap.end(); it++)
{
allFilePaths.push_back(it->first);
}
m_fileNameToWellPathFormationMap.clear();
for (const QString& filePath : allFilePaths)
{
readWellPathFormationsFromPath(filePath);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -37,9 +37,12 @@ class RifWellPathFormationsImporter
{
public:
cvf::ref<RigWellPathFormations> readWellPathFormations(const QString& formationFilePath, const QString& wellName);
cvf::ref<RigWellPathFormations> reloadWellPathFormations(const QString& formationFilePath, const QString& wellName);
std::map<QString, cvf::ref<RigWellPathFormations>> readWellPathFormationsFromPath(const QString& filePath);
void reloadAllWellPathFormations();
private:
void readAllWellPathFormations(const QString& filePath);

View File

@ -232,6 +232,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicWellPathsImportSsihubFeature";
menuBuilder << "RicWellPathFormationsImportFileFeature";
menuBuilder << "RicWellLogsImportFileFeature";
menuBuilder << "RicReloadWellPathFormationNamesFeature";
menuBuilder << "Separator";
}
else if (dynamic_cast<RimWellPath*>(uiItem))
@ -239,6 +240,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicWellPathsImportFileFeature";
menuBuilder << "RicWellPathFormationsImportFileFeature";
menuBuilder << "RicWellLogsImportFileFeature";
menuBuilder << "RicReloadWellPathFormationNamesFeature";
menuBuilder << "Separator";
menuBuilder << "RicNewRftPlotFeature";
menuBuilder << "RicNewPltPlotFeature";

View File

@ -721,7 +721,28 @@ bool RimWellPath::readWellPathFormationsFile(QString* errorMessage, RifWellPathF
}
else
{
if (errorMessage) (*errorMessage) = "Could not find the well path formation file: " + m_wellPathFormationFilePath();
if (errorMessage) (*errorMessage) = "Could not find the well pick file: " + m_wellPathFormationFilePath();
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellPath::reloadWellPathFormationsFile(QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter)
{
if (m_wellPathFormationFilePath().isEmpty())
{
return true;
}
if (caf::Utils::fileExists(m_wellPathFormationFilePath()))
{
m_wellPathFormations = wellPathFormationsImporter->reloadWellPathFormations(m_wellPathFormationFilePath(), m_formationKeyInFile());
}
else
{
if (errorMessage) (*errorMessage) = "Could not find the well pick file: " + m_wellPathFormationFilePath();
return false;
}
}

View File

@ -74,6 +74,7 @@ public:
void setFormationsGeometry(cvf::ref<RigWellPathFormations> wellPathFormations);
bool readWellPathFormationsFile(QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter);
bool reloadWellPathFormationsFile(QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter);
bool hasFormations() const;
const RigWellPathFormations* formationsGeometry() const;

View File

@ -508,7 +508,7 @@ RimWellPath* RimWellPathCollection::newestAddedWellPath()
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::readWellPathFormationFiles()
{
caf::ProgressInfo progress(wellPaths.size(), "Reading well path formations from file");
caf::ProgressInfo progress(wellPaths.size(), "Reading well picks from file");
for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++)
{
@ -525,6 +525,28 @@ void RimWellPathCollection::readWellPathFormationFiles()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::reloadAllWellPathFormations()
{
caf::ProgressInfo progress(wellPaths.size(), "Reloading well picks from file");
for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++)
{
QString errorMessage;
if (!wellPaths[wpIdx]->reloadWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter))
{
QMessageBox::warning(RiuMainWindow::instance(),
"File open error",
errorMessage);
}
progress.setProgressDescription(QString("Reloading formation file %1").arg(wpIdx));
progress.incrementProgress();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -96,6 +96,7 @@ public:
RimWellPath* newestAddedWellPath();
void readWellPathFormationFiles();
void reloadAllWellPathFormations();
RimWellPath* wellPathByName(const QString& wellPathName) const;
RimWellPath* tryFindMatchingWellPath(const QString& wellName) const;