#1404 Added plot object picker, and use from Well Allocation plot

This commit is contained in:
Magne Sjaastad 2017-04-07 11:24:50 +02:00
parent 6f5d451c66
commit 947845e7fd
6 changed files with 125 additions and 0 deletions

View File

@ -513,6 +513,14 @@ RimTotalWellAllocationPlot* RimWellAllocationPlot::totalWellFlowPlot()
return m_totalWellAllocationPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RimWellAllocationPlot::plotLegend()
{
return m_wellAllocationPlotLegend;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -68,6 +68,7 @@ public:
RimWellLogPlot* accumulatedWellFlowPlot();
RimTotalWellAllocationPlot* totalWellFlowPlot();
caf::PdmObject* plotLegend();
RimFlowDiagSolution* flowDiagSolution();
int timeStep();

View File

@ -46,6 +46,7 @@ ${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h
${CEE_CURRENT_LIST_DIR}RiuFlowCharacteristicsPlot.h
${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h
${CEE_CURRENT_LIST_DIR}RiuMessagePanel.h
${CEE_CURRENT_LIST_DIR}RiuPlotObjectPicker.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -89,6 +90,7 @@ ${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.cpp
${CEE_CURRENT_LIST_DIR}RiuFlowCharacteristicsPlot.cpp
${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.cpp
${CEE_CURRENT_LIST_DIR}RiuMessagePanel.cpp
${CEE_CURRENT_LIST_DIR}RiuPlotObjectPicker.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiuPlotObjectPicker.h"
#include "RiaApplication.h"
#include "RiuMainPlotWindow.h"
#include <QMouseEvent>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotObjectPicker::RiuPlotObjectPicker(QWidget* widget, caf::PdmObject* associatedObject) :
QObject(widget),
m_associatedObject(associatedObject)
{
widget->installEventFilter(this);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuPlotObjectPicker::eventFilter(QObject* watchedObject, QEvent* event)
{
if (event->type() == QEvent::MouseButtonRelease)
{
QMouseEvent* me = static_cast<QMouseEvent*>(event);
if (me->button() == Qt::LeftButton)
{
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
if (mainPlotWindow && m_associatedObject.notNull())
{
mainPlotWindow->selectAsCurrentItem(m_associatedObject);
return true;
}
}
}
// standard event processing
return QObject::eventFilter(watchedObject, event);
}

View File

@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmPointer.h"
#include <QObject>
namespace caf {
class PdmObject;
}
class QEvent;
class QWidget;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RiuPlotObjectPicker : public QObject
{
public:
explicit RiuPlotObjectPicker(QWidget* widget, caf::PdmObject* associatedObject);
protected:
bool eventFilter(QObject* watched, QEvent* event) override;
private:
caf::PdmPointer<caf::PdmObject> m_associatedObject;
};

View File

@ -27,6 +27,7 @@
#include "RimWellLogTrack.h"
#include "RiuNightchartsWidget.h"
#include "RiuPlotObjectPicker.h"
#include "cvfColor3.h"
@ -52,6 +53,7 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti
this->layout()->setSpacing(2);
m_titleLabel = new QLabel(this);
new RiuPlotObjectPicker(m_titleLabel, m_plotDefinition->accumulatedWellFlowPlot());
QFont font = m_titleLabel->font();
font.setPointSize(14);
@ -73,14 +75,19 @@ RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefiniti
plotWidgetsLayout->addLayout(rightColumnLayout);
m_legendWidget = new RiuNightchartsWidget(this);
new RiuPlotObjectPicker(m_legendWidget, m_plotDefinition->plotLegend());
rightColumnLayout->addWidget(m_legendWidget);
m_legendWidget->showPie(false);
QWidget* totalFlowAllocationWidget = m_plotDefinition->totalWellFlowPlot()->createViewWidget(this);
new RiuPlotObjectPicker(totalFlowAllocationWidget, m_plotDefinition->totalWellFlowPlot());
rightColumnLayout->addWidget(totalFlowAllocationWidget);
rightColumnLayout->addStretch();
QWidget* wellFlowWidget = m_plotDefinition->accumulatedWellFlowPlot()->createViewWidget(this);
plotWidgetsLayout->addWidget(wellFlowWidget);
}