#3450 #3445 LGR export. New command feature

This commit is contained in:
Bjørn Erik Jensen 2018-10-05 11:49:44 +02:00
parent 2f61681642
commit 2a59d86975
8 changed files with 488 additions and 0 deletions

View File

@ -19,6 +19,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToFileFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportSelectedWellPathsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportVisibleWellPathsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportWellPathsUi.h
${CMAKE_CURRENT_LIST_DIR}/RicExportCarfinForCompletionsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportCarfinForCompletionsUi.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -42,6 +44,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToFileFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportSelectedWellPathsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportVisibleWellPathsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportWellPathsUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportCarfinForCompletionsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportCarfinForCompletionsUi.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,187 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicExportCarfinForCompletionsFeature.h"
#include "RiaApplication.h"
#include "CompletionExportCommands/RicWellPathExportCompletionDataFeature.h"
#include "RicExportCarfinForCompletionsUi.h"
#include "RimDialogData.h"
#include "RimEclipseCase.h"
#include "RimWellPath.h"
#include "RimProject.h"
#include "RimWellPathCollection.h"
#include "RiuPlotMainWindow.h"
#include <cafPdmUiPropertyViewDialog.h>
#include <cafSelectionManager.h>
#include <cafSelectionManagerTools.h>
#include <QAction>
#include <QFileInfo>
CAF_CMD_SOURCE_INIT(RicExportCarfinForCompletionsFeature, "RicExportCarfinForCompletionsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportCarfinForCompletionsUi* RicExportCarfinForCompletionsFeature::openDialog()
{
RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project();
QString startPath = app->lastUsedDialogDirectory("WELL_PATH_EXPORT_DIR");
if (startPath.isEmpty())
{
QFileInfo fi(proj->fileName());
startPath = fi.absolutePath();
}
RicExportCarfinForCompletionsUi* featureUi = app->project()->dialogData()->exportCarfinForCompletionsData();
if (featureUi->exportFolder().isEmpty())
{
featureUi->setExportFolder(startPath);
}
if (!featureUi->caseToApply())
{
std::vector<RimCase*> cases;
app->project()->allCases(cases);
for (auto c : cases)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(c);
if (eclipseCase != nullptr)
{
featureUi->setCase(eclipseCase);
break;
}
}
}
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, featureUi, "Export Carfin", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
propertyDialog.resize(QSize(600, 230));
if (propertyDialog.exec() == QDialog::Accepted && !featureUi->exportFolder().isEmpty())
{
app->setLastUsedDialogDirectory("WELL_PATH_EXPORT_DIR", featureUi->exportFolder());
return featureUi;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportCarfinForCompletionsFeature::isCommandEnabled()
{
std::vector<RimWellPath*> wellPaths = caf::selectedObjectsByTypeStrict<RimWellPath*>();
return !wellPaths.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinForCompletionsFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellPath*> wellPaths = visibleWellPaths();
CVF_ASSERT(wellPaths.size() > 0);
std::vector<RimSimWellInView*> simWells;
QString dialogTitle = "Export Carfin";
auto dialogData = openDialog();
if (dialogData)
{
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinForCompletionsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Export Carfin");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RicExportCarfinForCompletionsFeature::visibleWellPaths()
{
std::vector<RimWellPath*> wellPaths;
{
std::vector<RimWellPathCollection*> wellPathCollections;
caf::SelectionManager::instance()->objectsByType(&wellPathCollections);
if (wellPathCollections.empty())
{
std::vector<RimWellPath*> selectedWellPaths;
caf::SelectionManager::instance()->objectsByType(&selectedWellPaths);
if (!selectedWellPaths.empty())
{
RimWellPathCollection* parent = nullptr;
selectedWellPaths[0]->firstAncestorOrThisOfType(parent);
if (parent)
{
wellPathCollections.push_back(parent);
}
}
}
if (!wellPathCollections.empty())
{
for (auto wellPathCollection : wellPathCollections)
{
for (const auto& wellPath : wellPathCollection->wellPaths())
{
if (wellPath->showWellPath())
{
wellPaths.push_back(wellPath);
}
}
}
}
else
{
// No well path or well path collection selected
auto allWellPaths = RiaApplication::instance()->project()->allWellPaths();
for (const auto& w : allWellPaths)
{
if (w->showWellPath())
{
wellPaths.push_back(w);
}
}
}
}
std::set<RimWellPath*> uniqueWellPaths(wellPaths.begin(), wellPaths.end());
wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end());
return wellPaths;
}

View File

@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RimSimWellInView;
class RimWellPath;
class RicExportCarfinForCompletionsUi;
//==================================================================================================
///
//==================================================================================================
class RicExportCarfinForCompletionsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
static RicExportCarfinForCompletionsUi* openDialog();
protected:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
public:
static std::vector<RimWellPath*> visibleWellPaths();
};

View File

@ -0,0 +1,166 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicExportCarfinForCompletionsUi.h"
#include "RicCellRangeUi.h"
#include "RimEclipseCase.h"
#include "RimTools.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafVecIjk.h"
CAF_PDM_SOURCE_INIT(RicExportCarfinForCompletionsUi, "RicExportCarfinForCompletionsUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportCarfinForCompletionsUi::RicExportCarfinForCompletionsUi()
{
CAF_PDM_InitObject("Export CARFIN", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_exportFolder, "ExportFolder", "Export Folder", "", "", "");
m_exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_caseToApply, "CaseToApply", "Source Case", "", "", "");
CAF_PDM_InitField(&m_cellCountI, "CellCountI", 2, "Cell Count I", "", "", "");
CAF_PDM_InitField(&m_cellCountJ, "CellCountJ", 2, "Cell Count J", "", "", "");
CAF_PDM_InitField(&m_cellCountK, "CellCountK", 2, "Cell Count K", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinForCompletionsUi::setCase(RimEclipseCase* rimCase)
{
bool isDifferent = (rimCase != m_caseToApply);
if (isDifferent)
{
m_caseToApply = rimCase;
setDefaultValuesFromCase();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::VecIjk RicExportCarfinForCompletionsUi::lgrCellCount() const
{
return caf::VecIjk (m_cellCountI, m_cellCountJ, m_cellCountK);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportCarfinForCompletionsUi::exportFolder() const
{
return m_exportFolder();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RicExportCarfinForCompletionsUi::caseToApply() const
{
return m_caseToApply();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinForCompletionsUi::setExportFolder(const QString& folder)
{
m_exportFolder = folder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinForCompletionsUi::setDefaultValuesFromCase()
{
if (m_caseToApply)
{
QString caseFolder = m_caseToApply->locationOnDisc();
m_exportFolder = caseFolder;
}
m_cellCountI = 2;
m_cellCountJ = 2;
m_cellCountK = 2;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RicExportCarfinForCompletionsUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_caseToApply)
{
RimTools::caseOptionItems(&options);
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinForCompletionsUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_caseToApply)
{
setDefaultValuesFromCase();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinForCompletionsUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_caseToApply);
uiOrdering.add(&m_exportFolder);
caf::PdmUiGroup* gridRefinement = uiOrdering.addNewGroup("Grid Refinement");
gridRefinement->add(&m_cellCountI);
gridRefinement->add(&m_cellCountJ);
gridRefinement->add(&m_cellCountK);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinForCompletionsUi::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_selectSaveFileName = true;
}
}
}

View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmObject.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmPtrField.h"
class RimEclipseCase;
class RicCellRangeUi;
namespace caf {
class VecIjk;
}
//==================================================================================================
///
//==================================================================================================
class RicExportCarfinForCompletionsUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
enum LgrSplitType { PER_CELL_LGR, SINGLE_LGR};
RicExportCarfinForCompletionsUi();
void setCase(RimEclipseCase* rimCase);
caf::VecIjk lgrCellCount() const;
QString exportFolder() const;
RimEclipseCase* caseToApply() const;
void setExportFolder(const QString& folder);
private:
void setDefaultValuesFromCase();
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
private:
caf::PdmField<QString> m_exportFolder;
caf::PdmPtrField<RimEclipseCase*> m_caseToApply;
caf::PdmField<int> m_cellCountI;
caf::PdmField<int> m_cellCountJ;
caf::PdmField<int> m_cellCountK;
};

View File

@ -307,6 +307,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicExportVisibleWellPathsFeature";
menuBuilder.subMenuEnd();
menuBuilder << "RicExportCarfinForCompletionsFeature";
if ( dynamic_cast<RimModeledWellPath*>(uiItem) )
{
menuBuilder << "RicShowWellPlanFeature";
@ -766,6 +768,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.subMenuEnd();
}
menuBuilder << "RicExportCarfinForCompletionsFeature";
}
menuBuilder << "RicCreateMultipleFracturesFeature";

View File

@ -23,6 +23,7 @@
#include "FractureCommands/RicCreateMultipleFracturesUi.h"
#include "HoloLensCommands/RicHoloLensExportToFolderUi.h"
#include "ExportCommands/RicExportWellPathsUi.h"
#include "ExportCommands/RicExportCarfinForCompletionsUi.h"
CAF_PDM_SOURCE_INIT(RimDialogData, "RimDialogData");
@ -47,6 +48,9 @@ RimDialogData::RimDialogData()
CAF_PDM_InitFieldNoDefault(&m_exportWellPathsData, "ExportwellPathsData", "Export Well Paths Data", "", "", "");
m_exportWellPathsData = new RicExportWellPathsUi();
CAF_PDM_InitFieldNoDefault(&m_exportCarfinForCompletionsData, "ExportCarfinForCompletions", "Export Carfin", "", "", "");
m_exportCarfinForCompletionsData = new RicExportCarfinForCompletionsUi();
}
//--------------------------------------------------------------------------------------------------
@ -114,3 +118,11 @@ RicExportWellPathsUi* RimDialogData::wellPathsExportData() const
return m_exportWellPathsData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportCarfinForCompletionsUi* RimDialogData::exportCarfinForCompletionsData() const
{
return m_exportCarfinForCompletionsData;
}

View File

@ -26,6 +26,7 @@ class RicExportCompletionDataSettingsUi;
class RiuCreateMultipleFractionsUi;
class RicHoloLensExportToFolderUi;
class RicExportWellPathsUi;
class RicExportCarfinForCompletionsUi;
//==================================================================================================
///
@ -55,6 +56,7 @@ public:
RiuCreateMultipleFractionsUi* multipleFractionsData() const;
RicHoloLensExportToFolderUi* holoLensExportToFolderData() const;
RicExportWellPathsUi* wellPathsExportData() const;
RicExportCarfinForCompletionsUi* exportCarfinForCompletionsData() const;
private:
caf::PdmChildField<RicExportCarfinUi*> m_exportCarfin;
@ -62,4 +64,5 @@ private:
caf::PdmChildField<RiuCreateMultipleFractionsUi*> m_multipleFractionsData;
caf::PdmChildField<RicHoloLensExportToFolderUi*> m_holoLenseExportToFolderData;
caf::PdmChildField<RicExportWellPathsUi*> m_exportWellPathsData;
caf::PdmChildField<RicExportCarfinForCompletionsUi*> m_exportCarfinForCompletionsData;
};