#3260 Well Path Export. Export dev file, new commands

This commit is contained in:
Bjørn Erik Jensen 2018-09-21 13:44:27 +02:00
parent bc6e75e88e
commit b028c36116
11 changed files with 614 additions and 4 deletions

View File

@ -35,6 +35,6 @@ protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
private:
std::vector<RimWellPath*> visibleWellPaths();
public:
static std::vector<RimWellPath*> visibleWellPaths();
};

View File

@ -1,4 +1,3 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicCellRangeUi.h
${CMAKE_CURRENT_LIST_DIR}/RicExportCarfin.h
@ -17,6 +16,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllViewsToFileFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSnapshotFilenameGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToClipboardFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToFileFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportSelectedWellPathsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportVisibleWellPathsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportWellPathsUi.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -37,6 +39,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllViewsToFileFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSnapshotFilenameGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToClipboardFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToFileFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportSelectedWellPathsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportVisibleWellPathsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportWellPathsUi.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,179 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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 "RicExportSelectedWellPathsFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RicExportWellPathsUi.h"
#include "RigWellPath.h"
#include "RimWellPath.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimDialogData.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include "cafPdmUiPropertyViewDialog.h"
#include <QAction>
#include <QFileInfo>
#include <QFileDialog>
#include <QMessageBox>
#include <memory>
CAF_CMD_SOURCE_INIT(RicExportSelectedWellPathsFeature, "RicExportSelectedWellPathsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder)
{
auto geom = wellPath->wellPathGeometry();
double currMd = geom->measureDepths().front() - mdStepSize;
double endMd = geom->measureDepths().back();
auto fileName = wellPath->name() + ".dev";
auto filePtr = openFileForExport(folder, fileName);
QTextStream stream(filePtr.get());
stream.setRealNumberNotation(QTextStream::FixedNotation);
stream << "WELLNAME: '" << wellPath->name() << "'" << endl;
while (currMd < endMd)
{
currMd += mdStepSize;
if (currMd > endMd) currMd = endMd;
auto pt = geom->interpolatedPointAlongWellPath(currMd);
double tvd = -pt.z();
// Write to file
stream << pt.x() << " " << pt.y() << " " << tvd << " " << currMd << endl;
}
filePtr->close();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QFilePtr RicExportSelectedWellPathsFeature::openFileForExport(const QString& folderName, const QString& fileName)
{
QDir exportFolder = QDir(folderName);
QString filePath = exportFolder.filePath(fileName);
QFilePtr exportFile(new QFile(filePath));
if (!exportFile->open(QIODevice::WriteOnly))
{
auto errorMessage = QString("Export Well Path: Could not open the file: %1").arg(filePath);
RiaLogging::error(errorMessage);
}
return exportFile;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::handleAction(const std::vector<RimWellPath*>& wellPaths)
{
if (!wellPaths.empty())
{
auto dialogData = openDialog();
if (dialogData)
{
auto folder = dialogData->exportFolder();
auto mdStepSize = dialogData->mdStepSize();
if (folder.isEmpty())
{
return;
}
for (auto wellPath : wellPaths)
{
exportWellPath(wellPath, mdStepSize, folder);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportSelectedWellPathsFeature::isCommandEnabled()
{
std::vector<RimWellPath*> wellPaths = caf::selectedObjectsByTypeStrict<RimWellPath*>();
return !wellPaths.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellPath*> wellPaths = caf::selectedObjectsByTypeStrict<RimWellPath*>();
handleAction(wellPaths);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Export Selected Well Paths");
actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportWellPathsUi* RicExportSelectedWellPathsFeature::openDialog()
{
RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project();
QString startPath = app->lastUsedDialogDirectory("WELL_LOGS_DIR");
if (startPath.isEmpty())
{
QFileInfo fi(proj->fileName());
startPath = fi.absolutePath();
}
RicExportWellPathsUi* featureUi = app->project()->dialogData()->wellPathsExportData();
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, featureUi, "Export Well Paths", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
propertyDialog.resize(QSize(600, 60));
if (propertyDialog.exec() == QDialog::Accepted && !featureUi->exportFolder().isEmpty())
{
auto dialogData = app->project()->dialogData()->wellPathsExportData();
app->setLastUsedDialogDirectory("WELL_LOGS_DIR", dialogData->exportFolder());
return dialogData;
}
return nullptr;
}

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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 <QFile>
#include "cafCmdFeature.h"
class RimWellPath;
class RicExportWellPathsUi;
//==================================================================================================
///
//==================================================================================================
typedef std::shared_ptr<QFile> QFilePtr;
//==================================================================================================
///
//==================================================================================================
class RicExportSelectedWellPathsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
static void exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder);
static QFilePtr openFileForExport(const QString& folderName, const QString& fileName);
static void handleAction(const std::vector<RimWellPath*>& wellPaths);
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook(QAction* actionToSetup);
private:
static RicExportWellPathsUi* openDialog();
};

View File

@ -0,0 +1,122 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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 "RicExportVisibleWellPathsFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RicExportSelectedWellPathsFeature.h"
#include "CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h"
#include "RigWellPath.h"
#include "RimWellPath.h"
#include "RimProject.h"
#include "RimSummaryCaseMainCollection.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
#include <QFileInfo>
#include <QFileDialog>
#include <QMessageBox>
#include <memory>
CAF_CMD_SOURCE_INIT(RicExportVisibleWellPathsFeature, "RicExportVisibleWellPathsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportVisibleWellPathsFeature::exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder)
{
auto geom = wellPath->wellPathGeometry();
double currMd = geom->measureDepths().front() - mdStepSize;
double endMd = geom->measureDepths().back();
auto fileName = wellPath->name() + ".dev";
auto filePtr = openFileForExport(folder, fileName);
QTextStream stream(filePtr.get());
stream.setRealNumberNotation(QTextStream::FixedNotation);
stream << "WELLNAME: " << wellPath->name() << endl;
while (currMd < endMd)
{
currMd += mdStepSize;
if (currMd > endMd) currMd = endMd;
auto pt = geom->interpolatedPointAlongWellPath(currMd);
double tvd = -pt.z();
// Write to file
stream << pt.x() << " " << pt.y() << " " << tvd << " " << currMd << endl;
}
filePtr->close();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QFilePtr RicExportVisibleWellPathsFeature::openFileForExport(const QString& folderName, const QString& fileName)
{
QDir exportFolder = QDir(folderName);
QString filePath = exportFolder.filePath(fileName);
QFilePtr exportFile(new QFile(filePath));
if (!exportFile->open(QIODevice::WriteOnly))
{
auto errorMessage = QString("Export Well Path: Could not open the file: %1").arg(filePath);
RiaLogging::error(errorMessage);
}
return exportFile;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportVisibleWellPathsFeature::isCommandEnabled()
{
std::vector<RimWellPath*> wellPaths = RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths();
return !wellPaths.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportVisibleWellPathsFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellPath*> wellPaths = RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths();
RicExportSelectedWellPathsFeature::handleAction(wellPaths);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportVisibleWellPathsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Export Visible Well Paths");
actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png"));
}

View File

@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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 <QFile>
#include "cafCmdFeature.h"
class RimWellPath;
//==================================================================================================
///
//==================================================================================================
typedef std::shared_ptr<QFile> QFilePtr;
//==================================================================================================
///
//==================================================================================================
class RicExportVisibleWellPathsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
void exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder);
QFilePtr openFileForExport(const QString& folderName, const QString& fileName);
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook(QAction* actionToSetup);
};

View File

@ -0,0 +1,107 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 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 "RicExportWellPathsUi.h"
#include "RiaApplication.h"
#include "RiaOptionItemFactory.h"
#include "RimCase.h"
#include "RimGridView.h"
#include "RimProject.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiOrdering.h"
CAF_PDM_SOURCE_INIT(RicExportWellPathsUi, "RicExportWellPathsUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportWellPathsUi::RicExportWellPathsUi()
{
CAF_PDM_InitObject("Resample LAS curves for export", "", "", "");
CAF_PDM_InitField(&m_exportFolder, "ExportFolder", QString(), "Export Folder", "", "", "");
m_exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_mdStepSize, "MdStepSize", 5.0, "MD Step Size", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportWellPathsUi::setMdStepSize(double mdStepSize)
{
m_mdStepSize = mdStepSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportWellPathsUi::exportFolder() const
{
return m_exportFolder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RicExportWellPathsUi::mdStepSize() const
{
return m_mdStepSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
//QList<caf::PdmOptionItemInfo> RicExportWellPathsUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
// bool* useOptionsOnly)
//{
// QList<caf::PdmOptionItemInfo> options;
//
// if (fieldNeedingOptions == &m_mdStepSize)
// {
// std::vector<RimGridView*> visibleViews;
// RiaApplication::instance()->project()->allVisibleGridViews(visibleViews);
//
// for (RimGridView* v : visibleViews)
// {
// RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName(v, &options);
// }
// }
//
// return options;
//}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportWellPathsUi::defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute)
{
if (field == &m_exportFolder)
{
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectDirectory = true;
}
}
}

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
class RimGridView;
//==================================================================================================
///
//==================================================================================================
class RicExportWellPathsUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicExportWellPathsUi();
void setMdStepSize(double mdStepSize);
QString exportFolder() const;
double mdStepSize() const;
private:
//QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
// bool* useOptionsOnly) override;
void defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute) override;
private:
caf::PdmField<QString> m_exportFolder;
caf::PdmField<double> m_mdStepSize;
};

View File

@ -302,6 +302,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicWellPathExportCompletionDataFeature";
menuBuilder.subMenuEnd();
menuBuilder.subMenuStart("Export Well Paths");
menuBuilder << "RicExportSelectedWellPathsFeature";
menuBuilder << "RicExportVisibleWellPathsFeature";
menuBuilder.subMenuEnd();
menuBuilder << "RicCreateMultipleFracturesFeature";
menuBuilder << "Separator";
@ -728,7 +733,33 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << text;
}
menuBuilder.subMenuEnd();
}
}
{
QStringList candidates;
if (!menuBuilder.isCmdFeatureAdded("RicExportSelectedWellPathsFeature"))
{
candidates << "RicExportSelectedWellPathsFeature";
}
if (!menuBuilder.isCmdFeatureAdded("RicExportVisibleWellPathsFeature"))
{
candidates << "RicExportVisibleWellPathsFeature";
}
if (!candidates.isEmpty())
{
menuBuilder.subMenuStart("Export Well Paths", QIcon(":/WellLogCurve16x16.png"));
for (const auto& text : candidates)
{
menuBuilder << text;
}
menuBuilder.subMenuEnd();
}
}

View File

@ -22,6 +22,7 @@
#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h"
#include "FractureCommands/RicCreateMultipleFracturesUi.h"
#include "HoloLensCommands/RicHoloLensExportToFolderUi.h"
#include "ExportCommands/RicExportWellPathsUi.h"
CAF_PDM_SOURCE_INIT(RimDialogData, "RimDialogData");
@ -43,6 +44,9 @@ RimDialogData::RimDialogData()
CAF_PDM_InitFieldNoDefault(&m_holoLenseExportToFolderData, "HoloLenseExportToFolderData", "Holo Lens Export To Folder Data", "", "", "");
m_holoLenseExportToFolderData = new RicHoloLensExportToFolderUi();
CAF_PDM_InitFieldNoDefault(&m_exportWellPathsData, "ExportwellPathsData", "Export Well Paths Data", "", "", "");
m_exportWellPathsData = new RicExportWellPathsUi();
}
//--------------------------------------------------------------------------------------------------
@ -102,3 +106,11 @@ RicHoloLensExportToFolderUi* RimDialogData::holoLensExportToFolderData() const
return m_holoLenseExportToFolderData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportWellPathsUi* RimDialogData::wellPathsExportData() const
{
return m_exportWellPathsData;
}

View File

@ -25,6 +25,7 @@ class RicExportCarfinUi;
class RicExportCompletionDataSettingsUi;
class RiuCreateMultipleFractionsUi;
class RicHoloLensExportToFolderUi;
class RicExportWellPathsUi;
//==================================================================================================
///
@ -53,10 +54,12 @@ public:
RiuCreateMultipleFractionsUi* multipleFractionsData() const;
RicHoloLensExportToFolderUi* holoLensExportToFolderData() const;
RicExportWellPathsUi* wellPathsExportData() const;
private:
caf::PdmChildField<RicExportCarfinUi*> m_exportCarfin;
caf::PdmChildField<RicExportCompletionDataSettingsUi*> m_exportCompletionData;
caf::PdmChildField<RiuCreateMultipleFractionsUi*> m_multipleFractionsData;
caf::PdmChildField<RicHoloLensExportToFolderUi*> m_holoLenseExportToFolderData;
caf::PdmChildField<RicExportWellPathsUi*> m_exportWellPathsData;
};