Merge branch 'measurement' into dev

This commit is contained in:
Magne Sjaastad committed 2019-01-03 07:34:04 +01:00
commit ca39bd3407
24 files changed
+1159 -197

No files matched your search

+4
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
@@ -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 )
@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "Rim3dView.h"
#include "RimIntersection.h"
#include "RimMeasurement.h"
#include "RimProject.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());
bool isControlButtonDown = QApplication::keyboardModifiers() & Qt::ControlModifier;
if (!isControlButtonDown)
{
if (measurement->pointsInDomainCoords().size() > 1)
{
measurement->removeAllPoints();
}
}
measurement->addPointInDomainCoords(domainCoord);
// Further Ui processing is stopped when true is returned
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicMeasurementPickEventHandler::notifyUnregistered() {}
@@ -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();
};
@@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "Rim3dView.h"
#include "RimMeasurement.h"
#include "RimProject.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");
auto* meas = measurement();
if (meas && meas->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;
}
@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 QObject;
class RiuMeasurementViewEventFilter;
//==================================================================================================
///
//==================================================================================================
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;
};
@@ -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
@@ -0,0 +1,242 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaColorTools.h"
#include "RiaFontCache.h"
#include "RiaPreferences.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 <cvfDrawableText.h>
#include "cvfRenderStateDepth.h"
#include "cvfRenderStatePoint.h"
#include "cvfBoundingBox.h"
#include "cvfqtUtils.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->pointsInDomainCoords().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());
}
if (m_labelPart.notNull())
{
model->addPart(m_labelPart.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivMeasurementPartMgr::clearGeometryCache()
{
m_linePart = nullptr;
m_pointPart = nullptr;
m_labelPart = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivMeasurementPartMgr::buildPolyLineParts(const caf::DisplayCoordTransform* displayCoordTransform)
{
auto pointsInDisplay = transformPolylinesPointsToDisplay(m_measurement->pointsInDomainCoords(), displayCoordTransform);
// Measurement lines
{
cvf::ref<cvf::DrawableGeo> polylineGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(pointsInDisplay);
if (polylineGeo.notNull())
{
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Cross Section Polyline");
part->setDrawable(polylineGeo.p());
part->updateBoundingBox();
part->setPriority(RivPartPriority::PartType::Highlight);
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;
}
}
// Measurement points
cvf::ref<cvf::DrawableGeo> polylinePointsGeo = RivPolylineGenerator::createPointsFromPolylineDrawable(pointsInDisplay);
if (polylinePointsGeo.notNull())
{
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Cross Section Polyline");
part->setDrawable(polylinePointsGeo.p());
part->updateBoundingBox();
part->setPriority(RivPartPriority::PartType::Highlight);
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;
}
// Text label
if(pointsInDisplay.size() > 1)
{
auto fontSize = RiaFontCache::FONT_SIZE_8;
auto backgroundColor = RiaApplication::instance()->preferences()->defaultViewerBackgroundColor;
auto fontColor = cvf::Color3f::BLACK;
QString text = m_measurement->label();
auto labelPosition = pointsInDisplay.back();
auto font = RiaFontCache::getFont(fontSize);
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
drawableText->setFont(font.p());
drawableText->setCheckPosVisible(false);
drawableText->setDrawBorder(true);
drawableText->setDrawBackground(true);
drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE);
drawableText->setBackgroundColor(backgroundColor);
drawableText->setBorderColor(RiaColorTools::computeOffsetColor(backgroundColor, 0.3f));
drawableText->setTextColor(fontColor);
cvf::String cvfString = cvfqt::Utils::toString(text);
cvf::Vec3f textCoord(labelPosition);
drawableText->addText(cvfString, textCoord);
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("RivMeasurementPartMgr: " + cvfString);
part->setDrawable(drawableText.p());
cvf::ref<cvf::Effect> eff = new cvf::Effect();
part->setEffect(eff.p());
part->setPriority(RivPartPriority::PartType::Text);
m_labelPart = 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->pointsInDomainCoords())
{
if (effectiveBoundingBox.contains(pt)) return true;
}
return false;
}
@@ -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;
cvf::ref<cvf::Part> m_labelPart;
};
@@ -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 )
@@ -0,0 +1,151 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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());
removeAllPoints();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMeasurement::isInMeasurementMode() const
{
return m_isInMeasurementMode;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeasurement::addPointInDomainCoords(const Vec3d& domainCoord)
{
auto activeView = RiaApplication::instance()->activeReservoirView();
if (m_sourceView.p() != activeView)
{
removeAllPoints();
}
m_pointsInDomainCoords.push_back(domainCoord);
m_sourceView = activeView;
updateView();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RimMeasurement::pointsInDomainCoords() const
{
return m_pointsInDomainCoords;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeasurement::removeAllPoints()
{
m_pointsInDomainCoords.clear();
updateView();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimMeasurement::label() const
{
auto lengths = calculateLenghts();
return QString("Total length: \t%1\nLast length: \t%2\nTotal horizontal length: \t%3\nLast horizontal length: \t%4")
.arg(lengths.totalLength)
.arg(lengths.lastSegmentLength)
.arg(lengths.totalHorizontalLength)
.arg(lengths.lastSegmentHorisontalLength);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMeasurement::Lengths RimMeasurement::calculateLenghts() const
{
Lengths lengths;
for (size_t p = 1; p < m_pointsInDomainCoords.size(); p++)
{
const auto& p0 = m_pointsInDomainCoords[p - 1];
const auto& p1 = m_pointsInDomainCoords[p];
lengths.lastSegmentLength = (p1 - p0).length();
const auto& p1_horiz = cvf::Vec3d(p1.x(), p1.y(), p0.z());
lengths.lastSegmentHorisontalLength = (p1_horiz - p0).length();
lengths.totalLength += lengths.lastSegmentLength;
lengths.totalHorizontalLength += lengths.lastSegmentHorisontalLength;
}
return lengths;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMeasurement::updateView() const
{
if (m_sourceView)
{
m_sourceView->createDisplayModelAndRedraw();
}
}
@@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmObject.h"
#include "cvfBase.h"
#include "cvfVector3.h"
class Rim3dView;
//==================================================================================================
///
///
//==================================================================================================
class RimMeasurement : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
using Vec3d = cvf::Vec3d;
public:
class Lengths
{
public:
Lengths()
: totalLength(0)
, lastSegmentLength(0)
, totalHorizontalLength(0)
, lastSegmentHorisontalLength(0)
, area(0)
{
}
double totalLength;
double lastSegmentLength;
double totalHorizontalLength;
double lastSegmentHorisontalLength;
double area;
};
RimMeasurement();
~RimMeasurement() override;
void setMeasurementMode(bool measurementMode);
bool isInMeasurementMode() const;
void addPointInDomainCoords(const Vec3d& pointInDomainCoord);
std::vector<Vec3d> pointsInDomainCoords() const;
void removeAllPoints();
QString label() const;
private:
Lengths calculateLenghts() const;
void updateView() const;
private:
bool m_isInMeasurementMode;
std::vector<Vec3d> m_pointsInDomainCoords;
caf::PdmPointer<Rim3dView> m_sourceView;
};
@@ -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->pointsInDomainCoords().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());
}
}
@@ -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;
@@ -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,11 @@ RimOilField::RimOilField(void)
&m_fractureTemplateCollection_OBSOLETE, "FractureDefinitionCollection", "Defenition of Fractures", "", "", "");
completionTemplateCollection = new RimCompletionTemplateCollection;
CAF_PDM_InitFieldNoDefault(&measurement, "Measurement", "Measurement", "", "", "");
measurement = new RimMeasurement();
measurement.xmlCapability()->disableIO();
analysisModels = new RimEclipseCaseCollection();
wellPathCollection = new RimWellPathCollection();
summaryCaseMainCollection = new RimSummaryCaseMainCollection();
@@ -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;
};
@@ -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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -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

+2 -1
View File
@@ -147,7 +147,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

@@ -76,6 +76,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.h
${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.h
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItemGroup.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellPathComponentPlotItem.h
${CMAKE_CURRENT_LIST_DIR}/RiuMeasurementViewEventFilter.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -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,14 @@ void RiuMainWindow::createToolBars()
m_holoLensToolBar->addAction(cmdFeatureMgr->action("RicHoloLensExportToSharingServerFeature"));
}
{
QToolBar* toolbar = addToolBar(tr("Measurement"));
toolbar->setObjectName(toolbar->windowTitle());
auto action = cmdFeatureMgr->action("RicToggleMeasurementModeFeature");
action->setCheckable(true);
toolbar->addAction(action);
}
RiaApplication* app = RiaApplication::instance();
if (app->preferences()->showTestToolbar())
{
@@ -869,6 +878,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();
}
}
//--------------------------------------------------------------------------------------------------
@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,10 +23,11 @@
#include "RiaColorTables.h"
#include "RiaDefines.h"
#include "MeasurementCommands/RicMeasurementPickEventHandler.h"
#include "RicContourMapPickEventHandler.h"
#include "RicEclipsePropertyFilterNewExec.h"
#include "RicGeoMechPropertyFilterNewExec.h"
#include "RicPickEventHandler.h"
#include "RicContourMapPickEventHandler.h"
#include "WellLogCommands/Ric3dWellLogCurvePickEventHandler.h"
#include "WellPathCommands/RicIntersectionPickEventHandler.h"
#include "WellPathCommands/RicWellPathPickEventHandler.h"
@@ -59,20 +60,22 @@
#include "RimPerforationInterval.h"
#include "RimSimWellInView.h"
#include "RimStimPlanFractureTemplate.h"
#include "RimTextAnnotation.h"
#include "RimViewController.h"
#include "RimWellPath.h"
#include "RiuMainWindow.h"
#include "RiuResultTextBuilder.h"
#include "Riu3dSelectionManager.h"
#include "RiuViewer.h"
#include "RiuMainWindow.h"
#include "RiuPickItemInfo.h"
#include "RiuResultTextBuilder.h"
#include "RiuViewer.h"
#include "RivFemPartGeometryGenerator.h"
#include "RivFemPickSourceInfo.h"
#include "RivIntersectionBoxSourceInfo.h"
#include "RivIntersectionSourceInfo.h"
#include "RivObjectSourceInfo.h"
#include "RivPartPriority.h"
#include "RivSimWellConnectionSourceInfo.h"
#include "RivSimWellPipeSourceInfo.h"
#include "RivSourceInfo.h"
@@ -85,14 +88,17 @@
#include "cafCmdFeatureManager.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafDisplayCoordTransform.h"
#include "cafOverlayScalarMapperLegend.h"
#include "cafPdmUiTreeView.h"
#include "cafSelectionManager.h"
#include "cafOverlayScalarMapperLegend.h"
#include "cvfDrawableGeo.h"
#include "cvfDrawableText.h"
#include "cvfHitItemCollection.h"
#include "cvfOverlayAxisCross.h"
#include "cvfPart.h"
#include "cvfRay.h"
#include "cvfScene.h"
#include "cvfTransform.h"
#include <QMenu>
@@ -100,24 +106,17 @@
#include <QStatusBar>
#include <array>
#include "cvfScene.h"
#include "RivPartPriority.h"
#include "cvfDrawableText.h"
#include "cvfRay.h"
#include "RimTextAnnotation.h"
//==================================================================================================
//
// RiaViewerCommands
//
//==================================================================================================
RicPickEventHandler* RiuViewerCommands::sm_overridingPickHandler = nullptr;
RicPickEventHandler* RiuViewerCommands::sm_overridingPickHandler = nullptr;
std::vector<RicDefaultPickEventHandler*> RiuViewerCommands::sm_defaultPickEventHandlers;
std::vector<RicDefaultPickEventHandler*> RiuViewerCommands::sm_defaultPickEventHandlers;
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer)
: QObject(ownerViewer)
@@ -127,7 +126,7 @@ RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer)
, m_currentPickPositionInDomainCoords(cvf::Vec3d::UNDEFINED)
, m_viewer(ownerViewer)
{
if ( sm_defaultPickEventHandlers.empty() )
if (sm_defaultPickEventHandlers.empty())
{
addDefaultPickEventHandler(RicIntersectionPickEventHandler::instance());
addDefaultPickEventHandler(Ric3dWellLogCurvePickEventHandler::instance());
@@ -137,24 +136,20 @@ RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuViewerCommands::~RiuViewerCommands()
{
}
RiuViewerCommands::~RiuViewerCommands() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::setOwnerView(Rim3dView * owner)
void RiuViewerCommands::setOwnerView(Rim3dView* owner)
{
m_reservoirView = owner;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
{
@@ -163,7 +158,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
std::vector<RiuPickItemInfo> pickItemInfos;
{
cvf::HitItemCollection hitItems;
if (m_viewer->rayPick( event->x(), event->y(), &hitItems))
if (m_viewer->rayPick(event->x(), event->y(), &hitItems))
{
pickItemInfos = RiuPickItemInfo::convertToPickItemInfos(hitItems);
}
@@ -171,9 +166,9 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
// Find the following data
const cvf::Part* firstHitPart = nullptr;
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED;
const cvf::Part* firstHitPart = nullptr;
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED;
if (pickItemInfos.size())
{
@@ -182,21 +177,21 @@ 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<RimPerforationInterval*>(objectSourceInfo->object()))
{
// Skip picking on perforation interval, display well path context menu
continue;
}
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickItem.sourceInfo());
if ( rivSourceInfo && rivSourceInfo->hasNNCIndices())
if (rivSourceInfo && rivSourceInfo->hasNNCIndices())
{
// Skip picking on nnc-s
continue;
}
firstHitPart = pickItem.pickedPart();
firstPartTriangleIndex = pickItem.faceIdx();
firstHitPart = pickItem.pickedPart();
firstPartTriangleIndex = pickItem.faceIdx();
globalIntersectionPoint = pickItem.globalPickedPoint();
break;
}
@@ -206,28 +201,30 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
if (m_reservoirView.p())
{
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView.p()->displayCoordTransform();
m_currentPickPositionInDomainCoords = transForm->transformToDomainCoord(globalIntersectionPoint);
m_currentPickPositionInDomainCoords = transForm->transformToDomainCoord(globalIntersectionPoint);
}
}
// Build menue
QMenu menu;
QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder;
m_currentGridIdx = cvf::UNDEFINED_SIZE_T;
m_currentGridIdx = cvf::UNDEFINED_SIZE_T;
m_currentCellIndex = cvf::UNDEFINED_SIZE_T;
// Check type of view
RimGridView* gridView = dynamic_cast<RimGridView*>(m_reservoirView.p());
RimGridView* gridView = dynamic_cast<RimGridView*>(m_reservoirView.p());
Rim2dIntersectionView* int2dView = dynamic_cast<Rim2dIntersectionView*>(m_reservoirView.p());
if (firstHitPart && firstPartTriangleIndex != cvf::UNDEFINED_UINT)
{
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionSourceInfo* crossSectionSourceInfo = dynamic_cast<const RivIntersectionSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo = dynamic_cast<const RivIntersectionBoxSourceInfo*>(firstHitPart->sourceInfo());
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionSourceInfo* crossSectionSourceInfo =
dynamic_cast<const RivIntersectionSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo =
dynamic_cast<const RivIntersectionBoxSourceInfo*>(firstHitPart->sourceInfo());
if (rivSourceInfo || femSourceInfo || crossSectionSourceInfo || intersectionBoxSourceInfo)
{
@@ -237,13 +234,13 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
// Set the data regarding what was hit
m_currentGridIdx = rivSourceInfo->gridIndex();
m_currentGridIdx = rivSourceInfo->gridIndex();
m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(firstPartTriangleIndex);
m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(firstPartTriangleIndex);
}
else if (femSourceInfo)
{
m_currentGridIdx = femSourceInfo->femPartIndex();
m_currentGridIdx = femSourceInfo->femPartIndex();
m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(firstPartTriangleIndex);
}
else if (crossSectionSourceInfo)
@@ -253,7 +250,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
RiuSelectionItem* selItem = new RiuGeneralSelectionItem(crossSectionSourceInfo->crossSection());
Riu3dSelectionManager::instance()->setSelectedItem(selItem, Riu3dSelectionManager::RUI_TEMPORARY);
if (gridView)
{
menuBuilder << "RicHideIntersectionFeature";
@@ -333,12 +330,12 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
menuBuilder.addSeparator();
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
if (eclipseView)
{
// Hide faults command
const RigFault* fault = eclipseView->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
const RigFault* fault =
eclipseView->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
if (fault)
{
menuBuilder.addSeparator();
@@ -346,11 +343,12 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
QString faultName = fault->name();
QVariantList hideFaultList;
qulonglong currentCellIndex = m_currentCellIndex;
qulonglong currentCellIndex = m_currentCellIndex;
hideFaultList.push_back(currentCellIndex);
hideFaultList.push_back(m_currentFaceIndex);
menuBuilder.addCmdFeatureWithUserData("RicEclipseHideFaultFeature", QString("Hide ") + faultName, hideFaultList);
menuBuilder.addCmdFeatureWithUserData(
"RicEclipseHideFaultFeature", QString("Hide ") + faultName, hideFaultList);
}
}
}
@@ -370,18 +368,20 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
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);
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
// 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"));
@@ -408,7 +408,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
menuBuilder.addSeparator();
menuBuilder << "RicNewWellPathAttributeFeature";
menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png"));
menuBuilder << "RicNewWellPathFractureAtPosFeature";
menuBuilder << "RicNewFishbonesSubsAtMeasuredDepthFeature";
menuBuilder << "RicNewPerforationIntervalAtMeasuredDepthFeature";
@@ -421,7 +421,8 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
}
}
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(firstHitPart->sourceInfo());
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo =
dynamic_cast<const RivSimWellPipeSourceInfo*>(firstHitPart->sourceInfo());
if (eclipseWellSourceInfo)
{
RimSimWellInView* well = eclipseWellSourceInfo->well();
@@ -429,7 +430,8 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
{
caf::SelectionManager::instance()->setSelectedItem(well);
RiuSelectionItem* selItem = new RiuSimWellSelectionItem(eclipseWellSourceInfo->well(), m_currentPickPositionInDomainCoords, eclipseWellSourceInfo->branchIndex());
RiuSelectionItem* selItem = new RiuSimWellSelectionItem(
eclipseWellSourceInfo->well(), m_currentPickPositionInDomainCoords, eclipseWellSourceInfo->branchIndex());
Riu3dSelectionManager::instance()->setSelectedItem(selItem, Riu3dSelectionManager::RUI_TEMPORARY);
menuBuilder << "RicNewWellLogCurveExtractionFeature";
@@ -443,7 +445,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
menuBuilder << "RicNewPltPlotFeature";
menuBuilder.addSeparator();
menuBuilder << "RicPlotProductionRateFeature";
menuBuilder << "RicShowWellAllocationPlotFeature";
@@ -505,7 +507,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardModifiers keyboardModifiers)
{
@@ -517,7 +519,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
}
// Do the ray intersection with the scene
std::vector<RiuPickItemInfo> pickItemInfos;
{
cvf::HitItemCollection hitItems;
@@ -526,27 +528,26 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
// Do specialized text pick, since vizfwk does not hit text
handleTextPicking(winPosX, winPosY, &hitItems);
if ( hitItems.count() )
if (hitItems.count())
{
pickItemInfos = RiuPickItemInfo::convertToPickItemInfos(hitItems);
}
}
// Make pickEventHandlers do their stuff
// Make pickEventHandlers do their stuff
if ( pickItemInfos.size() )
if (pickItemInfos.size())
{
Ric3DPickEvent viewerEventObject(pickItemInfos,
m_reservoirView);
Ric3DPickEvent viewerEventObject(pickItemInfos, m_reservoirView);
if (sm_overridingPickHandler && sm_overridingPickHandler->handlePickEvent(viewerEventObject))
{
return;
}
for ( size_t i = 0; i < sm_defaultPickEventHandlers.size(); i++ )
for (size_t i = 0; i < sm_defaultPickEventHandlers.size(); i++)
{
if ( sm_defaultPickEventHandlers[i]->handlePickEvent(viewerEventObject) )
if (sm_defaultPickEventHandlers[i]->handlePickEvent(viewerEventObject))
{
return;
}
@@ -555,43 +556,45 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
// Old pick handling. Todo: Encapsulate in pickEventHandlers
size_t gridIndex = cvf::UNDEFINED_SIZE_T;
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
size_t nncIndex = cvf::UNDEFINED_SIZE_T;
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE;
int gmFace = -1;
bool intersectionHit = false;
std::array<cvf::Vec3f, 3> intersectionTriangleHit;
size_t gridIndex = cvf::UNDEFINED_SIZE_T;
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
size_t nncIndex = cvf::UNDEFINED_SIZE_T;
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE;
int gmFace = -1;
bool intersectionHit = false;
std::array<cvf::Vec3f, 3> intersectionTriangleHit;
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO);
// Extract all the above information from the pick
{
const cvf::Part* firstHitPart = nullptr;
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
const cvf::Part* firstHitPart = nullptr;
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
const cvf::Part* firstNncHitPart = nullptr;
uint nncPartTriangleIndex = cvf::UNDEFINED_UINT;
const cvf::Part* firstNncHitPart = nullptr;
uint nncPartTriangleIndex = cvf::UNDEFINED_UINT;
if ( pickItemInfos.size() )
if (pickItemInfos.size())
{
size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T;;
size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T;;
size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T;
;
size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T;
;
findFirstItems(pickItemInfos, &indexToFirstNoneNncItem, &indexToNncItemNearFirstItem);
if ( indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T )
if (indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T)
{
localIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].localPickedPoint();
localIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].localPickedPoint();
globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint();
firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart();
firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx();
firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart();
firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx();
}
if ( indexToNncItemNearFirstItem != cvf::UNDEFINED_SIZE_T )
if (indexToNncItemNearFirstItem != cvf::UNDEFINED_SIZE_T)
{
firstNncHitPart = pickItemInfos[indexToNncItemNearFirstItem].pickedPart();
firstNncHitPart = pickItemInfos[indexToNncItemNearFirstItem].pickedPart();
nncPartTriangleIndex = pickItemInfos[indexToNncItemNearFirstItem].faceIdx();
}
}
@@ -611,17 +614,21 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
if (firstHitPart && firstHitPart->sourceInfo())
{
const RivObjectSourceInfo* rivObjectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>(firstHitPart->sourceInfo());
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionSourceInfo* crossSectionSourceInfo = dynamic_cast<const RivIntersectionSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo = dynamic_cast<const RivIntersectionBoxSourceInfo*>(firstHitPart->sourceInfo());
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(firstHitPart->sourceInfo());
const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast<const RivWellConnectionSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionSourceInfo* crossSectionSourceInfo =
dynamic_cast<const RivIntersectionSourceInfo*>(firstHitPart->sourceInfo());
const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo =
dynamic_cast<const RivIntersectionBoxSourceInfo*>(firstHitPart->sourceInfo());
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo =
dynamic_cast<const RivSimWellPipeSourceInfo*>(firstHitPart->sourceInfo());
const RivWellConnectionSourceInfo* wellConnectionSourceInfo =
dynamic_cast<const RivWellConnectionSourceInfo*>(firstHitPart->sourceInfo());
if (rivObjectSourceInfo)
{
RimFracture* fracture = dynamic_cast<RimFracture*>(rivObjectSourceInfo->object());
if ( fracture )
if (fracture)
{
{
bool blockSelectionOfFracture = false;
@@ -630,27 +637,29 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
std::vector<caf::PdmUiItem*> uiItems;
RiuMainWindow::instance()->projectTreeView()->selectedUiItems(uiItems);
if ( uiItems.size() == 1 )
if (uiItems.size() == 1)
{
auto selectedFractureTemplate = dynamic_cast<RimFractureTemplate*>(uiItems[0]);
if ( selectedFractureTemplate != nullptr && selectedFractureTemplate == fracture->fractureTemplate() )
if (selectedFractureTemplate != nullptr &&
selectedFractureTemplate == fracture->fractureTemplate())
{
blockSelectionOfFracture = true;
}
}
}
if ( !blockSelectionOfFracture )
if (!blockSelectionOfFracture)
{
RiuMainWindow::instance()->selectAsCurrentItem(fracture);
}
}
RimStimPlanFractureTemplate* stimPlanTempl = fracture ? dynamic_cast<RimStimPlanFractureTemplate*>(fracture->fractureTemplate()) : nullptr;
RimEllipseFractureTemplate* ellipseTempl = fracture ? dynamic_cast<RimEllipseFractureTemplate*>(fracture->fractureTemplate()) : nullptr;
if ( stimPlanTempl || ellipseTempl )
RimStimPlanFractureTemplate* stimPlanTempl =
fracture ? dynamic_cast<RimStimPlanFractureTemplate*>(fracture->fractureTemplate()) : nullptr;
RimEllipseFractureTemplate* ellipseTempl =
fracture ? dynamic_cast<RimEllipseFractureTemplate*>(fracture->fractureTemplate()) : nullptr;
if (stimPlanTempl || ellipseTempl)
{
// Set fracture resultInfo text
QString resultInfoText;
@@ -658,14 +667,17 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView->displayCoordTransform();
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(globalIntersectionPoint);
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
RivWellFracturePartMgr* partMgr = fracture->fracturePartManager();
if ( eclView ) resultInfoText = partMgr->resultInfoText(*eclView, domainCoord);
if (eclView) resultInfoText = partMgr->resultInfoText(*eclView, domainCoord);
// Set intersection point result text
QString intersectionPointText;
intersectionPointText.sprintf("Intersection point : Global [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z());
intersectionPointText.sprintf("Intersection point : Global [E: %.2f, N: %.2f, Depth: %.2f]",
domainCoord.x(),
domainCoord.y(),
-domainCoord.z());
resultInfoText.append(intersectionPointText);
// Display result info text
@@ -679,7 +691,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
RiuMainWindow::instance()->selectAsCurrentItem(textAnnot, true);
}
}
if (rivSourceInfo)
{
gridIndex = rivSourceInfo->gridIndex();
@@ -688,34 +700,32 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
CVF_ASSERT(rivSourceInfo->m_cellFaceFromTriangleMapper.notNull());
cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(firstPartTriangleIndex);
face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(firstPartTriangleIndex);
face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(firstPartTriangleIndex);
}
}
else if (femSourceInfo)
{
gridIndex = femSourceInfo->femPartIndex();
cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(firstPartTriangleIndex);
gmFace = femSourceInfo->triangleToElmMapper()->elementFace(firstPartTriangleIndex);
gmFace = femSourceInfo->triangleToElmMapper()->elementFace(firstPartTriangleIndex);
}
else if (crossSectionSourceInfo)
{
findCellAndGridIndex(crossSectionSourceInfo, firstPartTriangleIndex, &cellIndex, &gridIndex);
intersectionHit = true;
intersectionHit = true;
intersectionTriangleHit = crossSectionSourceInfo->triangle(firstPartTriangleIndex);
bool allowActiveViewChange = dynamic_cast<Rim2dIntersectionView*>(m_viewer->ownerViewWindow()) == nullptr;
RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection(), allowActiveViewChange);
}
else if (intersectionBoxSourceInfo)
{
findCellAndGridIndex(intersectionBoxSourceInfo, firstPartTriangleIndex, &cellIndex, &gridIndex);
intersectionHit = true;
intersectionHit = true;
intersectionTriangleHit = intersectionBoxSourceInfo->triangle(firstPartTriangleIndex);
RiuMainWindow::instance()->selectAsCurrentItem(intersectionBoxSourceInfo->intersectionBox());
}
else if (eclipseWellSourceInfo)
{
@@ -734,16 +744,17 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
{
RimEclipseCase* eclipseCase = nullptr;
eclipseView->firstAncestorOrThisOfTypeAsserted(eclipseCase);
if (eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities())
{
std::vector<RigCompletionData> completionsForOneCell;
{
auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities();
size_t timeStep = eclipseView->currentTimeStep();
auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities();
size_t timeStep = eclipseView->currentTimeStep();
const auto& multipleCompletions = connectionFactors->multipleCompletionsPerEclipseCell(wellConnectionSourceInfo->wellPath(), timeStep);
const auto& multipleCompletions = connectionFactors->multipleCompletionsPerEclipseCell(
wellConnectionSourceInfo->wellPath(), timeStep);
auto completionDataIt = multipleCompletions.find(globalCellIndex);
if (completionDataIt != multipleCompletions.end())
@@ -761,7 +772,8 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
}
QString resultInfoText;
resultInfoText += QString("<b>Well Connection Factor :</b> %1<br><br>").arg(aggregatedConnectionFactor);
resultInfoText +=
QString("<b>Well Connection Factor :</b> %1<br><br>").arg(aggregatedConnectionFactor);
{
RiuResultTextBuilder textBuilder(eclipseView, globalCellIndex, eclipseView->currentTimeStep());
@@ -775,7 +787,9 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
{
for (const auto& metaData : completionData.metadata())
{
resultInfoText += QString("<b>Name</b> %1 <b>Description</b> %2 <br>").arg(metaData.name).arg(metaData.comment);
resultInfoText += QString("<b>Name</b> %1 <b>Description</b> %2 <br>")
.arg(metaData.name)
.arg(metaData.comment);
}
}
@@ -788,11 +802,12 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
}
else if (dynamic_cast<const RivSimWellConnectionSourceInfo*>(firstHitPart->sourceInfo()))
{
const RivSimWellConnectionSourceInfo* simWellConnectionSourceInfo = dynamic_cast<const RivSimWellConnectionSourceInfo*>(firstHitPart->sourceInfo());
const RivSimWellConnectionSourceInfo* simWellConnectionSourceInfo =
dynamic_cast<const RivSimWellConnectionSourceInfo*>(firstHitPart->sourceInfo());
bool allowActiveViewChange = dynamic_cast<Rim2dIntersectionView*>(m_viewer->ownerViewWindow()) == nullptr;
size_t globalCellIndex = simWellConnectionSourceInfo->globalCellIndexFromTriangleIndex(firstPartTriangleIndex);
size_t globalCellIndex = simWellConnectionSourceInfo->globalCellIndexFromTriangleIndex(firstPartTriangleIndex);
double connectionFactor = simWellConnectionSourceInfo->connectionFactorFromTriangleIndex(firstPartTriangleIndex);
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
@@ -801,23 +816,25 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
RimEclipseCase* eclipseCase = nullptr;
eclipseView->firstAncestorOrThisOfTypeAsserted(eclipseCase);
if (eclipseCase->eclipseCaseData() &&
eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities())
if (eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities())
{
auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities();
size_t timeStep = eclipseView->currentTimeStep();
size_t timeStep = eclipseView->currentTimeStep();
const auto& completionData = connectionFactors->completionsForSimWell(simWellConnectionSourceInfo->simWellInView()->simWellData(), timeStep);
const auto& completionData = connectionFactors->completionsForSimWell(
simWellConnectionSourceInfo->simWellInView()->simWellData(), timeStep);
for (const auto& compData : completionData)
{
if (compData.completionDataGridCell().globalCellIndex() == globalCellIndex)
{
{
QString resultInfoText = QString("<b>Simulation Well Connection Factor :</b> %1<br><br>").arg(connectionFactor);
QString resultInfoText =
QString("<b>Simulation Well Connection Factor :</b> %1<br><br>").arg(connectionFactor);
{
RiuResultTextBuilder textBuilder(eclipseView, globalCellIndex, eclipseView->currentTimeStep());
RiuResultTextBuilder textBuilder(
eclipseView, globalCellIndex, eclipseView->currentTimeStep());
resultInfoText += textBuilder.geometrySelectionText("<br>");
}
@@ -829,9 +846,9 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
}
}
}
}
RiuMainWindow::instance()->selectAsCurrentItem(simWellConnectionSourceInfo->simWellInView(), allowActiveViewChange);
RiuMainWindow::instance()->selectAsCurrentItem(simWellConnectionSourceInfo->simWellInView(),
allowActiveViewChange);
}
}
}
@@ -840,7 +857,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
{
Riu3dSelectionManager::instance()->deleteAllItems();
}
else
else
{
bool appendToSelection = false;
if (keyboardModifiers & Qt::ControlModifier)
@@ -863,8 +880,8 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
RiuSelectionItem* selItem = nullptr;
{
Rim2dIntersectionView* intersectionView = dynamic_cast<Rim2dIntersectionView*>(m_reservoirView.p());
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
if (intersectionView)
{
@@ -874,13 +891,18 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
if (eclipseView)
{
selItem = new RiuEclipseSelectionItem(eclipseView, gridIndex, cellIndex, nncIndex, curveColor, face, localIntersectionPoint);
selItem = new RiuEclipseSelectionItem(
eclipseView, gridIndex, cellIndex, nncIndex, curveColor, face, localIntersectionPoint);
}
if (geomView)
{
if(intersectionHit) selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint, intersectionTriangleHit);
else selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint);
if (intersectionHit)
selItem = new RiuGeoMechSelectionItem(
geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint, intersectionTriangleHit);
else
selItem =
new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint);
}
if (intersectionView) selItem = new Riu2dIntersectionSelectionItem(intersectionView, selItem);
@@ -890,16 +912,15 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
{
Riu3dSelectionManager::instance()->appendItemToSelection(selItem);
}
else if(selItem)
else if (selItem)
{
Riu3dSelectionManager::instance()->setSelectedItem(selItem);
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::setPickEventHandler(RicPickEventHandler* pickEventHandler)
{
@@ -909,19 +930,19 @@ void RiuViewerCommands::setPickEventHandler(RicPickEventHandler* pickEventHandle
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::removePickEventHandlerIfActive(RicPickEventHandler* pickEventHandler)
{
if (sm_overridingPickHandler == pickEventHandler)
{
{
sm_overridingPickHandler = nullptr;
if (pickEventHandler) pickEventHandler->notifyUnregistered();
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RiuViewerCommands::lastPickPositionInDomainCoords() const
{
@@ -929,7 +950,7 @@ cvf::Vec3d RiuViewerCommands::lastPickPositionInDomainCoords() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::addDefaultPickEventHandler(RicDefaultPickEventHandler* pickEventHandler)
{
@@ -941,39 +962,42 @@ void RiuViewerCommands::addDefaultPickEventHandler(RicDefaultPickEventHandler* p
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::removeDefaultPickEventHandler(RicDefaultPickEventHandler* pickEventHandler)
{
for ( auto it = sm_defaultPickEventHandlers.begin(); it != sm_defaultPickEventHandlers.end(); ++it )
for (auto it = sm_defaultPickEventHandlers.begin(); it != sm_defaultPickEventHandlers.end(); ++it)
{
if ( *it == pickEventHandler )
if (*it == pickEventHandler)
{
sm_defaultPickEventHandlers.erase(it);
break;
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionSourceInfo* crossSectionSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex)
void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionSourceInfo* crossSectionSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex)
{
CVF_ASSERT(cellIndex && gridIndex);
RimCase* ownerCase = m_reservoirView->ownerCase();
RimCase* ownerCase = m_reservoirView->ownerCase();
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(ownerCase);
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(ownerCase);
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(ownerCase);
if (eclipseCase)
{
//RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
// RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
RimEclipseView* eclipseView;
crossSectionSourceInfo->crossSection()->firstAncestorOrThisOfType(eclipseView);
size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
const RigGridBase* hostGrid = eclipseView->mainGrid()->gridAndGridLocalIdxFromGlobalCellIdx(globalCellIndex, cellIndex);
*gridIndex = hostGrid->gridIndex();
*gridIndex = hostGrid->gridIndex();
}
else if (geomCase)
{
@@ -983,21 +1007,24 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionSourceInfo* cr
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex)
void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex)
{
CVF_ASSERT(cellIndex && gridIndex);
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
if (eclipseView)
{
size_t globalCellIndex = intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
const RigCell& cell = eclipseView->mainGrid()->globalCellArray()[globalCellIndex];
*cellIndex = cell.gridLocalCellIndex();
*gridIndex = cell.hostGrid()->gridIndex();
*cellIndex = cell.gridLocalCellIndex();
*gridIndex = cell.hostGrid()->gridIndex();
}
else if (geomView)
{
@@ -1006,35 +1033,34 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo*
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::findFirstItems(const std::vector<RiuPickItemInfo> & pickItemInfos,
size_t* indexToFirstNoneNncItem,
size_t* indexToNncItemNearFirsItem)
void RiuViewerCommands::findFirstItems(const std::vector<RiuPickItemInfo>& pickItemInfos,
size_t* indexToFirstNoneNncItem,
size_t* indexToNncItemNearFirsItem)
{
CVF_ASSERT(pickItemInfos.size() > 0);
CVF_ASSERT(indexToFirstNoneNncItem);
CVF_ASSERT(indexToNncItemNearFirsItem);
double pickDepthThresholdSquared = 0.05 *0.05;
double pickDepthThresholdSquared = 0.05 * 0.05;
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
if (eclipseView && eclipseView->mainGrid())
{
double characteristicCellSize = eclipseView->mainGrid()->characteristicIJCellSize();
pickDepthThresholdSquared = characteristicCellSize / 100.0;
pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared;
pickDepthThresholdSquared = characteristicCellSize / 100.0;
pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared;
}
}
size_t firstNonNncHitIndex = cvf::UNDEFINED_SIZE_T;
size_t nncNearFirstItemIndex = cvf::UNDEFINED_SIZE_T;
size_t firstNonNncHitIndex = cvf::UNDEFINED_SIZE_T;
size_t nncNearFirstItemIndex = cvf::UNDEFINED_SIZE_T;
cvf::Vec3d firstOrFirstNonNncIntersectionPoint = pickItemInfos[0].globalPickedPoint();
// Find first nnc part, and store as a separate thing if the nnc is first or close behind the first hit item.
// Find first nnc part, and store as a separate thing if the nnc is first or close behind the first hit item.
// Find index to first ordinary (non-nnc) part
for (size_t i = 0; i < pickItemInfos.size(); i++)
@@ -1044,14 +1070,15 @@ void RiuViewerCommands::findFirstItems(const std::vector<RiuPickItemInfo> & pick
bool canFindRelvantNNC = true;
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickItemInfos[i].sourceInfo());
if ( rivSourceInfo && rivSourceInfo->hasNNCIndices() )
if (rivSourceInfo && rivSourceInfo->hasNNCIndices())
{
if ( nncNearFirstItemIndex == cvf::UNDEFINED_SIZE_T && canFindRelvantNNC)
if (nncNearFirstItemIndex == cvf::UNDEFINED_SIZE_T && canFindRelvantNNC)
{
cvf::Vec3d distFirstNonNNCToCandidate = firstOrFirstNonNncIntersectionPoint - pickItemInfos[i].globalPickedPoint();
cvf::Vec3d distFirstNonNNCToCandidate =
firstOrFirstNonNncIntersectionPoint - pickItemInfos[i].globalPickedPoint();
// This candidate is an NNC hit
if ( distFirstNonNNCToCandidate.lengthSquared() < pickDepthThresholdSquared )
if (distFirstNonNNCToCandidate.lengthSquared() < pickDepthThresholdSquared)
{
nncNearFirstItemIndex = i;
}
@@ -1063,35 +1090,36 @@ void RiuViewerCommands::findFirstItems(const std::vector<RiuPickItemInfo> & pick
}
else
{
if ( firstNonNncHitIndex == cvf::UNDEFINED_SIZE_T )
if (firstNonNncHitIndex == cvf::UNDEFINED_SIZE_T)
{
firstNonNncHitIndex = i;
}
}
if (firstNonNncHitIndex != cvf::UNDEFINED_SIZE_T && (nncNearFirstItemIndex != cvf::UNDEFINED_SIZE_T || !canFindRelvantNNC) )
if (firstNonNncHitIndex != cvf::UNDEFINED_SIZE_T &&
(nncNearFirstItemIndex != cvf::UNDEFINED_SIZE_T || !canFindRelvantNNC))
{
break; // Found what can be found
}
}
(*indexToFirstNoneNncItem) = firstNonNncHitIndex;
(*indexToFirstNoneNncItem) = firstNonNncHitIndex;
(*indexToNncItemNearFirsItem) = nncNearFirstItemIndex;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k)
void RiuViewerCommands::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k)
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
if (eclipseView && eclipseView->eclipseCase())
{
eclipseView->eclipseCase()->eclipseCaseData()->grid(gridIdx)->ijkFromCellIndex(cellIndex, i, j, k);
}
if (geomView && geomView->geoMechCase())
{
geomView->femParts()->part(gridIdx)->getOrCreateStructGrid()->ijkFromCellIndex(cellIndex, i, j, k);
@@ -1099,7 +1127,7 @@ void RiuViewerCommands::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuViewerCommands::handleOverlayItemPicking(int winPosX, int winPosY)
{
@@ -1135,7 +1163,7 @@ bool RiuViewerCommands::handleOverlayItemPicking(int winPosX, int winPosY)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::handleTextPicking(int winPosX, int winPosY, cvf::HitItemCollection* hitItems)
{
@@ -1154,22 +1182,18 @@ void RiuViewerCommands::handleTextPicking(int winPosX, int winPosY, cvf::HitItem
for (size_t pIdx = 0; pIdx < partCollection.size(); ++pIdx)
{
if (partCollection[pIdx]->priority() == RivPartPriority::PartType::Text) // Just trying to avoid dyncasting all drawables
DrawableText* textDrawable = dynamic_cast<DrawableText*>(partCollection[pIdx]->drawable());
if (textDrawable)
{
DrawableText* textDrawable = dynamic_cast<DrawableText*> (partCollection[pIdx]->drawable());
if (textDrawable)
cvf::Vec3d ppoint;
if (textDrawable->rayIntersect(*ray, *(m_viewer->mainCamera()), &ppoint))
{
cvf::Vec3d ppoint;
if (textDrawable->rayIntersect(*ray, *( m_viewer->mainCamera()), &ppoint))
{
cvf::ref<HitItem> hitItem = new HitItem(0, ppoint);
hitItem->setPart(partCollection[pIdx].p());
hitItems->add(hitItem.p());
}
cvf::ref<HitItem> hitItem = new HitItem(0, ppoint);
hitItem->setPart(partCollection[pIdx].p());
hitItems->add(hitItem.p());
}
}
}
hitItems->sort();
}