Make sure PCB_GENERATOR's lock status follows their members.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16372
This commit is contained in:
Jeff Young 2023-12-15 17:36:42 +00:00
parent bcc823e8ff
commit 4844cffc00
4 changed files with 31 additions and 15 deletions

View File

@ -297,6 +297,7 @@ public:
virtual bool IsLocked() const;
virtual void SetLocked( bool aLocked ) { m_isLocked = aLocked; }
virtual void SetLockedProperty( bool aLocked );
virtual void StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings ) { }

View File

@ -32,6 +32,7 @@
#include <board.h>
#include <board_design_settings.h>
#include <pcb_group.h>
#include <pcb_generator.h>
#include <footprint.h>
#include <font/font.h>
@ -72,8 +73,8 @@ BOARD* BOARD_ITEM::GetBoard()
bool BOARD_ITEM::IsLocked() const
{
if( GetParentGroup() )
return GetParentGroup()->IsLocked();
if( GetParentGroup() && GetParentGroup()->IsLocked() )
return true;
const BOARD* board = GetBoard();
@ -81,6 +82,17 @@ bool BOARD_ITEM::IsLocked() const
}
void BOARD_ITEM::SetLockedProperty( bool aLocked )
{
PCB_GENERATOR* generator = dynamic_cast<PCB_GENERATOR*>( GetParentGroup() );
if( generator )
generator->SetLocked( aLocked );
else
SetLocked( aLocked );
}
STROKE_PARAMS BOARD_ITEM::GetStroke() const
{
wxCHECK( false, STROKE_PARAMS( pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH ) ) );
@ -338,7 +350,7 @@ static struct BOARD_ITEM_DESC
propMgr.AddProperty( new PROPERTY_ENUM<BOARD_ITEM, PCB_LAYER_ID>( _HKI( "Layer" ),
&BOARD_ITEM::SetLayer, &BOARD_ITEM::GetLayer ) );
propMgr.AddProperty( new PROPERTY<BOARD_ITEM, bool>( _HKI( "Locked" ),
&BOARD_ITEM::SetLocked, &BOARD_ITEM::IsLocked ) )
&BOARD_ITEM::SetLockedProperty, &BOARD_ITEM::IsLocked ) )
.SetAvailableFunc(
[=]( INSPECTABLE* aItem ) -> bool
{

View File

@ -35,6 +35,7 @@
#include <board_commit.h>
#include <board_design_settings.h>
#include <pcb_group.h>
#include <pcb_generator.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_target.h>
@ -1246,28 +1247,25 @@ int BOARD_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
}
}
bool modified = false;
for( EDA_ITEM* item : selection )
{
BOARD_ITEM* board_item = dynamic_cast<BOARD_ITEM*>( item );
wxCHECK2( board_item, continue );
PCB_GENERATOR* generator = dynamic_cast<PCB_GENERATOR*>( board_item->GetParentGroup() );
if( generator )
commit.Modify( generator );
commit.Modify( board_item );
if( aMode == ON )
{
modified |= !board_item->IsLocked();
board_item->SetLocked( true );
}
board_item->SetLockedProperty( true );
else
{
modified |= board_item->IsLocked();
board_item->SetLocked( false );
}
board_item->SetLockedProperty( false );
}
if( modified )
if( !commit.Empty() )
{
commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ) );

View File

@ -209,7 +209,12 @@ void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
for( EDA_ITEM* edaItem : selection )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( edaItem );
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( edaItem );
PCB_GENERATOR* generator = dynamic_cast<PCB_GENERATOR*>( item->GetParentGroup() );
if( generator )
changes.Modify( generator );
changes.Modify( item );
item->Set( property, newValue );
}