#1513 Fishbones : Add 'Fly to Object' for fishbones and perforations

This commit is contained in:
Magne Sjaastad 2017-05-21 09:15:54 +02:00
parent 4c19123b2d
commit 29bf25c56b
9 changed files with 242 additions and 3 deletions

View File

@ -47,6 +47,7 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.h
${CEE_CURRENT_LIST_DIR}RicCommandFeature.h
${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -87,6 +88,7 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,111 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicFlyToObjectFeature.h"
#include "RiaApplication.h"
#include "Rim3dPropertiesInterface.h"
#include "RimView.h"
#include "RiuViewer.h"
#include "cafDisplayCoordTransform.h"
#include "cafPdmObject.h"
#include "cafSelectionManager.h"
#include "cvfCamera.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicFlyToObjectFeature, "RicFlyToObjectFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicFlyToObjectFeature::isCommandEnabled()
{
if (RicFlyToObjectFeature::boundingBoxForSelectedObjects().isValid())
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicFlyToObjectFeature::onActionTriggered(bool isChecked)
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
RiuViewer* destinationViewer = activeView->viewer();
if (!destinationViewer) return;
cvf::BoundingBox bb = RicFlyToObjectFeature::boundingBoxForSelectedObjects();
CVF_ASSERT(bb.isValid());
cvf::ref<caf::DisplayCoordTransform> transForm = activeView->displayCoordTransform();
cvf::Vec3d centerInDisplayCoords = transForm->transformToDisplayCoord(bb.center());
cvf::Vec3d cameraEye = centerInDisplayCoords + cvf::Vec3d::X_AXIS * 50.0;
cvf::Vec3d cameraViewRefPoint = centerInDisplayCoords;
cvf::Vec3d cameraUp = cvf::Vec3d::Z_AXIS;
destinationViewer->mainCamera()->setFromLookAt(cameraEye, cameraViewRefPoint, cameraUp);
activeView->updateCurrentTimeStepAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicFlyToObjectFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Fly to Object");
//actionToSetup->setIcon(QIcon(":/3DView16x16.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RicFlyToObjectFeature::boundingBoxForSelectedObjects()
{
cvf::BoundingBox bb;
std::vector<caf::PdmObject*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
for (auto o : objects)
{
Rim3dPropertiesInterface* rim3dProperties = dynamic_cast<Rim3dPropertiesInterface*>(o);
if (rim3dProperties)
{
bb.add(rim3dProperties->boundingBoxInDomainCoords());
}
}
return bb;
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
#include "cvfBoundingBox.h"
namespace caf {
class PdmObject;
}
//==================================================================================================
///
//==================================================================================================
class RicFlyToObjectFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
virtual void onActionTriggered( bool isChecked ) override;
virtual bool isCommandEnabled() override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
static cvf::BoundingBox boundingBoxForSelectedObjects();
};

View File

@ -26,6 +26,7 @@
#include "cafPdmUiListEditor.h"
#include "cvfAssert.h"
#include "cvfBoundingBox.h"
#include <cstdlib>
@ -51,7 +52,6 @@ namespace caf {
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -446,6 +446,29 @@ void RimFishbonesMultipleSubs::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTr
m_name = QString("Fishbone %1").arg(index);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RimFishbonesMultipleSubs::boundingBoxInDomainCoords()
{
cvf::BoundingBox bb;
for (size_t i = 0; i < m_locationOfSubs().size(); i++)
{
for (size_t lateralIndex = 0; lateralIndex < m_lateralCountPerSub; lateralIndex++)
{
std::vector<cvf::Vec3d> coords = coordsForLateral(i, lateralIndex);
for (auto c : coords)
{
bb.add(c);
}
}
}
return bb;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -19,6 +19,7 @@
#pragma once
#include "RimCheckableNamedObject.h"
#include "Rim3dPropertiesInterface.h"
#include "cvfBase.h"
#include "cvfVector3.h"
@ -32,7 +33,7 @@ class RigFisbonesGeometry;
///
///
//==================================================================================================
class RimFishbonesMultipleSubs : public RimCheckableNamedObject
class RimFishbonesMultipleSubs : public RimCheckableNamedObject, public Rim3dPropertiesInterface
{
CAF_PDM_HEADER_INIT;
@ -54,6 +55,7 @@ public:
RimFishbonesMultipleSubs();
virtual ~RimFishbonesMultipleSubs();
void setMeasuredDepthAndCount(double measuredDepth, double spacing, int subCount);
std::vector<double> locationOfSubs() const;
@ -71,6 +73,9 @@ public:
std::vector<cvf::Vec3d> coordsForLateral(size_t subIndex, size_t lateralIndex) const;
std::vector<std::pair<cvf::Vec3d, double>> coordsAndMDForLateral(size_t subIndex, size_t lateralIndex) const;
// Override from Rim3dPropertiesInterface
virtual cvf::BoundingBox boundingBoxInDomainCoords() override;
protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;

View File

@ -0,0 +1,27 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBoundingBox.h"
class Rim3dPropertiesInterface
{
public:
virtual cvf::BoundingBox boundingBoxInDomainCoords() = 0;
};

View File

@ -401,6 +401,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicExportFishbonesLateralsFeature";
commandIds << "RicWellPathExportCompletionDataFeature";
commandIds << "RicWellPathImportCompletionsFileFeature";
commandIds << "RicFlyToObjectFeature";
// Work in progress -- End

View File

@ -19,7 +19,10 @@
#include "RimPerforationInterval.h"
#include "RigWellPath.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiTextEditor.h"
@ -57,6 +60,26 @@ void RimPerforationInterval::setStartAndEndMD(double startMD, double endMD)
m_endMD = endMD;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RimPerforationInterval::boundingBoxInDomainCoords()
{
cvf::BoundingBox bb;
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted(wellPath);
RigWellPath* rigWellPath = wellPath->wellPathGeometry();
if (rigWellPath)
{
bb.add(rigWellPath->interpolatedPointAlongWellPath(startMD()));
bb.add(rigWellPath->interpolatedPointAlongWellPath(endMD()));
}
return bb;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -20,6 +20,7 @@
#pragma once
#include "RimCheckableNamedObject.h"
#include "Rim3dPropertiesInterface.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@ -28,7 +29,7 @@
///
///
//==================================================================================================
class RimPerforationInterval : public RimCheckableNamedObject
class RimPerforationInterval : public RimCheckableNamedObject, public Rim3dPropertiesInterface
{
CAF_PDM_HEADER_INIT;
public:
@ -40,6 +41,8 @@ public:
double startMD() { return m_startMD(); }
double endMD() { return m_endMD(); }
virtual cvf::BoundingBox boundingBoxInDomainCoords() override;
protected:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;