#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;
}