Files
ResInsight/ApplicationLibCode/ProjectDataModel/Tools/RimAutomationSettings.cpp
Magne Sjaastad 860588d755 #12008 Improve display of curves from selected cells in 3D view
* Remove obsolete base class
* Add conversion between one/zero-based IJK
* Move code to RiaTextStringTools
* Add automatic update of grid cell curves when clicking in 3D view
* Fix missing conversion to QString
2025-02-14 09:35:28 +01:00

107 lines
4.2 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2025 Equinor ASA
//
// 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 "RimAutomationSettings.h"
#include "Summary/RiaSummaryTools.h"
#include "RimSummaryMultiPlotCollection.h"
#include "Summary/RimSummaryPlot.h"
#include "PlotBuilderCommands/RicSummaryPlotBuilder.h"
#include "RiuPlotMainWindowTools.h"
#include "RimSummaryMultiPlot.h"
CAF_PDM_SOURCE_INIT( RimAutomationSettings, "RimAutomationSettings" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAutomationSettings::RimAutomationSettings()
{
CAF_PDM_InitObject( "Automation Settings", ":/gear.svg" );
CAF_PDM_InitFieldNoDefault( &m_cellSelectionDestination,
"CellSelectionDestination",
"Cell Selection Destination",
"",
"Add curves to the selected Summary Plot when clicking on cells in a 3D view." );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryPlot*> RimAutomationSettings::summaryPlots() const
{
if ( auto summaryPlot = dynamic_cast<RimSummaryPlot*>( m_cellSelectionDestination() ) )
{
return { summaryPlot };
}
if ( auto multiSummaryPlot = dynamic_cast<RimSummaryMultiPlot*>( m_cellSelectionDestination() ) )
{
return multiSummaryPlot->summaryPlots();
}
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAutomationSettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
auto group = uiOrdering.addNewGroup( "Destination Plot for Cell Selection" );
group->add( &m_cellSelectionDestination );
m_cellSelectionDestination.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimAutomationSettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_cellSelectionDestination )
{
if ( auto summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection() )
{
for ( RimSummaryMultiPlot* multiPlot : summaryPlotColl->multiPlots() )
{
auto mainPlotName = multiPlot->description();
options.push_back( caf::PdmOptionItemInfo( mainPlotName, multiPlot, false, multiPlot->uiIconProvider() ) );
for ( RimSummaryPlot* plot : multiPlot->summaryPlots() )
{
QString displayName = mainPlotName + " : ";
displayName += plot->userDescriptionField()->uiCapability()->uiValue().toString();
options.push_back( caf::PdmOptionItemInfo( displayName, plot, false, plot->uiIconProvider() ) );
}
}
}
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
}
return options;
}