Don't mandate ownership semantics in API

This API doesn't transfer ownership, so no smart pointers are required --
this just needlessly tightens requirements on the user of the interface.

(Fixes five instances of MSVC C26410 warning)
This commit is contained in:
Simon Richter 2020-01-17 12:56:07 +01:00 committed by Seth Hillbrand
parent fdaaa0a704
commit 95c2b261e8
6 changed files with 32 additions and 35 deletions

View File

@ -125,8 +125,8 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
} }
} }
setupViewLayers( view, m_settings.m_layerSet ); setupViewLayers( *view, m_settings.m_layerSet );
setupPainter( painter ); setupPainter( *painter );
auto sheetSizeMils = m_settings.m_pageInfo.GetSizeMils(); auto sheetSizeMils = m_settings.m_pageInfo.GetSizeMils();
VECTOR2I sheetSizeIU( milsToIU( sheetSizeMils.GetWidth() ), milsToIU( sheetSizeMils.GetHeight() ) ); VECTOR2I sheetSizeIU( milsToIU( sheetSizeMils.GetWidth() ), milsToIU( sheetSizeMils.GetHeight() ) );
@ -181,23 +181,22 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
} }
void BOARD_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView, void BOARD_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet )
const LSET& aLayerSet )
{ {
// Disable all layers by default, let specific implementions enable required layers // Disable all layers by default, let specific implementions enable required layers
for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; ++i ) for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; ++i )
{ {
aView->SetLayerVisible( i, false ); aView.SetLayerVisible( i, false );
aView->SetTopLayer( i, false ); aView.SetTopLayer( i, false );
aView->SetLayerTarget( i, KIGFX::TARGET_NONCACHED ); aView.SetLayerTarget( i, KIGFX::TARGET_NONCACHED );
} }
} }
void BOARD_PRINTOUT::setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter ) void BOARD_PRINTOUT::setupPainter( KIGFX::PAINTER& aPainter )
{ {
if( !m_settings.m_background ) if( !m_settings.m_background )
aPainter->GetSettings()->SetBackgroundColor( COLOR4D::WHITE ); aPainter.GetSettings()->SetBackgroundColor( COLOR4D::WHITE );
} }

View File

@ -85,13 +85,12 @@ int GERBVIEW_PRINTOUT::milsToIU( double aMils ) const
} }
void GERBVIEW_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView, void GERBVIEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet )
const LSET& aLayerSet )
{ {
BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet ); BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet );
for( LSEQ layerSeq = m_settings.m_layerSet.Seq(); layerSeq; ++layerSeq ) for( LSEQ layerSeq = m_settings.m_layerSet.Seq(); layerSeq; ++layerSeq )
aView->SetLayerVisible( GERBVIEW_LAYER_ID_START + *layerSeq, true ); aView.SetLayerVisible( GERBVIEW_LAYER_ID_START + *layerSeq, true );
} }

View File

@ -35,7 +35,7 @@ public:
protected: protected:
int milsToIU( double aMils ) const override; int milsToIU( double aMils ) const override;
void setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView, const LSET& aLayerSet ) override; void setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet ) override;
void setupGal( KIGFX::GAL* aGal ) override; void setupGal( KIGFX::GAL* aGal ) override;

View File

@ -96,10 +96,10 @@ protected:
virtual int milsToIU( double aMils ) const = 0; virtual int milsToIU( double aMils ) const = 0;
///> Enables layers visibility for a printout ///> Enables layers visibility for a printout
virtual void setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView, const LSET& aLayerSet ); virtual void setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet );
///> Configures PAINTER object for a printout ///> Configures PAINTER object for a printout
virtual void setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter ); virtual void setupPainter( KIGFX::PAINTER& aPainter );
///> Configures GAL object for a printout ///> Configures GAL object for a printout
virtual void setupGal( KIGFX::GAL* aGal ); virtual void setupGal( KIGFX::GAL* aGal );

View File

@ -124,27 +124,26 @@ int PCBNEW_PRINTOUT::milsToIU( double aMils ) const
} }
void PCBNEW_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView, void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet )
const LSET& aLayerSet )
{ {
BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet ); BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet );
for( LSEQ layerSeq = m_settings.m_layerSet.Seq(); layerSeq; ++layerSeq ) for( LSEQ layerSeq = m_settings.m_layerSet.Seq(); layerSeq; ++layerSeq )
aView->SetLayerVisible( PCBNEW_LAYER_ID_START + *layerSeq, true ); aView.SetLayerVisible( PCBNEW_LAYER_ID_START + *layerSeq, true );
// Enable pad layers corresponding to the selected copper layers // Enable pad layers corresponding to the selected copper layers
if( aLayerSet.test( F_Cu ) ) if( aLayerSet.test( F_Cu ) )
aView->SetLayerVisible( LAYER_PAD_FR, true ); aView.SetLayerVisible( LAYER_PAD_FR, true );
if( aLayerSet.test( B_Cu ) ) if( aLayerSet.test( B_Cu ) )
aView->SetLayerVisible( LAYER_PAD_BK, true ); aView.SetLayerVisible( LAYER_PAD_BK, true );
if( ( aLayerSet & LSET::AllCuMask() ).any() ) // Items visible on any copper layer if( ( aLayerSet & LSET::AllCuMask() ).any() ) // Items visible on any copper layer
{ {
// Enable items on copper layers, but do not draw holes // Enable items on copper layers, but do not draw holes
for( GAL_LAYER_ID item : { LAYER_PADS_TH, LAYER_VIAS } ) for( GAL_LAYER_ID item : { LAYER_PADS_TH, LAYER_VIAS } )
{ {
aView->SetLayerVisible( item, true ); aView.SetLayerVisible( item, true );
} }
if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE ) if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE )
@ -153,8 +152,8 @@ void PCBNEW_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView
for( GAL_LAYER_ID holeLayer : { LAYER_PADS_PLATEDHOLES, LAYER_NON_PLATEDHOLES, for( GAL_LAYER_ID holeLayer : { LAYER_PADS_PLATEDHOLES, LAYER_NON_PLATEDHOLES,
LAYER_VIAS_HOLES } ) LAYER_VIAS_HOLES } )
{ {
aView->SetLayerVisible( holeLayer, true ); aView.SetLayerVisible( holeLayer, true );
aView->SetTopLayer( holeLayer, true ); aView.SetTopLayer( holeLayer, true );
} }
} }
} }
@ -168,37 +167,37 @@ void PCBNEW_PRINTOUT::setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView
}; };
for( int item : alwaysEnabled ) for( int item : alwaysEnabled )
aView->SetLayerVisible( item, true ); aView.SetLayerVisible( item, true );
} }
void PCBNEW_PRINTOUT::setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter ) void PCBNEW_PRINTOUT::setupPainter( KIGFX::PAINTER& aPainter )
{ {
BOARD_PRINTOUT::setupPainter( aPainter ); BOARD_PRINTOUT::setupPainter( aPainter );
KIGFX::PCB_PRINT_PAINTER* painter = static_cast<KIGFX::PCB_PRINT_PAINTER*>( aPainter.get() ); KIGFX::PCB_PRINT_PAINTER& painter = dynamic_cast<KIGFX::PCB_PRINT_PAINTER&>( aPainter );
switch( m_pcbnewSettings.m_drillMarks ) switch( m_pcbnewSettings.m_drillMarks )
{ {
case PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE: case PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE:
painter->SetDrillMarks( false, 0 ); painter.SetDrillMarks( false, 0 );
break; break;
case PCBNEW_PRINTOUT_SETTINGS::SMALL_DRILL_SHAPE: case PCBNEW_PRINTOUT_SETTINGS::SMALL_DRILL_SHAPE:
painter->SetDrillMarks( false, Millimeter2iu( 0.3 ) ); painter.SetDrillMarks( false, Millimeter2iu( 0.3 ) );
break; break;
case PCBNEW_PRINTOUT_SETTINGS::FULL_DRILL_SHAPE: case PCBNEW_PRINTOUT_SETTINGS::FULL_DRILL_SHAPE:
painter->SetDrillMarks( true ); painter.SetDrillMarks( true );
break; break;
} }
painter->GetSettings()->SetDrawIndividualViaLayers( painter.GetSettings()->SetDrawIndividualViaLayers(
m_pcbnewSettings.m_pagination == PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE ); m_pcbnewSettings.m_pagination == PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE );
painter->GetSettings()->SetLayerColor( LAYER_PADS_PLATEDHOLES, COLOR4D::WHITE ); painter.GetSettings()->SetLayerColor( LAYER_PADS_PLATEDHOLES, COLOR4D::WHITE );
painter->GetSettings()->SetLayerColor( LAYER_NON_PLATEDHOLES, COLOR4D::WHITE ); painter.GetSettings()->SetLayerColor( LAYER_NON_PLATEDHOLES, COLOR4D::WHITE );
painter->GetSettings()->SetLayerColor( LAYER_VIAS_HOLES, COLOR4D::WHITE ); painter.GetSettings()->SetLayerColor( LAYER_VIAS_HOLES, COLOR4D::WHITE );
} }

View File

@ -58,9 +58,9 @@ public:
protected: protected:
int milsToIU( double aMils ) const override; int milsToIU( double aMils ) const override;
void setupViewLayers( const std::unique_ptr<KIGFX::VIEW>& aView, const LSET& aLayerSet ) override; void setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet ) override;
void setupPainter( const std::unique_ptr<KIGFX::PAINTER>& aPainter ) override; void setupPainter( KIGFX::PAINTER& aPainter ) override;
void setupGal( KIGFX::GAL* aGal ) override; void setupGal( KIGFX::GAL* aGal ) override;