#3530 Support picking on 2d Maps.

This commit is contained in:
Gaute Lindkvist
2018-11-14 12:38:20 +01:00
parent cbc0e55303
commit 387741d0c1
7 changed files with 197 additions and 36 deletions

View File

@@ -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

View 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;
}

View 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;
};