#1971 WLP: Context command to create a new well log RFT curve from a selected well

This commit is contained in:
Rebecca Cox
2017-10-09 12:03:18 +02:00
parent 18552cf2f6
commit da118ac1da
8 changed files with 196 additions and 23 deletions

View File

@@ -20,20 +20,32 @@
#include "RiaApplication.h"
#include "RimEclipseWell.h"
#include "RimProject.h"
#include "RimWellLogRftCurve.h"
#include "RimWellLogTrack.h"
#include "RimWellLogPlot.h"
#include "RimWellLogCurve.h"
#include "RimEclipseResultCase.h"
#include "RigWellLogCurveData.h"
#include "RifReaderEclipseRft.h"
#include "RiuSelectionManager.h"
#include "RiuMainPlotWindow.h"
#include "RiuSelectionManager.h"
#include "RicWellLogPlotCurveFeatureImpl.h"
#include "RicNewWellLogPlotFeatureImpl.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QString>
#include <vector>
CAF_CMD_SOURCE_INIT(RicNewWellLogRftCurveFeature, "RicNewWellLogRftCurveFeature");
//--------------------------------------------------------------------------------------------------
@@ -41,7 +53,20 @@ CAF_CMD_SOURCE_INIT(RicNewWellLogRftCurveFeature, "RicNewWellLogRftCurveFeature"
//--------------------------------------------------------------------------------------------------
bool RicNewWellLogRftCurveFeature::isCommandEnabled()
{
return (selectedWellLogPlotTrack() != nullptr);
if (RicNewWellLogRftCurveFeature::selectedWellLogPlotTrack() != nullptr)
{
return true;
}
int branchIdx;
RimEclipseWell* simulationWell = RicNewWellLogRftCurveFeature::selectedSimulationWell(&branchIdx);
if (simulationWell != nullptr)
{
return RicNewWellLogRftCurveFeature::wellHasRftData(simulationWell->name());
}
return false;
}
//--------------------------------------------------------------------------------------------------
@@ -50,9 +75,32 @@ bool RicNewWellLogRftCurveFeature::isCommandEnabled()
void RicNewWellLogRftCurveFeature::onActionTriggered(bool isChecked)
{
RimWellLogTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
if (!wellLogPlotTrack) return;
if (wellLogPlotTrack)
{
int branchIdx;
RicNewWellLogRftCurveFeature::addCurve(wellLogPlotTrack, selectedSimulationWell(&branchIdx));
}
else
{
int branchIndex = -1;
RimEclipseWell* simWell = selectedSimulationWell(&branchIndex);
if (simWell)
{
RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogRftCurve* plotCurve = RicNewWellLogRftCurveFeature::addCurve(wellLogPlotTrack, simWell);
RicNewWellLogRftCurveFeature::addCurve(wellLogPlotTrack);
plotCurve->loadDataAndUpdate(true);
RimWellLogPlot* plot = NULL;
wellLogPlotTrack->firstAncestorOrThisOfType(plot);
if (plot && plotCurve->curveData())
{
plot->setDepthUnit(plotCurve->curveData()->depthUnit());
}
plotCurve->updateConnectedEditors();
}
}
}
//--------------------------------------------------------------------------------------------------
@@ -64,6 +112,49 @@ void RicNewWellLogRftCurveFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogRftCurve* RicNewWellLogRftCurveFeature::addCurve(RimWellLogTrack* plotTrack, const RimEclipseWell* simWell)
{
CVF_ASSERT(plotTrack);
RimWellLogRftCurve* curve = new RimWellLogRftCurve();
RimEclipseResultCase* resultCase;
std::vector<RimCase*> cases;
RiaApplication::instance()->project()->allCases(cases);
for (RimCase* rimCase : cases)
{
if (resultCase = dynamic_cast<RimEclipseResultCase*>(rimCase))
{
break;
}
}
if (simWell && resultCase)
{
curve->setEclipseResultCase(resultCase);
curve->setDefaultAddress(simWell->name());
}
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plotTrack->curveCount());
curve->setColor(curveColor);
plotTrack->addCurve(curve);
plotTrack->updateConnectedEditors();
RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow();
RiaApplication::instance()->project()->updateConnectedEditors();
plotwindow->selectAsCurrentItem(curve);
return curve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -77,20 +168,40 @@ RimWellLogTrack* RicNewWellLogRftCurveFeature::selectedWellLogPlotTrack()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogRftCurve* RicNewWellLogRftCurveFeature::addCurve(RimWellLogTrack* plotTrack)
RimEclipseWell* RicNewWellLogRftCurveFeature::selectedSimulationWell(int *branchIndex)
{
CVF_ASSERT(plotTrack);
RimWellLogRftCurve* curve = new RimWellLogRftCurve();
plotTrack->addCurve(curve);
plotTrack->updateConnectedEditors();
RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow();
RiaApplication::instance()->project()->updateConnectedEditors();
plotwindow->selectAsCurrentItem(curve);
return curve;
RiuSelectionItem* selItem = RiuSelectionManager::instance()->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
RiuSimWellSelectionItem* simWellSelItem = dynamic_cast<RiuSimWellSelectionItem*>(selItem);
if (simWellSelItem)
{
(*branchIndex) = static_cast<int>(simWellSelItem->m_branchIndex);
return simWellSelItem->m_simWell;
}
else
{
std::vector<RimEclipseWell*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
(*branchIndex) = 0;
return selection.size() > 0 ? selection[0] : NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewWellLogRftCurveFeature::wellHasRftData(const QString& wellName)
{
RimEclipseResultCase* resultCase;
std::vector<RimCase*> cases;
RiaApplication::instance()->project()->allCases(cases);
for (RimCase* rimCase : cases)
{
if (resultCase = dynamic_cast<RimEclipseResultCase*>(rimCase))
{
return resultCase->rftReader()->wellHasRftData(wellName);
}
}
return false;
}

View File

@@ -22,6 +22,8 @@
class RimWellLogRftCurve;
class RimWellLogTrack;
class RimEclipseWell;
class RimWellPath;
//==================================================================================================
///
@@ -30,12 +32,13 @@ class RicNewWellLogRftCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RimWellLogRftCurve* addCurve(RimWellLogTrack* plotTrack);
static RimWellLogTrack* selectedWellLogPlotTrack();
private:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
static RimWellLogRftCurve* addCurve(RimWellLogTrack* plotTrack, const RimEclipseWell* simWell);
static RimWellLogTrack* selectedWellLogPlotTrack();
static RimEclipseWell* selectedSimulationWell(int * branchIndex);
static bool wellHasRftData(const QString& wellName);
};

View File

@@ -272,6 +272,29 @@ const std::set<QString>& RifReaderEclipseRft::wellNames()
return m_wellNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseRft::wellHasRftData(QString wellName)
{
if (!m_ecl_rft_file)
{
open();
}
for (const QString& name : wellNames())
{
if (name == wellName)
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -45,6 +45,7 @@ public:
std::vector<QDateTime> availableTimeSteps(const QString& wellName, const RifEclipseRftAddress::RftWellLogChannelName& wellLogChannelName);
std::vector<RifEclipseRftAddress::RftWellLogChannelName> availableWellLogChannels(const QString& wellName);
const std::set<QString>& wellNames();
bool wellHasRftData(QString wellName);
private:
void open();

View File

@@ -366,6 +366,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
else if (dynamic_cast<RimEclipseWell*>(uiItem))
{
commandIds << "RicNewWellLogCurveExtractionFeature";
commandIds << "RicNewWellLogRftCurveFeature";
commandIds << "RicNewSimWellIntersectionFeature";
commandIds << "RicShowWellAllocationPlotFeature";
}

View File

@@ -134,6 +134,37 @@ RifEclipseRftAddress RimWellLogRftCurve::rftAddress() const
return RifEclipseRftAddress(m_wellName, m_timeStep, m_wellLogChannelName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::setDefaultAddress(QString wellName)
{
RifReaderEclipseRft* reader = rftReader();
if (!reader) return;
bool wellNameHasRftData = false;
std::set<QString> wellNames = reader->wellNames();
for (const QString& wellNameWithRft : wellNames)
{
if (wellName == wellNameWithRft)
{
wellNameHasRftData = true;
m_wellName = wellName;
break;
}
}
if (!wellNameHasRftData) return;
m_wellLogChannelName = RifEclipseRftAddress::PRESSURE;
std::vector<QDateTime> timeSteps = reader->availableTimeSteps(m_wellName, m_wellLogChannelName());
if (timeSteps.size() > 0)
{
m_timeStep = timeSteps[0];
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -52,6 +52,8 @@ public:
void setRftAddress(RifEclipseRftAddress address);
RifEclipseRftAddress rftAddress() const;
void setDefaultAddress(QString wellName);
protected:
// Overrides from RimWellLogPlotCurve
virtual QString createCurveAutoName() override;

View File

@@ -325,6 +325,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY);
commandIds << "RicNewWellLogCurveExtractionFeature";
commandIds << "RicNewWellLogRftCurveFeature";
commandIds << "RicNewRftPlotFeature";
commandIds << "RicShowWellAllocationPlotFeature";
commandIds << "RicPlotProductionRateFeature";