Bug fixes for locked tuning patterns.

The router uses locking to know the bounds of the
tuning pattern so it must be temporarily unlocked
while editing with the router.
This commit is contained in:
Jeff Young
2025-08-20 23:23:45 +01:00
parent f896417ed4
commit 90621947bf
3 changed files with 38 additions and 14 deletions
+33 -8
View File
@@ -840,13 +840,35 @@ bool PCB_TUNING_PATTERN::initBaseLines( PNS::ROUTER* aRouter, int aPNSLayer, BOA
return true;
}
bool PCB_TUNING_PATTERN::removeToBaseline( PNS::ROUTER* aRouter, int aPNSLayer,
SHAPE_LINE_CHAIN& aBaseLine )
class UNLOCKER
{
public:
UNLOCKER( PCB_TUNING_PATTERN* aPattern ) :
m_pattern( aPattern ),
m_wasLocked( aPattern->IsLocked() )
{
m_pattern->SetLocked( false );
}
~UNLOCKER()
{
if( m_wasLocked )
m_pattern->SetLocked( true );
}
private:
PCB_TUNING_PATTERN* m_pattern;
bool m_wasLocked;
};
bool PCB_TUNING_PATTERN::removeToBaseline( PNS::ROUTER* aRouter, int aPNSLayer, SHAPE_LINE_CHAIN& aBaseLine )
{
VECTOR2I startSnapPoint, endSnapPoint;
std::optional<PNS::LINE> pnsLine = getPNSLine( aBaseLine.CPoint( 0 ), aBaseLine.CLastPoint(),
aRouter, aPNSLayer, startSnapPoint, endSnapPoint );
std::optional<PNS::LINE> pnsLine = getPNSLine( aBaseLine.CPoint( 0 ), aBaseLine.CLastPoint(), aRouter,
aPNSLayer, startSnapPoint, endSnapPoint );
wxCHECK( pnsLine, false );
@@ -879,6 +901,7 @@ bool PCB_TUNING_PATTERN::removeToBaseline( PNS::ROUTER* aRouter, int aPNSLayer,
void PCB_TUNING_PATTERN::Remove( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COMMIT* aCommit )
{
UNLOCKER raiiUnlocker( this );
SetFlags( IN_EDIT );
aTool->Router()->SyncWorld();
@@ -1003,16 +1026,16 @@ bool PCB_TUNING_PATTERN::recoverBaseline( PNS::ROUTER* aRouter )
}
bool PCB_TUNING_PATTERN::resetToBaseline( GENERATOR_TOOL* aTool, int aPNSLayer,
SHAPE_LINE_CHAIN& aBaseLine, bool aPrimary )
bool PCB_TUNING_PATTERN::resetToBaseline( GENERATOR_TOOL* aTool, int aPNSLayer, SHAPE_LINE_CHAIN& aBaseLine,
bool aPrimary )
{
PNS_KICAD_IFACE* iface = aTool->GetInterface();
PNS::ROUTER* router = aTool->Router();
PNS::NODE* world = router->GetWorld();
VECTOR2I startSnapPoint, endSnapPoint;
std::optional<PNS::LINE> pnsLine = getPNSLine( aBaseLine.CPoint( 0 ), aBaseLine.CLastPoint(),
router, aPNSLayer, startSnapPoint, endSnapPoint );
std::optional<PNS::LINE> pnsLine = getPNSLine( aBaseLine.CPoint( 0 ), aBaseLine.CLastPoint(), router,
aPNSLayer, startSnapPoint, endSnapPoint );
if( !pnsLine )
{
@@ -1096,6 +1119,8 @@ bool PCB_TUNING_PATTERN::Update( GENERATOR_TOOL* aTool, BOARD* aBoard, BOARD_COM
if( !( GetFlags() & IN_EDIT ) )
return false;
UNLOCKER raiiUnlocker( this );
KIGFX::VIEW* view = aTool->GetManager()->GetView();
PNS::ROUTER* router = aTool->Router();
PNS_KICAD_IFACE* iface = aTool->GetInterface();
-4
View File
@@ -280,14 +280,10 @@ int GENERATOR_TOOL::GenEditAction( const TOOL_EVENT& aEvent )
else if( aEvent.IsAction( &PCB_ACTIONS::genFinishEdit ) )
{
gen->EditFinish( this, board(), commit );
wxASSERT( commit->Empty() );
}
else if( aEvent.IsAction( &PCB_ACTIONS::genCancelEdit ) )
{
gen->EditCancel( this, board(), commit );
wxASSERT( commit->Empty() );
}
else if( aEvent.IsAction( &PCB_ACTIONS::genRemove ) )
{
+5 -2
View File
@@ -234,8 +234,7 @@ void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
continue;
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( edaItem );
PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *item ),
aEvent.GetPropertyName() );
PROPERTY_BASE* property = m_propMgr.GetProperty( TYPE_HASH( *item ), aEvent.GetPropertyName() );
wxCHECK( property, /* void */ );
if( item->Type() == PCB_TABLECELL_T )
@@ -255,6 +254,10 @@ void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
// Perform grid updates as necessary based on value change
AfterCommit();
// PointEditor may need to update if locked/unlocked
if( aEvent.GetPropertyName() == _HKI( "Locked" ) )
m_frame->GetToolManager()->ProcessEvent( EVENTS::SelectedEvent );
aEvent.Skip();
}