#3804 #3805 Measurement. Add toolbar button and interactive picking

This commit is contained in:
Bjørn Erik Jensen 2018-12-19 14:41:17 +01:00
parent d202e430d2
commit 849a623379
23 changed files with 837 additions and 3 deletions

View File

@ -45,6 +45,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/Commands/EclipseCommands
${CMAKE_CURRENT_SOURCE_DIR}/FileInterface
${CMAKE_CURRENT_SOURCE_DIR}/SocketInterface
${CMAKE_CURRENT_SOURCE_DIR}/Measurement
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization/GridBox
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization/Intersections
@ -56,6 +57,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Annotations
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Completions
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Flow
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Measurement
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Summary
${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache
@ -109,6 +111,7 @@ list( APPEND REFERENCED_CMAKE_FILES
ProjectDataModel/Flow/CMakeLists_files.cmake
ProjectDataModel/Annotations/CMakeLists_files.cmake
ProjectDataModel/Completions/CMakeLists_files.cmake
ProjectDataModel/Measurement/CMakeLists_files.cmake
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
@ -132,6 +135,7 @@ list( APPEND REFERENCED_CMAKE_FILES
Commands/HoloLensCommands/CMakeLists_files.cmake
Commands/IntersectionBoxCommands/CMakeLists_files.cmake
Commands/IntersectionViewCommands/CMakeLists_files.cmake
Commands/MeasurementCommands/CMakeLists_files.cmake
Commands/OctaveScriptCommands/CMakeLists_files.cmake
Commands/OperationsUsingObjReferences/CMakeLists_files.cmake
Commands/SummaryPlotCommands/CMakeLists_files.cmake

View File

@ -0,0 +1,23 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicToggleMeasurementModeFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicMeasurementPickEventHandler.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicToggleMeasurementModeFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicMeasurementPickEventHandler.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
list(APPEND QT_MOC_HEADERS
)
source_group( "CommandFeature\\Measurement" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@ -0,0 +1,91 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicMeasurementPickEventHandler.h"
#include "RiaApplication.h"
#include "RimProject.h"
#include "RimIntersection.h"
#include "RimMeasurement.h"
#include "Rim3dView.h"
#include "cafDisplayCoordTransform.h"
#include "cafSelectionManager.h"
#include <vector>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicMeasurementPickEventHandler* RicMeasurementPickEventHandler::instance()
{
static RicMeasurementPickEventHandler* singleton = new RicMeasurementPickEventHandler;
return singleton;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicMeasurementPickEventHandler::handlePickEvent(const Ric3DPickEvent& eventObject)
{
auto measurement = RiaApplication::instance()->project()->measurement();
if (measurement && measurement->isInMeasurementMode())
{
{
Rim3dView* rimView = RiaApplication::instance()->activeReservoirView();
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_pickItemInfos.front().globalPickedPoint());
//if (intersection->inputPolyLineFromViewerEnabled())
{
measurement->addPointInDomain(domainCoord);
// Further Ui processing is stopped when true is returned
return true;
}
//else if (intersection->inputExtrusionPointsFromViewerEnabled())
//{
// intersection->appendPointToExtrusionDirection(domainCoord);
// // Further Ui processing is stopped when true is returned
// return true;
//}
//else if (intersection->inputTwoAzimuthPointsFromViewerEnabled())
//{
// intersection->appendPointToAzimuthLine(domainCoord);
// // Further Ui processing is stopped when true is returned
// return true;
//}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicMeasurementPickEventHandler::notifyUnregistered()
{
}

View File

@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPickEventHandler.h"
//==================================================================================================
///
//==================================================================================================
class RicMeasurementPickEventHandler : public RicPickEventHandler
{
public:
static RicMeasurementPickEventHandler* instance();
protected:
bool handlePickEvent(const Ric3DPickEvent& eventObject) override;
void notifyUnregistered();
};

View File

@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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 "RicToggleMeasurementModeFeature.h"
#include "RiaApplication.h"
#include "RimProject.h"
#include "RimMeasurement.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicToggleMeasurementModeFeature, "RicToggleMeasurementModeFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicToggleMeasurementModeFeature::refreshActionLook()
{
setupActionLook(action());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicToggleMeasurementModeFeature::isCommandEnabled()
{
return activeView() != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicToggleMeasurementModeFeature::onActionTriggered(bool isChecked)
{
auto meas = measurement();
meas->setMeasurementMode(!meas->isInMeasurementMode());
refreshActionLook();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicToggleMeasurementModeFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Measurement Mode");
if(measurement()->isInMeasurementMode())
actionToSetup->setIcon(QIcon(":/NoRuler16x16.png"));
else
actionToSetup->setIcon(QIcon(":/Ruler16x16.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMeasurement* RicToggleMeasurementModeFeature::measurement() const
{
return RiaApplication::instance()->project()->measurement();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dView* RicToggleMeasurementModeFeature::activeView() const
{
auto view = RiaApplication::instance()->activeReservoirView();
return view;
}

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- 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"
class RimMeasurement;
class Rim3dView;
//==================================================================================================
///
//==================================================================================================
class RicToggleMeasurementModeFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
void refreshActionLook();
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook(QAction* actionToSetup) override;
private:
RimMeasurement* measurement() const;
Rim3dView* activeView() const;
};

View File

@ -54,6 +54,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTextAnnotationSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivMeasurementPartMgr.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -106,6 +107,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTextAnnotationSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivMeasurementPartMgr.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,210 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RivMeasurementPartMgr.h"
#include "RiaApplication.h"
#include "RiaBoundingBoxTools.h"
#include "Rim3dView.h"
#include "RimAnnotationInViewCollection.h"
#include "RimProject.h"
#include "RimMeasurement.h"
#include "RimUserDefinedPolylinesAnnotationInView.h"
#include "RimPolylinesFromFileAnnotationInView.h"
#include "RivTextAnnotationPartMgr.h"
#include "RivReachCircleAnnotationPartMgr.h"
#include "RivPolylineAnnotationPartMgr.h"
#include "RivPolylineGenerator.h"
#include "RivPartPriority.h"
#include <cvfModelBasicList.h>
#include <cvfPart.h>
#include <cvfDrawableGeo.h>
#include "cvfRenderStateDepth.h"
#include "cvfRenderStatePoint.h"
#include "cvfBoundingBox.h"
#include "cafEffectGenerator.h"
#include "cafDisplayCoordTransform.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivMeasurementPartMgr::RivMeasurementPartMgr(Rim3dView* view)
: m_rimView(view), m_measurement(nullptr)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivMeasurementPartMgr::~RivMeasurementPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivMeasurementPartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& boundingBox)
{
if (m_measurement.isNull())
{
m_measurement = RiaApplication::instance()->project()->measurement();
}
if (m_measurement.isNull()) return;
if (m_measurement->pointsInDomain().empty()) return;
// Check bounding box
if (!isPolylinesInBoundingBox(boundingBox)) return;
buildPolyLineParts(displayCoordTransform);
if (m_linePart.notNull())
{
model->addPart(m_linePart.p());
}
if (m_pointPart.notNull())
{
model->addPart(m_pointPart.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivMeasurementPartMgr::clearGeometryCache()
{
m_linePart = nullptr;
m_pointPart = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivMeasurementPartMgr::buildPolyLineParts(const caf::DisplayCoordTransform* displayCoordTransform)
{
auto pointsInDisplay = transformPolylinesPointsToDisplay(m_measurement->pointsInDomain(), displayCoordTransform);
// Highlight line
{
cvf::ref<cvf::DrawableGeo> polylineGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(pointsInDisplay);
if (polylineGeo.notNull())
{
//if (useBufferObjects)
//{
// polylineGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
//}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Cross Section Polyline");
part->setDrawable(polylineGeo.p());
part->updateBoundingBox();
part->setPriority(RivPartPriority::PartType::Highlight);
// Always show this part, also when mesh is turned off
// part->setEnableMask(meshFaultBit);
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
eff = lineEffGen.generateUnCachedEffect();
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
depth->enableDepthTest(false);
eff->setRenderState(depth.p());
part->setEffect(eff.p());
m_linePart = part;
}
}
cvf::ref<cvf::DrawableGeo> polylinePointsGeo = RivPolylineGenerator::createPointsFromPolylineDrawable(pointsInDisplay);
if (polylinePointsGeo.notNull())
{
//if (useBufferObjects)
//{
// polylinePointsGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
//}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Cross Section Polyline");
part->setDrawable(polylinePointsGeo.p());
part->updateBoundingBox();
part->setPriority(RivPartPriority::PartType::Highlight);
// Always show this part, also when mesh is turned off
// part->setEnableMask(meshFaultBit);
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
eff = lineEffGen.generateUnCachedEffect();
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
depth->enableDepthTest(false);
eff->setRenderState(depth.p());
cvf::ref<cvf::RenderStatePoint> pointRendState = new cvf::RenderStatePoint(cvf::RenderStatePoint::FIXED_SIZE);
pointRendState->setSize(5.0f);
eff->setRenderState(pointRendState.p());
part->setEffect(eff.p());
m_pointPart = part;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RivMeasurementPartMgr::Vec3d>
RivMeasurementPartMgr::transformPolylinesPointsToDisplay(const std::vector<Vec3d>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf)
{
std::vector<Vec3d> pointsInDisplay;
for (const auto& pt : pointsInDomain)
{
pointsInDisplay.push_back(displayXf->transformToDisplayCoord(pt));
}
return pointsInDisplay;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivMeasurementPartMgr::isPolylinesInBoundingBox(const cvf::BoundingBox& boundingBox)
{
auto effectiveBoundingBox = RiaBoundingBoxTools::inflate(boundingBox, 3);
for (const auto& pt : m_measurement->pointsInDomain())
{
if (effectiveBoundingBox.contains(pt)) return true;
}
return false;
}

View File

@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// 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 "cvfBase.h"
#include "cvfAssert.h"
#include "cvfCollection.h"
#include "cvfObject.h"
#include "cafPdmPointer.h"
#include "cvfVector3.h"
namespace cvf
{
class BoundingBox;
class Part;
class ModelBasicList;
class Transform;
class Font;
}
namespace caf
{
class DisplayCoordTransform;
}
class Rim3dView;
class RimMeasurement;
class RivMeasurementPartMgr : public cvf::Object
{
using Vec3d = cvf::Vec3d;
public:
RivMeasurementPartMgr(Rim3dView* view);
~RivMeasurementPartMgr() override;
void appendGeometryPartsToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& boundingBox);
void clearGeometryCache();
private:
void buildPolyLineParts(const caf::DisplayCoordTransform* displayCoordTransform);
std::vector<Vec3d> transformPolylinesPointsToDisplay(const std::vector<Vec3d>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf);
bool isPolylinesInBoundingBox(const cvf::BoundingBox& boundingBox);
private:
caf::PdmPointer<Rim3dView> m_rimView;
caf::PdmPointer<RimMeasurement> m_measurement;
cvf::ref<cvf::Part> m_linePart;
cvf::ref<cvf::Part> m_pointPart;
};

View File

@ -0,0 +1,23 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimMeasurement.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimMeasurement.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
set (QT_MOC_HEADERS
${QT_MOC_HEADERS}
)
source_group( "ProjectDataModel\\Measurement" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@ -0,0 +1,100 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 "RimMeasurement.h"
#include "RiaApplication.h"
#include "Rim3dView.h"
#include "MeasurementCommands/RicMeasurementPickEventHandler.h"
#include "RiuViewerCommands.h"
CAF_PDM_SOURCE_INIT(RimMeasurement, "RimMeasurement");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMeasurement::RimMeasurement()
: m_isInMeasurementMode(false)
{
CAF_PDM_InitObject("Measurement", ":/TextAnnotation16x16.png", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMeasurement::~RimMeasurement()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeasurement::setMeasurementMode(bool measurementMode)
{
m_isInMeasurementMode = measurementMode;
if (m_isInMeasurementMode)
RiuViewerCommands::setPickEventHandler(RicMeasurementPickEventHandler::instance());
else
{
RiuViewerCommands::removePickEventHandlerIfActive(RicMeasurementPickEventHandler::instance());
m_pointsInDomain.clear();
updateView();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMeasurement::isInMeasurementMode() const
{
return m_isInMeasurementMode;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeasurement::addPointInDomain(const Vec3d& pointInDomain)
{
m_pointsInDomain.push_back(pointInDomain);
updateView();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimMeasurement::pointsInDomain() const
{
return m_pointsInDomain;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeasurement::updateView() const
{
auto view = RiaApplication::instance()->activeReservoirView();
if (view) view->scheduleCreateDisplayModelAndRedraw();
}

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 "cvfBase.h"
#include "cvfVector3.h"
#include "cafPdmObject.h"
//==================================================================================================
///
///
//==================================================================================================
class RimMeasurement : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
using Vec3d = cvf::Vec3d;
public:
RimMeasurement();
~RimMeasurement() override;
void setMeasurementMode(bool measurementMode);
bool isInMeasurementMode() const;
void addPointInDomain(const Vec3d& pointInDomain);
std::vector<Vec3d> pointsInDomain() const;
private:
void updateView() const;
bool m_isInMeasurementMode;
std::vector<Vec3d> m_pointsInDomain;
};

View File

@ -35,9 +35,11 @@
#include "RimViewLinker.h"
#include "RimWellPathCollection.h"
#include "RimViewNameConfig.h"
#include "RimMeasurement.h"
#include "RivAnnotationsPartMgr.h"
#include "RivWellPathsPartMgr.h"
#include "RivMeasurementPartMgr.h"
#include "RiuMainWindow.h"
#include "RiuViewer.h"
@ -141,6 +143,7 @@ Rim3dView::Rim3dView(void)
m_wellPathsPartManager = new RivWellPathsPartMgr(this);
m_annotationsPartManager = new RivAnnotationsPartMgr(this);
m_measurementPartManager = new RivMeasurementPartMgr(this);
this->setAs3DViewMdiWindow();
}
@ -350,6 +353,7 @@ void Rim3dView::setCurrentTimeStepAndUpdate(int frameIndex)
project->mainPlotCollection()->updateCurrentTimeStepInPlots();
appendAnnotationsToModel();
appendMeasurementToModel();
}
//--------------------------------------------------------------------------------------------------
@ -738,6 +742,29 @@ void Rim3dView::addAnnotationsToModel(cvf::ModelBasicList* wellPathModelBasicLis
wellPathModelBasicList->updateBoundingBoxesRecursive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::addMeasurementToModel(cvf::ModelBasicList* wellPathModelBasicList)
{
if (!this->ownerCase()) return;
RimMeasurement* measurement = RiaApplication::instance()->project()->measurement();
if (!measurement || measurement->pointsInDomain().empty())
{
m_measurementPartManager->clearGeometryCache();
}
else
{
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
m_measurementPartManager->appendGeometryPartsToModel(
wellPathModelBasicList, transForm.p(), ownerCase()->allCellsBoundingBox());
}
wellPathModelBasicList->updateBoundingBoxesRecursive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1072,3 +1099,25 @@ void Rim3dView::appendAnnotationsToModel()
frameScene->addModel(model.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dView::appendMeasurementToModel()
{
if (!m_viewer) return;
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
if (frameScene)
{
cvf::String name = "Measurement";
this->removeModelByName(frameScene, name);
cvf::ref<cvf::ModelBasicList> model = new cvf::ModelBasicList;
model->setName(name);
addMeasurementToModel(model.p());
frameScene->addModel(model.p());
}
}

View File

@ -43,6 +43,7 @@ class RimLegendConfig;
class RimWellPathCollection;
class RiuViewer;
class RivAnnotationsPartMgr;
class RivMeasurementPartMgr;
class RivWellPathsPartMgr;
class RimViewNameConfig;
@ -171,6 +172,7 @@ protected:
const cvf::BoundingBox& wellPathClipBoundingBox);
void addAnnotationsToModel(cvf::ModelBasicList* wellPathModelBasicList);
void addMeasurementToModel(cvf::ModelBasicList* wellPathModelBasicList);
void createHighlightAndGridBoxDisplayModel();
@ -208,6 +210,7 @@ protected:
cvf::ref<RivWellPathsPartMgr> m_wellPathsPartManager;
cvf::ref<RivAnnotationsPartMgr> m_annotationsPartManager;
cvf::ref<RivMeasurementPartMgr> m_measurementPartManager;
private:
// Overridden PdmObject methods:
@ -239,6 +242,7 @@ private:
void handleMdiWindowClosed() override;
void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) override;
void appendAnnotationsToModel();
void appendMeasurementToModel();
private:
caf::PdmField<QString> m_name_OBSOLETE;

View File

@ -32,7 +32,7 @@
#include "RimSummaryCase.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimWellPathCollection.h"
#include "RimMeasurement.h"
CAF_PDM_SOURCE_INIT(RimOilField, "ResInsightOilField");
//--------------------------------------------------------------------------------------------------
@ -58,6 +58,10 @@ RimOilField::RimOilField(void)
&m_fractureTemplateCollection_OBSOLETE, "FractureDefinitionCollection", "Defenition of Fractures", "", "", "");
completionTemplateCollection = new RimCompletionTemplateCollection;
CAF_PDM_InitFieldNoDefault(&measurement, "Measurement", "Measurement", "", "", "");
measurement = new RimMeasurement();
analysisModels = new RimEclipseCaseCollection();
wellPathCollection = new RimWellPathCollection();
summaryCaseMainCollection = new RimSummaryCaseMainCollection();

View File

@ -36,6 +36,7 @@ class RimSummaryCase;
class RimSummaryCaseMainCollection;
class RimWellPathCollection;
class RimAnnotationCollection;
class RimMeasurement;
//==================================================================================================
///
@ -65,11 +66,11 @@ public:
caf::PdmChildField<RimObservedDataCollection*> observedDataCollection;
caf::PdmChildField<RimFormationNamesCollection*> formationNamesCollection;
caf::PdmChildField<RimAnnotationCollection*> annotationCollection;
caf::PdmChildField<RimMeasurement*> measurement;
protected:
virtual void initAfterRead() override;
private:
caf::PdmChildField<RimFractureTemplateCollection*> m_fractureTemplateCollection_OBSOLETE;
};

View File

@ -55,6 +55,7 @@
#include "RimGridView.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimMainPlotCollection.h"
#include "RimMeasurement.h"
#include "RimMultiSnapshotDefinition.h"
#include "RimObservedDataCollection.h"
#include "RimOilField.h"
@ -1160,6 +1161,14 @@ RiaEclipseUnitTools::UnitSystemType RimProject::commonUnitSystemForAllCases() co
return commonUnitSystem;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMeasurement* RimProject::measurement() const
{
return activeOilField()->measurement;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1245,6 +1254,7 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS
if (oilField->formationNamesCollection()) uiTreeOrdering.add(oilField->formationNamesCollection());
if (oilField->completionTemplateCollection()) uiTreeOrdering.add(oilField->completionTemplateCollection());
if (oilField->annotationCollection()) uiTreeOrdering.add(oilField->annotationCollection());
if (oilField->measurement()) uiTreeOrdering.add(oilField->measurement());
}
uiTreeOrdering.add(scriptCollection());

View File

@ -41,11 +41,13 @@ class RimPolylinesAnnotation;
class RimSummaryCalculationCollection;
class RimCase;
class RimCommandObject;
class RimCommandObject;
class RimDialogData;
class RimEclipseCase;
class RimGeoMechCase;
class RimIdenticalGridCaseGroup;
class RimMainPlotCollection;
class RimMeasurement;
class RimMultiSnapshotDefinition;
class RimObservedData;
class RimOilField;
@ -161,6 +163,7 @@ public:
std::vector<RimValveTemplate*> allValveTemplates() const;
RiaEclipseUnitTools::UnitSystemType commonUnitSystemForAllCases() const;
RimMeasurement* measurement() const;
protected:
// Overridden methods

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

View File

@ -145,7 +145,8 @@
<file>PolylinesFromFile16x16.png</file>
<file>ReachCircle16x16.png</file>
<file>2DMapProjection16x16.png</file>
<file>Ruler16x16.png</file>
<file>NoRuler16x16.png</file>
</qresource>
<qresource prefix="/Shader/">
<file>fs_CellFace.glsl</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

View File

@ -75,6 +75,7 @@
#include "cafUtils.h"
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
#include "MeasurementCommands/RicToggleMeasurementModeFeature.h"
#include "SummaryPlotCommands/RicEditSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.h"
@ -597,6 +598,11 @@ void RiuMainWindow::createToolBars()
m_holoLensToolBar->addAction(cmdFeatureMgr->action("RicHoloLensExportToSharingServerFeature"));
}
{
QToolBar* measToolBar = addToolBar(tr("Measurement"));
measToolBar->addAction(cmdFeatureMgr->action("RicToggleMeasurementModeFeature"));
}
RiaApplication* app = RiaApplication::instance();
if (app->preferences()->showTestToolbar())
{
@ -869,6 +875,15 @@ void RiuMainWindow::slotRefreshViewActions()
<< "RicViewZoomAllFeature";
caf::CmdFeatureManager::instance()->refreshEnabledState(commandIds);
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
auto feature = dynamic_cast<RicToggleMeasurementModeFeature*>(
cmdFeatureMgr->getCommandFeature("RicToggleMeasurementModeFeature"));
if (feature)
{
feature->refreshActionLook();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,7 @@
#include "RicGeoMechPropertyFilterNewExec.h"
#include "RicPickEventHandler.h"
#include "RicContourMapPickEventHandler.h"
#include "MeasurementCommands/RicMeasurementPickEventHandler.h"
#include "WellLogCommands/Ric3dWellLogCurvePickEventHandler.h"
#include "WellPathCommands/RicIntersectionPickEventHandler.h"
#include "WellPathCommands/RicWellPathPickEventHandler.h"