2017-09-27 05:39:28 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// 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 "RicNewRftPlotFeature.h"
|
|
|
|
|
|
|
|
#include "RicWellLogPlotCurveFeatureImpl.h"
|
|
|
|
#include "RicNewWellLogPlotFeatureImpl.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
|
|
|
#include "RigWellLogCurveData.h"
|
|
|
|
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimView.h"
|
|
|
|
#include "RimWellLogExtractionCurve.h"
|
|
|
|
#include "RimWellRftPlot.h"
|
2017-10-02 02:40:33 -05:00
|
|
|
#include "RimWellLogPlot.h"
|
2017-09-27 05:39:28 -05:00
|
|
|
#include "RimWellLogTrack.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimRftPlotCollection.h"
|
|
|
|
#include "RimMainPlotCollection.h"
|
2017-10-05 09:25:04 -05:00
|
|
|
#include "RimEclipseResultCase.h"
|
2017-09-27 05:39:28 -05:00
|
|
|
|
|
|
|
#include "RiuMainPlotWindow.h"
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "RimEclipseWell.h"
|
|
|
|
#include "RiuSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT(RicNewRftPlotFeature, "RicNewRftPlotFeature");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-10-06 00:41:48 -05:00
|
|
|
template<typename T>
|
|
|
|
static T selectedPdmObject()
|
|
|
|
{
|
|
|
|
T objToFind = nullptr;
|
|
|
|
|
|
|
|
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
|
|
|
|
|
|
|
|
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
|
|
|
|
if (objHandle)
|
|
|
|
{
|
|
|
|
objHandle->firstAncestorOrThisOfType(objToFind);
|
|
|
|
}
|
|
|
|
|
|
|
|
return objToFind;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-27 05:39:28 -05:00
|
|
|
bool RicNewRftPlotFeature::isCommandEnabled()
|
|
|
|
{
|
|
|
|
if (RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot()) return false;
|
2017-10-05 09:25:04 -05:00
|
|
|
|
|
|
|
//int branchIndex;
|
|
|
|
|
|
|
|
auto eclWell = selectedPdmObject<RimEclipseWell*>();
|
|
|
|
auto rimWellPath = eclWell == nullptr ? selectedPdmObject<RimWellPath*>() : nullptr;
|
|
|
|
|
|
|
|
bool enable = true;
|
|
|
|
if (eclWell != nullptr)
|
|
|
|
{
|
|
|
|
auto eclCase = selectedPdmObject<RimEclipseResultCase*>();
|
|
|
|
if (eclWell != nullptr)
|
|
|
|
{
|
|
|
|
enable &= RimWellRftPlot::hasPressureData(eclCase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rimWellPath)
|
|
|
|
{
|
|
|
|
auto wellLogFile = rimWellPath->wellLogFile();
|
|
|
|
if (wellLogFile != nullptr)
|
|
|
|
{
|
|
|
|
enable &= RimWellRftPlot::hasPressureData(wellLogFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return enable;
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewRftPlotFeature::onActionTriggered(bool isChecked)
|
|
|
|
{
|
2017-10-05 09:25:04 -05:00
|
|
|
//if (RicWellLogPlotCurveFeatureImpl::parentWellRftPlot()) return;
|
2017-09-27 05:39:28 -05:00
|
|
|
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
|
|
|
|
auto rftPlotColl = proj->mainPlotCollection()->rftPlotCollection();
|
|
|
|
if (rftPlotColl)
|
|
|
|
{
|
2017-10-05 09:25:04 -05:00
|
|
|
QString wellName;
|
2017-10-02 02:40:33 -05:00
|
|
|
RimWellPath* wellPath = nullptr;
|
|
|
|
RimEclipseWell* eclipseWell = nullptr;
|
2017-10-05 09:25:04 -05:00
|
|
|
if ((wellPath = selectedPdmObject<RimWellPath*>()) != nullptr)
|
2017-10-02 02:40:33 -05:00
|
|
|
{
|
|
|
|
wellName = wellPath->name();
|
|
|
|
}
|
2017-10-05 09:25:04 -05:00
|
|
|
else if ((eclipseWell = selectedPdmObject<RimEclipseWell*>()) != nullptr)
|
2017-10-02 02:40:33 -05:00
|
|
|
{
|
|
|
|
wellName = eclipseWell->name();
|
|
|
|
}
|
2017-09-29 04:24:18 -05:00
|
|
|
|
2017-10-05 09:25:04 -05:00
|
|
|
QString plotName = QString(RimWellRftPlot::plotNameFormatString()).arg(wellName);
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-10-02 02:40:33 -05:00
|
|
|
auto rftPlot = new RimWellRftPlot();
|
|
|
|
rftPlot->setCurrentWellName(wellName);
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-10-02 02:40:33 -05:00
|
|
|
auto plotTrack = new RimWellLogTrack();
|
|
|
|
rftPlot->wellLogPlot()->addTrack(plotTrack);
|
|
|
|
plotTrack->setDescription(QString("Track %1").arg(rftPlot->wellLogPlot()->trackCount()));
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-10-02 02:40:33 -05:00
|
|
|
rftPlotColl->addPlot(rftPlot);
|
|
|
|
rftPlot->setDescription(plotName);
|
2017-09-27 05:39:28 -05:00
|
|
|
|
|
|
|
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow();
|
|
|
|
if (mainPlotWindow)
|
|
|
|
{
|
2017-10-02 02:40:33 -05:00
|
|
|
mainPlotWindow->selectAsCurrentItem(rftPlot);
|
|
|
|
mainPlotWindow->setExpanded(rftPlot, true);
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
2017-10-02 02:40:33 -05:00
|
|
|
|
|
|
|
rftPlot->loadDataAndUpdate();
|
|
|
|
rftPlotColl->updateConnectedEditors();
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewRftPlotFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
{
|
|
|
|
actionToSetup->setText("New RFT Plot");
|
|
|
|
actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png"));
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogTrack* RicNewRftPlotFeature::selectedWellLogPlotTrack() const
|
|
|
|
{
|
|
|
|
std::vector<RimWellLogTrack*> selection;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&selection);
|
|
|
|
return selection.size() > 0 ? selection[0] : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPath* RicNewRftPlotFeature::selectedWellPath() const
|
|
|
|
{
|
|
|
|
std::vector<RimWellPath*> selection;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&selection);
|
|
|
|
return selection.size() > 0 ? selection[0] : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimEclipseWell* RicNewRftPlotFeature::selectedSimulationWell(int * branchIndex) const
|
|
|
|
{
|
|
|
|
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 RicNewRftPlotFeature::caseAvailable() const
|
|
|
|
{
|
|
|
|
std::vector<RimCase*> cases;
|
|
|
|
RiaApplication::instance()->project()->allCases(cases);
|
|
|
|
|
|
|
|
return cases.size() > 0;
|
|
|
|
}
|
2017-10-05 09:25:04 -05:00
|
|
|
|