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"
# include "RiaPreferences.h"
2017-01-26 05:25:45 -06:00
2014-07-24 03:11:43 -05:00
# include "RigSingleWellResultsData.h"
2017-01-26 05:25:45 -06:00
2015-05-21 03:34:38 -05:00
# include "RimEclipseView.h"
2015-06-25 06:36:15 -05:00
# include "RimEclipseWell.h"
2017-01-26 05:25:45 -06:00
2014-07-24 03:11:43 -05:00
# include "RivReservoirViewPartMgr.h"
2017-01-26 05:25:45 -06:00
# include "cafPdmUiPushButtonEditor.h"
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
{
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-01-26 07:25:34 -06: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 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-01-26 01:12:28 -06:00
CAF_PDM_InitField ( & showWellsIntersectingVisibleCells , " ShowWellsIntersectingVisibleCells " , true , " Show Wells Intersecting Visible Cells " , " " , " " , " " ) ;
2017-01-26 03:27:23 -06:00
// Appearance
2017-01-26 05:25:45 -06:00
CAF_PDM_InitField ( & showWellHead , " ShowWellHead " , true , " Show Well Head " , " " , " " , " " ) ;
CAF_PDM_InitField ( & showWellLabel , " ShowWellLabel " , true , " Show Well Label " , " " , " " , " " ) ;
CAF_PDM_InitField ( & showWellPipe , " ShowWellPipe " , true , " Show Well Pipe " , " " , " " , " " ) ;
CAF_PDM_InitField ( & showWellSpheres , " ShowWellSpheres " , true , " Show Well Spheres " , " " , " " , " " ) ;
2017-01-26 03:27:23 -06: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 05:25:45 -06:00
CAF_PDM_InitField ( & spheresScaleFactor , " CellCenterSphereScale " , 0.2 , " Well Sphere Scale Factor " , " " , " " , " " ) ;
2017-01-26 03:27:23 -06:00
// Color
2013-10-01 04:13:23 -05:00
cvf : : Color3f defWellLabelColor = RiaApplication : : instance ( ) - > preferences ( ) - > defaultWellLabelColor ( ) ;
CAF_PDM_InitField ( & wellLabelColor , " WellLabelColor " , defWellLabelColor , " Well label color " , " " , " " , " " ) ;
2012-05-18 02:45:23 -05:00
2017-01-26 07:25:34 -06:00
CAF_PDM_InitField ( & showConnectionStatusColors , " ShowConnectionStatusColors " , true , " Show Connection Status Colors Along Well " , " " , " " , " " ) ;
2017-01-26 05:25:45 -06:00
cvf : : Color3f defaultApplyColor = cvf : : Color3f : : YELLOW ;
2017-01-26 07:25:34 -06:00
CAF_PDM_InitField ( & m_wellColorForApply , " WellColorForApply " , defaultApplyColor , " Single Well Color " , " " , " " , " " ) ;
2017-01-26 05:25:45 -06:00
2017-01-26 07:25:34 -06:00
CAF_PDM_InitField ( & m_applySingleColorToWells , " ApplySingleColorToWells " , false , " " , " " , " " , " " ) ;
2017-01-26 05:25:45 -06: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 07:25:34 -06:00
CAF_PDM_InitField ( & m_applyIndividualColorsToWells , " ApplyIndividualColorsToWells " , false , " " , " " , " " , " " ) ;
2017-01-26 05:25:45 -06: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 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-26 07:25:34 -06:00
CAF_PDM_InitField ( & wellPipeCoordType , " WellPipeCoordType " , WellPipeCoordEnum ( WELLPIPE_INTERPOLATED ) , " Well Pipe Geometry " , " " , " " , " " ) ;
2012-05-18 02:45:23 -05:00
2013-04-22 02:13:37 -05:00
CAF_PDM_InitField ( & wellCellsToRangeFilterMode , " GlobalWellCellVisibility " , WellCellsRangeFilterEnum ( RANGE_ADD_NONE ) , " Add cells to range filter " , " " , " " , " " ) ;
2013-04-24 03:38:50 -05:00
CAF_PDM_InitField ( & showWellCellFences , " ShowWellFences " , false , " Use well fence " , " " , " " , " " ) ;
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 " , " " , " " , " " ) ;
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 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-01-26 03:27:23 -06:00
CAF_PDM_InitField ( & obsoleteField_wellPipeVisibility , " GlobalWellPipeVisibility " , WellVisibilityEnum ( PIPES_OPEN_IN_VISIBLE_CELLS ) , " Global well pipe visibility " , " " , " " , " " ) ;
obsoleteField_wellPipeVisibility . uiCapability ( ) - > setUiHidden ( true ) ;
obsoleteField_wellPipeVisibility . xmlCapability ( ) - > setIOWritable ( false ) ;
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
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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 ;
2013-04-22 02:13:37 -05:00
if ( this - > wellCellsToRangeFilterMode ( ) = = RANGE_ADD_NONE ) 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 ] ;
2013-09-06 08:45:21 -05:00
if ( well & & well - > wellResults ( ) & & ( ( well - > showWell ( ) & & well - > showWellCells ( ) ) | | this - > wellCellsToRangeFilterMode ( ) = = RANGE_ADD_ALL ) )
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 ;
2013-04-22 02:13:37 -05:00
if ( this - > wellCellsToRangeFilterMode ( ) = = RANGE_ADD_INDIVIDUAL | | this - > wellCellsToRangeFilterMode ( ) = = RANGE_ADD_ALL ) return true ;
2012-05-18 02:45:23 -05:00
// 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
if ( m_reservoirView )
2012-05-18 02:45:23 -05:00
{
2017-01-26 03:27:23 -06:00
if ( & isActive = = changedField
| | & showWellLabel = = changedField
| | & wellCellsToRangeFilterMode = = changedField
| | & showWellCellFences = = changedField
| | & 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-01-26 07:25:34 -06:00
| | & showWellSpheres = = changedField
| | & showConnectionStatusColors = = changedField )
2017-01-26 03:27:23 -06:00
{
m_reservoirView - > schedulePipeGeometryRegen ( ) ;
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
| | & showWellHead = = changedField
| | & isAutoDetectingBranches = = changedField
| | & wellHeadPosition = = changedField
| | & wellLabelColor = = changedField
| | & showWellsIntersectingVisibleCells = = changedField
| | & wellPipeCoordType = = changedField
| | & showWellPipe = = changedField )
2016-12-07 05:01:31 -06:00
{
2017-01-26 03:27:23 -06:00
m_reservoirView - > schedulePipeGeometryRegen ( ) ;
2016-12-07 05:01:31 -06:00
m_reservoirView - > scheduleCreateDisplayModelAndRedraw ( ) ;
}
}
2017-01-26 03:27:23 -06:00
if ( & showWellPipe = = changedField
| | & showWellSpheres = = changedField
| | & showWellHead = = changedField
| | & showWellLabel = = changedField )
2012-05-18 02:45:23 -05:00
{
2017-01-26 03:27:23 -06:00
for ( RimEclipseWell * w : wells )
2012-05-18 02:45:23 -05:00
{
2017-01-26 03:27:23 -06:00
w - > updateConnectedEditors ( ) ;
2012-05-18 02:45:23 -05:00
}
}
2017-01-26 05:25:45 -06:00
if ( & m_applyIndividualColorsToWells = = changedField )
{
for ( size_t i = 0 ; i < wells . size ( ) ; i + + )
{
cvf : : Color3f col = cycledPaletteColor ( i ) ;
wells [ i ] - > wellPipeColor = col ;
wells [ i ] - > updateConnectedEditors ( ) ;
}
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 ( ) ;
m_applySingleColorToWells = false ;
}
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-01-26 01:12:28 -06:00
uiOrdering . add ( & showWellsIntersectingVisibleCells ) ;
2017-01-26 03:27:23 -06:00
caf : : PdmUiGroup * appearanceGroup = uiOrdering . addNewGroup ( " Appearance " ) ;
appearanceGroup - > add ( & showWellLabel ) ;
appearanceGroup - > add ( & showWellHead ) ;
appearanceGroup - > add ( & showWellPipe ) ;
appearanceGroup - > add ( & showWellSpheres ) ;
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 ) ;
caf : : PdmUiGroup * colorGroup = uiOrdering . addNewGroup ( " Color " ) ;
colorGroup - > add ( & wellLabelColor ) ;
2017-01-26 05:25:45 -06:00
colorGroup - > add ( & m_applyIndividualColorsToWells ) ;
2017-01-26 07:25:34 -06:00
colorGroup - > add ( & m_wellColorForApply ) ;
colorGroup - > add ( & m_applySingleColorToWells ) ;
colorGroup - > add ( & showConnectionStatusColors ) ;
2013-04-24 03:38:50 -05:00
2017-01-26 07:25:34 -06:00
uiOrdering . add ( & wellPipeCoordType ) ;
2013-04-24 03:38:50 -05:00
2013-04-24 23:33:37 -05:00
caf : : PdmUiGroup * advancedGroup = uiOrdering . addNewGroup ( " Advanced " ) ;
advancedGroup - > add ( & isAutoDetectingBranches ) ;
2017-01-26 07:25:34 -06:00
advancedGroup - > add ( & wellCellTransparencyLevel ) ;
2017-01-26 03:27:23 -06:00
2017-01-26 07:25:34 -06:00
uiOrdering . add ( & wellHeadPosition ) ;
2017-01-26 03:27:23 -06:00
caf : : PdmUiGroup * filterGroup = uiOrdering . addNewGroup ( " Well range filter " ) ;
filterGroup - > add ( & wellCellsToRangeFilterMode ) ;
filterGroup - > add ( & showWellCellFences ) ;
filterGroup - > add ( & wellCellFenceType ) ;
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 )
{
w - > showWell = false ;
}
}
else if ( obsoleteField_wellPipeVisibility ( ) = = PIPES_FORCE_ALL_ON )
{
showWellsIntersectingVisibleCells = false ;
for ( RimEclipseWell * w : wells )
{
w - > showWell = true ;
}
}
else if ( obsoleteField_wellPipeVisibility ( ) = = PIPES_INDIVIDUALLY )
{
showWellsIntersectingVisibleCells = false ;
}
}
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 )
{
editorAttr - > m_buttonText = " Apply Individual Well Colors " ;
}
}
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 ;
editorAttr - > m_buttonText = " Apply Single Well Color " ;
}
}
}
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
for ( size_t i = 0 ; i < wells ( ) . size ( ) ; + + i )
{
2016-12-14 00:15:44 -06:00
bool wellPipeVisible = wells [ i ] - > isWellPipeVisible ( frameIndex ) ;
bool wellSphereVisible = wells [ i ] - > isWellSpheresVisible ( frameIndex ) ;
2016-12-13 02:35:01 -06:00
m_framesOfResultWellPipeVisibilities [ frameIndex ] [ wells [ i ] - > resultWellIndex ( ) ] = wellPipeVisible | | wellSphereVisible ;
2013-04-26 09:46:38 -05:00
}
}
2015-11-30 07:02:52 -06:00
2017-01-26 05:25:45 -06:00
//--------------------------------------------------------------------------------------------------
/// TODO: Consider creating a factory for colors, see also RimSummaryCurveAppearanceCalculator
//--------------------------------------------------------------------------------------------------
cvf : : Color3f RimEclipseWellCollection : : cycledPaletteColor ( size_t colorIndex )
{
static const size_t colorCount = 15 ;
static const cvf : : ubyte colorData [ ] [ 3 ] =
{
{ 0 , 112 , 136 } , // Dark Green-Blue
{ 202 , 0 , 0 } , // Red
{ 78 , 204 , 0 } , // Clear Green
{ 236 , 118 , 0 } , // Orange
{ 0 , 0 , 0 } , // Black
{ 56 , 56 , 255 } , // Vivid Blue
{ 248 , 0 , 170 } , // Magenta
{ 169 , 2 , 240 } , // Purple
{ 0 , 221 , 221 } , // Turquoise
{ 201 , 168 , 206 } , // Light Violet
{ 0 , 205 , 68 } , // Bluish Green
{ 236 , 188 , 0 } , // Mid Yellow
{ 51 , 204 , 255 } , // Bluer Turquoise
{ 164 , 193 , 0 } , // Mid Yellowish Green
{ 0 , 143 , 239 } , // Dark Light Blue
} ;
size_t paletteIdx = colorIndex % colorCount ;
cvf : : Color3ub ubColor ( colorData [ paletteIdx ] [ 0 ] , colorData [ paletteIdx ] [ 1 ] , colorData [ paletteIdx ] [ 2 ] ) ;
cvf : : Color3f cvfColor ( ubColor ) ;
return cvfColor ;
}
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 ) ;
}