Refactor and rename QIconProvider -> IconProvider (#5893)

* Refactor and rename QIconProvider -> IconProvider
* Generate icons on demand as unique_ptrs
This commit is contained in:
Gaute Lindkvist
2020-05-09 11:25:11 +02:00
committed by GitHub
parent b84e868564
commit 2e79cf614f
42 changed files with 383 additions and 379 deletions

View File

@@ -125,9 +125,9 @@ RimWellAllocationPlot::RimWellAllocationPlot()
this->setAsPlotMdiWindow();
m_accumulatedWellFlowPlot->setAvailableDepthUnits( {} );
m_accumulatedWellFlowPlot->setAvailableDepthTypes( {RiaDefines::DepthTypeEnum::CONNECTION_NUMBER,
RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH,
RiaDefines::DepthTypeEnum::PSEUDO_LENGTH} );
m_accumulatedWellFlowPlot->setAvailableDepthTypes( { RiaDefines::DepthTypeEnum::CONNECTION_NUMBER,
RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH,
RiaDefines::DepthTypeEnum::PSEUDO_LENGTH } );
m_accumulatedWellFlowPlot->setCommonDataSourceEnabled( false );
@@ -710,7 +710,7 @@ QList<caf::PdmOptionItemInfo>
{
std::set<QString> sortedWellNames = this->findSortedWellNames();
caf::QIconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.png" );
for ( const QString& wname : sortedWellNames )
{
options.push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );

View File

@@ -519,7 +519,7 @@ QList<caf::PdmOptionItemInfo>
{
if ( m_case && m_case->eclipseCaseData() )
{
caf::QIconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.png" );
const std::set<QString> sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames();
for ( const QString& name : sortedWellNameSet )
{

View File

@@ -293,7 +293,7 @@ QList<caf::PdmOptionItemInfo>
{
if ( m_case && m_case->eclipseCaseData() )
{
caf::QIconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.png" );
const std::set<QString> sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames();
for ( const QString& name : sortedWellNameSet )
{

View File

@@ -209,7 +209,7 @@ void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplatesRecursively( QL
}
}
caf::QIconProvider templateIcon( ":/SummaryTemplate16x16.png" );
caf::IconProvider templateIcon( ":/SummaryTemplate16x16.png" );
auto files = templateFolderItem->fileNames();
for ( auto file : files )

View File

@@ -69,21 +69,19 @@ caf::PdmFieldHandle* RimCellFilter::userDescriptionField()
//--------------------------------------------------------------------------------------------------
void RimCellFilter::updateIconState()
{
caf::QIconProvider iconProvider = this->uiIconProvider();
caf::IconProvider iconProvider = this->uiIconProvider();
if ( iconProvider.isNull() ) return;
if ( !iconProvider.valid() ) return;
QPixmap sign;
if ( filterMode() == INCLUDE )
{
sign.load( ":/Plus.png" );
iconProvider.setOverlayResourceString( ":/Plus.png" );
}
else
{
sign.load( ":/Minus.png" );
iconProvider.setOverlayResourceString( ":/Minus.png" );
}
iconProvider.setOverlayPixmap( sign );
iconProvider.setActive( isActive && !isActive.uiCapability()->isUiReadOnly() );
this->setUiIcon( iconProvider );

View File

@@ -348,7 +348,7 @@ QList<caf::PdmOptionItemInfo>
{
caf::PdmChildArrayField<RimSimWellInView*>& simWells = coll->wells;
caf::QIconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.png" );
for ( RimSimWellInView* eclWell : simWells )
{
options.push_back( caf::PdmOptionItemInfo( eclWell->name(), eclWell, false, simWellIcon ) );

View File

@@ -96,7 +96,7 @@ RimGridView::RimGridView()
m_surfaceResultDefCollection.uiCapability()->setUiTreeHidden( true );
m_surfaceResultDefCollection = new RimIntersectionResultsDefinitionCollection;
m_surfaceResultDefCollection->uiCapability()->setUiName( "Separate Surface Results" );
m_surfaceResultDefCollection->uiCapability()->setUiIcon( caf::QIconProvider( ":/ReservoirSurface16x16.png" ) );
m_surfaceResultDefCollection->uiCapability()->setUiIcon( caf::IconProvider( ":/ReservoirSurface16x16.png" ) );
CAF_PDM_InitFieldNoDefault( &m_gridCollection, "GridCollection", "GridCollection", "", "", "" );
m_gridCollection.uiCapability()->setUiHidden( true );

View File

@@ -591,7 +591,7 @@ QList<caf::PdmOptionItemInfo> RimMultiPlot::calculateValueOptions( const caf::Pd
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
enumVal,
false,
caf::QIconProvider( iconPath ) ) );
caf::IconProvider( iconPath ) ) );
}
else
{
@@ -599,7 +599,7 @@ QList<caf::PdmOptionItemInfo> RimMultiPlot::calculateValueOptions( const caf::Pd
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
enumVal,
false,
caf::QIconProvider( iconPath ) ) );
caf::IconProvider( iconPath ) ) );
}
}
}

View File

@@ -632,7 +632,7 @@ void RimPlotCurve::updateUiIconFromPlotSymbol()
QSizeF iconSize( 24, 24 );
QwtGraphic graphic = m_qwtPlotCurve->legendIcon( 0, iconSize );
QPixmap pixmap = graphic.toPixmap();
setUiIcon( caf::QIconProvider( pixmap ) );
setUiIcon( caf::IconProvider( pixmap ) );
}
}

View File

@@ -244,7 +244,7 @@ void RimTools::wellPathOptionItems( QList<caf::PdmOptionItemInfo>* options )
{
caf::PdmChildArrayField<RimWellPath*>& wellPaths = wellPathColl->wellPaths;
caf::QIconProvider wellIcon( ":/Well.png" );
caf::IconProvider wellIcon( ":/Well.png" );
for ( RimWellPath* wellPath : wellPaths )
{
options->push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath, false, wellIcon ) );
@@ -263,7 +263,7 @@ void RimTools::wellPathWithFormationsOptionItems( QList<caf::PdmOptionItemInfo>*
std::vector<RimWellPath*> wellPaths;
RimTools::wellPathWithFormations( &wellPaths );
caf::QIconProvider wellIcon( ":/Well.png" );
caf::IconProvider wellIcon( ":/Well.png" );
for ( RimWellPath* wellPath : wellPaths )
{
options->push_back( caf::PdmOptionItemInfo( wellPath->name(), wellPath, false, wellIcon ) );

View File

@@ -512,7 +512,7 @@ void RimViewController::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi
//--------------------------------------------------------------------------------------------------
void RimViewController::updateDisplayNameAndIcon()
{
caf::QIconProvider iconProvider;
caf::IconProvider iconProvider;
RimViewLinker::findNameAndIconFromView( &m_name.v(), &iconProvider, managedView() );
iconProvider.setActive( m_isActive() );
setUiIcon( iconProvider );

View File

@@ -19,10 +19,10 @@
#pragma once
#include "cafIconProvider.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cafQIconProvider.h"
#include "cvfObject.h"

View File

@@ -46,8 +46,8 @@
#include "RiuViewer.h"
#include "RiaOptionItemFactory.h"
#include "cafIconProvider.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafQIconProvider.h"
#include "cvfCamera.h"
#include "cvfMatrix4.h"
#include "cvfScene.h"
@@ -412,7 +412,7 @@ bool RimViewLinker::isActive() const
//--------------------------------------------------------------------------------------------------
void RimViewLinker::updateUiNameAndIcon()
{
caf::QIconProvider iconProvider;
caf::IconProvider iconProvider;
RimViewLinker::findNameAndIconFromView( &m_name.v(), &iconProvider, m_masterView );
if ( m_masterView ) m_masterView->updateAutoName();
@@ -445,7 +445,7 @@ void RimViewLinker::scheduleCreateDisplayModelAndRedrawForDependentViews()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewLinker::findNameAndIconFromView( QString* name, caf::QIconProvider* icon, RimGridView* view )
void RimViewLinker::findNameAndIconFromView( QString* name, caf::IconProvider* icon, RimGridView* view )
{
CVF_ASSERT( name && icon );
@@ -456,7 +456,7 @@ void RimViewLinker::findNameAndIconFromView( QString* name, caf::QIconProvider*
}
else
{
*icon = caf::QIconProvider();
*icon = caf::IconProvider();
}
}

View File

@@ -30,7 +30,7 @@
namespace caf
{
class QIconProvider;
class IconProvider;
}
namespace cvf
@@ -88,7 +88,7 @@ public:
void addViewControllers( caf::PdmUiTreeOrdering& uiTreeOrdering ) const;
static void findNameAndIconFromView( QString* name, caf::QIconProvider* icon, RimGridView* view );
static void findNameAndIconFromView( QString* name, caf::IconProvider* icon, RimGridView* view );
void updateCursorPosition( const RimGridView* sourceView, const cvf::Vec3d& domainCoord );

View File

@@ -799,8 +799,8 @@ QList<caf::PdmOptionItemInfo>
options.push_back( caf::PdmOptionItemInfo( "No Trajectory Types", -1 ) );
}
}
std::vector<RimWellLogExtractionCurve::TrajectoryType> trajectoryTypes = {RimWellLogExtractionCurve::WELL_PATH,
RimWellLogExtractionCurve::SIMULATION_WELL};
std::vector<RimWellLogExtractionCurve::TrajectoryType> trajectoryTypes = { RimWellLogExtractionCurve::WELL_PATH,
RimWellLogExtractionCurve::SIMULATION_WELL };
for ( RimWellLogExtractionCurve::TrajectoryType trajectoryType : trajectoryTypes )
{
caf::PdmOptionItemInfo item( caf::AppEnum<RimWellLogExtractionCurve::TrajectoryType>::uiText( trajectoryType ),
@@ -846,7 +846,7 @@ QList<caf::PdmOptionItemInfo>
{
std::set<QString> sortedWellNames = eclipseCase->sortedSimWellNames();
caf::QIconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.png" );
for ( const QString& wname : sortedWellNames )
{
options.push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );

View File

@@ -654,7 +654,7 @@ QList<caf::PdmOptionItemInfo>
{
std::set<QString> sortedWellNames = this->sortedSimWellNames();
caf::QIconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.png" );
for ( const QString& wname : sortedWellNames )
{
options.push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );

View File

@@ -605,7 +605,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions( const c
std::set<QString> wellNames = reader->wellNames();
for ( const QString& name : wellNames )
{
options.push_back( caf::PdmOptionItemInfo( name, name, false, caf::QIconProvider( ":/Well.png" ) ) );
options.push_back( caf::PdmOptionItemInfo( name, name, false, caf::IconProvider( ":/Well.png" ) ) );
}
}
}

View File

@@ -294,7 +294,7 @@ void RimWellLogTrack::simWellOptionItems( QList<caf::PdmOptionItemInfo>* options
sortedWellNames = eclipseCase->eclipseCaseData()->findSortedWellNames();
}
caf::QIconProvider simWellIcon( ":/Well.png" );
caf::IconProvider simWellIcon( ":/Well.png" );
for ( const QString& wname : sortedWellNames )
{
options->push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) );
@@ -1930,21 +1930,21 @@ std::vector<std::pair<double, double>> RimWellLogTrack::waterAndRockRegions( Ria
}
double waterEndMD = extractor->cellIntersectionMDs().front();
double rockEndMD = extractor->cellIntersectionMDs().back();
return {{waterStartMD, waterEndMD}, {waterEndMD, rockEndMD}};
return { { waterStartMD, waterEndMD }, { waterEndMD, rockEndMD } };
}
else if ( depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH )
{
double waterStartTVD = 0.0;
double waterEndTVD = extractor->cellIntersectionTVDs().front();
double rockEndTVD = extractor->cellIntersectionTVDs().back();
return {{waterStartTVD, waterEndTVD}, {waterEndTVD, rockEndTVD}};
return { { waterStartTVD, waterEndTVD }, { waterEndTVD, rockEndTVD } };
}
else if ( depthType == RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH_RKB )
{
double waterStartTVDRKB = extractor->wellPathData()->rkbDiff();
double waterEndTVDRKB = extractor->cellIntersectionTVDs().front() + extractor->wellPathData()->rkbDiff();
double rockEndTVDRKB = extractor->cellIntersectionTVDs().back() + extractor->wellPathData()->rkbDiff();
return {{waterStartTVDRKB, waterEndTVDRKB}, {waterEndTVDRKB, rockEndTVDRKB}};
return { { waterStartTVDRKB, waterEndTVDRKB }, { waterEndTVDRKB, rockEndTVDRKB } };
}
return {};
}
@@ -2386,7 +2386,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
const std::vector<std::pair<double, double>> waterAndRockIntervals =
waterAndRockRegions( plot->depthType(), extractor );
m_annotationTool->attachNamedRegions( m_plotWidget,
{"Sea Level", ""},
{ "Sea Level", "" },
xRange,
waterAndRockIntervals,
m_regionAnnotationDisplay(),
@@ -2394,7 +2394,7 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
( ( 100 - m_colorShadingTransparency ) * 255 ) / 100,
m_showRegionLabels(),
RiuPlotAnnotationTool::LEFT_COLUMN,
{Qt::SolidPattern, Qt::Dense6Pattern} );
{ Qt::SolidPattern, Qt::Dense6Pattern } );
}
if ( m_formationSource == CASE )
@@ -2593,16 +2593,16 @@ void RimWellLogTrack::updateWellPathAttributesOnPlot()
}
const std::map<RiaDefines::WellPathComponentType, int> sortIndices =
{{RiaDefines::WellPathComponentType::WELL_PATH, 0},
{RiaDefines::WellPathComponentType::CASING, 1},
{RiaDefines::WellPathComponentType::LINER, 2},
{RiaDefines::WellPathComponentType::PERFORATION_INTERVAL, 3},
{RiaDefines::WellPathComponentType::FISHBONES, 4},
{RiaDefines::WellPathComponentType::FRACTURE, 5},
{RiaDefines::WellPathComponentType::PACKER, 6},
{RiaDefines::WellPathComponentType::ICD, 7},
{RiaDefines::WellPathComponentType::AICD, 8},
{RiaDefines::WellPathComponentType::ICV, 9}};
{ { RiaDefines::WellPathComponentType::WELL_PATH, 0 },
{ RiaDefines::WellPathComponentType::CASING, 1 },
{ RiaDefines::WellPathComponentType::LINER, 2 },
{ RiaDefines::WellPathComponentType::PERFORATION_INTERVAL, 3 },
{ RiaDefines::WellPathComponentType::FISHBONES, 4 },
{ RiaDefines::WellPathComponentType::FRACTURE, 5 },
{ RiaDefines::WellPathComponentType::PACKER, 6 },
{ RiaDefines::WellPathComponentType::ICD, 7 },
{ RiaDefines::WellPathComponentType::AICD, 8 },
{ RiaDefines::WellPathComponentType::ICV, 9 } };
std::stable_sort( allWellPathComponents.begin(),
allWellPathComponents.end(),

View File

@@ -616,7 +616,7 @@ void RimEnsembleCurveSet::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector Y" );
curveDataGroup->add( &m_yValuesSummaryCaseCollection );
curveDataGroup->add( &m_yValuesSummaryAddressUiField );
curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, {false, 1, 0} );
curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { false, 1, 0 } );
curveDataGroup->add( &m_plotAxis );
}
@@ -680,19 +680,14 @@ void RimEnsembleCurveSet::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOr
uiTreeOrdering.skipRemainingChildren( true );
caf::QIconProvider iconProvider = this->uiIconProvider();
if ( iconProvider.isNull() ) return;
caf::IconProvider iconProvider = this->uiIconProvider();
if ( !iconProvider.valid() ) return;
RimEnsembleCurveSetCollection* coll = nullptr;
this->firstAncestorOrThisOfType( coll );
if ( coll && coll->curveSetForSourceStepping() == this )
{
QPixmap updownpixmap( ":/StepUpDownCorner16x16.png" );
iconProvider.setOverlayPixmap( updownpixmap );
}
else
{
iconProvider.setOverlayPixmap( QPixmap() );
iconProvider.setOverlayResourceString( ":/StepUpDownCorner16x16.png" );
}
this->setUiIcon( iconProvider );

View File

@@ -77,8 +77,8 @@ void RimSummaryCrossPlotCollection::summaryPlotItemInfos( QList<caf::PdmOptionIt
{
for ( RimSummaryPlot* plot : m_summaryCrossPlots() )
{
caf::QIconProvider icon = plot->uiCapability()->uiIconProvider();
QString displayName = plot->description();
caf::IconProvider icon = plot->uiCapability()->uiIconProvider();
QString displayName = plot->description();
optionInfos->push_back( caf::PdmOptionItemInfo( displayName, plot, false, icon ) );
}

View File

@@ -596,22 +596,18 @@ void RimSummaryCurve::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderi
{
RimPlotCurve::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
caf::QIconProvider iconProvider = this->uiIconProvider();
if ( iconProvider.isNull() ) return;
QIcon icon = iconProvider.icon();
caf::IconProvider iconProvider = this->uiIconProvider();
if ( !iconProvider.valid() ) return;
RimSummaryCurveCollection* coll = nullptr;
this->firstAncestorOrThisOfType( coll );
if ( coll && coll->curveForSourceStepping() == this )
{
QPixmap updownpixmap( ":/StepUpDownCorner16x16.png" );
iconProvider.setOverlayPixmap( updownpixmap );
iconProvider.setOverlayResourceString( ":/StepUpDownCorner16x16.png" );
}
else
{
iconProvider.setOverlayPixmap( QPixmap() );
iconProvider.setOverlayResourceString( "" );
}
setUiIcon( iconProvider );
@@ -645,10 +641,10 @@ void RimSummaryCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
QString curveDataGroupName = "Summary Vector";
if ( isCrossPlotCurve() ) curveDataGroupName += " Y";
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword( curveDataGroupName, "Summary Vector Y" );
curveDataGroup->add( &m_yValuesSummaryCase, {true, 3, 1} );
curveDataGroup->add( &m_yValuesSummaryAddressUiField, {true, 2, 1} );
curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, {false, 1, 0} );
curveDataGroup->add( &m_plotAxis, {true, 3, 1} );
curveDataGroup->add( &m_yValuesSummaryCase, { true, 3, 1 } );
curveDataGroup->add( &m_yValuesSummaryAddressUiField, { true, 2, 1 } );
curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { false, 1, 0 } );
curveDataGroup->add( &m_plotAxis, { true, 3, 1 } );
if ( isCrossPlotCurve() )
m_showErrorBars = false;
@@ -659,9 +655,9 @@ void RimSummaryCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
if ( isCrossPlotCurve() )
{
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector X" );
curveDataGroup->add( &m_xValuesSummaryCase, {true, 3, 1} );
curveDataGroup->add( &m_xValuesSummaryAddressUiField, {true, 2, 1} );
curveDataGroup->add( &m_xPushButtonSelectSummaryAddress, {false, 1, 0} );
curveDataGroup->add( &m_xValuesSummaryCase, { true, 3, 1 } );
curveDataGroup->add( &m_xValuesSummaryAddressUiField, { true, 2, 1 } );
curveDataGroup->add( &m_xPushButtonSelectSummaryAddress, { false, 1, 0 } );
}
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );