Unroll from PICKER_TOOL so we can handle amplitude/spacing events.

Also fixes a bug where we didn't clear the router on an <ESC>.
This commit is contained in:
Jeff Young 2023-10-11 15:50:15 +01:00
parent 1aeccc5895
commit d6c2ad7503
3 changed files with 87 additions and 14 deletions

View File

@ -734,6 +734,8 @@ public:
m_removedItems.clear();
aTool->Router()->StopRouting();
if( aCommit )
aCommit->Revert();
}
@ -1178,6 +1180,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool<GENERATOR_TOOL>();
PNS::ROUTER* router = generatorTool->Router();
m_pickerItem = nullptr;
m_meander = nullptr;
@ -1193,6 +1196,24 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
controls->ShowCursor( true );
};
auto updateMeander =
[&]()
{
if( m_meander && m_meander->GetPosition() != m_meander->GetEnd() )
{
m_meander->EditStart( generatorTool, m_board, m_frame, nullptr );
m_meander->Update( generatorTool, m_board, m_frame, nullptr );
m_statusPopup->Popup();
canvas()->SetStatusPopup( m_statusPopup.get() );
m_view->Update( &m_preview );
m_meander->UpdateStatus( generatorTool, m_frame, m_statusPopup.get() );
m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, 20 ) );
}
};
// Set initial cursor
setCursor();
@ -1281,20 +1302,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
// First click already made; we're in preview-meander mode
m_meander->SetEnd( cursorPos );
if( m_meander->GetPosition() != m_meander->GetEnd() )
{
m_meander->EditStart( generatorTool, m_board, m_frame, nullptr );
m_meander->Update( generatorTool, m_board, m_frame, nullptr );
m_statusPopup->Popup();
canvas()->SetStatusPopup( m_statusPopup.get() );
m_view->Update( &m_preview );
m_meander->UpdateStatus( generatorTool, m_frame, m_statusPopup.get() );
m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, 20 ) );
}
updateMeander();
}
}
else if( evt->IsClick( BUT_RIGHT ) )
@ -1302,6 +1310,30 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
PCB_SELECTION dummy;
m_menu.ShowContextMenu( dummy );
}
else if( evt->IsAction( &PCB_ACTIONS::spacingIncrease )
|| evt->IsAction( &PCB_ACTIONS::spacingDecrease ) )
{
if( m_meander )
{
auto* placer = static_cast<PNS::MEANDER_PLACER_BASE*>( router->Placer() );
placer->SpacingStep( evt->IsAction( &PCB_ACTIONS::spacingIncrease ) ? 1 : -1 );
m_meander->SetSpacing( placer->MeanderSettings().m_spacing );
updateMeander();
}
}
else if( evt->IsAction( &PCB_ACTIONS::amplIncrease )
|| evt->IsAction( &PCB_ACTIONS::amplDecrease ) )
{
if( m_meander )
{
auto* placer = static_cast<PNS::MEANDER_PLACER_BASE*>( router->Placer() );
placer->AmplitudeStep( evt->IsAction( &PCB_ACTIONS::amplIncrease ) ? 1 : -1 );
m_meander->SetMaxAmplitude( placer->MeanderSettings().m_maxAmplitude );
updateMeander();
}
}
// TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions",
// but we don't at present have that, so we just knock out some of the egregious ones.
else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) )

View File

@ -194,6 +194,43 @@ TOOL_ACTION PCB_ACTIONS::placeMeanders( TOOL_ACTION_ARGS()
.Icon( BITMAPS::ps_tune_length )
.Flags( AF_ACTIVATE ) );
TOOL_ACTION PCB_ACTIONS::spacingIncrease( TOOL_ACTION_ARGS()
.Name( "pcbnew.lengthTuner.SpacingIncrease" )
.Scope( AS_GLOBAL )
.DefaultHotkey( '1' )
.LegacyHotkeyName( "Increase meander spacing by one step." )
.MenuText( _( "Increase Spacing" ) )
.Tooltip( _( "Increase meander spacing by one step." ) )
.Icon( BITMAPS::router_len_tuner_dist_incr ) );
TOOL_ACTION PCB_ACTIONS::spacingDecrease( TOOL_ACTION_ARGS()
.Name( "pcbnew.lengthTuner.SpacingDecrease" )
.Scope( AS_GLOBAL )
.DefaultHotkey( '2' )
.LegacyHotkeyName( "Decrease meander spacing by one step." )
.MenuText( _( "Decrease Spacing" ) )
.Tooltip( _( "Decrease meander spacing by one step." ) )
.Icon( BITMAPS::router_len_tuner_dist_decr ) );
TOOL_ACTION PCB_ACTIONS::amplIncrease( TOOL_ACTION_ARGS()
.Name( "pcbnew.lengthTuner.AmplIncrease" )
.Scope( AS_GLOBAL )
.DefaultHotkey( '3' )
.LegacyHotkeyName( "Increase meander amplitude by one step." )
.MenuText( _( "Increase Amplitude" ) )
.Tooltip( _( "Increase meander amplitude by one step." ) )
.Icon( BITMAPS::router_len_tuner_amplitude_incr ) );
TOOL_ACTION PCB_ACTIONS::amplDecrease( TOOL_ACTION_ARGS()
.Name( "pcbnew.lengthTuner.AmplDecrease" )
.Scope( AS_GLOBAL )
.DefaultHotkey( '4' )
.LegacyHotkeyName( "Decrease meander amplitude by one step." )
.MenuText( _( "Decrease Amplitude" ) )
.Tooltip( _( "Decrease meander amplitude by one step." ) )
.Icon( BITMAPS::router_len_tuner_amplitude_decr ) );
TOOL_ACTION PCB_ACTIONS::drawAlignedDimension( TOOL_ACTION_ARGS()
.Name( "pcbnew.InteractiveDrawing.alignedDimension" )
.Scope( AS_GLOBAL )

View File

@ -199,6 +199,10 @@ public:
static TOOL_ACTION placeText;
static TOOL_ACTION drawTextBox;
static TOOL_ACTION placeMeanders;
static TOOL_ACTION spacingIncrease;
static TOOL_ACTION spacingDecrease;
static TOOL_ACTION amplIncrease;
static TOOL_ACTION amplDecrease;
static TOOL_ACTION drawAlignedDimension;
static TOOL_ACTION drawCenterDimension;
static TOOL_ACTION drawRadialDimension;