ResInsight/ApplicationLibCode/ProjectDataModel/RimEclipseFaultColors.cpp

147 lines
5.8 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimEclipseFaultColors.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimFaultInViewCollection.h"
#include "RiuMainWindow.h"
#include "cafPdmUiTreeOrdering.h"
CAF_PDM_SOURCE_INIT( RimEclipseFaultColors, "RimFaultResultSlot" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseFaultColors::RimEclipseFaultColors()
{
CAF_PDM_InitObject( "Fault Result", ":/draw_style_faults_24x24.png" );
CAF_PDM_InitField( &showCustomFaultResult, "ShowCustomFaultResult", false, "Show Custom Fault Result" );
showCustomFaultResult.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_customFaultResultColors, "CustomResultSlot", "Custom Fault Result", ":/CellResult.png" );
m_customFaultResultColors = new RimEclipseCellColors();
m_customFaultResultColors->enableDeltaResults( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseFaultColors::~RimEclipseFaultColors()
{
delete m_customFaultResultColors;
m_customFaultResultColors = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseFaultColors::setReservoirView( RimEclipseView* ownerReservoirView )
{
m_reservoirView = ownerReservoirView;
m_customFaultResultColors->setReservoirView( ownerReservoirView );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseFaultColors::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
updateUiIconFromToggleField();
if ( m_reservoirView ) m_reservoirView->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseFaultColors::initAfterRead()
{
m_customFaultResultColors->initAfterRead();
updateUiIconFromToggleField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCellColors* RimEclipseFaultColors::customFaultResult()
{
return m_customFaultResultColors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseFaultColors::updateUiFieldsFromActiveResult()
{
m_customFaultResultColors->updateUiFieldsFromActiveResult();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimEclipseFaultColors::objectToggleField()
{
return &showCustomFaultResult;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseFaultColors::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" );
m_customFaultResultColors->uiOrdering( uiConfigName, *group1 );
auto eclipseView = firstAncestorOfType<RimEclipseView>();
if ( eclipseView )
{
eclipseView->faultCollection()->uiOrderingFaults( uiConfigName, uiOrdering );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseFaultColors::hasValidCustomResult()
{
if ( showCustomFaultResult() )
{
if ( m_customFaultResultColors->hasResult() || m_customFaultResultColors->isTernarySaturationSelected() )
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseFaultColors::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
{
m_customFaultResultColors()->defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
}