#1174 Added context menu to WellAllocationPlot and added feature

This commit is contained in:
Magne Sjaastad 2017-02-13 13:28:56 +01:00
parent 9aa98a3895
commit 45f3240932
7 changed files with 175 additions and 4 deletions

View File

@ -6,12 +6,14 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature
${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.h
${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicShowContributingWellsFeature.h"
#include "RiaApplication.h"
#include "RimDefines.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimEclipseWell.h"
#include "RimEclipseWellCollection.h"
#include "RimWellAllocationPlot.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicShowContributingWellsFeature, "RicShowContributingWellsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicShowContributingWellsFeature::isCommandEnabled()
{
RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot();
if (!wellAllocationPlot) return false;
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if (!activeView) return false;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowContributingWellsFeature::onActionTriggered(bool isChecked)
{
RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot();
if (!wellAllocationPlot) return;
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if (activeView)
{
activeView->cellResult->setResultType(RimDefines::FLOW_DIAGNOSTICS);
activeView->cellResult->setResultVariable("MaxFractionTracer");
activeView->cellResult->updateConnectedEditors();
const std::vector<QString> contributingTracers = wellAllocationPlot->contributingTracerNames();
for (RimEclipseWell* well : activeView->wellCollection()->wells())
{
if (std::find(contributingTracers.begin(), contributingTracers.end(), well->name()) != contributingTracers.end()
|| wellAllocationPlot->wellName() == well->name())
{
well->showWell = true;
}
else
{
well->showWell = false;
}
}
activeView->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowContributingWellsFeature::setupActionLook(QAction* actionToSetup)
{
//actionToSetup->setIcon(QIcon(":/new_icon16x16.png"));
actionToSetup->setText("Show Contributing Wells");
}

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicShowContributingWellsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -221,6 +221,12 @@ void RimWellAllocationPlot::updateFromWell()
}
}
m_contributingTracerNames.clear();
if (wfCalculator)
{
m_contributingTracerNames = wfCalculator->tracerNames();
}
// Create tracks and curves from the calculated data
size_t branchCount = pipeBranchesCLCoords.size();
@ -540,6 +546,14 @@ QString RimWellAllocationPlot::wellName() const
return m_wellName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<QString> RimWellAllocationPlot::contributingTracerNames() const
{
return m_contributingTracerNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -68,6 +68,7 @@ public:
QString wellName() const;
const std::vector<QString> contributingTracerNames() const;
void removeFromMdiAreaAndDeleteViewWidget();
@ -112,4 +113,5 @@ private:
caf::PdmChildField<RimTotalWellAllocationPlot*> m_totalWellAllocationPlot;
caf::PdmChildField<RimWellAllocationPlotLegend*> m_wellAllocationPlotLegend;
std::vector<QString> m_contributingTracerNames;
};

View File

@ -20,15 +20,20 @@
#include "RiaApplication.h"
#include "RimContextCommandBuilder.h"
#include "RimTotalWellAllocationPlot.h"
#include "RimWellAllocationPlot.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimTotalWellAllocationPlot.h"
#include "RiuNightchartsWidget.h"
#include "cvfColor3.h"
#include <QBoxLayout>
#include <QContextMenuEvent>
#include <QLabel>
#include "RiuNightchartsWidget.h"
#include "cvfColor3.h"
#include <QMenu>
@ -157,6 +162,24 @@ QSize RiuWellAllocationPlot::minimumSizeHint() const
return QSize(0, 100);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::contextMenuEvent(QContextMenuEvent* event)
{
QMenu menu;
QStringList commandIds;
commandIds << "RicShowContributingWellsFeature";
RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu);
if (menu.actions().size() > 0)
{
menu.exec(event->globalPos());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -57,6 +57,8 @@ protected:
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
virtual void contextMenuEvent(QContextMenuEvent *) override;
private:
void setDefaults();