2017-01-13 06:32:02 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-01-13 06:32:02 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-01-13 06:32:02 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-01-13 06:32:02 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicShowWellAllocationPlotFeature.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "Rim3dView.h"
|
2017-03-01 06:23:16 -06:00
|
|
|
#include "RimEclipseResultCase.h"
|
2017-01-13 06:32:02 -06:00
|
|
|
#include "RimFlowPlotCollection.h"
|
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimProject.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimSimWellInView.h"
|
2017-01-13 06:32:02 -06:00
|
|
|
#include "RimWellAllocationPlot.h"
|
|
|
|
|
2018-02-27 08:21:14 -06:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
2017-01-13 06:32:02 -06:00
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
2017-11-30 05:05:43 -06:00
|
|
|
#include "RimEclipseView.h"
|
|
|
|
#include "RimSimWellInViewCollection.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include <QAction>
|
2017-01-13 06:32:02 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicShowWellAllocationPlotFeature, "RicShowWellAllocationPlotFeature" );
|
2017-01-13 06:32:02 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-01-13 06:32:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicShowWellAllocationPlotFeature::isCommandEnabled()
|
|
|
|
{
|
2017-11-30 05:05:43 -06:00
|
|
|
std::vector<RimSimWellInView*> simWellCollection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &simWellCollection );
|
2017-03-01 06:23:16 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( simWellCollection.size() > 0 )
|
2017-11-30 05:05:43 -06:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<RimWellPath*> wellPathCollection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &wellPathCollection );
|
|
|
|
|
|
|
|
if ( wellPathCollection.empty() ) return false;
|
2017-11-30 05:05:43 -06:00
|
|
|
|
2019-10-22 06:10:48 -05:00
|
|
|
Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !view ) return false;
|
|
|
|
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>( view );
|
|
|
|
if ( !eclView ) return false;
|
2017-11-30 05:05:43 -06:00
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
RimSimWellInView* simWellFromWellPath =
|
|
|
|
eclView->wellCollection()->findWell( wellPathCollection[0]->associatedSimulationWellName() );
|
2017-11-30 05:05:43 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( simWellFromWellPath )
|
2017-03-01 06:23:16 -06:00
|
|
|
{
|
2017-03-14 07:15:00 -05:00
|
|
|
return true;
|
2017-03-01 06:23:16 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2017-01-13 06:32:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-01-13 06:32:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicShowWellAllocationPlotFeature::onActionTriggered( bool isChecked )
|
2017-01-13 06:32:02 -06:00
|
|
|
{
|
2017-10-13 02:29:42 -05:00
|
|
|
std::vector<RimSimWellInView*> collection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &collection );
|
2017-01-13 06:32:02 -06:00
|
|
|
|
2017-11-30 05:05:43 -06:00
|
|
|
std::vector<RimWellPath*> wellPathCollection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &wellPathCollection );
|
2017-11-30 05:05:43 -06:00
|
|
|
|
|
|
|
RimSimWellInView* simWell = nullptr;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( collection.size() > 0 )
|
2017-01-13 06:32:02 -06:00
|
|
|
{
|
2017-11-30 05:05:43 -06:00
|
|
|
simWell = collection[0];
|
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( wellPathCollection.size() > 0 )
|
2017-11-30 05:05:43 -06:00
|
|
|
{
|
2019-10-22 06:10:48 -05:00
|
|
|
Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !view ) return;
|
|
|
|
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>( view );
|
|
|
|
if ( !eclView ) return;
|
2017-01-13 06:32:02 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
simWell = eclView->wellCollection()->findWell( wellPathCollection[0]->associatedSimulationWellName() );
|
|
|
|
if ( !simWell ) return;
|
2017-11-30 05:05:43 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else
|
|
|
|
return;
|
2017-11-30 05:05:43 -06:00
|
|
|
|
2020-05-12 02:50:38 -05:00
|
|
|
if ( RimProject::current() )
|
2017-11-30 05:05:43 -06:00
|
|
|
{
|
2020-06-08 04:09:11 -05:00
|
|
|
RimFlowPlotCollection* flowPlotColl = RimProject::current()->mainPlotCollection->flowPlotCollection();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( flowPlotColl )
|
2017-01-13 06:32:02 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
flowPlotColl->defaultWellAllocPlot()->setFromSimulationWell( simWell );
|
2017-11-30 05:05:43 -06:00
|
|
|
flowPlotColl->defaultWellAllocPlot()->updateConnectedEditors();
|
|
|
|
|
|
|
|
// Make sure the summary plot window is created and visible
|
2018-02-27 08:21:14 -06:00
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( flowPlotColl->defaultWellAllocPlot() );
|
2017-01-13 06:32:02 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-01-13 06:32:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicShowWellAllocationPlotFeature::setupActionLook( QAction* actionToSetup )
|
2017-01-13 06:32:02 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/WellAllocPlot16x16.png" ) );
|
|
|
|
actionToSetup->setText( "Plot Well Allocation" );
|
2017-01-13 06:32:02 -06:00
|
|
|
}
|