mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor and rename QIconProvider -> IconProvider (#5893)
* Refactor and rename QIconProvider -> IconProvider * Generate icons on demand as unique_ptrs
This commit is contained in:
parent
b84e868564
commit
2e79cf614f
@ -31,7 +31,7 @@ void RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName( Rim3dView*
|
||||
|
||||
QString displayName = view->autoName();
|
||||
|
||||
caf::QIconProvider iconProvider = view->uiCapability()->uiIconProvider();
|
||||
caf::IconProvider iconProvider = view->uiCapability()->uiIconProvider();
|
||||
|
||||
optionItems->push_back( caf::PdmOptionItemInfo( displayName, view, false, iconProvider ) );
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ QList<caf::PdmOptionItemInfo> RicSelectViewUI::calculateValueOptions( const caf:
|
||||
{
|
||||
for ( Rim3dView* v : m_currentCase->views() )
|
||||
{
|
||||
caf::QIconProvider iconProvider = v->uiCapability()->uiIconProvider();
|
||||
QString displayName = v->name();
|
||||
caf::IconProvider iconProvider = v->uiCapability()->uiIconProvider();
|
||||
QString displayName = v->name();
|
||||
|
||||
options.push_back( caf::PdmOptionItemInfo( displayName, v, false, iconProvider ) );
|
||||
}
|
||||
|
@ -65,10 +65,13 @@ void RicCompareTo3dViewFeature::setupActionLook( QAction* actionToSetup )
|
||||
auto view = static_cast<Rim3dView*>( userData.value<void*>() );
|
||||
if ( view )
|
||||
{
|
||||
actionToSetup->setIcon( view->uiIconProvider().icon() );
|
||||
auto icon = view->uiIconProvider().icon();
|
||||
if ( icon ) actionToSetup->setIcon( *icon );
|
||||
}
|
||||
else
|
||||
{
|
||||
actionToSetup->setIcon( QIcon( ":/ComparisonView16x16.png" ) );
|
||||
caf::IconProvider iconProvider( ":/ComparisonView16x16.png" );
|
||||
auto icon = iconProvider.icon();
|
||||
if ( icon ) actionToSetup->setIcon( *icon );
|
||||
}
|
||||
}
|
||||
|
@ -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 ) );
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
|
@ -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 );
|
||||
|
@ -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 ) );
|
||||
|
@ -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 );
|
||||
|
@ -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 ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 ) );
|
||||
|
@ -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 );
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafIconProvider.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafQIconProvider.h"
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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 ) );
|
||||
|
@ -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 ) );
|
||||
|
@ -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" ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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(),
|
||||
|
@ -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 );
|
||||
|
@ -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 ) );
|
||||
}
|
||||
|
@ -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" );
|
||||
|
@ -61,7 +61,7 @@ class QXmlStreamWriter;
|
||||
#include "cafInternalPdmXmlFieldCapability.h"
|
||||
|
||||
#include "cafPdmUiFieldSpecialization.h"
|
||||
#include "cafQIconProvider.h"
|
||||
#include "cafIconProvider.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
|
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
|
||||
project (cafPdmUiCore)
|
||||
project (cafPdmUiCore)
|
||||
|
||||
# Unity Build
|
||||
if (CAF_ENABLE_UNITY_BUILD)
|
||||
@ -9,7 +9,7 @@ if (CAF_ENABLE_UNITY_BUILD)
|
||||
endif()
|
||||
|
||||
# These headers need to go through Qt's MOC compiler
|
||||
set (MOC_HEADER_FILES
|
||||
set (MOC_HEADER_FILES
|
||||
cafPdmUiEditorHandle.h
|
||||
cafPdmUiFieldEditorHandle.h
|
||||
cafPdmUiSelection3dEditorVisualizer.h
|
||||
@ -72,9 +72,8 @@ set( PROJECT_FILES
|
||||
cafPdmUiSelection3dEditorVisualizer.cpp
|
||||
cafQShortenedLabel.cpp
|
||||
cafQShortenedLabel.h
|
||||
cafQIconProvider.cpp
|
||||
cafQIconProvider.h
|
||||
|
||||
cafIconProvider.cpp
|
||||
cafIconProvider.h
|
||||
)
|
||||
|
||||
add_library( ${PROJECT_NAME}
|
||||
@ -92,7 +91,7 @@ target_include_directories(${PROJECT_NAME}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
if (MSVC)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4100 /wd4127")
|
||||
endif()
|
||||
|
||||
|
213
Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.cpp
Normal file
213
Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafIconProvider.cpp
Normal file
@ -0,0 +1,213 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2019- Ceetron Solutions AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
#include "cafIconProvider.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
|
||||
using namespace caf;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
IconProvider::IconProvider()
|
||||
: m_active(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
IconProvider::IconProvider(const QString& iconResourceString)
|
||||
: m_active(true)
|
||||
, m_iconResourceString(iconResourceString)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::IconProvider::IconProvider(const QPixmap& pixmap)
|
||||
: m_active(true)
|
||||
, m_pixmap(new QPixmap(pixmap))
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
IconProvider::IconProvider(const IconProvider& rhs)
|
||||
: m_active(rhs.m_active)
|
||||
, m_iconResourceString(rhs.m_iconResourceString)
|
||||
, m_overlayResourceString(rhs.m_overlayResourceString)
|
||||
, m_backgroundColorString(rhs.m_backgroundColorString)
|
||||
{
|
||||
copyPixmap(rhs);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
IconProvider& IconProvider::operator=(const IconProvider& rhs)
|
||||
{
|
||||
m_active = rhs.m_active;
|
||||
m_iconResourceString = rhs.m_iconResourceString;
|
||||
m_overlayResourceString = rhs.m_overlayResourceString;
|
||||
m_backgroundColorString = rhs.m_backgroundColorString;
|
||||
copyPixmap(rhs);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void IconProvider::setActive(bool active)
|
||||
{
|
||||
m_active = active;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<QIcon> IconProvider::icon(const QSize& size /*= QSize(16, 16)*/) const
|
||||
{
|
||||
if (!isGuiApplication())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (m_pixmap) return std::unique_ptr<QIcon>(new QIcon(*m_pixmap));
|
||||
|
||||
QPixmap pixmap(size);
|
||||
|
||||
if (!m_backgroundColorString.isEmpty() && QColor::isValidColor(m_backgroundColorString))
|
||||
{
|
||||
pixmap.fill(QColor(m_backgroundColorString));
|
||||
}
|
||||
else pixmap.fill(Qt::transparent);
|
||||
|
||||
if (!m_iconResourceString.isEmpty())
|
||||
{
|
||||
QPixmap iconPixmap = QIcon(m_iconResourceString).pixmap(size, m_active ? QIcon::Normal : QIcon::Disabled);
|
||||
QPainter painter(&pixmap);
|
||||
painter.drawPixmap(0, 0, iconPixmap);
|
||||
}
|
||||
|
||||
if (!m_overlayResourceString.isEmpty())
|
||||
{
|
||||
QPixmap overlayPixmap = QIcon(m_overlayResourceString).pixmap(size, m_active ? QIcon::Normal : QIcon::Disabled);
|
||||
QPainter painter(&pixmap);
|
||||
painter.drawPixmap(0, 0, overlayPixmap);
|
||||
}
|
||||
|
||||
return std::unique_ptr<QIcon>(new QIcon(pixmap));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void IconProvider::setIconResourceString(const QString& iconResourceString)
|
||||
{
|
||||
m_iconResourceString = iconResourceString;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void IconProvider::setOverlayResourceString(const QString& overlayResourceString)
|
||||
{
|
||||
m_overlayResourceString = overlayResourceString;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void IconProvider::setBackgroundColorString(const QString& colorName)
|
||||
{
|
||||
m_backgroundColorString = colorName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::IconProvider::valid() const
|
||||
{
|
||||
if (isGuiApplication())
|
||||
{
|
||||
if (m_pixmap && !m_pixmap->isNull()) return true;
|
||||
|
||||
if (!m_backgroundColorString.isEmpty() && QColor::isValidColor(m_backgroundColorString))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!m_iconResourceString.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Use a pixmap instead of the resource strings.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::IconProvider::setPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
m_pixmap.reset(new QPixmap(pixmap));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::IconProvider::isGuiApplication()
|
||||
{
|
||||
return dynamic_cast<QApplication*>(QCoreApplication::instance()) != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void IconProvider::copyPixmap(const IconProvider& rhs)
|
||||
{
|
||||
if (rhs.m_pixmap)
|
||||
{
|
||||
m_pixmap = std::unique_ptr<QPixmap>(new QPixmap(*rhs.m_pixmap));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2019- Ceetron Solutions AS
|
||||
// Copyright (C) 2020- Ceetron Solutions AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
@ -37,47 +37,50 @@
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class QIcon;
|
||||
class QPixmap;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
//==================================================================================================
|
||||
/// Utility class to provide QIcons when required. Qt crashes if a non-empty QIcon is created
|
||||
/// Utility class to provide Icons when required. Qt crashes if a non-empty QIcon is created
|
||||
/// ... without a GUI Application running. So create the icon on demand instead.
|
||||
//==================================================================================================
|
||||
class QIconProvider
|
||||
class IconProvider
|
||||
{
|
||||
public:
|
||||
QIconProvider();
|
||||
QIconProvider(const QString& iconResourceString);
|
||||
QIconProvider(const QPixmap& pixmap);
|
||||
QIconProvider(const QIconProvider& rhs);
|
||||
QIconProvider& operator=(const QIconProvider& rhs);
|
||||
IconProvider();
|
||||
IconProvider(const QString& iconResourceString);
|
||||
IconProvider(const QPixmap& pixmap);
|
||||
IconProvider(const IconProvider& rhs);
|
||||
IconProvider& operator=(const IconProvider& rhs);
|
||||
|
||||
void setActive(bool active);
|
||||
bool valid() const;
|
||||
|
||||
QIcon icon() const;
|
||||
virtual bool isNull() const;
|
||||
void setActive(bool active);
|
||||
void setIconResourceString(const QString& iconResourceString);
|
||||
void setPixmap(const QPixmap& pixmap);
|
||||
void setOverlayPixmap(const QPixmap& pixmap);
|
||||
void setBackgroundColor(const QColor& color);
|
||||
std::unique_ptr<QIcon> icon(const QSize& size = QSize(16, 16)) const;
|
||||
|
||||
protected:
|
||||
bool hasValidPixmap() const;
|
||||
virtual QIcon generateIcon() const;
|
||||
static bool isGuiApplication();
|
||||
void setIconResourceString(const QString& iconResourceString);
|
||||
void setOverlayResourceString(const QString& overlayResourceString);
|
||||
void setBackgroundColorString(const QString& colorName);
|
||||
|
||||
void setPixmap(const QPixmap& pixmap);
|
||||
|
||||
private:
|
||||
void copyPixmaps(const QIconProvider& other);
|
||||
static bool isGuiApplication();
|
||||
void copyPixmap(const IconProvider& rhs);
|
||||
private:
|
||||
bool m_active;
|
||||
|
||||
protected:
|
||||
QString m_iconResourceString;
|
||||
std::unique_ptr<QPixmap> m_iconPixmap;
|
||||
std::unique_ptr<QPixmap> m_overlayPixmap;
|
||||
QColor m_backgoundColor;
|
||||
mutable QIcon m_icon;
|
||||
bool m_active;
|
||||
QString m_overlayResourceString;
|
||||
QString m_backgroundColorString;
|
||||
|
||||
std::unique_ptr<QPixmap> m_pixmap;
|
||||
};
|
||||
}
|
@ -174,10 +174,10 @@ void PdmUiFieldEditorHandle::updateLabelFromField(QShortenedLabel* label, const
|
||||
const PdmUiFieldHandle* fieldHandle = dynamic_cast<const PdmUiFieldHandle*>(pdmItem());
|
||||
if (fieldHandle)
|
||||
{
|
||||
QIcon ic = fieldHandle->uiIcon(uiConfigName);
|
||||
if (!ic.isNull())
|
||||
auto ic = fieldHandle->uiIcon(uiConfigName);
|
||||
if (ic)
|
||||
{
|
||||
label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
|
||||
label->setPixmap(ic->pixmap(ic->actualSize(QSize(64, 64))));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ namespace caf
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiItemInfo::PdmUiItemInfo(const QString& uiName,
|
||||
QIconProvider iconProvider /*= QIconProvider() */,
|
||||
IconProvider iconProvider /*= IconProvider() */,
|
||||
QString toolTip /*= ""*/,
|
||||
QString whatsThis /*= ""*/,
|
||||
QString extraDebugText /*= ""*/)
|
||||
@ -90,7 +90,7 @@ PdmUiItemInfo::PdmUiItemInfo(const QString& uiName,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QIcon PdmUiItemInfo::icon() const
|
||||
std::unique_ptr<QIcon> PdmUiItemInfo::icon() const
|
||||
{
|
||||
return m_iconProvider.icon();
|
||||
}
|
||||
@ -98,7 +98,7 @@ QIcon PdmUiItemInfo::icon() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QIconProvider& PdmUiItemInfo::iconProvider() const
|
||||
const IconProvider& PdmUiItemInfo::iconProvider() const
|
||||
{
|
||||
return m_iconProvider;
|
||||
}
|
||||
@ -109,7 +109,7 @@ const QIconProvider& PdmUiItemInfo::iconProvider() const
|
||||
PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText,
|
||||
const QVariant& aValue,
|
||||
bool isReadOnly /* = false */,
|
||||
const QIconProvider& anIcon /* = QIconProvider()*/)
|
||||
const IconProvider& anIcon /* = IconProvider()*/)
|
||||
: m_optionUiText(anOptionUiText)
|
||||
, m_value(aValue)
|
||||
, m_isReadOnly(isReadOnly)
|
||||
@ -124,7 +124,7 @@ PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText,
|
||||
PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText,
|
||||
caf::PdmObjectHandle* obj,
|
||||
bool isReadOnly /*= false*/,
|
||||
const QIconProvider& anIcon /*= QIconProvider()*/)
|
||||
const IconProvider& anIcon /*= IconProvider()*/)
|
||||
: m_optionUiText(anOptionUiText)
|
||||
, m_isReadOnly(isReadOnly)
|
||||
, m_iconProvider(anIcon)
|
||||
@ -137,7 +137,7 @@ PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText,
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmOptionItemInfo
|
||||
PdmOptionItemInfo::createHeader(const QString& anOptionUiText, bool isReadOnly /*= false*/, const QIconProvider& anIcon /*= QIconProvider()*/)
|
||||
PdmOptionItemInfo::createHeader(const QString& anOptionUiText, bool isReadOnly /*= false*/, const IconProvider& anIcon /*= IconProvider()*/)
|
||||
{
|
||||
PdmOptionItemInfo header(anOptionUiText, QVariant(), isReadOnly, anIcon);
|
||||
|
||||
@ -187,7 +187,7 @@ bool PdmOptionItemInfo::isHeading() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QIcon PdmOptionItemInfo::icon() const
|
||||
std::unique_ptr<QIcon> PdmOptionItemInfo::icon() const
|
||||
{
|
||||
return m_iconProvider.icon();
|
||||
}
|
||||
@ -248,7 +248,7 @@ void PdmUiItem::setUiName(const QString& uiName, const QString& uiConfigName /*=
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QIcon PdmUiItem::uiIcon(const QString& uiConfigName) const
|
||||
std::unique_ptr<QIcon> PdmUiItem::uiIcon(const QString& uiConfigName) const
|
||||
{
|
||||
return uiIconProvider(uiConfigName).icon();
|
||||
}
|
||||
@ -256,22 +256,22 @@ const QIcon PdmUiItem::uiIcon(const QString& uiConfigName) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QIconProvider PdmUiItem::uiIconProvider(const QString& uiConfigName) const
|
||||
const IconProvider PdmUiItem::uiIconProvider(const QString& uiConfigName) const
|
||||
{
|
||||
const PdmUiItemInfo* conInfo = configInfo(uiConfigName);
|
||||
const PdmUiItemInfo* defInfo = defaultInfo();
|
||||
const PdmUiItemInfo* sttInfo = m_staticItemInfo;
|
||||
|
||||
if (conInfo && !(conInfo->iconProvider().isNull())) return conInfo->iconProvider();
|
||||
if (defInfo && !(defInfo->iconProvider().isNull())) return defInfo->iconProvider();
|
||||
if (sttInfo && !(sttInfo->iconProvider().isNull())) return sttInfo->iconProvider();
|
||||
if (conInfo && conInfo->iconProvider().valid()) return conInfo->iconProvider();
|
||||
if (defInfo && defInfo->iconProvider().valid()) return defInfo->iconProvider();
|
||||
if (sttInfo && sttInfo->iconProvider().valid()) return sttInfo->iconProvider();
|
||||
|
||||
return QIconProvider();
|
||||
return IconProvider();
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiItem::setUiIcon(const QIconProvider& uiIconProvider, const QString& uiConfigName /*= ""*/)
|
||||
void PdmUiItem::setUiIcon(const IconProvider& uiIconProvider, const QString& uiConfigName /*= ""*/)
|
||||
{
|
||||
m_configItemInfos[uiConfigName].m_iconProvider = uiIconProvider;
|
||||
}
|
||||
@ -281,7 +281,7 @@ void PdmUiItem::setUiIcon(const QIconProvider& uiIconProvider, const QString& ui
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiItem::setUiIconFromResourceString(const QString& uiIconResourceName, const QString& uiConfigName /*= ""*/)
|
||||
{
|
||||
setUiIcon(caf::QIconProvider(uiIconResourceName), uiConfigName);
|
||||
setUiIcon(caf::IconProvider(uiIconResourceName), uiConfigName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -653,7 +653,7 @@ PdmUiItem::PdmUiItem()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiItem::updateUiIconFromState(bool isActive, const QString& uiConfigName)
|
||||
{
|
||||
QIconProvider normalIconProvider = this->uiIconProvider(uiConfigName);
|
||||
IconProvider normalIconProvider = this->uiIconProvider(uiConfigName);
|
||||
normalIconProvider.setActive(isActive);
|
||||
this->setUiIcon(normalIconProvider, uiConfigName);
|
||||
}
|
||||
|
@ -38,9 +38,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmUiFieldSpecialization.h"
|
||||
#include "cafQIconProvider.h"
|
||||
#include "cafIconProvider.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <set>
|
||||
@ -80,18 +81,18 @@ public:
|
||||
QString extraDebugText = "");
|
||||
|
||||
PdmUiItemInfo(const QString& uiName,
|
||||
QIconProvider iconProvider = QIconProvider(),
|
||||
IconProvider iconProvider = IconProvider(),
|
||||
QString toolTip = "",
|
||||
QString whatsThis = "",
|
||||
QString extraDebugText = "");
|
||||
|
||||
QIcon icon() const;
|
||||
const QIconProvider& iconProvider() const;
|
||||
std::unique_ptr<QIcon> icon() const;
|
||||
const IconProvider& iconProvider() const;
|
||||
|
||||
private:
|
||||
friend class PdmUiItem;
|
||||
QString m_uiName;
|
||||
QIconProvider m_iconProvider;
|
||||
IconProvider m_iconProvider;
|
||||
QColor m_contentTextColor; ///< Color of a fields value text. Invalid by default. An Invalid color is not used.
|
||||
QString m_toolTip;
|
||||
QString m_whatsThis;
|
||||
@ -116,14 +117,14 @@ public:
|
||||
// Note the extra dummy parameter. This ensures compilation fails for non-enum types and these variants get removed
|
||||
// due to SFINAE (https://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error)
|
||||
template<typename T>
|
||||
PdmOptionItemInfo(const QString& anOptionUiText, T aValue, bool isReadOnly = false, const QIconProvider& anIcon = QIconProvider(), typename std::enable_if<std::is_enum<T>::value>::type* = 0)
|
||||
PdmOptionItemInfo(const QString& anOptionUiText, T aValue, bool isReadOnly = false, const IconProvider& anIcon = IconProvider(), typename std::enable_if<std::is_enum<T>::value>::type* = 0)
|
||||
: PdmOptionItemInfo(anOptionUiText, QVariant(static_cast<int>(aValue)), isReadOnly, anIcon)
|
||||
{
|
||||
}
|
||||
PdmOptionItemInfo(const QString& anOptionUiText, const QVariant& aValue, bool isReadOnly = false, const QIconProvider& anIcon = QIconProvider());
|
||||
PdmOptionItemInfo(const QString& anOptionUiText, caf::PdmObjectHandle* obj, bool isReadOnly = false, const QIconProvider& anIcon = QIconProvider());
|
||||
PdmOptionItemInfo(const QString& anOptionUiText, const QVariant& aValue, bool isReadOnly = false, const IconProvider& anIcon = IconProvider());
|
||||
PdmOptionItemInfo(const QString& anOptionUiText, caf::PdmObjectHandle* obj, bool isReadOnly = false, const IconProvider& anIcon = IconProvider());
|
||||
|
||||
static PdmOptionItemInfo createHeader(const QString& anOptionUiText, bool isReadOnly = false, const QIconProvider& anIcon = QIconProvider());
|
||||
static PdmOptionItemInfo createHeader(const QString& anOptionUiText, bool isReadOnly = false, const IconProvider& anIcon = IconProvider());
|
||||
|
||||
void setLevel(int level);
|
||||
|
||||
@ -131,7 +132,7 @@ public:
|
||||
const QVariant value() const;
|
||||
bool isReadOnly() const;
|
||||
bool isHeading() const;
|
||||
const QIcon icon() const;
|
||||
std::unique_ptr<QIcon> icon() const;
|
||||
int level() const;
|
||||
|
||||
|
||||
@ -147,7 +148,7 @@ private:
|
||||
QString m_optionUiText;
|
||||
QVariant m_value;
|
||||
bool m_isReadOnly;
|
||||
QIconProvider m_iconProvider;
|
||||
IconProvider m_iconProvider;
|
||||
int m_level;
|
||||
};
|
||||
|
||||
@ -234,10 +235,10 @@ public:
|
||||
const QString uiName(const QString& uiConfigName = "") const;
|
||||
void setUiName(const QString& uiName, const QString& uiConfigName = "");
|
||||
|
||||
const QIcon uiIcon(const QString& uiConfigName = "") const;
|
||||
const QIconProvider uiIconProvider(const QString& uiConfigName = "") const;
|
||||
void setUiIcon(const QIconProvider& uiIcon, const QString& uiConfigName = "");
|
||||
void setUiIconFromResourceString(const QString& uiIconResourceName, const QString& uiConfigName = "");
|
||||
std::unique_ptr<QIcon> uiIcon(const QString& uiConfigName = "") const;
|
||||
const IconProvider uiIconProvider(const QString& uiConfigName = "") const;
|
||||
void setUiIcon(const IconProvider& uiIcon, const QString& uiConfigName = "");
|
||||
void setUiIconFromResourceString(const QString& uiIconResourceName, const QString& uiConfigName = "");
|
||||
|
||||
const QColor uiContentTextColor(const QString& uiConfigName = "") const;
|
||||
void setUiContentTextColor(const QColor& uiIcon, const QString& uiConfigName = "");
|
||||
|
@ -179,7 +179,7 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(const QString & title, const QString& iconR
|
||||
{
|
||||
m_uiItem = new PdmUiItem();
|
||||
m_uiItem->setUiName(title);
|
||||
m_uiItem->setUiIcon(QIconProvider(iconResourceName));
|
||||
m_uiItem->setUiIcon(IconProvider(iconResourceName));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -1,212 +0,0 @@
|
||||
#include "cafQIconProvider.h"
|
||||
|
||||
#include "cafAssert.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
|
||||
using namespace caf;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QIconProvider::QIconProvider()
|
||||
: m_active(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QIconProvider::QIconProvider(const QString& iconResourceString)
|
||||
: m_active(true)
|
||||
, m_iconResourceString(iconResourceString)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QIconProvider::QIconProvider(const QPixmap& pixmap)
|
||||
: m_active(true)
|
||||
, m_iconPixmap(new QPixmap(pixmap))
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QIconProvider::QIconProvider(const QIconProvider& rhs)
|
||||
: m_icon(rhs.m_icon)
|
||||
, m_active(rhs.m_active)
|
||||
, m_iconResourceString(rhs.m_iconResourceString)
|
||||
, m_backgoundColor(rhs.m_backgoundColor)
|
||||
{
|
||||
copyPixmaps(rhs);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QIconProvider& QIconProvider::operator=(const QIconProvider& rhs)
|
||||
{
|
||||
m_icon = rhs.m_icon;
|
||||
m_active = rhs.m_active;
|
||||
m_iconResourceString = rhs.m_iconResourceString;
|
||||
m_backgoundColor = rhs.m_backgoundColor;
|
||||
|
||||
copyPixmaps(rhs);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QIcon QIconProvider::icon() const
|
||||
{
|
||||
if (m_icon.isNull())
|
||||
{
|
||||
m_icon = generateIcon();
|
||||
}
|
||||
|
||||
if (!m_active && isGuiApplication())
|
||||
{
|
||||
QPixmap disabledPixmap = m_icon.pixmap(16, 16, QIcon::Disabled);
|
||||
return QIcon(disabledPixmap);
|
||||
}
|
||||
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool QIconProvider::isNull() const
|
||||
{
|
||||
return !isGuiApplication();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QIconProvider::setActive(bool active)
|
||||
{
|
||||
m_active = active;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QIconProvider::setIconResourceString(const QString& iconResourceString)
|
||||
{
|
||||
m_iconResourceString = iconResourceString;
|
||||
m_icon = QIcon();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QIconProvider::setPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
m_iconPixmap.reset(new QPixmap(pixmap));
|
||||
m_icon = QIcon();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Generate the actual icon. Will generate a NULL-icon if a QtGuiApplication isn't running.
|
||||
/// Override in a sub-class if you want to generate a custom icon procedurally
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QIcon QIconProvider::generateIcon() const
|
||||
{
|
||||
if (!isGuiApplication())
|
||||
{
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
QIcon generatedIcon;
|
||||
|
||||
if (m_backgoundColor.isValid())
|
||||
{
|
||||
QPixmap pixmap(16,16);
|
||||
pixmap.fill(m_backgoundColor);
|
||||
|
||||
generatedIcon = QIcon(pixmap);
|
||||
}
|
||||
else if (hasValidPixmap())
|
||||
{
|
||||
generatedIcon = QIcon(*m_iconPixmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
generatedIcon = QIcon(m_iconResourceString);
|
||||
}
|
||||
|
||||
if (m_overlayPixmap && !m_overlayPixmap->isNull())
|
||||
{
|
||||
QPixmap pixmap;
|
||||
pixmap = generatedIcon.pixmap(16, 16, QIcon::Normal);
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.drawPixmap(0, 0, *m_overlayPixmap);
|
||||
|
||||
generatedIcon = QIcon(pixmap);
|
||||
}
|
||||
|
||||
return generatedIcon;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool QIconProvider::isGuiApplication()
|
||||
{
|
||||
return dynamic_cast<QApplication*>(QCoreApplication::instance()) != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool QIconProvider::hasValidPixmap() const
|
||||
{
|
||||
return m_iconPixmap && !m_iconPixmap->isNull();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::QIconProvider::setOverlayPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
m_overlayPixmap.reset(new QPixmap(pixmap));
|
||||
m_icon = QIcon();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::QIconProvider::setBackgroundColor(const QColor& color)
|
||||
{
|
||||
if (m_backgoundColor != color)
|
||||
{
|
||||
m_backgoundColor = color;
|
||||
m_icon = QIcon();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::QIconProvider::copyPixmaps(const QIconProvider& other)
|
||||
{
|
||||
if (other.m_iconPixmap)
|
||||
{
|
||||
m_iconPixmap.reset(new QPixmap(*other.m_iconPixmap));
|
||||
}
|
||||
|
||||
if (other.m_overlayPixmap)
|
||||
{
|
||||
m_overlayPixmap.reset(new QPixmap(*other.m_overlayPixmap));
|
||||
}
|
||||
}
|
@ -212,7 +212,7 @@ public:
|
||||
options.push_back(caf::PdmOptionItemInfo(text, text));
|
||||
|
||||
text = "Second";
|
||||
options.push_back(caf::PdmOptionItemInfo::createHeader(text, false, caf::QIconProvider(":/images/win/textbold.png")));
|
||||
options.push_back(caf::PdmOptionItemInfo::createHeader(text, false, caf::IconProvider(":/images/win/textbold.png")));
|
||||
|
||||
{
|
||||
text = "Second_a";
|
||||
@ -224,7 +224,7 @@ public:
|
||||
{
|
||||
text = "Second_b";
|
||||
caf::PdmOptionItemInfo itemInfo =
|
||||
caf::PdmOptionItemInfo(text, text, false, caf::QIconProvider(":/images/win/filenew.png"));
|
||||
caf::PdmOptionItemInfo(text, text, false, caf::IconProvider(":/images/win/filenew.png"));
|
||||
itemInfo.setLevel(1);
|
||||
options.push_back(itemInfo);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ QList<caf::PdmOptionItemInfo> ManyGroups::calculateValueOptions(const caf::PdmFi
|
||||
options.push_back(caf::PdmOptionItemInfo(text, text));
|
||||
|
||||
text = "Second";
|
||||
options.push_back(caf::PdmOptionItemInfo::createHeader(text, false, caf::QIconProvider(":/images/win/textbold.png")));
|
||||
options.push_back(caf::PdmOptionItemInfo::createHeader(text, false, caf::IconProvider(":/images/win/textbold.png")));
|
||||
|
||||
{
|
||||
text = "Second_a";
|
||||
@ -147,7 +147,7 @@ QList<caf::PdmOptionItemInfo> ManyGroups::calculateValueOptions(const caf::PdmFi
|
||||
{
|
||||
text = "Second_b";
|
||||
caf::PdmOptionItemInfo itemInfo =
|
||||
caf::PdmOptionItemInfo(text, text, false, caf::QIconProvider(":/images/win/filenew.png"));
|
||||
caf::PdmOptionItemInfo(text, text, false, caf::IconProvider(":/images/win/filenew.png"));
|
||||
itemInfo.setLevel(1);
|
||||
options.push_back(itemInfo);
|
||||
}
|
||||
|
@ -55,12 +55,12 @@ void TapCvfSpecialization::defineEditorAttribute(const caf::PdmFieldHandle* fiel
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void TapCvfSpecialization::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
caf::QIconProvider iconProvider = this->uiIconProvider();
|
||||
caf::IconProvider iconProvider = this->uiIconProvider();
|
||||
|
||||
cvf::Color3f cvfColor = m_colorField();
|
||||
QColor qcolor(cvfColor.rByte(), cvfColor.gByte(), cvfColor.bByte());
|
||||
|
||||
iconProvider.setBackgroundColor(qcolor);
|
||||
iconProvider.setBackgroundColorString(qcolor.name());
|
||||
|
||||
this->setUiIcon(iconProvider);
|
||||
}
|
||||
|
@ -71,9 +71,10 @@ void PdmUiActionPushButtonEditor::configureAndUpdateUi( const QString& uiConfigN
|
||||
|
||||
m_buttonLayout->setAlignment(Qt::AlignRight);
|
||||
|
||||
if( !uiField()->uiIcon( uiConfigName ).isNull() )
|
||||
auto icon = uiField()->uiIcon(uiConfigName);
|
||||
if( icon )
|
||||
{
|
||||
m_pushButton->setIcon( uiField()->uiIcon( uiConfigName ) );
|
||||
m_pushButton->setIcon( *icon );
|
||||
m_pushButton->setMaximumWidth(m_pushButton->sizeHint().width());
|
||||
}
|
||||
else
|
||||
|
@ -211,7 +211,11 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
{
|
||||
for (const auto& option : options)
|
||||
{
|
||||
m_comboBox->addItem(option.icon(), option.optionUiText());
|
||||
auto icon = option.icon();
|
||||
if (icon)
|
||||
m_comboBox->addItem(*icon, option.optionUiText());
|
||||
else
|
||||
m_comboBox->addItem(option.optionUiText());
|
||||
m_comboBox->setIconSize(m_attributes.iconSize);
|
||||
}
|
||||
m_comboBox->setCurrentIndex(uiField()->uiValue().toInt());
|
||||
|
@ -184,15 +184,16 @@ void PdmUiTableViewEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
if (childArrayFH && childArrayFH->uiCapability())
|
||||
{
|
||||
QString text = "";
|
||||
if ( childArrayFH->uiCapability()->uiIcon(uiConfigName).isNull() )
|
||||
auto icon = childArrayFH->uiCapability()->uiIcon(uiConfigName);
|
||||
if ( icon )
|
||||
{
|
||||
m_tableHeadingIcon->setText(childArrayFH->uiCapability()->uiName(uiConfigName) + QString(" (%1)").arg(childArrayFH->size()));
|
||||
m_tableHeading->setText("");
|
||||
m_tableHeadingIcon->setPixmap(icon->pixmap(16, 16));
|
||||
m_tableHeading->setText(childArrayFH->uiCapability()->uiName(uiConfigName) + QString(" (%1)").arg(childArrayFH->size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tableHeadingIcon->setPixmap(childArrayFH->uiCapability()->uiIcon(uiConfigName).pixmap(16, 16));
|
||||
m_tableHeading->setText(childArrayFH->uiCapability()->uiName(uiConfigName) + QString(" (%1)").arg(childArrayFH->size()));
|
||||
m_tableHeadingIcon->setText(childArrayFH->uiCapability()->uiName(uiConfigName) + QString(" (%1)").arg(childArrayFH->size()));
|
||||
m_tableHeading->setText("");
|
||||
}
|
||||
m_tableModelPdm->createPersistentPushButtonWidgets(m_tableView);
|
||||
}
|
||||
|
@ -56,10 +56,10 @@ void PdmUiToolButtonEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
{
|
||||
CAF_ASSERT(!m_toolButton.isNull());
|
||||
|
||||
QIcon ic = uiField()->uiIcon(uiConfigName);
|
||||
if (!ic.isNull())
|
||||
auto ic = uiField()->uiIcon(uiConfigName);
|
||||
if (ic)
|
||||
{
|
||||
m_toolButton->setIcon(ic);
|
||||
m_toolButton->setIcon(*ic);
|
||||
}
|
||||
|
||||
QString buttonText = uiField()->uiName(uiConfigName);
|
||||
|
@ -356,7 +356,8 @@ QVariant caf::PdmUiTreeSelectionQModel::data(const QModelIndex &index, int role
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
return optionItemInfo->icon();
|
||||
auto icon = optionItemInfo->icon();
|
||||
return icon ? *icon : QIcon();
|
||||
}
|
||||
else if (role == Qt::CheckStateRole && !optionItemInfo->isHeading())
|
||||
{
|
||||
|
@ -631,7 +631,8 @@ QVariant PdmUiTreeViewQModel::data(const QModelIndex &index, int role ) const
|
||||
{
|
||||
if (uitreeOrdering->activeItem())
|
||||
{
|
||||
return uitreeOrdering->activeItem()->uiIcon();
|
||||
auto icon = uitreeOrdering->activeItem()->uiIcon();
|
||||
return icon ? *icon : QIcon();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user