mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3924 Measurements : Remove double mouse click event handling
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -21,11 +21,8 @@
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimMeasurement.h"
|
||||
|
||||
#include "RiuMeasurementViewEventFilter.h"
|
||||
#include "RiuViewer.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafSelectionManager.h"
|
||||
@@ -33,7 +30,6 @@
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicToggleMeasurementModeFeature, "RicToggleMeasurementModeFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -45,7 +41,7 @@ void RicToggleMeasurementModeFeature::refreshActionLook()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicToggleMeasurementModeFeature::isCommandEnabled()
|
||||
{
|
||||
@@ -53,34 +49,24 @@ bool RicToggleMeasurementModeFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicToggleMeasurementModeFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
auto meas = measurement();
|
||||
meas->setMeasurementMode(!meas->isInMeasurementMode());
|
||||
refreshActionLook();
|
||||
|
||||
auto* view = activeView();
|
||||
if (meas->isInMeasurementMode())
|
||||
{
|
||||
view->viewer()->installEventFilter(eventFilter(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
view->viewer()->removeEventFilter(eventFilter(this));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicToggleMeasurementModeFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Measurement Mode");
|
||||
|
||||
auto* meas = measurement();
|
||||
if(meas && meas->isInMeasurementMode())
|
||||
if (meas && meas->isInMeasurementMode())
|
||||
actionToSetup->setIcon(QIcon(":/NoRuler16x16.png"));
|
||||
else
|
||||
actionToSetup->setIcon(QIcon(":/Ruler16x16.png"));
|
||||
@@ -102,12 +88,3 @@ Rim3dView* RicToggleMeasurementModeFeature::activeView() const
|
||||
auto view = RiaApplication::instance()->activeReservoirView();
|
||||
return view;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuMeasurementViewEventFilter* RicToggleMeasurementModeFeature::eventFilter(QObject* parent)
|
||||
{
|
||||
static auto* filter = new RiuMeasurementViewEventFilter(parent);
|
||||
return filter;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,4 @@ protected:
|
||||
private:
|
||||
RimMeasurement* measurement() const;
|
||||
Rim3dView* activeView() const;
|
||||
|
||||
static RiuMeasurementViewEventFilter* eventFilter(QObject* parent);
|
||||
};
|
||||
|
||||
@@ -153,7 +153,6 @@ ${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItemGroup.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuWellPathComponentPlotItem.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuMeasurementViewEventFilter.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
@@ -198,7 +197,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuMessagePanel.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuMeasurementViewEventFilter.h
|
||||
)
|
||||
|
||||
list(APPEND QT_UI_FILES
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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