mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1592 Remove duplicate code for new well path fracture features
This commit is contained in:
parent
8f003449b2
commit
e09ab3c3da
@ -20,28 +20,9 @@
|
|||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
#include "RimCase.h"
|
#include "RicNewWellPathFractureFeature.h"
|
||||||
#include "RimEllipseFractureTemplate.h"
|
|
||||||
#include "RimFractureTemplateCollection.h"
|
|
||||||
#include "RimOilField.h"
|
|
||||||
#include "RimProject.h"
|
|
||||||
#include "RimView.h"
|
|
||||||
#include "RimWellPath.h"
|
|
||||||
#include "RimWellPathCollection.h"
|
|
||||||
#include "RimWellPathFracture.h"
|
|
||||||
#include "RimWellPathFractureCollection.h"
|
|
||||||
|
|
||||||
#include "RiuMainWindow.h"
|
|
||||||
#include "RiuSelectionManager.h"
|
#include "RiuSelectionManager.h"
|
||||||
#include "RiuViewer.h"
|
|
||||||
|
|
||||||
#include "RivWellPathSourceInfo.h"
|
|
||||||
|
|
||||||
#include "cafSelectionManager.h"
|
|
||||||
|
|
||||||
#include "cvfAssert.h"
|
|
||||||
#include "cvfVector3.h"
|
|
||||||
#include "cvfRenderState_FF.h"
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
@ -54,57 +35,16 @@ CAF_CMD_SOURCE_INIT(RicNewWellPathFractureAtPosFeature, "RicNewWellPathFractureA
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicNewWellPathFractureAtPosFeature::onActionTriggered(bool isChecked)
|
void RicNewWellPathFractureAtPosFeature::onActionTriggered(bool isChecked)
|
||||||
{
|
{
|
||||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
|
||||||
if (!activeView) return;
|
|
||||||
|
|
||||||
RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
|
RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
|
||||||
RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
|
RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
|
||||||
|
|
||||||
RiuWellPathSelectionItem* wellPathItem = nullptr;
|
RiuWellPathSelectionItem* wellPathItem = dynamic_cast<RiuWellPathSelectionItem*>(selItem);
|
||||||
if (selItem->type() == RiuSelectionItem::WELLPATH_SELECTION_OBJECT)
|
if (!wellPathItem) return;
|
||||||
{
|
|
||||||
wellPathItem = static_cast<RiuWellPathSelectionItem*>(selItem);
|
|
||||||
if (!wellPathItem) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RimWellPath* wellPath = wellPathItem->m_wellpath;
|
RimWellPath* wellPath = wellPathItem->m_wellpath;
|
||||||
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(wellPath);
|
if (!wellPath) return;
|
||||||
if (!objHandle) return;
|
|
||||||
|
|
||||||
RimWellPath* wellPathObj = nullptr;
|
|
||||||
objHandle->firstAncestorOrThisOfType(wellPathObj);
|
|
||||||
if (!wellPathObj) return;
|
|
||||||
|
|
||||||
RimWellPathFractureCollection* fractureCollection = wellPathObj->fractureCollection();
|
|
||||||
|
|
||||||
RimWellPathFracture* fracture = new RimWellPathFracture();
|
|
||||||
fractureCollection->fractures.push_back(fracture);
|
|
||||||
|
|
||||||
fracture->setMeasuredDepth(wellPathItem->m_measuredDepth);
|
|
||||||
|
|
||||||
RimOilField* oilfield = nullptr;
|
|
||||||
objHandle->firstAncestorOrThisOfType(oilfield);
|
|
||||||
if (!oilfield) return;
|
|
||||||
|
|
||||||
std::vector<RimFracture* > oldFractures;
|
|
||||||
oilfield->descendantsIncludingThisOfType(oldFractures);
|
|
||||||
QString fracNum = QString("%1").arg(oldFractures.size(), 2, 10, QChar('0'));
|
|
||||||
|
|
||||||
fracture->setName(QString("Fracture_") + fracNum);
|
|
||||||
|
|
||||||
|
|
||||||
if (oilfield->fractureDefinitionCollection->fractureDefinitions.size() > 0)
|
|
||||||
{
|
|
||||||
RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->fractureDefinitions[0];
|
|
||||||
fracture->setFractureTemplate(fracDef);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wellPathObj->updateConnectedEditors();
|
|
||||||
RiuMainWindow::instance()->selectAsCurrentItem(fracture);
|
|
||||||
|
|
||||||
activeView->scheduleCreateDisplayModelAndRedraw();
|
|
||||||
|
|
||||||
|
RicNewWellPathFractureFeature::addFracture(wellPath, wellPathItem->m_measuredDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -121,19 +61,5 @@ void RicNewWellPathFractureAtPosFeature::setupActionLook(QAction* actionToSetup)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RicNewWellPathFractureAtPosFeature::isCommandEnabled()
|
bool RicNewWellPathFractureAtPosFeature::isCommandEnabled()
|
||||||
{
|
{
|
||||||
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
|
return true;
|
||||||
if (!pdmUiItem) return false;
|
|
||||||
|
|
||||||
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
|
|
||||||
if (!objHandle) return false;
|
|
||||||
|
|
||||||
RimWellPathCollection* wellPathColl = nullptr;
|
|
||||||
objHandle->firstAncestorOrThisOfType(wellPathColl);
|
|
||||||
|
|
||||||
if (wellPathColl)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,9 @@
|
|||||||
class RicNewWellPathFractureAtPosFeature : public caf::CmdFeature
|
class RicNewWellPathFractureAtPosFeature : public caf::CmdFeature
|
||||||
{
|
{
|
||||||
CAF_CMD_HEADER_INIT;
|
CAF_CMD_HEADER_INIT;
|
||||||
protected:
|
|
||||||
|
|
||||||
|
protected:
|
||||||
virtual void onActionTriggered(bool isChecked) override;
|
virtual void onActionTriggered(bool isChecked) override;
|
||||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||||
virtual bool isCommandEnabled() override;
|
virtual bool isCommandEnabled() override;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -18,11 +18,8 @@
|
|||||||
|
|
||||||
#include "RicNewWellPathFractureFeature.h"
|
#include "RicNewWellPathFractureFeature.h"
|
||||||
|
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
|
|
||||||
|
|
||||||
#include "RigWellPath.h"
|
#include "RigWellPath.h"
|
||||||
|
|
||||||
#include "RimCase.h"
|
#include "RimCase.h"
|
||||||
@ -34,9 +31,10 @@
|
|||||||
#include "RimWellPathCollection.h"
|
#include "RimWellPathCollection.h"
|
||||||
#include "RimWellPathFracture.h"
|
#include "RimWellPathFracture.h"
|
||||||
#include "RimWellPathFractureCollection.h"
|
#include "RimWellPathFractureCollection.h"
|
||||||
|
|
||||||
#include "RiuMainWindow.h"
|
#include "RiuMainWindow.h"
|
||||||
|
|
||||||
|
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
|
||||||
|
|
||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
@ -49,29 +47,27 @@ CAF_CMD_SOURCE_INIT(RicNewWellPathFractureFeature, "RicNewWellPathFractureFeatur
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked)
|
void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double measuredDepth)
|
||||||
{
|
{
|
||||||
RimWellPathFractureCollection* fractureColl = RicNewWellPathFractureFeature::selectedWellPathFractureCollection();
|
CVF_ASSERT(wellPath);
|
||||||
if (!fractureColl) return;
|
|
||||||
|
|
||||||
RimWellPath* wellPath = nullptr;
|
|
||||||
fractureColl->firstAncestorOrThisOfTypeAsserted(wellPath);
|
|
||||||
|
|
||||||
if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return;
|
if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return;
|
||||||
|
|
||||||
|
RimWellPathFractureCollection* fractureCollection = wellPath->fractureCollection();
|
||||||
|
CVF_ASSERT(fractureCollection);
|
||||||
|
|
||||||
RimWellPathFracture* fracture = new RimWellPathFracture();
|
RimWellPathFracture* fracture = new RimWellPathFracture();
|
||||||
fractureColl->fractures.push_back(fracture);
|
fractureCollection->fractures.push_back(fracture);
|
||||||
|
|
||||||
float md_default = 0.0f;
|
fracture->setMeasuredDepth(measuredDepth);
|
||||||
fracture->setMeasuredDepth(md_default);
|
|
||||||
fracture->fractureUnit = wellPath->unitSystem();
|
fracture->fractureUnit = wellPath->unitSystem();
|
||||||
|
|
||||||
RigWellPath* wellPathGeometry = wellPath->wellPathGeometry();
|
RigWellPath* wellPathGeometry = wellPath->wellPathGeometry();
|
||||||
cvf::Vec3d positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath(md_default);
|
cvf::Vec3d positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath(measuredDepth);
|
||||||
fracture->setAnchorPosition(positionAtWellpath);
|
fracture->setAnchorPosition(positionAtWellpath);
|
||||||
|
|
||||||
RimOilField* oilfield = nullptr;
|
RimOilField* oilfield = nullptr;
|
||||||
fractureColl->firstAncestorOrThisOfType(oilfield);
|
fractureCollection->firstAncestorOrThisOfType(oilfield);
|
||||||
if (!oilfield) return;
|
if (!oilfield) return;
|
||||||
|
|
||||||
std::vector<RimFracture* > oldFractures;
|
std::vector<RimFracture* > oldFractures;
|
||||||
@ -90,13 +86,28 @@ void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked)
|
|||||||
RiuMainWindow::instance()->selectAsCurrentItem(fracture);
|
RiuMainWindow::instance()->selectAsCurrentItem(fracture);
|
||||||
|
|
||||||
RimWellPathCollection* wellPathColl = nullptr;
|
RimWellPathCollection* wellPathColl = nullptr;
|
||||||
fractureColl->firstAncestorOrThisOfType(wellPathColl);
|
fractureCollection->firstAncestorOrThisOfType(wellPathColl);
|
||||||
if (wellPathColl)
|
if (wellPathColl)
|
||||||
{
|
{
|
||||||
wellPathColl->scheduleGeometryRegenAndRedrawViews();
|
wellPathColl->scheduleGeometryRegenAndRedrawViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
RimWellPathFractureCollection* fractureColl = RicNewWellPathFractureFeature::selectedWellPathFractureCollection();
|
||||||
|
if (!fractureColl) return;
|
||||||
|
|
||||||
|
RimWellPath* wellPath = nullptr;
|
||||||
|
fractureColl->firstAncestorOrThisOfTypeAsserted(wellPath);
|
||||||
|
|
||||||
|
double defaultMeasuredDepth = 0.0f;
|
||||||
|
RicNewWellPathFractureFeature::addFracture(wellPath, defaultMeasuredDepth);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class RimWellPathFractureCollection;
|
class RimWellPathFractureCollection;
|
||||||
|
class RimWellPath;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -31,6 +32,9 @@ class RicNewWellPathFractureFeature : public caf::CmdFeature
|
|||||||
{
|
{
|
||||||
CAF_CMD_HEADER_INIT;
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void addFracture(RimWellPath* wellPath, double measuredDepth);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onActionTriggered(bool isChecked) override;
|
virtual void onActionTriggered(bool isChecked) override;
|
||||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user