mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3530 Support picking on 2d Maps.
This commit is contained in:
parent
cbc0e55303
commit
387741d0c1
@ -47,6 +47,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportFeatureImpl.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.h
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPickEventHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.h
|
||||
|
||||
# General delete of any object in a child array field
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.h
|
||||
@ -122,6 +123,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportFeatureImpl.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.cpp
|
||||
|
||||
# General delete of any object in a child array field
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.cpp
|
||||
|
82
ApplicationCode/Commands/RicContourMapPickEventHandler.cpp
Normal file
82
ApplicationCode/Commands/RicContourMapPickEventHandler.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicContourMapPickEventHandler.h"
|
||||
#include "RimContourMapProjection.h"
|
||||
#include "RimContourMapView.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "Rim3dView.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RivObjectSourceInfo.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
|
||||
#include "cvfPart.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicContourMapPickEventHandler* RicContourMapPickEventHandler::instance()
|
||||
{
|
||||
static RicContourMapPickEventHandler* singleton = new RicContourMapPickEventHandler;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicContourMapPickEventHandler::handlePickEvent(const Ric3DPickEvent& eventObject)
|
||||
{
|
||||
if (eventObject.m_pickItemInfos.empty()) return false;
|
||||
|
||||
const RiuPickItemInfo& firstPickedItem = eventObject.m_pickItemInfos.front();
|
||||
const cvf::Part* firstPickedPart = firstPickedItem.pickedPart();
|
||||
|
||||
const RivObjectSourceInfo* sourceInfo = dynamic_cast<const RivObjectSourceInfo*>(firstPickedPart->sourceInfo());
|
||||
if (sourceInfo)
|
||||
{
|
||||
RimContourMapProjection* contourMap = dynamic_cast<RimContourMapProjection*>(sourceInfo->object());
|
||||
if (contourMap)
|
||||
{
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(contourMap);
|
||||
|
||||
RimContourMapView* view = nullptr;
|
||||
contourMap->firstAncestorOrThisOfTypeAsserted(view);
|
||||
|
||||
cvf::Vec2ui pickedPoint;
|
||||
double valueAtPoint = 0.0;
|
||||
if (contourMap->checkForMapIntersection(firstPickedItem.globalPickedPoint(), &pickedPoint, &valueAtPoint))
|
||||
{
|
||||
QString curveText;
|
||||
curveText += QString("%1\n").arg(view->createAutoName());
|
||||
curveText += QString("Sample, I, J: [%1, %2]\n").arg(pickedPoint.x()).arg(pickedPoint.y());
|
||||
curveText += QString("Result Type: %1\n").arg(contourMap->resultDescriptionText());
|
||||
curveText += QString("Aggregated Value: %1\n").arg(valueAtPoint);
|
||||
|
||||
RiuMainWindow::instance()->setResultInfo(curveText);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
34
ApplicationCode/Commands/RicContourMapPickEventHandler.h
Normal file
34
ApplicationCode/Commands/RicContourMapPickEventHandler.h
Normal file
@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicPickEventHandler.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicContourMapPickEventHandler : public RicDefaultPickEventHandler
|
||||
{
|
||||
public:
|
||||
static RicContourMapPickEventHandler* instance();
|
||||
|
||||
protected:
|
||||
bool handlePickEvent(const Ric3DPickEvent& eventObject) override;
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList
|
||||
cvf::ScalarMapper* mapper = m_contourMapProjection->legendConfig()->scalarMapper();
|
||||
RivScalarMapperUtils::applyTextureResultsToPart(part.p(), textureCoords.p(), mapper, 1.0f, caf::FC_NONE, true, m_parentContourMap->backgroundColor());
|
||||
|
||||
part->setSourceInfo(new RivMeshLinesSourceInfo(m_contourMapProjection.p()));
|
||||
part->setSourceInfo(new RivObjectSourceInfo(m_contourMapProjection.p()));
|
||||
|
||||
model->addPart(part.p());
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "RivReservoirViewPartMgr.h"
|
||||
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimContourMapView.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
@ -130,10 +131,8 @@ void RimContourMapProjection::generateGridMapping()
|
||||
m_weightingResult->loadResult();
|
||||
int timeStep = 0;
|
||||
if (m_weightingResult->hasDynamicResult())
|
||||
{
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
timeStep = view->currentTimeStep();
|
||||
{
|
||||
timeStep = view()->currentTimeStep();
|
||||
|
||||
}
|
||||
weightingResultValues = &(m_weightingResult->currentGridCellResults()->cellScalarResults(gridScalarResultIdx)[timeStep]);
|
||||
@ -239,14 +238,11 @@ void RimContourMapProjection::generateResults()
|
||||
int nVertices = vertexCount();
|
||||
m_aggregatedResults = std::vector<double>(nVertices, std::numeric_limits<double>::infinity());
|
||||
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
int timeStep = view->currentTimeStep();
|
||||
int timeStep = view()->currentTimeStep();
|
||||
RimEclipseCellColors* cellColors = view()->cellResult();
|
||||
|
||||
RimEclipseResultCase* eclipseCase = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(eclipseCase);
|
||||
RimEclipseCellColors* cellColors = view->cellResult();
|
||||
|
||||
{
|
||||
if (!cellColors->isTernarySaturationSelected())
|
||||
{
|
||||
@ -437,7 +433,12 @@ bool RimContourMapProjection::isColumnResult() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimContourMapProjection::value(uint i, uint j) const
|
||||
{
|
||||
return m_aggregatedResults.at(gridIndex(i, j));
|
||||
size_t index = gridIndex(i, j);
|
||||
if (index < vertexCount())
|
||||
{
|
||||
return m_aggregatedResults.at(gridIndex(i, j));
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -568,10 +569,8 @@ double RimContourMapProjection::calculateValue(uint i, uint j) const
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::hasResultAt(uint i, uint j) const
|
||||
{
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
RimEclipseCellColors* cellColors = view->cellResult();
|
||||
{
|
||||
RimEclipseCellColors* cellColors = view()->cellResult();
|
||||
|
||||
if (cellColors->isTernarySaturationSelected())
|
||||
{
|
||||
@ -625,9 +624,7 @@ uint RimContourMapProjection::validVertexCount() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRegularLegendConfig* RimContourMapProjection::legendConfig() const
|
||||
{
|
||||
RimEclipseView* view = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(view);
|
||||
return view->cellResult()->legendConfig();
|
||||
return view()->cellResult()->legendConfig();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -635,10 +632,7 @@ RimRegularLegendConfig* RimContourMapProjection::legendConfig() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapProjection::calculateTotalCellVisibility()
|
||||
{
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
|
||||
m_cellGridIdxVisibility = view->currentTotalCellVisibility();
|
||||
m_cellGridIdxVisibility = view()->currentTotalCellVisibility();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -655,6 +649,15 @@ cvf::Vec2d RimContourMapProjection::globalPos2d(uint i, uint j) const
|
||||
(j * gridExtent.y()) / (gridSize2d.y() - 1));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::ijFromLocalPos(const cvf::Vec2d& localPos2d) const
|
||||
{
|
||||
cvf::Vec2ui ijCoords(localPos2d.x() / sampleSpacing(), localPos2d.y() / sampleSpacing());
|
||||
return ijCoords;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -831,9 +834,7 @@ double RimContourMapProjection::findColumnResult(ResultAggregation resultAggrega
|
||||
double ntg = ntgResults.at(cellResultIdx);
|
||||
double dz = dzResults.at(cellResultIdx);
|
||||
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
int timeStep = view->currentTimeStep();
|
||||
int timeStep = view()->currentTimeStep();
|
||||
|
||||
double resultValue = 0.0;
|
||||
if (resultAggregation == RESULTS_OIL_COLUMN || resultAggregation == RESULTS_HC_COLUMN)
|
||||
@ -878,6 +879,16 @@ RimEclipseResultCase* RimContourMapProjection::eclipseCase()
|
||||
return eclipseCase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimContourMapView* RimContourMapProjection::view() const
|
||||
{
|
||||
RimContourMapView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -910,14 +921,12 @@ cvf::Vec2ui RimContourMapProjection::ijFromGridIndex(size_t index) const
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapProjection::updateLegend()
|
||||
{
|
||||
RimEclipseView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
RimEclipseCellColors* cellColors = view->cellResult();
|
||||
{
|
||||
RimEclipseCellColors* cellColors = view()->cellResult();
|
||||
|
||||
if (getLegendRangeFrom3dGrid())
|
||||
{
|
||||
cellColors->updateLegendData(view->currentTimeStep(), legendConfig());
|
||||
cellColors->updateLegendData(view()->currentTimeStep(), legendConfig());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -962,6 +971,20 @@ QString RimContourMapProjection::resultAggregationText() const
|
||||
return m_resultAggregation().uiText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimContourMapProjection::resultDescriptionText() const
|
||||
{
|
||||
QString resultText = resultAggregationText();
|
||||
if (!isColumnResult())
|
||||
{
|
||||
resultText += QString(", %1").arg(view()->cellResult()->resultVariable());
|
||||
}
|
||||
|
||||
return resultText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -976,6 +999,19 @@ void RimContourMapProjection::updatedWeightingResult()
|
||||
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::checkForMapIntersection(const cvf::Vec3d& localPoint3d, cvf::Vec2ui* contourMapIJ, double* valueAtPoint) const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(contourMapIJ);
|
||||
CVF_TIGHT_ASSERT(valueAtPoint);
|
||||
cvf::Vec2d localPos2d(localPoint3d.x(), localPoint3d.y());
|
||||
*contourMapIJ = ijFromLocalPos(localPos2d);
|
||||
*valueAtPoint = value(contourMapIJ->x(), contourMapIJ->y());
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1036,12 +1072,10 @@ void RimContourMapProjection::fieldChangedByUi(const caf::PdmFieldHandle* change
|
||||
|
||||
m_weightingResult->loadResult();
|
||||
|
||||
RimEclipseView* view = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(view);
|
||||
view->updateConnectedEditors();
|
||||
view()->updateConnectedEditors();
|
||||
|
||||
RimProject* proj;
|
||||
view->firstAncestorOrThisOfTypeAsserted(proj);
|
||||
firstAncestorOrThisOfTypeAsserted(proj);
|
||||
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
class RigMainGrid;
|
||||
class RigResultAccessor;
|
||||
class RimContourMapView;
|
||||
class RimEclipseResultCase;
|
||||
class RimEclipseResultDefinition;
|
||||
|
||||
@ -98,9 +99,11 @@ public:
|
||||
|
||||
ResultAggregation resultAggregation() const;
|
||||
QString resultAggregationText() const;
|
||||
|
||||
QString resultDescriptionText() const;
|
||||
void updatedWeightingResult();
|
||||
|
||||
bool checkForMapIntersection(const cvf::Vec3d& localPoint3d, cvf::Vec2ui* contourMapIJ, double* valueAtPoint) const;
|
||||
|
||||
protected:
|
||||
double calculateValue(uint i, uint j) const;
|
||||
|
||||
@ -108,6 +111,8 @@ protected:
|
||||
void generateGridMapping();
|
||||
void calculateTotalCellVisibility();
|
||||
cvf::Vec2d globalPos2d(uint i, uint j) const;
|
||||
cvf::Vec2ui ijFromLocalPos(const cvf::Vec2d& localPos2d) const;
|
||||
|
||||
const std::vector<std::pair<size_t, double>>& cellsAtPos2d(uint i, uint j) const;
|
||||
std::vector<double> xPositions() const;
|
||||
std::vector<double> yPositions() const;
|
||||
@ -117,6 +122,7 @@ protected:
|
||||
double findColumnResult(ResultAggregation resultAggregation, size_t cellGlobalIdx) const;
|
||||
const RimEclipseResultCase* eclipseCase() const;
|
||||
RimEclipseResultCase* eclipseCase();
|
||||
RimContourMapView* view() const;
|
||||
RigMainGrid* mainGrid() const;
|
||||
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
@ -137,5 +143,5 @@ protected:
|
||||
std::vector<std::vector<std::pair<size_t, double>>> m_projected3dGridIndices;
|
||||
|
||||
cvf::ref<RigResultAccessor> m_resultAccessor;
|
||||
|
||||
|
||||
};
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "RicEclipsePropertyFilterNewExec.h"
|
||||
#include "RicGeoMechPropertyFilterNewExec.h"
|
||||
#include "RicPickEventHandler.h"
|
||||
#include "RicContourMapPickEventHandler.h"
|
||||
#include "WellLogCommands/Ric3dWellLogCurvePickEventHandler.h"
|
||||
#include "WellPathCommands/RicIntersectionPickEventHandler.h"
|
||||
#include "WellPathCommands/RicWellPathPickEventHandler.h"
|
||||
@ -127,6 +128,7 @@ RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer)
|
||||
addDefaultPickEventHandler(RicIntersectionPickEventHandler::instance());
|
||||
addDefaultPickEventHandler(Ric3dWellLogCurvePickEventHandler::instance());
|
||||
addDefaultPickEventHandler(RicWellPathPickEventHandler::instance());
|
||||
addDefaultPickEventHandler(RicContourMapPickEventHandler::instance());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user