2016-12-20 13:10:03 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// 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 "RicNewSimWellFractureAtPosFeature.h"
|
|
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2017-03-07 10:09:19 +01:00
|
|
|
#include "RigEclipseCaseData.h"
|
2016-12-20 13:10:03 +01:00
|
|
|
|
2018-02-06 13:15:36 +01:00
|
|
|
#include "Rim3dView.h"
|
2016-12-20 13:10:03 +01:00
|
|
|
#include "RimCase.h"
|
2017-03-07 10:09:19 +01:00
|
|
|
#include "RimEclipseResultCase.h"
|
2018-02-06 13:15:36 +01:00
|
|
|
#include "RimEclipseView.h"
|
2017-01-12 13:29:18 +01:00
|
|
|
#include "RimEllipseFractureTemplate.h"
|
2017-02-07 11:08:56 +01:00
|
|
|
#include "RimFractureTemplateCollection.h"
|
2017-01-04 14:02:32 +01:00
|
|
|
#include "RimOilField.h"
|
|
|
|
|
#include "RimProject.h"
|
2017-01-02 11:10:25 +01:00
|
|
|
#include "RimSimWellFracture.h"
|
|
|
|
|
#include "RimSimWellFractureCollection.h"
|
2017-10-13 09:29:42 +02:00
|
|
|
#include "RimSimWellInView.h"
|
2018-02-06 13:15:36 +01:00
|
|
|
#include "RimStimPlanColors.h"
|
2017-01-04 14:02:32 +01:00
|
|
|
|
2018-02-27 15:53:33 +01:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2018-11-30 12:53:46 +01:00
|
|
|
#include "Riu3dSelectionManager.h"
|
2017-01-04 14:02:32 +01:00
|
|
|
#include "RivSimWellPipeSourceInfo.h"
|
2016-12-20 13:10:03 +01:00
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
2017-01-02 10:10:45 +01:00
|
|
|
#include <QAction>
|
2016-12-20 13:10:03 +01:00
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT(RicNewSimWellFractureAtPosFeature, "RicNewSimWellFractureAtPosFeature");
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked)
|
|
|
|
|
{
|
2018-01-23 07:28:32 +01:00
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
|
if (proj->allFractureTemplates().empty()) return;
|
|
|
|
|
|
2018-01-09 10:11:28 +01:00
|
|
|
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
|
2017-01-03 09:34:31 +01:00
|
|
|
if (!activeView) return;
|
|
|
|
|
|
2018-11-30 12:53:46 +01:00
|
|
|
Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance();
|
|
|
|
|
RiuSelectionItem* selItem = riuSelManager->selectedItem(Riu3dSelectionManager::RUI_TEMPORARY);
|
2017-01-03 09:34:31 +01:00
|
|
|
|
2017-09-07 20:33:17 +02:00
|
|
|
RiuSimWellSelectionItem* simWellItem = static_cast<RiuSimWellSelectionItem*>(selItem);
|
|
|
|
|
if (!simWellItem) return;
|
2017-01-03 09:34:31 +01:00
|
|
|
|
2017-10-13 09:29:42 +02:00
|
|
|
RimSimWellInView* simWell = simWellItem->m_simWell;
|
2017-06-20 10:17:23 +02:00
|
|
|
if (!simWell) return;
|
2017-01-03 09:34:31 +01:00
|
|
|
|
2017-06-20 10:17:23 +02:00
|
|
|
RimSimWellFractureCollection* fractureCollection = simWell->simwellFractureCollection();
|
2017-01-03 09:34:31 +01:00
|
|
|
if (!fractureCollection) return;
|
|
|
|
|
|
|
|
|
|
RimSimWellFracture* fracture = new RimSimWellFracture();
|
2018-02-06 13:15:36 +01:00
|
|
|
if (fractureCollection->simwellFractures.empty())
|
|
|
|
|
{
|
2018-09-27 20:17:56 +02:00
|
|
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
|
|
|
|
if (eclipseView)
|
2018-02-06 13:15:36 +01:00
|
|
|
{
|
2018-09-27 20:17:56 +02:00
|
|
|
eclipseView->fractureColors()->setDefaultResultName();
|
2018-02-06 13:15:36 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-03 09:34:31 +01:00
|
|
|
fractureCollection->simwellFractures.push_back(fracture);
|
|
|
|
|
|
2017-01-30 14:28:37 +01:00
|
|
|
fracture->setClosestWellCoord(simWellItem->m_domainCoord, simWellItem->m_branchIndex);
|
2017-01-04 14:02:32 +01:00
|
|
|
|
|
|
|
|
RimOilField* oilfield = nullptr;
|
2017-06-20 10:17:23 +02:00
|
|
|
simWell->firstAncestorOrThisOfType(oilfield);
|
2017-01-04 14:02:32 +01:00
|
|
|
if (!oilfield) return;
|
|
|
|
|
|
2017-01-31 15:54:04 +01:00
|
|
|
std::vector<RimFracture* > oldFractures;
|
|
|
|
|
oilfield->descendantsIncludingThisOfType(oldFractures);
|
|
|
|
|
QString fracNum = QString("%1").arg(oldFractures.size(), 2, 10, QChar('0'));
|
|
|
|
|
|
2017-02-22 13:24:07 +01:00
|
|
|
fracture->setName(QString("Fracture_") + fracNum);
|
2017-01-31 15:54:04 +01:00
|
|
|
|
2018-02-21 09:10:40 +01:00
|
|
|
auto unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN;
|
2017-06-21 11:06:38 +02:00
|
|
|
{
|
|
|
|
|
RimEclipseResultCase* eclipseCase = nullptr;
|
|
|
|
|
simWell->firstAncestorOrThisOfType(eclipseCase);
|
2018-02-21 09:10:40 +01:00
|
|
|
if (eclipseCase)
|
|
|
|
|
{
|
|
|
|
|
unitSet = eclipseCase->eclipseCaseData()->unitsType();
|
|
|
|
|
}
|
2017-03-07 10:09:19 +01:00
|
|
|
|
2018-02-21 09:10:40 +01:00
|
|
|
fracture->setFractureUnit(unitSet);
|
2017-01-04 14:02:32 +01:00
|
|
|
}
|
2018-02-21 09:10:40 +01:00
|
|
|
|
2018-12-13 19:49:37 +01:00
|
|
|
RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection()->firstFractureOfUnit(unitSet);
|
2018-02-21 09:10:40 +01:00
|
|
|
fracture->setFractureTemplate(fracDef);
|
2017-01-04 14:02:32 +01:00
|
|
|
|
2017-06-20 10:17:23 +02:00
|
|
|
simWell->updateConnectedEditors();
|
2017-01-04 10:08:27 +01:00
|
|
|
|
2017-01-05 14:52:59 +01:00
|
|
|
activeView->scheduleCreateDisplayModelAndRedraw();
|
2017-06-21 11:06:38 +02:00
|
|
|
|
|
|
|
|
RimEclipseCase* eclipseCase = nullptr;
|
|
|
|
|
simWell->firstAncestorOrThisOfType(eclipseCase);
|
|
|
|
|
if (eclipseCase)
|
|
|
|
|
{
|
2019-06-21 07:07:37 +02:00
|
|
|
proj->reloadCompletionTypeResultsForEclipseCase(eclipseCase);
|
|
|
|
|
proj->updateConnectedEditors();
|
2017-06-21 11:06:38 +02:00
|
|
|
}
|
2019-06-21 07:07:37 +02:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem(fracture);
|
2016-12-20 13:10:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicNewSimWellFractureAtPosFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
|
{
|
2017-01-05 14:57:04 +01:00
|
|
|
actionToSetup->setIcon(QIcon(":/FractureSymbol16x16.png"));
|
2019-04-08 11:04:21 +02:00
|
|
|
actionToSetup->setText("Create Fracture");
|
2016-12-20 13:10:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RicNewSimWellFractureAtPosFeature::isCommandEnabled()
|
|
|
|
|
{
|
2018-01-23 07:28:32 +01:00
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
|
if (proj->allFractureTemplates().empty()) return false;
|
|
|
|
|
|
2016-12-20 13:10:03 +01:00
|
|
|
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
|
|
|
|
|
if (!pdmUiItem) return false;
|
|
|
|
|
|
|
|
|
|
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
|
|
|
|
|
if (!objHandle) return false;
|
|
|
|
|
|
2017-10-13 09:29:42 +02:00
|
|
|
RimSimWellInView* eclipseWell = nullptr;
|
2016-12-20 13:10:03 +01:00
|
|
|
objHandle->firstAncestorOrThisOfType(eclipseWell);
|
|
|
|
|
|
|
|
|
|
if (eclipseWell)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|