diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 806e5bc397..7d7d2a237c 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -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 diff --git a/ApplicationCode/Commands/RicFlyToObjectFeature.cpp b/ApplicationCode/Commands/RicFlyToObjectFeature.cpp new file mode 100644 index 0000000000..cc205b2875 --- /dev/null +++ b/ApplicationCode/Commands/RicFlyToObjectFeature.cpp @@ -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 +// 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 + +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 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 objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + for (auto o : objects) + { + Rim3dPropertiesInterface* rim3dProperties = dynamic_cast(o); + if (rim3dProperties) + { + bb.add(rim3dProperties->boundingBoxInDomainCoords()); + } + } + + return bb; +} + diff --git a/ApplicationCode/Commands/RicFlyToObjectFeature.h b/ApplicationCode/Commands/RicFlyToObjectFeature.h new file mode 100644 index 0000000000..f8028c44d9 --- /dev/null +++ b/ApplicationCode/Commands/RicFlyToObjectFeature.h @@ -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 +// 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(); +}; diff --git a/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesMultipleSubs.cpp b/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesMultipleSubs.cpp index 238d2a6dd9..e3743ba9c4 100644 --- a/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesMultipleSubs.cpp +++ b/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesMultipleSubs.cpp @@ -26,6 +26,7 @@ #include "cafPdmUiListEditor.h" #include "cvfAssert.h" +#include "cvfBoundingBox.h" #include @@ -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 coords = coordsForLateral(i, lateralIndex); + + for (auto c : coords) + { + bb.add(c); + } + } + } + + return bb; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesMultipleSubs.h b/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesMultipleSubs.h index f5fccaf5a0..de8c8eff03 100644 --- a/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesMultipleSubs.h +++ b/ApplicationCode/ProjectDataModel/Fishbones/RimFishbonesMultipleSubs.h @@ -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 locationOfSubs() const; @@ -70,6 +72,9 @@ public: std::vector coordsForLateral(size_t subIndex, size_t lateralIndex) const; std::vector> 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; diff --git a/ApplicationCode/ProjectDataModel/Rim3dPropertiesInterface.h b/ApplicationCode/ProjectDataModel/Rim3dPropertiesInterface.h new file mode 100644 index 0000000000..694b89ea7a --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dPropertiesInterface.h @@ -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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBoundingBox.h" + +class Rim3dPropertiesInterface +{ +public: + virtual cvf::BoundingBox boundingBoxInDomainCoords() = 0; +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index d2aeb22561..122fe09190 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -401,6 +401,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "RicExportFishbonesLateralsFeature"; commandIds << "RicWellPathExportCompletionDataFeature"; commandIds << "RicWellPathImportCompletionsFileFeature"; + commandIds << "RicFlyToObjectFeature"; // Work in progress -- End diff --git a/ApplicationCode/ProjectDataModel/RimPerforationInterval.cpp b/ApplicationCode/ProjectDataModel/RimPerforationInterval.cpp index 1e4c9ead04..8a6a8ad40b 100644 --- a/ApplicationCode/ProjectDataModel/RimPerforationInterval.cpp +++ b/ApplicationCode/ProjectDataModel/RimPerforationInterval.cpp @@ -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; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimPerforationInterval.h b/ApplicationCode/ProjectDataModel/RimPerforationInterval.h index 23b07fa08b..e73d8a7852 100644 --- a/ApplicationCode/ProjectDataModel/RimPerforationInterval.h +++ b/ApplicationCode/ProjectDataModel/RimPerforationInterval.h @@ -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;