#1592 Move new well path fracture feature to WellPathFractureCollection

This commit is contained in:
Magne Sjaastad 2017-06-09 12:19:14 +02:00
parent 395e232b77
commit 8f003449b2
3 changed files with 38 additions and 27 deletions

View File

@ -18,8 +18,11 @@
#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"
@ -48,28 +51,27 @@ CAF_CMD_SOURCE_INIT(RicNewWellPathFractureFeature, "RicNewWellPathFractureFeatur
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked) void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked)
{ {
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); RimWellPathFractureCollection* fractureColl = RicNewWellPathFractureFeature::selectedWellPathFractureCollection();
if (!pdmUiItem) return; if (!fractureColl) return;
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (!objHandle) return;
RimWellPath* wellPath = nullptr; RimWellPath* wellPath = nullptr;
objHandle->firstAncestorOrThisOfType(wellPath); fractureColl->firstAncestorOrThisOfTypeAsserted(wellPath);
CVF_ASSERT(wellPath);
if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return;
RimWellPathFracture* fracture = new RimWellPathFracture(); RimWellPathFracture* fracture = new RimWellPathFracture();
wellPath->fractureCollection()->fractures.push_back(fracture); fractureColl->fractures.push_back(fracture);
float md_default = 0.0f; float md_default = 0.0f;
fracture->setMeasuredDepth(md_default); fracture->setMeasuredDepth(md_default);
fracture->fractureUnit = wellPath->unitSystem();
RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); RigWellPath* wellPathGeometry = wellPath->wellPathGeometry();
cvf::Vec3d positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath(md_default); cvf::Vec3d positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath(md_default);
fracture->setAnchorPosition(positionAtWellpath); fracture->setAnchorPosition(positionAtWellpath);
RimOilField* oilfield = nullptr; RimOilField* oilfield = nullptr;
objHandle->firstAncestorOrThisOfType(oilfield); fractureColl->firstAncestorOrThisOfType(oilfield);
if (!oilfield) return; if (!oilfield) return;
std::vector<RimFracture* > oldFractures; std::vector<RimFracture* > oldFractures;
@ -88,7 +90,7 @@ void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked)
RiuMainWindow::instance()->selectAsCurrentItem(fracture); RiuMainWindow::instance()->selectAsCurrentItem(fracture);
RimWellPathCollection* wellPathColl = nullptr; RimWellPathCollection* wellPathColl = nullptr;
objHandle->firstAncestorOrThisOfType(wellPathColl); fractureColl->firstAncestorOrThisOfType(wellPathColl);
if (wellPathColl) if (wellPathColl)
{ {
wellPathColl->scheduleGeometryRegenAndRedrawViews(); wellPathColl->scheduleGeometryRegenAndRedrawViews();
@ -109,19 +111,28 @@ void RicNewWellPathFractureFeature::setupActionLook(QAction* actionToSetup)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RicNewWellPathFractureFeature::isCommandEnabled() bool RicNewWellPathFractureFeature::isCommandEnabled()
{ {
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); if (selectedWellPathFractureCollection())
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 true;
} }
return false; return false;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathFractureCollection* RicNewWellPathFractureFeature::selectedWellPathFractureCollection()
{
RimWellPathFractureCollection* objToFind = nullptr;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
if (objHandle)
{
objHandle->firstAncestorOrThisOfType(objToFind);
}
return objToFind;
}

View File

@ -22,6 +22,7 @@
#include <vector> #include <vector>
class RimWellPathFractureCollection;
//================================================================================================== //==================================================================================================
/// ///
@ -29,11 +30,12 @@
class RicNewWellPathFractureFeature : public caf::CmdFeature class RicNewWellPathFractureFeature : 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;
private:
static RimWellPathFractureCollection* selectedWellPathFractureCollection();
}; };

View File

@ -222,7 +222,6 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicNewWellLogFileCurveFeature"; commandIds << "RicNewWellLogFileCurveFeature";
commandIds << "RicNewWellLogCurveExtractionFeature"; commandIds << "RicNewWellLogCurveExtractionFeature";
commandIds << "RicNewWellPathIntersectionFeature"; commandIds << "RicNewWellPathIntersectionFeature";
commandIds << "RicNewWellPathFractureFeature";
} }
else if (dynamic_cast<RimCalcScript*>(uiItem)) else if (dynamic_cast<RimCalcScript*>(uiItem))
{ {
@ -378,10 +377,6 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
{ {
commandIds << "RicShowFlowCharacteristicsPlotFeature"; commandIds << "RicShowFlowCharacteristicsPlotFeature";
} }
else if (dynamic_cast<RimWellPathFracture*>(uiItem))
{
commandIds << "RicNewWellPathFractureFeature";
}
else if (dynamic_cast<RimSimWellFracture*>(uiItem)) else if (dynamic_cast<RimSimWellFracture*>(uiItem))
{ {
commandIds << "RicNewSimWellFractureFeature"; commandIds << "RicNewSimWellFractureFeature";
@ -443,6 +438,9 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicWellPathImportCompletionsFileFeature"; commandIds << "RicWellPathImportCompletionsFileFeature";
commandIds << "RicFlyToObjectFeature"; commandIds << "RicFlyToObjectFeature";
// Fracture commands
commandIds << "RicNewWellPathFractureFeature";
// Work in progress -- End // Work in progress -- End
caf::PdmUiItem* uiItem = uiItems[0]; caf::PdmUiItem* uiItem = uiItems[0];