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 "RimCase.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 "RicNewWellPathFractureFeature.h"
|
||||
|
||||
#include "RiuMainWindow.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>
|
||||
|
||||
@ -54,57 +35,16 @@ CAF_CMD_SOURCE_INIT(RicNewWellPathFractureAtPosFeature, "RicNewWellPathFractureA
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathFractureAtPosFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (!activeView) return;
|
||||
|
||||
RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
|
||||
RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
|
||||
|
||||
RiuWellPathSelectionItem* wellPathItem = nullptr;
|
||||
if (selItem->type() == RiuSelectionItem::WELLPATH_SELECTION_OBJECT)
|
||||
{
|
||||
wellPathItem = static_cast<RiuWellPathSelectionItem*>(selItem);
|
||||
RiuWellPathSelectionItem* wellPathItem = dynamic_cast<RiuWellPathSelectionItem*>(selItem);
|
||||
if (!wellPathItem) return;
|
||||
}
|
||||
|
||||
RimWellPath* wellPath = wellPathItem->m_wellpath;
|
||||
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(wellPath);
|
||||
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();
|
||||
if (!wellPath) return;
|
||||
|
||||
RicNewWellPathFractureFeature::addFracture(wellPath, wellPathItem->m_measuredDepth);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -121,19 +61,5 @@ void RicNewWellPathFractureAtPosFeature::setupActionLook(QAction* actionToSetup)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewWellPathFractureAtPosFeature::isCommandEnabled()
|
||||
{
|
||||
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
|
||||
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
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
protected:
|
||||
|
||||
protected:
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
virtual bool isCommandEnabled() override;
|
||||
|
||||
|
||||
};
|
||||
|
@ -18,11 +18,8 @@
|
||||
|
||||
#include "RicNewWellPathFractureFeature.h"
|
||||
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
|
||||
|
||||
#include "RigWellPath.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
@ -34,9 +31,10 @@
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathFracture.h"
|
||||
#include "RimWellPathFractureCollection.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
|
||||
|
||||
#include "cafSelectionManager.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();
|
||||
if (!fractureColl) return;
|
||||
|
||||
RimWellPath* wellPath = nullptr;
|
||||
fractureColl->firstAncestorOrThisOfTypeAsserted(wellPath);
|
||||
CVF_ASSERT(wellPath);
|
||||
|
||||
if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return;
|
||||
|
||||
RimWellPathFracture* fracture = new RimWellPathFracture();
|
||||
fractureColl->fractures.push_back(fracture);
|
||||
RimWellPathFractureCollection* fractureCollection = wellPath->fractureCollection();
|
||||
CVF_ASSERT(fractureCollection);
|
||||
|
||||
float md_default = 0.0f;
|
||||
fracture->setMeasuredDepth(md_default);
|
||||
RimWellPathFracture* fracture = new RimWellPathFracture();
|
||||
fractureCollection->fractures.push_back(fracture);
|
||||
|
||||
fracture->setMeasuredDepth(measuredDepth);
|
||||
fracture->fractureUnit = wellPath->unitSystem();
|
||||
|
||||
RigWellPath* wellPathGeometry = wellPath->wellPathGeometry();
|
||||
cvf::Vec3d positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath(md_default);
|
||||
cvf::Vec3d positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath(measuredDepth);
|
||||
fracture->setAnchorPosition(positionAtWellpath);
|
||||
|
||||
RimOilField* oilfield = nullptr;
|
||||
fractureColl->firstAncestorOrThisOfType(oilfield);
|
||||
fractureCollection->firstAncestorOrThisOfType(oilfield);
|
||||
if (!oilfield) return;
|
||||
|
||||
std::vector<RimFracture* > oldFractures;
|
||||
@ -90,13 +86,28 @@ void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked)
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(fracture);
|
||||
|
||||
RimWellPathCollection* wellPathColl = nullptr;
|
||||
fractureColl->firstAncestorOrThisOfType(wellPathColl);
|
||||
fractureCollection->firstAncestorOrThisOfType(wellPathColl);
|
||||
if (wellPathColl)
|
||||
{
|
||||
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>
|
||||
|
||||
class RimWellPathFractureCollection;
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -31,6 +32,9 @@ class RicNewWellPathFractureFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void addFracture(RimWellPath* wellPath, double measuredDepth);
|
||||
|
||||
protected:
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
|
Loading…
Reference in New Issue
Block a user