ResInsight/ApplicationLibCode/ProjectDataModel/RimNameConfig.cpp

148 lines
5.7 KiB
C++
Raw Normal View History

2018-08-07 06:34:13 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
2019-01-09 08:21:38 -06:00
// Copyright (C) 2018- Equinor ASA
2019-09-06 06:17:36 -05:00
//
2018-08-07 06:34:13 -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.
// + m_addWellName {m_fieldValue=true m_defaultFieldValue=true } caf::PdmField<bool>
// 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.
2019-09-06 06:17:36 -05:00
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
2018-08-07 06:34:13 -05:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimNameConfig.h"
#include "Rim3dWellLogCurve.h"
2019-09-06 06:17:36 -05:00
#include "RimProject.h"
2018-08-07 06:34:13 -05:00
//==================================================================================================
2019-09-06 06:17:36 -05:00
///
///
2018-08-07 06:34:13 -05:00
//==================================================================================================
2019-11-25 05:38:00 -06:00
CAF_PDM_ABSTRACT_SOURCE_INIT( RimNameConfig, "RimCurveNameConfig" );
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
2019-11-25 05:38:00 -06:00
RimNameConfig::RimNameConfig( const QString& customName )
2018-08-07 06:34:13 -05:00
{
2019-09-06 06:17:36 -05:00
CAF_PDM_InitObject( "Curve Name Generator", "", "", "" );
2018-08-07 06:34:13 -05:00
2019-09-06 06:17:36 -05:00
CAF_PDM_InitFieldNoDefault( &m_customName, "CustomCurveName", "Custom Name Part", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_autoName, "AutoCurveName", "Full Name", "", "", "" );
m_autoName.registerGetMethod( this, &RimNameConfig::autoName );
2018-08-07 06:34:13 -05:00
m_autoName.xmlCapability()->disableIO();
2019-09-06 06:17:36 -05:00
m_autoName.uiCapability()->setUiReadOnly( true );
2019-11-25 05:38:00 -06:00
m_customName = customName;
2018-08-07 06:34:13 -05:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
RimNameConfig::~RimNameConfig()
{
}
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimNameConfig::customName() const
{
return m_customName;
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimNameConfig::nameField()
{
return &m_autoName;
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
QString RimNameConfig::name() const
{
2019-09-06 06:17:36 -05:00
return m_autoName();
2018-08-07 06:34:13 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void RimNameConfig::uiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
2019-09-06 06:17:36 -05:00
defineUiOrdering( uiConfigName, uiOrdering );
}
//--------------------------------------------------------------------------------------------------
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void RimNameConfig::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
2018-08-07 06:34:13 -05:00
{
2019-09-06 06:17:36 -05:00
uiOrdering.add( &m_customName );
uiOrdering.add( &m_autoName );
2018-08-07 06:34:13 -05:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void RimNameConfig::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
2018-08-07 06:34:13 -05:00
{
updateAllSettings();
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
QString RimNameConfig::autoName() const
{
RimNameConfigHolderInterface* plotHolder;
2019-09-06 06:17:36 -05:00
this->firstAncestorOrThisOfTypeAsserted( plotHolder );
return plotHolder->createAutoName();
2018-08-07 06:34:13 -05:00
}
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
void RimNameConfig::setCustomName( const QString& name )
2018-08-07 06:34:13 -05:00
{
m_customName = name;
}
2019-11-25 05:38:00 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimNameConfig::enableAllAutoNameTags( bool enable )
{
doEnableAllAutoNameTags( enable );
}
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
2019-09-06 06:17:36 -05:00
///
2018-08-07 06:34:13 -05:00
//--------------------------------------------------------------------------------------------------
void RimNameConfig::updateAllSettings()
{
m_autoName.uiCapability()->updateConnectedEditors();
m_customName.uiCapability()->updateConnectedEditors();
RimNameConfigHolderInterface* holder;
2019-09-06 06:17:36 -05:00
this->firstAncestorOrThisOfTypeAsserted( holder );
2019-11-25 05:38:00 -06:00
holder->updateAutoName();
2019-09-06 06:17:36 -05:00
caf::PdmObject* pdmObject = dynamic_cast<caf::PdmObject*>( holder );
if ( pdmObject )
2018-08-07 06:34:13 -05:00
{
2019-09-06 06:17:36 -05:00
pdmObject->updateConnectedEditors();
2018-08-07 06:34:13 -05:00
}
}