GAL: ViewGetLOD should not be able to change the VIEW

Make the VIEW* parameter const. Since PCB_TEXT does a null-check,
it's not very clear if this can ever be null (and if it is,
why don't the other VIEW_ITEMs check?), so don't make them
all references too at this time.

Also dereference a few pointers a bit earlier to make non-null
promises sooner rather than later.
This commit is contained in:
John Beard 2025-01-02 19:24:39 +08:00
parent 527faddbfd
commit 520a7cf62c
25 changed files with 43 additions and 43 deletions

View File

@ -195,7 +195,7 @@ std::vector<int> SCH_LINE::ViewGetLayers() const
} }
double SCH_LINE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double SCH_LINE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
if( aLayer == LAYER_OP_VOLTAGES ) if( aLayer == LAYER_OP_VOLTAGES )
{ {

View File

@ -202,7 +202,7 @@ public:
std::vector<int> ViewGetLayers() const override; std::vector<int> ViewGetLayers() const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
const BOX2I GetBoundingBox() const override; const BOX2I GetBoundingBox() const override;

View File

@ -979,7 +979,7 @@ const BOX2I GERBER_DRAW_ITEM::ViewBBox() const
} }
double GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
// DCodes will be shown only if zoom is appropriate: // DCodes will be shown only if zoom is appropriate:
// Returns the level of detail of the item. // Returns the level of detail of the item.

View File

@ -214,7 +214,7 @@ public:
virtual const BOX2I ViewBBox() const override; virtual const BOX2I ViewBBox() const override;
/// @copydoc VIEW_ITEM::ViewGetLOD() /// @copydoc VIEW_ITEM::ViewGetLOD()
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
///< @copydoc EDA_ITEM::Visit() ///< @copydoc EDA_ITEM::Visit()
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData, INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,

View File

@ -145,7 +145,7 @@ public:
* @return the level of detail. 0 always shows the item, because the actual zoom level * @return the level of detail. 0 always shows the item, because the actual zoom level
* (or VIEW scale) is always > 0 * (or VIEW scale) is always > 0
*/ */
virtual double ViewGetLOD( int aLayer, VIEW* aView ) const virtual double ViewGetLOD( int aLayer, const VIEW* aView ) const
{ {
// By default always show the item // By default always show the item
return LOD_SHOW; return LOD_SHOW;

View File

@ -2257,7 +2257,7 @@ std::vector<int> FOOTPRINT::ViewGetLayers() const
} }
double FOOTPRINT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double FOOTPRINT::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
{ {

View File

@ -909,7 +909,7 @@ public:
virtual std::vector<int> ViewGetLayers() const override; virtual std::vector<int> ViewGetLayers() const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
virtual const BOX2I ViewBBox() const override; virtual const BOX2I ViewBBox() const override;

View File

@ -1724,10 +1724,10 @@ std::vector<int> PAD::ViewGetLayers() const
} }
double PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PAD::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() ); PCB_PAINTER& painter = static_cast<PCB_PAINTER&>( *aView->GetPainter() );
PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings(); PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
const BOARD* board = GetBoard(); const BOARD* board = GetBoard();
// Meta control for hiding all pads // Meta control for hiding all pads
@ -1752,10 +1752,10 @@ double PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
} }
else if( IsNetnameLayer( aLayer ) ) else if( IsNetnameLayer( aLayer ) )
{ {
if( renderSettings->GetHighContrast() ) if( renderSettings.GetHighContrast() )
{ {
// Hide netnames unless pad is flashed to a high-contrast layer // Hide netnames unless pad is flashed to a high-contrast layer
if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) ) if( !FlashLayer( renderSettings.GetPrimaryHighContrastLayer() ) )
return LOD_HIDE; return LOD_HIDE;
} }
else else

View File

@ -872,7 +872,7 @@ public:
virtual std::vector<int> ViewGetLayers() const override; virtual std::vector<int> ViewGetLayers() const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
virtual const BOX2I ViewBBox() const override; virtual const BOX2I ViewBBox() const override;

View File

@ -167,7 +167,7 @@ wxString PCB_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFu
} }
double PCB_FIELD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_FIELD::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
if( !aView ) if( !aView )
return LOD_SHOW; return LOD_SHOW;

View File

@ -76,7 +76,7 @@ public:
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override; wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;

View File

@ -335,7 +335,7 @@ std::vector<int> PCB_GROUP::ViewGetLayers() const
} }
double PCB_GROUP::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_GROUP::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
if( aView->IsLayerVisible( LAYER_ANCHOR ) ) if( aView->IsLayerVisible( LAYER_ANCHOR ) )
return LOD_SHOW; return LOD_SHOW;

View File

@ -175,7 +175,7 @@ public:
std::vector<int> ViewGetLayers() const override; std::vector<int> ViewGetLayers() const override;
/// @copydoc VIEW_ITEM::ViewGetLOD /// @copydoc VIEW_ITEM::ViewGetLOD
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
/// @copydoc BOARD_ITEM::Move /// @copydoc BOARD_ITEM::Move
void Move( const VECTOR2I& aMoveVector ) override; void Move( const VECTOR2I& aMoveVector ) override;

View File

@ -104,7 +104,7 @@ void PCB_REFERENCE_IMAGE::swapData( BOARD_ITEM* aItem )
} }
double PCB_REFERENCE_IMAGE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_REFERENCE_IMAGE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() ); PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings(); PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();

View File

@ -58,7 +58,7 @@ public:
wxString GetClass() const override { return wxT( "PCB_REFERENCE_IMAGE" ); } wxString GetClass() const override { return wxT( "PCB_REFERENCE_IMAGE" ); }
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
const BOX2I GetBoundingBox() const override; const BOX2I GetBoundingBox() const override;

View File

@ -569,10 +569,10 @@ void PCB_SHAPE::SetIsProxyItem( bool aIsProxy )
} }
double PCB_SHAPE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_SHAPE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() ); KIGFX::PCB_PAINTER& painter = static_cast<KIGFX::PCB_PAINTER&>( *aView->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings(); KIGFX::PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
{ {
@ -581,9 +581,9 @@ double PCB_SHAPE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
return LOD_HIDE; return LOD_HIDE;
// Hide shadow on dimmed tracks // Hide shadow on dimmed tracks
if( renderSettings->GetHighContrast() ) if( renderSettings.GetHighContrast() )
{ {
if( m_layer != renderSettings->GetPrimaryHighContrastLayer() ) if( m_layer != renderSettings.GetPrimaryHighContrastLayer() )
return LOD_HIDE; return LOD_HIDE;
} }
} }

View File

@ -172,7 +172,7 @@ public:
std::vector<int> ViewGetLayers() const override; std::vector<int> ViewGetLayers() const override;
///< @copydoc VIEW_ITEM::ViewGetLOD ///< @copydoc VIEW_ITEM::ViewGetLOD
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
double Similarity( const BOARD_ITEM& aBoardItem ) const override; double Similarity( const BOARD_ITEM& aBoardItem ) const override;

View File

@ -209,13 +209,13 @@ std::vector<int> PCB_TEXT::ViewGetLayers() const
} }
double PCB_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_TEXT::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
if( !aView ) if( !aView )
return LOD_SHOW; return LOD_SHOW;
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() ); KIGFX::PCB_PAINTER& painter = static_cast<KIGFX::PCB_PAINTER&>( *aView->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings(); KIGFX::PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
if( !aView->IsLayerVisible( GetLayer() ) ) if( !aView->IsLayerVisible( GetLayer() ) )
return LOD_HIDE; return LOD_HIDE;
@ -223,9 +223,9 @@ double PCB_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
{ {
// Hide shadow on dimmed tracks // Hide shadow on dimmed tracks
if( renderSettings->GetHighContrast() ) if( renderSettings.GetHighContrast() )
{ {
if( m_layer != renderSettings->GetPrimaryHighContrastLayer() ) if( m_layer != renderSettings.GetPrimaryHighContrastLayer() )
return LOD_HIDE; return LOD_HIDE;
} }
} }

View File

@ -157,7 +157,7 @@ public:
std::vector<int> ViewGetLayers() const override; std::vector<int> ViewGetLayers() const override;
///< @copydoc VIEW_ITEM::ViewGetLOD ///< @copydoc VIEW_ITEM::ViewGetLOD
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
// Virtual function // Virtual function
const BOX2I GetBoundingBox() const override; const BOX2I GetBoundingBox() const override;

View File

@ -393,10 +393,10 @@ VECTOR2I PCB_TEXTBOX::GetDrawPos( bool aIsFlipped ) const
} }
double PCB_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_TEXTBOX::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() ); KIGFX::PCB_PAINTER& painter = static_cast<KIGFX::PCB_PAINTER&>( *aView->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings(); KIGFX::PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
if( aLayer == LAYER_LOCKED_ITEM_SHADOW ) if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
{ {
@ -405,9 +405,9 @@ double PCB_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
return LOD_HIDE; return LOD_HIDE;
// Hide shadow on dimmed tracks // Hide shadow on dimmed tracks
if( renderSettings->GetHighContrast() ) if( renderSettings.GetHighContrast() )
{ {
if( m_layer != renderSettings->GetPrimaryHighContrastLayer() ) if( m_layer != renderSettings.GetPrimaryHighContrastLayer() )
return LOD_HIDE; return LOD_HIDE;
} }
} }

View File

@ -147,7 +147,7 @@ public:
BITMAPS GetMenuImage() const override; BITMAPS GetMenuImage() const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
std::vector<int> ViewGetLayers() const override; std::vector<int> ViewGetLayers() const override;

View File

@ -1350,7 +1350,7 @@ std::vector<int> PCB_TRACK::ViewGetLayers() const
} }
double PCB_TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_TRACK::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() ); PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings(); PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
@ -1467,7 +1467,7 @@ std::vector<int> PCB_VIA::ViewGetLayers() const
} }
double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_VIA::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() ); PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings(); PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();

View File

@ -227,7 +227,7 @@ public:
virtual std::vector<int> ViewGetLayers() const override; virtual std::vector<int> ViewGetLayers() const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
const BOX2I ViewBBox() const override; const BOX2I ViewBBox() const override;
@ -511,7 +511,7 @@ public:
std::vector<int> ViewGetLayers() const override; std::vector<int> ViewGetLayers() const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override; void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;

View File

@ -536,7 +536,7 @@ std::vector<int> ZONE::ViewGetLayers() const
} }
double ZONE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double ZONE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
{ {
if( !aView ) if( !aView )
return LOD_SHOW; return LOD_SHOW;

View File

@ -190,7 +190,7 @@ public:
virtual std::vector<int> ViewGetLayers() const override; virtual std::vector<int> ViewGetLayers() const override;
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; } void SetFillMode( ZONE_FILL_MODE aFillMode ) { m_fillMode = aFillMode; }
ZONE_FILL_MODE GetFillMode() const { return m_fillMode; } ZONE_FILL_MODE GetFillMode() const { return m_fillMode; }