2012-05-18 09:45:23 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 15:04:57 +02:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
2012-05-18 09:45:23 +02: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 13:36:15 +02:00
# include "RimEclipseWellCollection.h"
2012-05-18 09:45:23 +02:00
2013-10-01 11:13:23 +02:00
# include "RiaApplication.h"
2017-02-10 08:39:25 +01:00
# include "RiaColorTables.h"
2013-10-01 11:13:23 +02:00
# include "RiaPreferences.h"
2017-01-26 12:25:45 +01:00
2017-02-02 10:34:32 +01:00
# include "RigEclipseCaseData.h"
2017-02-24 13:18:27 +01:00
# include "RigSingleWellResultsData.h"
2017-01-26 12:25:45 +01:00
2017-02-02 10:34:32 +01:00
# include "RimEclipseCase.h"
2015-05-21 10:34:38 +02:00
# include "RimEclipseView.h"
2015-06-25 13:36:15 +02:00
# include "RimEclipseWell.h"
2017-02-10 19:12:21 +01:00
# include "RimProject.h"
# include "RimWellAllocationPlot.h"
2017-01-26 12:25:45 +01:00
2017-01-26 17:41:34 +01:00
# include "RiuMainWindow.h"
2017-02-02 10:34:32 +01:00
2014-07-24 10:11:43 +02:00
# include "RivReservoirViewPartMgr.h"
2017-01-26 12:25:45 +01:00
# include "cafPdmUiPushButtonEditor.h"
2017-02-01 08:16:30 +01:00
# include "cafPdmUiCheckBoxTristateEditor.h"
2017-01-26 12:25:45 +01:00
2013-05-06 10:55:00 +02:00
2012-05-18 09:45:23 +02:00
namespace caf
{
2017-01-26 08:12:28 +01:00
// OBSOLETE enum
2012-05-18 09:45:23 +02:00
template < >
2015-06-25 12:09:16 +02:00
void RimEclipseWellCollection : : WellVisibilityEnum : : setUp ( )
2012-05-18 09:45:23 +02:00
{
2015-06-25 12:09:16 +02: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 09:13:37 +02:00
}
}
namespace caf
{
2017-01-26 17:41:34 +01:00
// OBSOLETE enum
2013-04-22 09:13:37 +02:00
template < >
2015-06-25 12:09:16 +02:00
void RimEclipseWellCollection : : WellCellsRangeFilterEnum : : setUp ( )
2013-04-22 09:13:37 +02:00
{
2015-06-25 12:09:16 +02: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 09:45:23 +02:00
}
}
namespace caf
{
template < >
2015-06-25 12:09:16 +02:00
void RimEclipseWellCollection : : WellFenceEnum : : setUp ( )
2012-05-18 09:45:23 +02:00
{
2015-06-25 12:09:16 +02: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 09:45:23 +02:00
}
}
2013-08-26 21:56:40 +02:00
namespace caf
{
template < >
2015-06-25 12:09:16 +02:00
void RimEclipseWellCollection : : WellHeadPositionEnum : : setUp ( )
2013-08-26 21:56:40 +02:00
{
2017-01-26 14:25:34 +01:00
addItem ( RimEclipseWellCollection : : WELLHEAD_POS_ACTIVE_CELLS_BB , " WELLHEAD_POS_ACTIVE_CELLS_BB " , " All Active Cells " ) ;
addItem ( RimEclipseWellCollection : : WELLHEAD_POS_TOP_COLUMN , " WELLHEAD_POS_TOP_COLUMN " , " Active Cell Column " ) ;
2015-06-25 12:09:16 +02:00
setDefault ( RimEclipseWellCollection : : WELLHEAD_POS_TOP_COLUMN ) ;
2013-08-26 21:56:40 +02:00
}
}
2012-05-18 09:45:23 +02:00
2017-01-18 08:06:03 +01: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 12:09:16 +02:00
CAF_PDM_SOURCE_INIT ( RimEclipseWellCollection , " Wells " ) ;
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 12:09:16 +02:00
RimEclipseWellCollection : : RimEclipseWellCollection ( )
2012-05-18 09:45:23 +02:00
{
2015-08-10 08:00:16 +02:00
CAF_PDM_InitObject ( " Simulation Wells " , " :/WellCollection.png " , " " , " " ) ;
2012-05-18 09:45:23 +02:00
2013-08-26 21:56:40 +02:00
CAF_PDM_InitField ( & isActive , " Active " , true , " Active " , " " , " " , " " ) ;
2015-08-05 13:27:36 +02:00
isActive . uiCapability ( ) - > setUiHidden ( true ) ;
2013-04-25 09:07:29 +02:00
2017-02-07 18:16:19 +01:00
CAF_PDM_InitField ( & showWellsIntersectingVisibleCells , " ShowWellsIntersectingVisibleCells " , false , " Hide Wells Not Intersecting Filtered Cells " , " " , " " , " " ) ;
2017-01-26 08:12:28 +01:00
2017-01-26 10:27:23 +01:00
// Appearance
2017-02-08 14:00:06 +01: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 08:16:30 +01: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 10:27:23 +01:00
// Scaling
CAF_PDM_InitField ( & wellHeadScaleFactor , " WellHeadScale " , 1.0 , " Well Head Scale Factor " , " " , " " , " " ) ;
CAF_PDM_InitField ( & pipeScaleFactor , " WellPipeRadiusScale " , 0.1 , " Well Pipe Scale Factor " , " " , " " , " " ) ;
2017-01-26 12:25:45 +01:00
CAF_PDM_InitField ( & spheresScaleFactor , " CellCenterSphereScale " , 0.2 , " Well Sphere Scale Factor " , " " , " " , " " ) ;
2017-01-26 10:27:23 +01:00
// Color
2013-10-01 11:13:23 +02:00
cvf : : Color3f defWellLabelColor = RiaApplication : : instance ( ) - > preferences ( ) - > defaultWellLabelColor ( ) ;
2017-01-30 14:53:20 +01:00
CAF_PDM_InitField ( & wellLabelColor , " WellLabelColor " , defWellLabelColor , " Well Label Color " , " " , " " , " " ) ;
2012-05-18 09:45:23 +02:00
2017-01-26 14:25:34 +01:00
CAF_PDM_InitField ( & showConnectionStatusColors , " ShowConnectionStatusColors " , true , " Show Connection Status Colors Along Well " , " " , " " , " " ) ;
2017-01-26 12:25:45 +01:00
cvf : : Color3f defaultApplyColor = cvf : : Color3f : : YELLOW ;
2017-02-08 14:00:06 +01:00
CAF_PDM_InitField ( & m_wellColorForApply , " WellColorForApply " , defaultApplyColor , " Well Color " , " " , " " , " " ) ;
2017-01-26 12:25:45 +01:00
2017-01-26 14:25:34 +01:00
CAF_PDM_InitField ( & m_applySingleColorToWells , " ApplySingleColorToWells " , false , " " , " " , " " , " " ) ;
2017-01-26 12:25:45 +01:00
m_applySingleColorToWells . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiPushButtonEditor : : uiEditorTypeName ( ) ) ;
m_applySingleColorToWells . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
m_applySingleColorToWells . xmlCapability ( ) - > setIOReadable ( false ) ;
m_applySingleColorToWells . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 14:25:34 +01:00
CAF_PDM_InitField ( & m_applyIndividualColorsToWells , " ApplyIndividualColorsToWells " , false , " " , " " , " " , " " ) ;
2017-01-26 12:25:45 +01:00
m_applyIndividualColorsToWells . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiPushButtonEditor : : uiEditorTypeName ( ) ) ;
m_applyIndividualColorsToWells . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
m_applyIndividualColorsToWells . xmlCapability ( ) - > setIOReadable ( false ) ;
m_applyIndividualColorsToWells . xmlCapability ( ) - > setIOWritable ( false ) ;
2012-06-26 16:10:41 +02:00
CAF_PDM_InitField ( & pipeCrossSectionVertexCount , " WellPipeVertexCount " , 12 , " Pipe vertex count " , " " , " " , " " ) ;
2015-08-05 13:27:36 +02:00
pipeCrossSectionVertexCount . uiCapability ( ) - > setUiHidden ( true ) ;
2017-01-30 14:53:20 +01:00
CAF_PDM_InitField ( & wellPipeCoordType , " WellPipeCoordType " , WellPipeCoordEnum ( WELLPIPE_INTERPOLATED ) , " Type " , " " , " " , " " ) ;
2012-05-18 09:45:23 +02:00
2017-02-02 09:10:34 +01:00
CAF_PDM_InitFieldNoDefault ( & m_showWellCells , " ShowWellCellsTristate " , " Show Well Cells " , " " , " " , " " ) ;
2017-02-02 08:26:27 +01:00
m_showWellCells . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiCheckBoxTristateEditor : : uiEditorTypeName ( ) ) ;
m_showWellCells . xmlCapability ( ) - > setIOReadable ( false ) ;
m_showWellCells . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 17:41:34 +01:00
CAF_PDM_InitField ( & wellCellFenceType , " DefaultWellFenceDirection " , WellFenceEnum ( K_DIRECTION ) , " Well Fence Direction " , " " , " " , " " ) ;
2012-05-18 09:45:23 +02:00
2017-01-26 14:25:34 +01:00
CAF_PDM_InitField ( & wellCellTransparencyLevel , " WellCellTransparency " , 0.5 , " Well Cell Transparency " , " " , " " , " " ) ;
CAF_PDM_InitField ( & isAutoDetectingBranches , " IsAutoDetectingBranches " , true , " Branch Detection " , " " , " Toggle wether 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 " , " " ) ;
CAF_PDM_InitField ( & wellHeadPosition , " WellHeadPosition " , WellHeadPositionEnum ( WELLHEAD_POS_TOP_COLUMN ) , " Well Head Position On Top Of " , " " , " " , " " ) ;
2016-12-06 11:40:08 +01:00
2012-05-18 09:45:23 +02:00
CAF_PDM_InitFieldNoDefault ( & wells , " Wells " , " Wells " , " " , " " , " " ) ;
2015-08-10 08:00:16 +02:00
wells . uiCapability ( ) - > setUiHidden ( true ) ;
2012-05-18 09:45:23 +02:00
2017-02-02 09:56:49 +01: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 11:27:55 +01:00
CAF_PDM_InitField ( & obsoleteField_wellPipeVisibility , " GlobalWellPipeVisibility " , WellVisibilityEnum ( PIPES_INDIVIDUALLY ) , " Global well pipe visibility " , " " , " " , " " ) ;
2017-01-26 10:27:23 +01:00
obsoleteField_wellPipeVisibility . uiCapability ( ) - > setUiHidden ( true ) ;
obsoleteField_wellPipeVisibility . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 17:41:34 +01:00
2017-02-02 11:27:55 +01:00
CAF_PDM_InitField ( & obsoleteField_wellCellsToRangeFilterMode , " GlobalWellCellVisibility " , WellCellsRangeFilterEnum ( RANGE_ADD_INDIVIDUAL ) , " Add cells to range filter " , " " , " " , " " ) ;
2017-01-26 17:41:34 +01:00
obsoleteField_wellCellsToRangeFilterMode . uiCapability ( ) - > setUiHidden ( true ) ;
obsoleteField_wellCellsToRangeFilterMode . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-01-26 10:27:23 +01:00
2017-02-02 09:56:49 +01: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 09:10:34 +01:00
obsoleteField_showWellHead . uiCapability ( ) - > setUiHidden ( true ) ;
obsoleteField_showWellLabel . uiCapability ( ) - > setUiHidden ( true ) ;
2017-02-02 09:56:49 +01:00
obsoleteField_showWellCellFence . uiCapability ( ) - > setUiHidden ( true ) ;
2017-02-02 09:10:34 +01:00
obsoleteField_showWellHead . xmlCapability ( ) - > setIOWritable ( false ) ;
obsoleteField_showWellLabel . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-02-02 09:56:49 +01:00
obsoleteField_showWellCellFence . xmlCapability ( ) - > setIOWritable ( false ) ;
2017-02-02 09:10:34 +01:00
2012-05-18 09:45:23 +02:00
m_reservoirView = NULL ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 12:09:16 +02:00
RimEclipseWellCollection : : ~ RimEclipseWellCollection ( )
2012-05-18 09:45:23 +02:00
{
2012-06-26 16:10:41 +02:00
wells . deleteAllChildObjects ( ) ;
2012-05-18 09:45:23 +02:00
}
2017-02-02 08:26:27 +01: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 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 12:09:16 +02:00
RimEclipseWell * RimEclipseWellCollection : : findWell ( QString name )
2012-05-18 09:45:23 +02: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 12:09:16 +02:00
bool RimEclipseWellCollection : : hasVisibleWellCells ( )
2012-05-18 09:45:23 +02:00
{
2013-08-26 21:56:40 +02:00
if ( ! this - > isActive ( ) ) return false ;
2012-05-18 09:45:23 +02: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 12:08:00 +02:00
RimEclipseWell * well = this - > wells ( ) [ i ] ;
2017-01-26 17:41:34 +01:00
if ( well & & well - > wellResults ( ) & & ( ( well - > showWell ( ) & & well - > showWellCells ( ) ) ) )
2012-05-18 09:45:23 +02: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 14:03:01 +02:00
if ( wellResultFrame . m_wellResultBranches [ wsIdx ] . m_branchResultPoints . size ( ) > 0 ) hasCells = true ;
2012-05-18 09:45:23 +02:00
}
}
}
}
if ( ! hasCells ) return false ;
// Todo: Handle range filter intersection
return true ;
}
//--------------------------------------------------------------------------------------------------
2017-01-26 12:25:45 +01:00
/// Used to know if we need animation of time steps due to the wells
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
2016-12-12 10:08:11 +01:00
bool RimEclipseWellCollection : : hasVisibleWellPipes ( )
2012-05-18 09:45:23 +02:00
{
2013-08-26 21:56:40 +02:00
if ( ! this - > isActive ( ) ) return false ;
2012-05-18 09:45:23 +02:00
if ( this - > wells ( ) . size ( ) = = 0 ) return false ;
return true ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 12:09:16 +02:00
void RimEclipseWellCollection : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
2012-05-18 09:45:23 +02:00
{
2017-01-26 10:27:23 +01:00
if ( & isActive = = changedField )
2012-05-18 09:45:23 +02:00
{
2014-08-01 13:35:52 +02:00
this - > updateUiIconFromToggleField ( ) ;
2012-05-18 09:45:23 +02:00
}
2017-01-26 10:27:23 +01:00
2017-02-01 08:16:30 +01:00
if ( & m_showWellLabel = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellLabel = ! ( m_showWellLabel ( ) . isFalse ( ) ) ;
2017-02-02 09:56:49 +01:00
w - > updateConnectedEditors ( ) ;
2017-02-01 08:16:30 +01:00
}
}
if ( & m_showWellHead = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellHead = ! ( m_showWellHead ( ) . isFalse ( ) ) ;
2017-02-02 09:56:49 +01:00
w - > updateConnectedEditors ( ) ;
2017-02-01 08:16:30 +01:00
}
}
if ( & m_showWellPipe = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellPipe = ! ( m_showWellPipe ( ) . isFalse ( ) ) ;
2017-02-02 09:56:49 +01:00
w - > updateConnectedEditors ( ) ;
2017-02-01 08:16:30 +01:00
}
}
if ( & m_showWellSpheres = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellSpheres = ! ( m_showWellSpheres ( ) . isFalse ( ) ) ;
2017-02-02 09:56:49 +01:00
w - > updateConnectedEditors ( ) ;
2017-02-01 08:16:30 +01:00
}
}
2017-02-02 08:26:27 +01:00
if ( & m_showWellCells = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellCells = ! ( m_showWellCells ( ) . isFalse ( ) ) ;
2017-02-02 09:56:49 +01:00
w - > updateConnectedEditors ( ) ;
}
}
if ( & m_showWellCellFence = = changedField )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellCellFence = ! ( m_showWellCellFence ( ) . isFalse ( ) ) ;
w - > updateConnectedEditors ( ) ;
2017-02-02 08:26:27 +01:00
}
}
2017-02-01 08:16:30 +01:00
2017-01-26 10:27:23 +01:00
if ( m_reservoirView )
2012-05-18 09:45:23 +02:00
{
2017-01-26 10:27:23 +01:00
if ( & isActive = = changedField
2017-02-01 08:16:30 +01:00
| | & m_showWellLabel = = changedField
2017-02-02 08:26:27 +01:00
| | & m_showWellCells = = changedField
2017-02-02 09:56:49 +01:00
| | & m_showWellCellFence = = changedField
2017-01-26 10:27:23 +01:00
| | & wellCellFenceType = = changedField )
2012-05-18 09:45:23 +02:00
{
2015-06-18 13:09:09 +02:00
m_reservoirView - > scheduleGeometryRegen ( VISIBLE_WELL_CELLS ) ;
2013-09-08 22:59:46 +02:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
2012-05-18 09:45:23 +02:00
}
2017-01-26 10:27:23 +01:00
else if ( & wellCellTransparencyLevel = = changedField )
{
2013-09-08 22:59:46 +02:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
2012-05-18 09:45:23 +02:00
}
2017-01-26 10:27:23 +01:00
else if ( & spheresScaleFactor = = changedField
2017-02-01 08:16:30 +01:00
| | & m_showWellSpheres = = changedField
2017-01-26 14:25:34 +01:00
| | & showConnectionStatusColors = = changedField )
2017-01-26 10:27:23 +01:00
{
m_reservoirView - > schedulePipeGeometryRegen ( ) ;
2013-09-08 22:59:46 +02:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
2012-05-18 09:45:23 +02:00
}
2017-01-26 10:27:23 +01:00
else if ( & pipeCrossSectionVertexCount = = changedField
| | & pipeScaleFactor = = changedField
| | & wellHeadScaleFactor = = changedField
2017-02-01 08:16:30 +01:00
| | & m_showWellHead = = changedField
2017-01-26 10:27:23 +01:00
| | & isAutoDetectingBranches = = changedField
| | & wellHeadPosition = = changedField
| | & wellLabelColor = = changedField
| | & wellPipeCoordType = = changedField
2017-02-01 08:16:30 +01:00
| | & m_showWellPipe = = changedField )
2016-12-07 12:01:31 +01:00
{
2017-01-26 10:27:23 +01:00
m_reservoirView - > schedulePipeGeometryRegen ( ) ;
2016-12-07 12:01:31 +01:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
}
2017-02-07 15:07:11 +01:00
else if ( & showWellsIntersectingVisibleCells = = changedField )
{
m_reservoirView - > scheduleGeometryRegen ( VISIBLE_WELL_CELLS ) ;
m_reservoirView - > schedulePipeGeometryRegen ( ) ;
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
}
2016-12-07 12:01:31 +01:00
}
2017-01-26 12:25:45 +01:00
if ( & m_applyIndividualColorsToWells = = changedField )
{
2017-02-02 10:34:32 +01:00
assignDefaultWellColors ( ) ;
2017-01-26 12:25:45 +01: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 19:12:21 +01:00
RimEclipseWellCollection : : updateWellAllocationPlots ( ) ;
2017-01-26 12:25:45 +01:00
m_applySingleColorToWells = false ;
}
2017-01-26 17:41:34 +01:00
2017-02-02 08:26:27 +01:00
if ( & m_showWellCells = = changedField )
2017-01-26 17:41:34 +01:00
{
RiuMainWindow : : instance ( ) - > refreshDrawStyleActions ( ) ;
}
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
2017-02-02 10:34:32 +01:00
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : assignDefaultWellColors ( )
{
2017-02-10 08:39:25 +01:00
const caf : : ColorTable & colorTable = RiaColorTables : : wellsPaletteColors ( ) ;
2017-02-15 13:26:59 +01:00
cvf : : Color3ubArray catColors = colorTable . color3ubArray ( ) ;
cvf : : Color3ubArray interpolatedCatColors = caf : : ColorTable : : interpolateColorArray ( catColors , wells . size ( ) ) ;
2017-02-10 08:39:25 +01:00
2017-02-15 13:26:59 +01:00
for ( size_t wIdx = 0 ; wIdx < wells . size ( ) ; + + wIdx )
2017-02-02 10:34:32 +01:00
{
2017-02-15 13:26:59 +01:00
RimEclipseWell * well = wells [ wIdx ] ;
2017-02-02 10:34:32 +01:00
if ( well )
{
2017-02-15 13:26:59 +01:00
cvf : : Color3f col = cvf : : Color3f ( interpolatedCatColors [ wIdx ] ) ;
2017-02-02 10:34:32 +01:00
well - > wellPipeColor = col ;
well - > updateConnectedEditors ( ) ;
}
}
2017-02-10 19:12:21 +01: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 10:34:32 +01:00
}
//--------------------------------------------------------------------------------------------------
2012-05-18 09:45:23 +02:00
///
//--------------------------------------------------------------------------------------------------
2015-06-25 12:09:16 +02:00
void RimEclipseWellCollection : : setReservoirView ( RimEclipseView * ownerReservoirView )
2012-05-18 09:45:23 +02:00
{
m_reservoirView = ownerReservoirView ;
}
2013-04-24 10:38:50 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 12:09:16 +02:00
void RimEclipseWellCollection : : defineUiOrdering ( QString uiConfigName , caf : : PdmUiOrdering & uiOrdering )
2013-04-24 10:38:50 +02:00
{
2017-02-01 08:16:30 +01:00
updateStateForVisibilityCheckboxes ( ) ;
2017-01-26 08:12:28 +01:00
uiOrdering . add ( & showWellsIntersectingVisibleCells ) ;
2017-01-30 14:53:20 +01:00
caf : : PdmUiGroup * appearanceGroup = uiOrdering . addNewGroup ( " Visibility " ) ;
2017-02-01 08:16:30 +01:00
appearanceGroup - > add ( & m_showWellLabel ) ;
appearanceGroup - > add ( & m_showWellHead ) ;
appearanceGroup - > add ( & m_showWellPipe ) ;
appearanceGroup - > add ( & m_showWellSpheres ) ;
2013-04-24 10:38:50 +02:00
2017-01-26 10:27:23 +01:00
caf : : PdmUiGroup * sizeScalingGroup = uiOrdering . addNewGroup ( " Size Scaling " ) ;
sizeScalingGroup - > add ( & wellHeadScaleFactor ) ;
sizeScalingGroup - > add ( & pipeScaleFactor ) ;
sizeScalingGroup - > add ( & spheresScaleFactor ) ;
caf : : PdmUiGroup * colorGroup = uiOrdering . addNewGroup ( " Color " ) ;
colorGroup - > add ( & wellLabelColor ) ;
2017-01-26 12:25:45 +01:00
colorGroup - > add ( & m_applyIndividualColorsToWells ) ;
2017-02-08 14:00:06 +01:00
caf : : PdmUiGroup * singleWellColorGroup = colorGroup - > addNewGroup ( " Uniform Well Coloring " ) ;
singleWellColorGroup - > add ( & m_wellColorForApply ) ;
singleWellColorGroup - > add ( & m_applySingleColorToWells ) ;
2013-04-24 10:38:50 +02:00
2017-01-30 14:53:20 +01:00
caf : : PdmUiGroup * wellPipeGroup = uiOrdering . addNewGroup ( " Well Pipe Geometry " ) ;
wellPipeGroup - > add ( & wellPipeCoordType ) ;
wellPipeGroup - > add ( & isAutoDetectingBranches ) ;
2017-02-08 14:00:06 +01:00
wellPipeGroup - > add ( & showConnectionStatusColors ) ;
2013-04-24 10:38:50 +02:00
2013-04-25 06:33:37 +02:00
caf : : PdmUiGroup * advancedGroup = uiOrdering . addNewGroup ( " Advanced " ) ;
2017-01-26 14:25:34 +01:00
advancedGroup - > add ( & wellCellTransparencyLevel ) ;
2017-01-30 14:53:20 +01:00
advancedGroup - > add ( & wellHeadPosition ) ;
2017-01-26 10:27:23 +01:00
2017-01-26 17:41:34 +01:00
caf : : PdmUiGroup * filterGroup = uiOrdering . addNewGroup ( " Well Cells " ) ;
filterGroup - > add ( & obsoleteField_wellCellsToRangeFilterMode ) ;
2017-02-02 08:26:27 +01:00
filterGroup - > add ( & m_showWellCells ) ;
2017-02-02 09:56:49 +01:00
filterGroup - > add ( & m_showWellCellFence ) ;
2017-01-26 10:27:23 +01:00
filterGroup - > add ( & wellCellFenceType ) ;
2017-01-26 18:01:00 +01:00
2017-02-02 09:56:49 +01:00
m_showWellCellFence . uiCapability ( ) - > setUiReadOnly ( ! showWellCells ( ) ) ;
2017-01-26 18:01:00 +01:00
wellCellFenceType . uiCapability ( ) - > setUiReadOnly ( ! showWellCells ( ) ) ;
2013-04-24 10:38:50 +02:00
}
2013-04-25 09:07:29 +02:00
2017-02-01 08:16:30 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : updateStateForVisibilityCheckboxes ( )
{
size_t showLabelCount = 0 ;
size_t showWellHeadCount = 0 ;
size_t showPipeCount = 0 ;
size_t showSphereCount = 0 ;
2017-02-02 08:26:27 +01:00
size_t showWellCellsCount = 0 ;
2017-02-02 09:56:49 +01:00
size_t showWellCellFenceCount = 0 ;
2017-02-01 08:16:30 +01:00
for ( RimEclipseWell * w : wells )
{
if ( w - > showWellLabel ( ) ) showLabelCount + + ;
if ( w - > showWellHead ( ) ) showWellHeadCount + + ;
if ( w - > showWellPipe ( ) ) showPipeCount + + ;
if ( w - > showWellSpheres ( ) ) showSphereCount + + ;
2017-02-02 08:26:27 +01:00
if ( w - > showWellCells ( ) ) showWellCellsCount + + ;
2017-02-02 09:56:49 +01:00
if ( w - > showWellCellFence ( ) ) showWellCellFenceCount + + ;
2017-02-01 08:16:30 +01:00
}
updateStateFromEnabledChildCount ( showLabelCount , & m_showWellLabel ) ;
updateStateFromEnabledChildCount ( showWellHeadCount , & m_showWellHead ) ;
updateStateFromEnabledChildCount ( showPipeCount , & m_showWellPipe ) ;
updateStateFromEnabledChildCount ( showSphereCount , & m_showWellSpheres ) ;
2017-02-02 08:26:27 +01:00
updateStateFromEnabledChildCount ( showWellCellsCount , & m_showWellCells ) ;
2017-02-02 09:56:49 +01:00
updateStateFromEnabledChildCount ( showWellCellFenceCount , & m_showWellCellFence ) ;
2017-02-01 08:16:30 +01: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-25 09:07:29 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 12:09:16 +02:00
caf : : PdmFieldHandle * RimEclipseWellCollection : : objectToggleField ( )
2013-04-25 09:07:29 +02:00
{
2013-08-26 21:56:40 +02:00
return & isActive ;
2013-04-25 11:09:34 +02:00
}
2013-04-26 16:46:38 +02:00
2017-01-26 08:12:28 +01: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 09:10:34 +01:00
w - > showWellPipe = false ;
2017-01-26 08:12:28 +01:00
}
}
else if ( obsoleteField_wellPipeVisibility ( ) = = PIPES_FORCE_ALL_ON )
{
showWellsIntersectingVisibleCells = false ;
for ( RimEclipseWell * w : wells )
{
2017-02-02 09:10:34 +01:00
w - > showWellPipe = true ;
2017-01-26 08:12:28 +01:00
}
}
2017-01-26 17:41:34 +01:00
if ( obsoleteField_wellCellsToRangeFilterMode ( ) = = RANGE_ADD_NONE )
{
2017-02-02 08:26:27 +01:00
for ( RimEclipseWell * w : wells )
{
2017-02-02 09:10:34 +01:00
w - > showWellCells = false ;
2017-02-02 08:26:27 +01:00
}
2017-01-26 17:41:34 +01:00
}
else if ( obsoleteField_wellCellsToRangeFilterMode ( ) = = RANGE_ADD_ALL )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellCells = true ;
}
}
2017-02-02 09:10:34 +01:00
if ( ! obsoleteField_showWellLabel ( ) )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellLabel = false ;
}
}
if ( ! obsoleteField_showWellHead ( ) )
{
for ( RimEclipseWell * w : wells )
{
w - > showWellHead = false ;
}
}
2017-02-02 09:56:49 +01:00
if ( obsoleteField_showWellCellFence ( ) )
2017-02-02 09:10:34 +01:00
{
for ( RimEclipseWell * w : wells )
{
2017-02-02 09:56:49 +01:00
w - > showWellCellFence = true ;
2017-02-02 09:10:34 +01:00
}
}
2017-01-26 08:12:28 +01:00
}
2017-01-26 12:25:45 +01: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-02-08 14:00:06 +01:00
editorAttr - > m_buttonText = " Apply Default Well Colors " ;
2017-01-26 12:25:45 +01: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 ( ) ) ;
QPixmap pixmap ( 100 , 100 ) ;
pixmap . fill ( col ) ;
QIcon colorIcon ( pixmap ) ;
editorAttr - > m_buttonIcon = colorIcon ;
2017-02-08 14:00:06 +01:00
editorAttr - > m_buttonText = " Apply Uniform Well Color " ;
2017-01-26 12:25:45 +01:00
}
}
}
2013-04-26 16:46:38 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-12-13 09:35:01 +01:00
const std : : vector < cvf : : ubyte > & RimEclipseWellCollection : : resultWellGeometryVisibilities ( size_t frameIndex )
2013-04-26 16:46:38 +02:00
{
2016-12-13 09:35:01 +01:00
calculateWellGeometryVisibility ( frameIndex ) ;
2015-12-11 17:45:09 +01:00
return m_framesOfResultWellPipeVisibilities [ frameIndex ] ;
2013-04-26 16:46:38 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-25 12:09:16 +02:00
void RimEclipseWellCollection : : scheduleIsWellPipesVisibleRecalculation ( )
2013-04-26 16:46:38 +02:00
{
2015-12-11 17:45:09 +01:00
m_framesOfResultWellPipeVisibilities . clear ( ) ;
2013-04-26 16:46:38 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2016-12-13 09:35:01 +01:00
void RimEclipseWellCollection : : calculateWellGeometryVisibility ( size_t frameIndex )
2013-04-26 16:46:38 +02:00
{
2015-12-11 17:45:09 +01:00
if ( m_framesOfResultWellPipeVisibilities . size ( ) > frameIndex & & m_framesOfResultWellPipeVisibilities [ frameIndex ] . size ( ) ) return ;
2013-04-26 16:46:38 +02:00
2015-12-11 17:45:09 +01:00
if ( m_framesOfResultWellPipeVisibilities . size ( ) < = frameIndex )
m_framesOfResultWellPipeVisibilities . resize ( frameIndex + 1 ) ;
2013-04-26 16:46:38 +02:00
2015-12-11 17:45:09 +01:00
if ( m_framesOfResultWellPipeVisibilities [ frameIndex ] . size ( ) < = wells ( ) . size ( ) )
m_framesOfResultWellPipeVisibilities [ frameIndex ] . resize ( wells ( ) . size ( ) , false ) ;
2013-04-26 16:46:38 +02:00
2017-01-27 15:48:56 +01:00
for ( const RimEclipseWell * well : wells ( ) )
2013-04-26 16:46:38 +02:00
{
2017-01-27 15:48:56 +01:00
bool wellPipeVisible = well - > isWellPipeVisible ( frameIndex ) ;
bool wellSphereVisible = well - > isWellSpheresVisible ( frameIndex ) ;
2016-12-13 09:35:01 +01:00
2017-01-27 15:48:56 +01:00
m_framesOfResultWellPipeVisibilities [ frameIndex ] [ well - > resultWellIndex ( ) ] = wellPipeVisible | | wellSphereVisible ;
2013-04-26 16:46:38 +02:00
}
}
2015-11-30 14:02:52 +01:00
bool lessEclipseWell ( const caf : : PdmPointer < RimEclipseWell > & w1 , const caf : : PdmPointer < RimEclipseWell > & w2 )
{
2015-11-30 14:50:16 +01:00
if ( w1 . notNull ( ) & & w2 . notNull ( ) )
return ( w1 - > name ( ) < w2 - > name ( ) ) ;
else if ( w1 . notNull ( ) )
return true ;
else
return false ;
2015-11-30 14:02:52 +01:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection : : sortWellsByName ( )
{
std : : sort ( wells . begin ( ) , wells . end ( ) , lessEclipseWell ) ;
}