#4320 Add create valve to 3d context menu when clicking on perforation

This commit is contained in:
Gaute Lindkvist 2019-04-12 15:42:25 +02:00
parent 1caed321b0
commit 0861a79dfa
7 changed files with 251 additions and 79 deletions

View File

@ -2091,8 +2091,6 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
applySettingsToAllViews = (reply == QMessageBox::Ok);
}
std::set<caf::PdmUiItem*> uiEditorsToUpdate;
for (auto viewWindow : allViewWindows)
{
for (auto fontTypeSizePair : fontSizes)
@ -2102,10 +2100,7 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
{
int oldFontSize = RiaFontCache::pointSizeFromFontSizeEnum(oldFontSizeEnum);
int newFontSize = RiaFontCache::pointSizeFromFontSizeEnum(fontTypeSizePair.second);
if (viewWindow->applyFontSize(fontTypeSizePair.first, oldFontSize, newFontSize, applySettingsToAllViews))
{
uiEditorsToUpdate.insert(viewWindow);
}
viewWindow->applyFontSize(fontTypeSizePair.first, oldFontSize, newFontSize, applySettingsToAllViews);
}
}
@ -2122,14 +2117,12 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
{
rim3dView->setBackgroundColor(m_preferences->defaultViewerBackgroundColor());
rim3dView->applyBackgroundColorAndFontChanges();
uiEditorsToUpdate.insert(rim3dView);
}
if (oldPreferences && (applySettingsToAllViews || rim3dView->scaleZ == static_cast<double>(oldPreferences->defaultScaleFactorZ())))
{
rim3dView->scaleZ = static_cast<double>(m_preferences->defaultScaleFactorZ());
rim3dView->updateScaling();
uiEditorsToUpdate.insert(rim3dView);
if (rim3dView == activeViewWindow())
{
RiuMainWindow::instance()->updateScaleValue();
@ -2142,7 +2135,6 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
if (oldPreferences && (applySettingsToAllViews || eclipseView->wellCollection()->wellLabelColor() == oldPreferences->defaultWellLabelColor()))
{
eclipseView->wellCollection()->wellLabelColor = m_preferences->defaultWellLabelColor();
uiEditorsToUpdate.insert(eclipseView->wellCollection());
}
eclipseView->scheduleReservoirGridGeometryRegen();
}
@ -2156,7 +2148,6 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
if (applySettingsToAllViews || matchingColor)
{
wellPathCollection->wellPathLabelColor = oldPreferences->defaultWellLabelColor();
uiEditorsToUpdate.insert(wellPathCollection);
}
if (oldPreferences->defaultPlotFontSize() != m_preferences->defaultPlotFontSize())
@ -2165,6 +2156,9 @@ void RiaApplication::applyPreferences(const RiaPreferences* oldPreferences)
}
}
std::vector<caf::PdmUiItem*> uiEditorsToUpdate;
caf::SelectionManager::instance()->selectedItems(uiEditorsToUpdate);
for (caf::PdmUiItem* uiItem : uiEditorsToUpdate)
{
uiItem->updateConnectedEditors();

View File

@ -8,6 +8,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalAtMeasuredDepthFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewValveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewValveTemplateFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewValveAtMeasuredDepthFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDeleteValveTemplateFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportCompletionsFileFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportPerforationIntervalsFeature.h
@ -22,6 +23,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewValveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewValveTemplateFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewValveAtMeasuredDepthFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDeleteValveTemplateFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportCompletionsFileFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportPerforationIntervalsFeature.cpp

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor 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 "RicNewValveAtMeasuredDepthFeature.h"
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimPerforationCollection.h"
#include "RimPerforationInterval.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellPathValve.h"
#include "Riu3DMainWindowTools.h"
#include "Riu3dSelectionManager.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewValveAtMeasuredDepthFeature, "RicNewValveAtMeasuredDepthFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewValveAtMeasuredDepthFeature::onActionTriggered(bool isChecked)
{
RiuWellPathSelectionItem* wellPathSelItem = wellPathSelectionItem();
CVF_ASSERT(wellPathSelItem);
RimWellPath* wellPath = wellPathSelItem->m_wellpath;
CVF_ASSERT(wellPath);
if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return;
RimPerforationInterval* perfInterval = dynamic_cast<RimPerforationInterval*>(wellPathSelItem->m_wellPathComponent);
double measuredDepth = wellPathSelItem->m_measuredDepth;
RimWellPathValve* valve = new RimWellPathValve;
std::vector<RimWellPathValve*> existingValves = perfInterval->valves();
valve->setName(QString("Valve #%1").arg(existingValves.size() + 1));
RimProject* project;
perfInterval->firstAncestorOrThisOfTypeAsserted(project);
std::vector<RimValveTemplate*> allValveTemplates = project->allValveTemplates();
if (!allValveTemplates.empty())
{
valve->setValveTemplate(allValveTemplates.front());
}
perfInterval->addValve(valve);
valve->setMeasuredDepthAndCount(measuredDepth, perfInterval->endMD() - measuredDepth, 1);
RimWellPathCollection* wellPathCollection = nullptr;
wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
wellPathCollection->uiCapability()->updateConnectedEditors();
wellPathCollection->scheduleRedrawAffectedViews();
Riu3DMainWindowTools::selectAsCurrentItem(valve);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewValveAtMeasuredDepthFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/ICDValve16x16.png"));
actionToSetup->setText("Create Valve at this Depth");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewValveAtMeasuredDepthFeature::isCommandEnabled()
{
if (wellPathSelectionItem() && dynamic_cast<RimPerforationInterval*>(wellPathSelectionItem()->m_wellPathComponent))
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellPathSelectionItem* RicNewValveAtMeasuredDepthFeature::wellPathSelectionItem()
{
Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance();
RiuSelectionItem* selItem = riuSelManager->selectedItem(Riu3dSelectionManager::RUI_TEMPORARY);
RiuWellPathSelectionItem* wellPathItem = dynamic_cast<RiuWellPathSelectionItem*>(selItem);
return wellPathItem;
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
class RiuWellPathSelectionItem;
//==================================================================================================
///
//==================================================================================================
class RicNewValveAtMeasuredDepthFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
bool isCommandEnabled() override;
private:
static RiuWellPathSelectionItem* wellPathSelectionItem();
};

View File

@ -262,9 +262,11 @@ RiuGeoMechSelectionItem* Riu2dIntersectionSelectionItem::geoMechSelectionItem()
//--------------------------------------------------------------------------------------------------
RiuWellPathSelectionItem::RiuWellPathSelectionItem(const RivWellPathSourceInfo* wellPathSourceInfo,
const cvf::Vec3d& pipeCenterLineIntersectionInDomainCoords,
double measuredDepth)
: m_pipeCenterlineIntersectionInDomainCoords(pipeCenterLineIntersectionInDomainCoords),
m_measuredDepth(measuredDepth)
double measuredDepth,
RimWellPathComponentInterface* component /*=nullptr*/)
: m_pipeCenterlineIntersectionInDomainCoords(pipeCenterLineIntersectionInDomainCoords)
, m_measuredDepth(measuredDepth)
, m_wellPathComponent(component)
{
m_wellpath = wellPathSourceInfo->wellPath();
}

View File

@ -38,6 +38,7 @@ class RimGeoMechView;
class RimSimWellInView;
class Rim2dIntersectionView;
class RimWellPath;
class RimWellPathComponentInterface;
class RiuSelectionChangedHandler;
class RiuSelectionItem;
class RivSimWellPipeSourceInfo;
@ -237,7 +238,8 @@ class RiuWellPathSelectionItem : public RiuSelectionItem
public:
explicit RiuWellPathSelectionItem(const RivWellPathSourceInfo* wellPathSourceInfo,
const cvf::Vec3d& pipeCenterLineIntersectionInDomainCoords,
double measuredDepth);
double measuredDepth,
RimWellPathComponentInterface* wellPathComponent = nullptr);
~RiuWellPathSelectionItem() override {};
@ -247,9 +249,10 @@ public:
}
public:
RimWellPath* m_wellpath;
cvf::Vec3d m_pipeCenterlineIntersectionInDomainCoords;
double m_measuredDepth;
RimWellPath* m_wellpath;
cvf::Vec3d m_pipeCenterlineIntersectionInDomainCoords;
double m_measuredDepth;
RimWellPathComponentInterface* m_wellPathComponent;
};

View File

@ -168,6 +168,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
// Find the following data
const cvf::Part* firstHitPart = nullptr;
const cvf::Part* additionalHitPart = nullptr;
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED;
@ -178,9 +179,10 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
for (const auto& pickItem : pickItemInfos)
{
const RivObjectSourceInfo* objectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>(pickItem.sourceInfo());
if (objectSourceInfo && dynamic_cast<RimPerforationInterval*>(objectSourceInfo->object()))
if (objectSourceInfo && dynamic_cast<RimWellPathComponentInterface*>(objectSourceInfo->object()))
{
// Skip picking on perforation interval, display well path context menu
// Store any component hit, but keep going to find main well path
additionalHitPart = pickItem.pickedPart();
continue;
}
@ -361,73 +363,86 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
// Well log curve creation commands
if (firstHitPart && firstHitPart->sourceInfo())
{
RimWellPath* wellPath = nullptr;
const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(firstHitPart->sourceInfo());
if (wellPathSourceInfo)
{
RimWellPath* wellPath = wellPathSourceInfo->wellPath();
if (wellPath)
wellPath = wellPathSourceInfo->wellPath();
}
RimWellPathComponentInterface* wellPathComponent = nullptr;
if (additionalHitPart)
{
const RivObjectSourceInfo* objectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>(additionalHitPart->sourceInfo());
if (objectSourceInfo)
{
if (firstPartTriangleIndex != cvf::UNDEFINED_UINT)
{
cvf::Vec3d pickedPositionInUTM = m_currentPickPositionInDomainCoords;
if (int2dView) pickedPositionInUTM = int2dView->transformToUtm(pickedPositionInUTM);
double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, pickedPositionInUTM);
cvf::Vec3d closestPointOnCenterLine =
wellPathSourceInfo->closestPointOnCenterLine(firstPartTriangleIndex, pickedPositionInUTM);
RiuSelectionItem* selItem =
new RiuWellPathSelectionItem(wellPathSourceInfo, closestPointOnCenterLine, measuredDepth);
Riu3dSelectionManager::instance()->setSelectedItem(selItem, Riu3dSelectionManager::RUI_TEMPORARY);
}
// TODO: Update so these also use RiuWellPathSelectionItem
caf::SelectionManager::instance()->setSelectedItem(wellPath);
menuBuilder << "RicNewWellLogCurveExtractionFeature";
menuBuilder << "RicNewWellLogFileCurveFeature";
menuBuilder.addSeparator();
menuBuilder.subMenuStart("Well Plots", QIcon(":/WellLogTrack16x16.png"));
menuBuilder << "RicNewRftPlotFeature";
menuBuilder << "RicNewPltPlotFeature";
menuBuilder.addSeparator();
menuBuilder << "RicShowWellAllocationPlotFeature";
menuBuilder << "RicNewWellBoreStabilityPlotFeature";
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
menuBuilder.subMenuStart("3D Well Log Curves", QIcon(":/WellLogCurve16x16.png"));
menuBuilder << "RicAdd3dWellLogCurveFeature";
menuBuilder << "RicAdd3dWellLogFileCurveFeature";
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
menuBuilder.subMenuStart("Create Completions", QIcon(":/FishBoneGroup16x16.png"));
menuBuilder << "RicNewPerforationIntervalAtMeasuredDepthFeature";
menuBuilder << "RicNewFishbonesSubsAtMeasuredDepthFeature";
menuBuilder << "RicNewWellPathFractureAtPosFeature";
menuBuilder.addSeparator();
menuBuilder << "RicNewWellPathAttributeFeature";
menuBuilder << "RicWellPathImportCompletionsFileFeature";
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
menuBuilder << "RicNewWellPathIntersectionFeature";
wellPathComponent = dynamic_cast<RimWellPathComponentInterface*>(objectSourceInfo->object());
}
}
if (wellPath)
{
if (firstPartTriangleIndex != cvf::UNDEFINED_UINT)
{
cvf::Vec3d pickedPositionInUTM = m_currentPickPositionInDomainCoords;
if (int2dView) pickedPositionInUTM = int2dView->transformToUtm(pickedPositionInUTM);
double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, pickedPositionInUTM);
cvf::Vec3d closestPointOnCenterLine =
wellPathSourceInfo->closestPointOnCenterLine(firstPartTriangleIndex, pickedPositionInUTM);
RiuSelectionItem* selItem =
new RiuWellPathSelectionItem(wellPathSourceInfo, closestPointOnCenterLine, measuredDepth, wellPathComponent);
Riu3dSelectionManager::instance()->setSelectedItem(selItem, Riu3dSelectionManager::RUI_TEMPORARY);
}
// TODO: Update so these also use RiuWellPathSelectionItem
caf::SelectionManager::instance()->setSelectedItem(wellPath);
menuBuilder << "RicNewWellLogCurveExtractionFeature";
menuBuilder << "RicNewWellLogFileCurveFeature";
menuBuilder.addSeparator();
menuBuilder.subMenuStart("Well Plots", QIcon(":/WellLogTrack16x16.png"));
menuBuilder << "RicNewRftPlotFeature";
menuBuilder << "RicNewPltPlotFeature";
menuBuilder.addSeparator();
menuBuilder << "RicShowWellAllocationPlotFeature";
menuBuilder << "RicNewWellBoreStabilityPlotFeature";
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
menuBuilder.subMenuStart("3D Well Log Curves", QIcon(":/WellLogCurve16x16.png"));
menuBuilder << "RicAdd3dWellLogCurveFeature";
menuBuilder << "RicAdd3dWellLogFileCurveFeature";
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
menuBuilder.subMenuStart("Create Completions", QIcon(":/FishBoneGroup16x16.png"));
menuBuilder << "RicNewPerforationIntervalAtMeasuredDepthFeature";
menuBuilder << "RicNewValveAtMeasuredDepthFeature";
menuBuilder << "RicNewFishbonesSubsAtMeasuredDepthFeature";
menuBuilder << "RicNewWellPathFractureAtPosFeature";
menuBuilder.addSeparator();
menuBuilder << "RicNewWellPathAttributeFeature";
menuBuilder << "RicWellPathImportCompletionsFileFeature";
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
menuBuilder << "RicNewWellPathIntersectionFeature";
}
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo =
dynamic_cast<const RivSimWellPipeSourceInfo*>(firstHitPart->sourceInfo());
if (eclipseWellSourceInfo)