2014-07-29 08:49:54 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
2014-07-31 11:09:48 +02:00
# include "RimFaultResultSettings.h"
2014-07-29 08:49:54 +02:00
2014-07-30 14:26:39 +02:00
# include "RimReservoirView.h"
# include "RimResultSlot.h"
# include "RiuMainWindow.h"
# include "RimUiTreeModelPdm.h"
2014-07-29 08:49:54 +02:00
namespace caf
{
template < >
2014-07-31 11:09:48 +02:00
void AppEnum < RimFaultResultSettings : : FaultVisualizationMode > : : setUp ( )
2014-07-29 08:49:54 +02:00
{
2014-07-31 11:09:48 +02:00
addItem ( RimFaultResultSettings : : FAULT_COLOR , " FAULT_COLOR " , " Fault Colors " ) ;
addItem ( RimFaultResultSettings : : CELL_RESULT_MAPPING , " CELL_RESULT_MAPPING " , " Grid Cell Results " ) ;
addItem ( RimFaultResultSettings : : CUSTOM_RESULT_MAPPING , " CUSTOM_RESULT_MAPPING " , " Custom Cell Results " ) ;
setDefault ( RimFaultResultSettings : : CELL_RESULT_MAPPING ) ;
2014-07-29 08:49:54 +02:00
}
}
2014-07-31 11:09:48 +02:00
CAF_PDM_SOURCE_INIT ( RimFaultResultSettings , " RimFaultResultSlot " ) ;
2014-07-29 08:49:54 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-07-31 11:09:48 +02:00
RimFaultResultSettings : : RimFaultResultSettings ( )
2014-07-29 08:49:54 +02:00
{
CAF_PDM_InitObject ( " Fault Result Slot " , " " , " " , " " ) ;
2014-07-31 11:09:48 +02:00
CAF_PDM_InitField ( & visualizationMode , " VisualizationMode " , caf : : AppEnum < RimFaultResultSettings : : FaultVisualizationMode > ( RimFaultResultSettings : : CELL_RESULT_MAPPING ) , " Fault Color Mapping " , " " , " " , " " ) ;
2014-07-29 08:49:54 +02:00
2014-07-31 11:09:48 +02:00
CAF_PDM_InitFieldNoDefault ( & m_customFaultResult , " CustomResultSlot " , " Custom Fault Result " , " :/CellResult.png " , " " , " " ) ;
m_customFaultResult = new RimResultSlot ( ) ;
2014-07-30 14:26:39 +02:00
updateVisibility ( ) ;
2014-07-29 08:49:54 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-07-31 11:09:48 +02:00
RimFaultResultSettings : : ~ RimFaultResultSettings ( )
2014-07-29 08:49:54 +02:00
{
}
2014-07-30 14:26:39 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-07-31 11:09:48 +02:00
void RimFaultResultSettings : : setReservoirView ( RimReservoirView * ownerReservoirView )
2014-07-30 14:26:39 +02:00
{
2014-07-31 08:46:30 +02:00
m_reservoirView = ownerReservoirView ;
2014-07-31 11:09:48 +02:00
m_customFaultResult - > setReservoirView ( ownerReservoirView ) ;
2014-07-30 14:26:39 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-07-31 11:09:48 +02:00
void RimFaultResultSettings : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
2014-07-30 14:26:39 +02:00
{
2014-07-31 10:49:23 +02:00
if ( changedField = = & visualizationMode )
2014-07-30 14:26:39 +02:00
{
updateVisibility ( ) ;
RiuMainWindow : : instance ( ) - > uiPdmModel ( ) - > updateUiSubTree ( this ) ;
}
2014-07-31 08:46:30 +02:00
if ( m_reservoirView ) m_reservoirView - > createDisplayModelAndRedraw ( ) ;
2014-07-30 14:26:39 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-07-31 11:09:48 +02:00
void RimFaultResultSettings : : initAfterRead ( )
2014-07-30 14:26:39 +02:00
{
updateVisibility ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-07-31 11:09:48 +02:00
void RimFaultResultSettings : : updateVisibility ( )
2014-07-30 14:26:39 +02:00
{
2014-07-31 10:49:23 +02:00
if ( this - > visualizationMode ( ) = = FAULT_COLOR | | this - > visualizationMode ( ) = = CELL_RESULT_MAPPING )
2014-07-30 14:26:39 +02:00
{
2014-07-31 11:09:48 +02:00
this - > m_customFaultResult . setUiHidden ( true ) ;
this - > m_customFaultResult . setUiChildrenHidden ( true ) ;
2014-07-30 14:26:39 +02:00
}
else
{
2014-07-31 11:09:48 +02:00
this - > m_customFaultResult . setUiHidden ( false ) ;
this - > m_customFaultResult . setUiChildrenHidden ( false ) ;
2014-07-31 08:46:30 +02:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-07-31 11:09:48 +02:00
RimResultSlot * RimFaultResultSettings : : customFaultResult ( )
2014-07-31 08:46:30 +02:00
{
2014-07-31 10:49:23 +02:00
if ( this - > visualizationMode ( ) = = CUSTOM_RESULT_MAPPING )
2014-07-31 08:46:30 +02:00
{
2014-07-31 11:09:48 +02:00
return this - > m_customFaultResult ( ) ;
2014-07-30 14:26:39 +02:00
}
2014-07-31 08:46:30 +02:00
return NULL ;
2014-07-30 14:26:39 +02:00
}