mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3805 Measurement. Double click in view to reset measurement
This commit is contained in:
@@ -20,9 +20,13 @@
|
|||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "Rim3dView.h"
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimMeasurement.h"
|
#include "RimMeasurement.h"
|
||||||
|
|
||||||
|
#include "RiuMeasurementViewEventFilter.h"
|
||||||
|
#include "RiuViewer.h"
|
||||||
|
|
||||||
#include "cafPdmUiPropertyViewDialog.h"
|
#include "cafPdmUiPropertyViewDialog.h"
|
||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
@@ -56,6 +60,16 @@ void RicToggleMeasurementModeFeature::onActionTriggered(bool isChecked)
|
|||||||
auto meas = measurement();
|
auto meas = measurement();
|
||||||
meas->setMeasurementMode(!meas->isInMeasurementMode());
|
meas->setMeasurementMode(!meas->isInMeasurementMode());
|
||||||
refreshActionLook();
|
refreshActionLook();
|
||||||
|
|
||||||
|
auto* view = activeView();
|
||||||
|
if (meas->isInMeasurementMode())
|
||||||
|
{
|
||||||
|
view->viewer()->installEventFilter(eventFilter(this));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
view->viewer()->removeEventFilter(eventFilter(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -88,3 +102,12 @@ Rim3dView* RicToggleMeasurementModeFeature::activeView() const
|
|||||||
auto view = RiaApplication::instance()->activeReservoirView();
|
auto view = RiaApplication::instance()->activeReservoirView();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RiuMeasurementViewEventFilter* RicToggleMeasurementModeFeature::eventFilter(QObject* parent)
|
||||||
|
{
|
||||||
|
static auto* filter = new RiuMeasurementViewEventFilter(parent);
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
|
|
||||||
class RimMeasurement;
|
class RimMeasurement;
|
||||||
class Rim3dView;
|
class Rim3dView;
|
||||||
|
class QObject;
|
||||||
|
class RiuMeasurementViewEventFilter;
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@@ -42,4 +45,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
RimMeasurement* measurement() const;
|
RimMeasurement* measurement() const;
|
||||||
Rim3dView* activeView() const;
|
Rim3dView* activeView() const;
|
||||||
|
|
||||||
|
static RiuMeasurementViewEventFilter* eventFilter(QObject* parent);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ void RivMeasurementPartMgr::clearGeometryCache()
|
|||||||
{
|
{
|
||||||
m_linePart = nullptr;
|
m_linePart = nullptr;
|
||||||
m_pointPart = nullptr;
|
m_pointPart = nullptr;
|
||||||
|
m_labelPart = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -59,9 +59,7 @@ void RimMeasurement::setMeasurementMode(bool measurementMode)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
RiuViewerCommands::removePickEventHandlerIfActive(RicMeasurementPickEventHandler::instance());
|
RiuViewerCommands::removePickEventHandlerIfActive(RicMeasurementPickEventHandler::instance());
|
||||||
|
removeAllPoints();
|
||||||
m_pointsInDomain.clear();
|
|
||||||
updateView();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +88,15 @@ std::vector<cvf::Vec3d> RimMeasurement::pointsInDomain() const
|
|||||||
return m_pointsInDomain;
|
return m_pointsInDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimMeasurement::removeAllPoints()
|
||||||
|
{
|
||||||
|
m_pointsInDomain.clear();
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public:
|
|||||||
void addPointInDomain(const Vec3d& pointInDomain);
|
void addPointInDomain(const Vec3d& pointInDomain);
|
||||||
std::vector<Vec3d> pointsInDomain() const;
|
std::vector<Vec3d> pointsInDomain() const;
|
||||||
|
|
||||||
|
void removeAllPoints();
|
||||||
|
|
||||||
QString label() const;
|
QString label() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItemGroup.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItemGroup.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellPathComponentPlotItem.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuWellPathComponentPlotItem.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiuMeasurementViewEventFilter.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@@ -152,6 +153,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItemGroup.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItemGroup.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellPathComponentPlotItem.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiuWellPathComponentPlotItem.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiuMeasurementViewEventFilter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
@@ -196,6 +198,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuMessagePanel.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h
|
${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiuMeasurementViewEventFilter.h
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND QT_UI_FILES
|
list(APPEND QT_UI_FILES
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RiuMeasurementViewEventFilter.h"
|
||||||
|
|
||||||
|
#include "ToggleCommands/RicToggleItemsFeatureImpl.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "RimCaseCollection.h"
|
||||||
|
#include "RimEclipseCase.h"
|
||||||
|
#include "RimGeoMechCase.h"
|
||||||
|
#include "RimGeoMechView.h"
|
||||||
|
#include "RimIdenticalGridCaseGroup.h"
|
||||||
|
#include "RimMeasurement.h"
|
||||||
|
#include "RimProject.h"
|
||||||
|
|
||||||
|
#include "RiuMainWindow.h"
|
||||||
|
#include "RiuPlotMainWindow.h"
|
||||||
|
|
||||||
|
#include "cafCmdFeature.h"
|
||||||
|
#include "cafCmdFeatureManager.h"
|
||||||
|
#include "cafPdmUiTreeView.h"
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RiuMeasurementViewEventFilter::RiuMeasurementViewEventFilter(QObject* parent)
|
||||||
|
: QObject(parent), m_inResetMeasurementMode(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RiuMeasurementViewEventFilter::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::MouseButtonDblClick)
|
||||||
|
{
|
||||||
|
auto* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||||
|
if (mouseEvent->button() == Qt::MouseButton::LeftButton)
|
||||||
|
{
|
||||||
|
auto* measurement = RiaApplication::instance()->project()->measurement();
|
||||||
|
measurement->removeAllPoints();
|
||||||
|
m_inResetMeasurementMode = true;
|
||||||
|
|
||||||
|
//Swallow event
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_inResetMeasurementMode && event->type() == QEvent::MouseButtonRelease)
|
||||||
|
{
|
||||||
|
// This code is necessary to prevent setting a new measurement point when double clicking
|
||||||
|
auto* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||||
|
if (mouseEvent->button() == Qt::MouseButton::LeftButton)
|
||||||
|
{
|
||||||
|
m_inResetMeasurementMode = false;
|
||||||
|
|
||||||
|
// Swallow event
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// standard event processing
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
class RiuMeasurementViewEventFilter : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit RiuMeasurementViewEventFilter(QObject* parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_inResetMeasurementMode;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user