2012-05-18 02:45:23 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 08:04:57 -05:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
2012-05-18 02:45:23 -05: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.
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
2015-06-25 06:36:15 -05:00
# include "RimEclipseWellCollection.h"
2012-05-18 02:45:23 -05:00
2013-10-01 04:13:23 -05:00
# include "RiaApplication.h"
2017-02-10 01:39:25 -06:00
# include "RiaColorTables.h"
2013-10-01 04:13:23 -05:00
# include "RiaPreferences.h"
2017-01-26 05:25:45 -06:00
2017-02-02 03:34:32 -06:00
# include "RigEclipseCaseData.h"
2017-02-24 06:18:27 -06:00
# include "RigSingleWellResultsData.h"
2017-01-26 05:25:45 -06:00
2017-02-02 03:34:32 -06:00
# include "RimEclipseCase.h"
2015-05-21 03:34:38 -05:00
# include "RimEclipseView.h"
2015-06-25 06:36:15 -05:00
# include "RimEclipseWell.h"
2017-02-10 12:12:21 -06:00
# include "RimProject.h"
# include "RimWellAllocationPlot.h"
2017-01-30 07:28:37 -06:00
# include "RimSimWellFracture.h"
# include "RimSimWellFractureCollection.h"
2017-01-26 05:25:45 -06:00
2017-01-26 10:41:34 -06:00
# include "RiuMainWindow.h"
2017-02-02 03:34:32 -06:00
2014-07-24 03:11:43 -05:00
# include "RivReservoirViewPartMgr.h"
2017-01-26 05:25:45 -06:00
# include "cafPdmUiPushButtonEditor.h"
2017-02-01 01:16:30 -06:00
# include "cafPdmUiCheckBoxTristateEditor.h"
2017-03-13 05:05:46 -05:00
# include "RimEclipseResultCase.h"
2017-01-26 05:25:45 -06:00
2013-05-06 03:55:00 -05:00
2012-05-18 02:45:23 -05:00
namespace caf
{
2017-01-26 01:12:28 -06:00
// OBSOLETE enum
2012-05-18 02:45:23 -05:00
template < >
2015-06-25 05:09:16 -05:00
void RimEclipseWellCollection : : WellVisibilityEnum : : setUp ( )
2012-05-18 02:45:23 -05:00
{
2015-06-25 05:09:16 -05:00
addItem ( RimEclipseWellCollection : : PIPES_FORCE_ALL_OFF , " FORCE_ALL_OFF " , " All Off " ) ;
addItem ( RimEclipseWellCollection : : PIPES_INDIVIDUALLY , " ALL_ON " , " Individual " ) ;
addItem ( RimEclipseWellCollection : : PIPES_OPEN_IN_VISIBLE_CELLS , " OPEN_IN_VISIBLE_CELLS " , " Visible cells filtered " ) ;
addItem ( RimEclipseWellCollection : : PIPES_FORCE_ALL_ON , " FORCE_ALL_ON " , " All On " ) ;
2013-04-22 02:13:37 -05:00
}
}
namespace caf
{
2017-01-26 10:41:34 -06:00
// OBSOLETE enum
2013-04-22 02:13:37 -05:00
template < >
2015-06-25 05:09:16 -05:00
void RimEclipseWellCollection : : WellCellsRangeFilterEnum : : setUp ( )
2013-04-22 02:13:37 -05:00
{
2015-06-25 05:09:16 -05:00
addItem ( RimEclipseWellCollection : : RANGE_ADD_NONE , " FORCE_ALL_OFF " , " All Off " ) ;
addItem ( RimEclipseWellCollection : : RANGE_ADD_INDIVIDUAL , " ALL_ON " , " Individually " ) ;
addItem ( RimEclipseWellCollection : : RANGE_ADD_ALL , " FORCE_ALL_ON " , " All On " ) ;
2012-05-18 02:45:23 -05:00
}
}
namespace caf
{
template < >
2015-06-25 05:09:16 -05:00
void RimEclipseWellCollection : : WellFenceEnum : : setUp ( )
2012-05-18 02:45:23 -05:00
{
2015-06-25 05:09:16 -05:00
addItem ( RimEclipseWellCollection : : K_DIRECTION , " K_DIRECTION " , " K - Direction " ) ;
addItem ( RimEclipseWellCollection : : J_DIRECTION , " J_DIRECTION " , " J - Direction " ) ;
addItem ( RimEclipseWellCollection : : I_DIRECTION , " I_DIRECTION " , " I - Direction " ) ;
setDefault ( RimEclipseWellCollection : : K_DIRECTION ) ;
2012-05-18 02:45:23 -05:00
}
}
2013-08-26 14:56:40 -05:00
namespace caf
{
template < >
2015-06-25 05:09:16 -05:00
void RimEclipseWellCollection : : WellHeadPositionEnum : : setUp ( )
2013-08-26 14:56:40 -05:00
{
2017-04-07 01:40:54 -05:00
addItem ( RimEclipseWellCollection : : WELLHEAD_POS_ACTIVE_CELLS_BB , " WELLHEAD_POS_ACTIVE_CELLS_BB " , " Top of Active Cells " ) ;
addItem ( RimEclipseWellCollection : : WELLHEAD_POS_TOP_COLUMN , " WELLHEAD_POS_TOP_COLUMN " , " Top of Active Cell Column " ) ;
2015-06-25 05:09:16 -05:00
setDefault ( RimEclipseWellCollection : : WELLHEAD_POS_TOP_COLUMN ) ;
2013-08-26 14:56:40 -05:00
}
}
2012-05-18 02:45:23 -05:00
2017-01-18 01:06:03 -06:00
namespace caf
{
template < >
void RimEclipseWellCollection : : WellPipeCoordEnum : : setUp ( )
{
addItem ( RimEclipseWellCollection : : WELLPIPE_INTERPOLATED , " WELLPIPE_INTERPOLATED " , " Interpolated " ) ;
addItem ( RimEclipseWellCollection : : WELLPIPE_CELLCENTER , " WELLPIPE_CELLCENTER " , " Cell Centers " ) ;
setDefault ( RimEclipseWellCollection : : WELLPIPE_INTERPOLATED ) ;
}
}
2015-06-25 05:09:16 -05:00
CAF_PDM_SOURCE_INIT ( RimEclipseWellCollection , " Wells " ) ;
2012-05-18 02:45:23 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
RimEclipseWellCollection : : RimEclipseWellCollection ( )
2012-05-18 02:45:23 -05:00
{
2015-08-10 01:00:16 -05:00
CAF_PDM_InitObject ( " Simulation Wells " , " :/WellCollection.png " , " " , " " ) ;
2012-05-18 02:45:23 -05:00
2013-08-26 14:56:40 -05:00
CAF_PDM_InitField ( & isActive , " Active " , true , " Active " , " " , " " , " " ) ;
2015-08-05 06:27:36 -05:00
isActive . uiCapability ( ) - > setUiHidden ( true ) ;
2013-04-25 02:07:29 -05:00
2017-04-07 01:40:54 -05:00
//CAF_PDM_InitField(&showWellsIntersectingVisibleCells, "ShowWellsIntersectingVisibleCells", false, "Hide Wells Not Intersecting Filtered Cells", "", "", "");
CAF_PDM_InitField ( & showWellsIntersectingVisibleCells , " ShowWellsIntersectingVisibleCells " , false , " Wells Through Visible Cells Only " , " " , " " , " " ) ;
//CAF_PDM_InitField(&showWellsIntersectingVisibleCells, "ShowWellsIntersectingVisibleCells", false, "Hide Wells Missing Visible Cells", "", "", "");
2017-01-26 01:12:28 -06:00
2017-01-26 03:27:23 -06:00
// Appearance
2017-02-08 07:00:06 -06:00
CAF_PDM_InitFieldNoDefault ( & m_showWellHead , " ShowWellHeadTristate " , " Well Head " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & m_showWellLabel , " ShowWellLabelTristate " , " Label " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & m_showWellPipe , " ShowWellPipe " , " Pipe " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & m_showWellSpheres , " ShowWellSpheres " , " Spheres " , " " , " " , " " ) ;
2017-02-01 01:16:30 -06:00
m_showWellHead . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiCheckBoxTristateEditor : : uiEditorTypeName ( ) ) ;
m_showWellHead . xmlCapability ( ) - > setIOReadable ( false ) ;
m_showWellHead . xmlCapability ( ) - > setIOWritable ( false ) ;
m_showWellLabel . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiCheckBoxTristateEditor : : uiEditorTypeName ( ) ) ;
m_showWellLabel . xmlCapability ( ) - > setIOReadable ( false ) ;
m_showWellLabel . xmlCapability ( ) - > setIOWritable ( false ) ;
m_showWellPipe . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiCheckBoxTristateEditor : : uiEditorTypeName ( ) ) ;
m_showWellPipe . xmlCapability ( ) - > setIOReadable ( false ) ;
m_showWellPipe . xmlCapability ( ) - > setIOWritable ( false ) ;
m_showWellSpheres . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiCheckBoxTristateEditor : : uiEditorTypeName ( ) ) ;
m_showWellSpheres . xmlCapability ( ) - > setIOReadable ( false ) ;
m_showWellSpheres . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 03:27:23 -06:00
// Scaling
2017-04-07 01:40:54 -05:00
CAF_PDM_InitField ( & wellHeadScaleFactor , " WellHeadScale " , 1.0 , " Well Head Scale " , " " , " " , " " ) ;
CAF_PDM_InitField ( & pipeScaleFactor , " WellPipeRadiusScale " , 0.1 , " Pipe Radius Scale " , " " , " " , " " ) ;
CAF_PDM_InitField ( & spheresScaleFactor , " CellCenterSphereScale " , 0.2 , " Sphere Radius Scale " , " " , " " , " " ) ;
2017-01-26 03:27:23 -06:00
// Color
2013-10-01 04:13:23 -05:00
cvf : : Color3f defWellLabelColor = RiaApplication : : instance ( ) - > preferences ( ) - > defaultWellLabelColor ( ) ;
2017-04-07 01:40:54 -05:00
CAF_PDM_InitField ( & wellLabelColor , " WellLabelColor " , defWellLabelColor , " Label Color " , " " , " " , " " ) ;
2012-05-18 02:45:23 -05:00
2017-04-07 01:40:54 -05:00
CAF_PDM_InitField ( & showConnectionStatusColors , " ShowConnectionStatusColors " , true , " Color Pipe Connections " , " " , " " , " " ) ;
2017-01-26 07:25:34 -06:00
2017-01-26 05:25:45 -06:00
cvf : : Color3f defaultApplyColor = cvf : : Color3f : : YELLOW ;
2017-04-07 01:40:54 -05:00
CAF_PDM_InitField ( & m_wellColorForApply , " WellColorForApply " , defaultApplyColor , " " , " " , " " , " " ) ;
2017-01-26 05:25:45 -06:00
2017-04-07 01:40:54 -05:00
CAF_PDM_InitField ( & m_applySingleColorToWells , " ApplySingleColorToWells " , false , " Uniform Pipe Colors " , " " , " " , " " ) ;
2017-01-26 05:25:45 -06:00
m_applySingleColorToWells . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiPushButtonEditor : : uiEditorTypeName ( ) ) ;
2017-04-07 01:40:54 -05:00
m_applySingleColorToWells . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : LEFT ) ;
2017-01-26 05:25:45 -06:00
m_applySingleColorToWells . xmlCapability ( ) - > setIOReadable ( false ) ;
m_applySingleColorToWells . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-04-07 01:40:54 -05:00
CAF_PDM_InitField ( & m_applyIndividualColorsToWells , " ApplyIndividualColorsToWells " , false , " Unique Pipe Colors " , " " , " " , " " ) ;
2017-01-26 05:25:45 -06:00
m_applyIndividualColorsToWells . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiPushButtonEditor : : uiEditorTypeName ( ) ) ;
2017-04-07 01:40:54 -05:00
m_applyIndividualColorsToWells . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : LEFT ) ;
2017-01-26 05:25:45 -06:00
m_applyIndividualColorsToWells . xmlCapability ( ) - > setIOReadable ( false ) ;
m_applyIndividualColorsToWells . xmlCapability ( ) - > setIOWritable ( false ) ;
2012-06-26 09:10:41 -05:00
CAF_PDM_InitField ( & pipeCrossSectionVertexCount , " WellPipeVertexCount " , 12 , " Pipe vertex count " , " " , " " , " " ) ;
2015-08-05 06:27:36 -05:00
pipeCrossSectionVertexCount . uiCapability ( ) - > setUiHidden ( true ) ;
2017-01-30 07:53:20 -06:00
CAF_PDM_InitField ( & wellPipeCoordType , " WellPipeCoordType " , WellPipeCoordEnum ( WELLPIPE_INTERPOLATED ) , " Type " , " " , " " , " " ) ;
2012-05-18 02:45:23 -05:00
2017-02-02 02:10:34 -06:00
CAF_PDM_InitFieldNoDefault ( & m_showWellCells , " ShowWellCellsTristate " , " Show Well Cells " , " " , " " , " " ) ;
2017-02-02 01:26:27 -06:00
m_showWellCells . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiCheckBoxTristateEditor : : uiEditorTypeName ( ) ) ;
m_showWellCells . xmlCapability ( ) - > setIOReadable ( false ) ;
m_showWellCells . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 10:41:34 -06:00
CAF_PDM_InitField ( & wellCellFenceType , " DefaultWellFenceDirection " , WellFenceEnum ( K_DIRECTION ) , " Well Fence Direction " , " " , " " , " " ) ;
2012-05-18 02:45:23 -05:00
2017-01-26 07:25:34 -06:00
CAF_PDM_InitField ( & wellCellTransparencyLevel , " WellCellTransparency " , 0.5 , " Well Cell Transparency " , " " , " " , " " ) ;
2017-04-18 04:32:04 -05:00
CAF_PDM_InitField ( & isAutoDetectingBranches , " IsAutoDetectingBranches " , true , " Branch Detection " , " " , " Toggle whether the well pipe visualization will try to detect when a part of the well \n is really a branch, and thus is starting from wellhead " , " " ) ;
2017-04-07 01:40:54 -05:00
CAF_PDM_InitField ( & wellHeadPosition , " WellHeadPosition " , WellHeadPositionEnum ( WELLHEAD_POS_TOP_COLUMN ) , " Well Head Position " , " " , " " , " " ) ;
2016-12-06 04:40:08 -06:00
2012-05-18 02:45:23 -05:00
CAF_PDM_InitFieldNoDefault ( & wells , " Wells " , " Wells " , " " , " " , " " ) ;
2015-08-10 01:00:16 -05:00
wells . uiCapability ( ) - > setUiHidden ( true ) ;
2012-05-18 02:45:23 -05:00
2017-02-02 02:56:49 -06:00
CAF_PDM_InitFieldNoDefault ( & m_showWellCellFence , " ShowWellCellFenceTristate " , " Show Well Cell Fence " , " " , " " , " " ) ;
m_showWellCellFence . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiCheckBoxTristateEditor : : uiEditorTypeName ( ) ) ;
m_showWellCellFence . xmlCapability ( ) - > setIOReadable ( false ) ;
m_showWellCellFence . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-02-02 04:27:55 -06:00
CAF_PDM_InitField ( & obsoleteField_wellPipeVisibility , " GlobalWellPipeVisibility " , WellVisibilityEnum ( PIPES_INDIVIDUALLY ) , " Global well pipe visibility " , " " , " " , " " ) ;
2017-01-26 03:27:23 -06:00
obsoleteField_wellPipeVisibility . uiCapability ( ) - > setUiHidden ( true ) ;
obsoleteField_wellPipeVisibility . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 10:41:34 -06:00
2017-02-02 04:27:55 -06:00
CAF_PDM_InitField ( & obsoleteField_wellCellsToRangeFilterMode , " GlobalWellCellVisibility " , WellCellsRangeFilterEnum ( RANGE_ADD_INDIVIDUAL ) , " Add cells to range filter " , " " , " " , " " ) ;
2017-01-26 10:41:34 -06:00
obsoleteField_wellCellsToRangeFilterMode . uiCapability ( ) - > setUiHidden ( true ) ;
obsoleteField_wellCellsToRangeFilterMode . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 03:27:23 -06:00
2017-02-02 02:56:49 -06:00
CAF_PDM_InitField ( & obsoleteField_showWellHead , " ShowWellHead " , true , " Show Well Head " , " " , " " , " " ) ;
CAF_PDM_InitField ( & obsoleteField_showWellLabel , " ShowWellLabel " , true , " Show Well Label " , " " , " " , " " ) ;
CAF_PDM_InitField ( & obsoleteField_showWellCellFence , " ShowWellFences " , false , " Show Well Cell Fence " , " " , " " , " " ) ;
2017-02-02 02:10:34 -06:00
2017-04-07 01:40:54 -05:00
CAF_PDM_InitField ( & m_showWellCommunicationLines , " ShowWellCommunicationLines " , false , " Communication Lines " , " " , " " , " " ) ;
2017-03-13 05:05:46 -05:00
2017-02-02 02:10:34 -06:00
obsoleteField_showWellHead . uiCapability ( ) - > setUiHidden ( true ) ;
obsoleteField_showWellLabel . uiCapability ( ) - > setUiHidden ( true ) ;
2017-02-02 02:56:49 -06:00
obsoleteField_showWellCellFence . uiCapability ( ) - > setUiHidden ( true ) ;
2017-02-02 02:10:34 -06:00
obsoleteField_showWellHead . xmlCapability ( ) - > setIOWritable ( false ) ;
obsoleteField_showWellLabel . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-02-02 02:56:49 -06:00
obsoleteField_showWellCellFence . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 03:27:23 -06:00
2012-05-18 02:45:23 -05:00
m_reservoirView = NULL ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
RimEclipseWellCollection : : ~ RimEclipseWellCollection ( )
2012-05-18 02:45:23 -05:00
{
2012-06-26 09:10:41 -05:00
wells . deleteAllChildObjects ( ) ;
2012-05-18 02:45:23 -05:00
}
2017-02-02 01:26:27 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : setShowWellCellsState ( bool enable )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellCells = enable ;
}
updateConnectedEditors ( ) ;
if ( m_reservoirView )
{
m_reservoirView - > scheduleGeometryRegen ( VISIBLE_WELL_CELLS ) ;
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseWellCollection : : showWellCells ( )
{
if ( m_showWellCells ( ) . isFalse ( ) )
{
return false ;
}
else
{
return true ;
}
}
2012-05-18 02:45:23 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
RimEclipseWell * RimEclipseWellCollection : : findWell ( QString name )
2012-05-18 02:45:23 -05:00
{
for ( size_t i = 0 ; i < this - > wells ( ) . size ( ) ; + + i )
{
if ( this - > wells ( ) [ i ] - > name ( ) = = name )
{
return this - > wells ( ) [ i ] ;
}
}
return NULL ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
bool RimEclipseWellCollection : : hasVisibleWellCells ( )
2012-05-18 02:45:23 -05:00
{
2013-08-26 14:56:40 -05:00
if ( ! this - > isActive ( ) ) return false ;
2012-05-18 02:45:23 -05:00
if ( this - > wells ( ) . size ( ) = = 0 ) return false ;
bool hasCells = false ;
for ( size_t i = 0 ; ! hasCells & & i < this - > wells ( ) . size ( ) ; + + i )
{
2015-06-25 05:08:00 -05:00
RimEclipseWell * well = this - > wells ( ) [ i ] ;
2017-01-26 10:41:34 -06:00
if ( well & & well - > wellResults ( ) & & ( ( well - > showWell ( ) & & well - > showWellCells ( ) ) ) )
2012-05-18 02:45:23 -05:00
{
for ( size_t tIdx = 0 ; ! hasCells & & tIdx < well - > wellResults ( ) - > m_wellCellsTimeSteps . size ( ) ; + + tIdx )
{
const RigWellResultFrame & wellResultFrame = well - > wellResults ( ) - > m_wellCellsTimeSteps [ tIdx ] ;
for ( size_t wsIdx = 0 ; ! hasCells & & wsIdx < wellResultFrame . m_wellResultBranches . size ( ) ; + + wsIdx )
{
2013-08-26 07:03:01 -05:00
if ( wellResultFrame . m_wellResultBranches [ wsIdx ] . m_branchResultPoints . size ( ) > 0 ) hasCells = true ;
2012-05-18 02:45:23 -05:00
}
}
}
}
if ( ! hasCells ) return false ;
// Todo: Handle range filter intersection
return true ;
}
//--------------------------------------------------------------------------------------------------
2017-01-26 05:25:45 -06:00
/// Used to know if we need animation of time steps due to the wells
2012-05-18 02:45:23 -05:00
//--------------------------------------------------------------------------------------------------
2016-12-12 03:08:11 -06:00
bool RimEclipseWellCollection : : hasVisibleWellPipes ( )
2012-05-18 02:45:23 -05:00
{
2013-08-26 14:56:40 -05:00
if ( ! this - > isActive ( ) ) return false ;
2012-05-18 02:45:23 -05:00
if ( this - > wells ( ) . size ( ) = = 0 ) return false ;
return true ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
void RimEclipseWellCollection : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
2012-05-18 02:45:23 -05:00
{
2017-01-26 03:27:23 -06:00
if ( & isActive = = changedField )
2012-05-18 02:45:23 -05:00
{
2014-08-01 06:35:52 -05:00
this - > updateUiIconFromToggleField ( ) ;
2012-05-18 02:45:23 -05:00
}
2017-01-26 03:27:23 -06:00
2017-02-01 01:16:30 -06:00
if ( & m_showWellLabel = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellLabel = ! ( m_showWellLabel ( ) . isFalse ( ) ) ;
2017-02-02 02:56:49 -06:00
w - > updateConnectedEditors ( ) ;
2017-02-01 01:16:30 -06:00
}
}
if ( & m_showWellHead = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellHead = ! ( m_showWellHead ( ) . isFalse ( ) ) ;
2017-02-02 02:56:49 -06:00
w - > updateConnectedEditors ( ) ;
2017-02-01 01:16:30 -06:00
}
}
if ( & m_showWellPipe = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellPipe = ! ( m_showWellPipe ( ) . isFalse ( ) ) ;
2017-02-02 02:56:49 -06:00
w - > updateConnectedEditors ( ) ;
2017-02-01 01:16:30 -06:00
}
}
if ( & m_showWellSpheres = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellSpheres = ! ( m_showWellSpheres ( ) . isFalse ( ) ) ;
2017-02-02 02:56:49 -06:00
w - > updateConnectedEditors ( ) ;
2017-02-01 01:16:30 -06:00
}
}
2017-02-02 01:26:27 -06:00
if ( & m_showWellCells = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellCells = ! ( m_showWellCells ( ) . isFalse ( ) ) ;
2017-02-02 02:56:49 -06:00
w - > updateConnectedEditors ( ) ;
}
}
if ( & m_showWellCellFence = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellCellFence = ! ( m_showWellCellFence ( ) . isFalse ( ) ) ;
w - > updateConnectedEditors ( ) ;
2017-02-02 01:26:27 -06:00
}
}
2017-02-01 01:16:30 -06:00
2017-01-26 03:27:23 -06:00
if ( m_reservoirView )
2012-05-18 02:45:23 -05:00
{
2017-01-26 03:27:23 -06:00
if ( & isActive = = changedField
2017-02-01 01:16:30 -06:00
| | & m_showWellLabel = = changedField
2017-02-02 01:26:27 -06:00
| | & m_showWellCells = = changedField
2017-02-02 02:56:49 -06:00
| | & m_showWellCellFence = = changedField
2017-01-26 03:27:23 -06:00
| | & wellCellFenceType = = changedField )
2012-05-18 02:45:23 -05:00
{
2015-06-18 06:09:09 -05:00
m_reservoirView - > scheduleGeometryRegen ( VISIBLE_WELL_CELLS ) ;
2013-09-08 15:59:46 -05:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
2012-05-18 02:45:23 -05:00
}
2017-01-26 03:27:23 -06:00
else if ( & wellCellTransparencyLevel = = changedField )
{
2013-09-08 15:59:46 -05:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
2012-05-18 02:45:23 -05:00
}
2017-01-26 03:27:23 -06:00
else if ( & spheresScaleFactor = = changedField
2017-02-01 01:16:30 -06:00
| | & m_showWellSpheres = = changedField
2017-01-26 07:25:34 -06:00
| | & showConnectionStatusColors = = changedField )
2017-01-26 03:27:23 -06:00
{
2017-03-13 05:05:46 -05:00
m_reservoirView - > scheduleSimWellGeometryRegen ( ) ;
2013-09-08 15:59:46 -05:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
2012-05-18 02:45:23 -05:00
}
2017-01-26 03:27:23 -06:00
else if ( & pipeCrossSectionVertexCount = = changedField
| | & pipeScaleFactor = = changedField
| | & wellHeadScaleFactor = = changedField
2017-02-01 01:16:30 -06:00
| | & m_showWellHead = = changedField
2017-01-26 03:27:23 -06:00
| | & isAutoDetectingBranches = = changedField
| | & wellHeadPosition = = changedField
| | & wellLabelColor = = changedField
| | & wellPipeCoordType = = changedField
2017-02-01 01:16:30 -06:00
| | & m_showWellPipe = = changedField )
2016-12-07 05:01:31 -06:00
{
2017-03-13 05:05:46 -05:00
m_reservoirView - > scheduleSimWellGeometryRegen ( ) ;
2016-12-07 05:01:31 -06:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
}
2017-02-07 08:07:11 -06:00
else if ( & showWellsIntersectingVisibleCells = = changedField )
{
m_reservoirView - > scheduleGeometryRegen ( VISIBLE_WELL_CELLS ) ;
2017-03-13 05:05:46 -05:00
m_reservoirView - > scheduleSimWellGeometryRegen ( ) ;
2017-02-07 08:07:11 -06:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
2016-12-07 05:01:31 -06:00
}
}
2017-01-26 05:25:45 -06:00
if ( & m_applyIndividualColorsToWells = = changedField )
{
2017-02-02 03:34:32 -06:00
assignDefaultWellColors ( ) ;
2017-01-26 05:25:45 -06:00
if ( m_reservoirView ) m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
m_applyIndividualColorsToWells = false ;
}
if ( & m_applySingleColorToWells = = changedField )
{
cvf : : Color3f col = m_wellColorForApply ( ) ;
for ( size_t i = 0 ; i < wells . size ( ) ; i + + )
{
wells [ i ] - > wellPipeColor = col ;
wells [ i ] - > updateConnectedEditors ( ) ;
}
if ( m_reservoirView ) m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
2017-02-10 12:12:21 -06:00
RimEclipseWellCollection : : updateWellAllocationPlots ( ) ;
2017-01-26 05:25:45 -06:00
m_applySingleColorToWells = false ;
}
2017-01-30 07:28:37 -06:00
2017-02-02 01:26:27 -06:00
if ( & m_showWellCells = = changedField )
2017-01-26 10:41:34 -06:00
{
RiuMainWindow : : instance ( ) - > refreshDrawStyleActions ( ) ;
}
2012-05-18 02:45:23 -05:00
2017-03-13 05:05:46 -05:00
if ( & m_showWellCommunicationLines = = changedField )
{
if ( m_reservoirView ) m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
}
2017-03-15 04:10:43 -05:00
2017-02-03 03:52:22 -06:00
if ( & wellPipeCoordType = = changedField )
2017-01-30 07:28:37 -06:00
{
for ( RimEclipseWell * w : wells )
{
for ( RimSimWellFracture * frac : w - > simwellFractureCollection ( ) - > simwellFractures ( ) )
{
frac - > recomputeWellCenterlineCoordinates ( ) ;
}
}
}
2012-05-18 02:45:23 -05:00
}
//--------------------------------------------------------------------------------------------------
2017-02-02 03:34:32 -06:00
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : assignDefaultWellColors ( )
{
2017-04-06 07:12:24 -05:00
RimEclipseCase * ownerCase ;
firstAncestorOrThisOfTypeAsserted ( ownerCase ) ;
2017-02-15 06:26:59 -06:00
for ( size_t wIdx = 0 ; wIdx < wells . size ( ) ; + + wIdx )
2017-02-02 03:34:32 -06:00
{
2017-02-15 06:26:59 -06:00
RimEclipseWell * well = wells [ wIdx ] ;
2017-04-06 07:12:24 -05:00
if ( well & & well - > wellResults ( ) )
2017-02-02 03:34:32 -06:00
{
2017-04-06 07:12:24 -05:00
well - > wellPipeColor = ownerCase - > defaultWellColor ( well - > wellResults ( ) - > m_wellName ) ;
2017-02-02 03:34:32 -06:00
}
}
2017-02-10 12:12:21 -06:00
RimEclipseWellCollection : : updateWellAllocationPlots ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : updateWellAllocationPlots ( )
{
RimProject * proj = RiaApplication : : instance ( ) - > project ( ) ;
std : : vector < RimWellAllocationPlot * > wellAllocationPlots ;
proj - > descendantsIncludingThisOfType ( wellAllocationPlots ) ;
for ( auto wap : wellAllocationPlots )
{
wap - > loadDataAndUpdate ( ) ;
}
2017-02-02 03:34:32 -06:00
}
2012-05-18 02:45:23 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
void RimEclipseWellCollection : : setReservoirView ( RimEclipseView * ownerReservoirView )
2012-05-18 02:45:23 -05:00
{
m_reservoirView = ownerReservoirView ;
}
2013-04-24 03:38:50 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
void RimEclipseWellCollection : : defineUiOrdering ( QString uiConfigName , caf : : PdmUiOrdering & uiOrdering )
2013-04-24 03:38:50 -05:00
{
2017-02-01 01:16:30 -06:00
updateStateForVisibilityCheckboxes ( ) ;
2017-01-30 07:53:20 -06:00
caf : : PdmUiGroup * appearanceGroup = uiOrdering . addNewGroup ( " Visibility " ) ;
2017-04-07 01:40:54 -05:00
appearanceGroup - > add ( & showWellsIntersectingVisibleCells ) ;
2017-02-01 01:16:30 -06:00
appearanceGroup - > add ( & m_showWellLabel ) ;
appearanceGroup - > add ( & m_showWellHead ) ;
appearanceGroup - > add ( & m_showWellPipe ) ;
appearanceGroup - > add ( & m_showWellSpheres ) ;
2017-04-07 01:40:54 -05:00
appearanceGroup - > add ( & m_showWellCommunicationLines ) ;
caf : : PdmUiGroup * filterGroup = uiOrdering . addNewGroup ( " Well Cells and Fence " ) ;
filterGroup - > add ( & m_showWellCells ) ;
filterGroup - > add ( & m_showWellCellFence ) ;
filterGroup - > add ( & wellCellFenceType ) ;
2013-04-24 03:38:50 -05:00
2017-01-26 03:27:23 -06:00
caf : : PdmUiGroup * sizeScalingGroup = uiOrdering . addNewGroup ( " Size Scaling " ) ;
sizeScalingGroup - > add ( & wellHeadScaleFactor ) ;
sizeScalingGroup - > add ( & pipeScaleFactor ) ;
sizeScalingGroup - > add ( & spheresScaleFactor ) ;
2017-04-07 01:40:54 -05:00
caf : : PdmUiGroup * colorGroup = uiOrdering . addNewGroup ( " Colors " ) ;
colorGroup - > setCollapsedByDefault ( true ) ;
colorGroup - > add ( & showConnectionStatusColors ) ;
2017-01-26 03:27:23 -06:00
colorGroup - > add ( & wellLabelColor ) ;
2017-01-26 05:25:45 -06:00
colorGroup - > add ( & m_applyIndividualColorsToWells ) ;
2017-04-07 01:40:54 -05:00
colorGroup - > add ( & m_applySingleColorToWells ) ;
colorGroup - > add ( & m_wellColorForApply ) ;
2017-01-26 05:25:45 -06:00
2017-04-07 01:40:54 -05:00
caf : : PdmUiGroup * wellPipeGroup = uiOrdering . addNewGroup ( " Well Pipe Geometry " ) ;
2017-01-30 07:53:20 -06:00
wellPipeGroup - > add ( & wellPipeCoordType ) ;
wellPipeGroup - > add ( & isAutoDetectingBranches ) ;
2013-04-24 03:38:50 -05:00
2013-04-24 23:33:37 -05:00
caf : : PdmUiGroup * advancedGroup = uiOrdering . addNewGroup ( " Advanced " ) ;
2017-04-07 01:40:54 -05:00
advancedGroup - > setCollapsedByDefault ( true ) ;
2017-01-26 07:25:34 -06:00
advancedGroup - > add ( & wellCellTransparencyLevel ) ;
2017-01-30 07:53:20 -06:00
advancedGroup - > add ( & wellHeadPosition ) ;
2017-01-26 03:27:23 -06:00
2017-03-13 05:05:46 -05:00
RimEclipseResultCase * ownerCase ;
firstAncestorOrThisOfTypeAsserted ( ownerCase ) ;
m_showWellCommunicationLines . uiCapability ( ) - > setUiHidden ( ! ownerCase - > flowDiagSolverInterface ( ) ) ;
2017-02-02 02:56:49 -06:00
m_showWellCellFence . uiCapability ( ) - > setUiReadOnly ( ! showWellCells ( ) ) ;
2017-01-26 11:01:00 -06:00
wellCellFenceType . uiCapability ( ) - > setUiReadOnly ( ! showWellCells ( ) ) ;
2013-04-24 03:38:50 -05:00
}
2013-04-25 02:07:29 -05:00
2017-02-01 01:16:30 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : updateStateForVisibilityCheckboxes ( )
{
size_t showLabelCount = 0 ;
size_t showWellHeadCount = 0 ;
size_t showPipeCount = 0 ;
size_t showSphereCount = 0 ;
2017-02-02 01:26:27 -06:00
size_t showWellCellsCount = 0 ;
2017-02-02 02:56:49 -06:00
size_t showWellCellFenceCount = 0 ;
2017-02-01 01:16:30 -06:00
for ( RimEclipseWell * w : wells )
{
if ( w - > showWellLabel ( ) ) showLabelCount + + ;
if ( w - > showWellHead ( ) ) showWellHeadCount + + ;
if ( w - > showWellPipe ( ) ) showPipeCount + + ;
if ( w - > showWellSpheres ( ) ) showSphereCount + + ;
2017-02-02 01:26:27 -06:00
if ( w - > showWellCells ( ) ) showWellCellsCount + + ;
2017-02-02 02:56:49 -06:00
if ( w - > showWellCellFence ( ) ) showWellCellFenceCount + + ;
2017-02-01 01:16:30 -06:00
}
updateStateFromEnabledChildCount ( showLabelCount , & m_showWellLabel ) ;
updateStateFromEnabledChildCount ( showWellHeadCount , & m_showWellHead ) ;
updateStateFromEnabledChildCount ( showPipeCount , & m_showWellPipe ) ;
updateStateFromEnabledChildCount ( showSphereCount , & m_showWellSpheres ) ;
2017-02-02 01:26:27 -06:00
updateStateFromEnabledChildCount ( showWellCellsCount , & m_showWellCells ) ;
2017-02-02 02:56:49 -06:00
updateStateFromEnabledChildCount ( showWellCellFenceCount , & m_showWellCellFence ) ;
2017-02-01 01:16:30 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : updateStateFromEnabledChildCount ( size_t enabledChildCount , caf : : PdmField < caf : : Tristate > * fieldToUpdate )
{
caf : : Tristate tristate ;
if ( enabledChildCount = = 0 )
{
tristate = caf : : Tristate : : State : : False ;
}
else if ( enabledChildCount = = wells . size ( ) )
{
tristate = caf : : Tristate : : State : : True ;
}
else
{
tristate = caf : : Tristate : : State : : PartiallyTrue ;
}
fieldToUpdate - > setValue ( tristate ) ;
2013-04-24 03:38:50 -05:00
}
2013-04-25 02:07:29 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
caf : : PdmFieldHandle * RimEclipseWellCollection : : objectToggleField ( )
2013-04-25 02:07:29 -05:00
{
2013-08-26 14:56:40 -05:00
return & isActive ;
2013-04-25 04:09:34 -05:00
}
2013-04-26 09:46:38 -05:00
2017-01-26 01:12:28 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : initAfterRead ( )
{
if ( obsoleteField_wellPipeVisibility ( ) = = PIPES_OPEN_IN_VISIBLE_CELLS )
{
showWellsIntersectingVisibleCells = true ;
}
else if ( obsoleteField_wellPipeVisibility ( ) = = PIPES_FORCE_ALL_OFF )
{
showWellsIntersectingVisibleCells = false ;
for ( RimEclipseWell * w : wells )
{
2017-02-02 02:10:34 -06:00
w - > showWellPipe = false ;
2017-01-26 01:12:28 -06:00
}
}
else if ( obsoleteField_wellPipeVisibility ( ) = = PIPES_FORCE_ALL_ON )
{
showWellsIntersectingVisibleCells = false ;
for ( RimEclipseWell * w : wells )
{
2017-02-02 02:10:34 -06:00
w - > showWellPipe = true ;
2017-01-26 01:12:28 -06:00
}
}
2017-01-26 10:41:34 -06:00
if ( obsoleteField_wellCellsToRangeFilterMode ( ) = = RANGE_ADD_NONE )
2017-01-26 01:12:28 -06:00
{
2017-02-02 01:26:27 -06:00
for ( RimEclipseWell * w : wells )
{
2017-02-02 02:10:34 -06:00
w - > showWellCells = false ;
2017-02-02 01:26:27 -06:00
}
2017-01-26 10:41:34 -06:00
}
else if ( obsoleteField_wellCellsToRangeFilterMode ( ) = = RANGE_ADD_ALL )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellCells = true ;
}
}
2017-02-02 02:10:34 -06:00
if ( ! obsoleteField_showWellLabel ( ) )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellLabel = false ;
}
}
if ( ! obsoleteField_showWellHead ( ) )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellHead = false ;
}
}
2017-02-02 02:56:49 -06:00
if ( obsoleteField_showWellCellFence ( ) )
2017-02-02 02:10:34 -06:00
{
for ( RimEclipseWell * w : wells )
{
2017-02-02 02:56:49 -06:00
w - > showWellCellFence = true ;
2017-02-02 02:10:34 -06:00
}
2017-01-26 01:12:28 -06:00
}
}
2017-01-26 05:25:45 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : defineEditorAttribute ( const caf : : PdmFieldHandle * field , QString uiConfigName , caf : : PdmUiEditorAttribute * attribute )
{
if ( & m_applyIndividualColorsToWells = = field )
{
caf : : PdmUiPushButtonEditorAttribute * editorAttr = dynamic_cast < caf : : PdmUiPushButtonEditorAttribute * > ( attribute ) ;
if ( editorAttr )
{
2017-04-07 01:40:54 -05:00
editorAttr - > m_buttonText = " Apply " ;
2017-01-26 05:25:45 -06:00
}
}
if ( & m_applySingleColorToWells = = field )
{
caf : : PdmUiPushButtonEditorAttribute * editorAttr = dynamic_cast < caf : : PdmUiPushButtonEditorAttribute * > ( attribute ) ;
if ( editorAttr )
{
QColor col ;
col . setRgbF ( m_wellColorForApply ( ) . r ( ) , m_wellColorForApply ( ) . g ( ) , m_wellColorForApply ( ) . b ( ) ) ;
2017-04-07 01:40:54 -05:00
QPixmap pixmap ( 20 , 20 ) ;
2017-01-26 05:25:45 -06:00
pixmap . fill ( col ) ;
QIcon colorIcon ( pixmap ) ;
editorAttr - > m_buttonIcon = colorIcon ;
2017-04-07 01:40:54 -05:00
editorAttr - > m_buttonText = " Apply " ;
2017-01-26 05:25:45 -06:00
}
}
}
2013-04-26 09:46:38 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-12-13 02:35:01 -06:00
const std : : vector < cvf : : ubyte > & RimEclipseWellCollection : : resultWellGeometryVisibilities ( size_t frameIndex )
2013-04-26 09:46:38 -05:00
{
2016-12-13 02:35:01 -06:00
calculateWellGeometryVisibility ( frameIndex ) ;
2015-12-11 10:45:09 -06:00
return m_framesOfResultWellPipeVisibilities [ frameIndex ] ;
2013-04-26 09:46:38 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 05:09:16 -05:00
void RimEclipseWellCollection : : scheduleIsWellPipesVisibleRecalculation ( )
2013-04-26 09:46:38 -05:00
{
2015-12-11 10:45:09 -06:00
m_framesOfResultWellPipeVisibilities . clear ( ) ;
2013-04-26 09:46:38 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-12-13 02:35:01 -06:00
void RimEclipseWellCollection : : calculateWellGeometryVisibility ( size_t frameIndex )
2013-04-26 09:46:38 -05:00
{
2015-12-11 10:45:09 -06:00
if ( m_framesOfResultWellPipeVisibilities . size ( ) > frameIndex & & m_framesOfResultWellPipeVisibilities [ frameIndex ] . size ( ) ) return ;
2013-04-26 09:46:38 -05:00
2015-12-11 10:45:09 -06:00
if ( m_framesOfResultWellPipeVisibilities . size ( ) < = frameIndex )
m_framesOfResultWellPipeVisibilities . resize ( frameIndex + 1 ) ;
2013-04-26 09:46:38 -05:00
2015-12-11 10:45:09 -06:00
if ( m_framesOfResultWellPipeVisibilities [ frameIndex ] . size ( ) < = wells ( ) . size ( ) )
m_framesOfResultWellPipeVisibilities [ frameIndex ] . resize ( wells ( ) . size ( ) , false ) ;
2013-04-26 09:46:38 -05:00
2017-01-27 08:48:56 -06:00
for ( const RimEclipseWell * well : wells ( ) )
2013-04-26 09:46:38 -05:00
{
2017-01-27 08:48:56 -06:00
bool wellPipeVisible = well - > isWellPipeVisible ( frameIndex ) ;
bool wellSphereVisible = well - > isWellSpheresVisible ( frameIndex ) ;
2016-12-13 02:35:01 -06:00
2017-01-27 08:48:56 -06:00
m_framesOfResultWellPipeVisibilities [ frameIndex ] [ well - > resultWellIndex ( ) ] = wellPipeVisible | | wellSphereVisible ;
2013-04-26 09:46:38 -05:00
}
}
2015-11-30 07:02:52 -06:00
bool lessEclipseWell ( const caf : : PdmPointer < RimEclipseWell > & w1 , const caf : : PdmPointer < RimEclipseWell > & w2 )
{
2015-11-30 07:50:16 -06:00
if ( w1 . notNull ( ) & & w2 . notNull ( ) )
return ( w1 - > name ( ) < w2 - > name ( ) ) ;
else if ( w1 . notNull ( ) )
return true ;
else
return false ;
2015-11-30 07:02:52 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : sortWellsByName ( )
{
std : : sort ( wells . begin ( ) , wells . end ( ) , lessEclipseWell ) ;
}