Retire length tuning tool in favour of first-class meanders.

This commit is contained in:
Jeff Young 2023-10-11 17:10:48 +01:00
parent 1ca477aeee
commit 1b676985f6
12 changed files with 132 additions and 574 deletions

View File

@ -98,6 +98,18 @@ static std::string TuningToString( const LENGTH_TUNING_MODE aTuning )
}
static LENGTH_TUNING_MODE FromPNSMode( PNS::ROUTER_MODE aRouterMode )
{
switch( aRouterMode )
{
case PNS::PNS_MODE_TUNE_SINGLE: return LENGTH_TUNING_MODE::SINGLE;
case PNS::PNS_MODE_TUNE_DIFF_PAIR: return LENGTH_TUNING_MODE::DIFF_PAIR;
case PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW: return LENGTH_TUNING_MODE::DIFF_PAIR_SKEW;
default: return LENGTH_TUNING_MODE::SINGLE;
}
}
static PNS::MEANDER_SIDE SideFromString( const std::string& aStr )
{
if( aStr == "default" )
@ -219,24 +231,45 @@ public:
bool baselineValid() { return m_baseLine && m_baseLine->PointCount() > 1; }
static PCB_GENERATOR_MEANDERS* CreateNew( GENERATOR_TOOL* aTool, PCB_BASE_EDIT_FRAME* aFrame,
BOARD_CONNECTED_ITEM* aStartItem )
BOARD_CONNECTED_ITEM* aStartItem,
LENGTH_TUNING_MODE aMode )
{
BOARD* board = aStartItem->GetBoard();
std::shared_ptr<DRC_ENGINE>& drcEngine = board->GetDesignSettings().m_DRCEngine;
DRC_CONSTRAINT constraint;
PCB_LAYER_ID layer = aStartItem->GetLayer();
PNS::RULE_RESOLVER* resolver = aTool->Router()->GetRuleResolver();
LENGTH_TUNING_MODE mode = resolver->DpCoupledNet( aStartItem->GetNet() ) ? DIFF_PAIR
: SINGLE;
PCB_GENERATOR_MEANDERS* meander = new PCB_GENERATOR_MEANDERS( board, layer, mode );
if( aMode == SINGLE && resolver->DpCoupledNet( aStartItem->GetNet() ) )
aMode = DIFF_PAIR;
PCB_GENERATOR_MEANDERS* meander = new PCB_GENERATOR_MEANDERS( board, layer, aMode );
constraint = drcEngine->EvalRules( LENGTH_CONSTRAINT, aStartItem, nullptr, layer );
if( aMode == DIFF_PAIR_SKEW )
{
if( constraint.IsNull() )
{
WX_UNIT_ENTRY_DIALOG dlg( aFrame, _( "Place Meander" ), _( "Target length:" ),
WX_UNIT_ENTRY_DIALOG dlg( aFrame, _( "Tune Skew" ), _( "Target skew:" ), 0 );
if( dlg.ShowModal() != wxID_OK )
return nullptr;
meander->m_targetSkew = dlg.GetValue();
meander->m_overrideCustomRules = true;
}
else
{
meander->m_targetSkew = constraint.GetValue().Opt();
meander->m_overrideCustomRules = false;
}
}
else
{
if( constraint.IsNull() )
{
WX_UNIT_ENTRY_DIALOG dlg( aFrame, _( "Tune Length" ), _( "Target length:" ),
100 * PCB_IU_PER_MM );
if( dlg.ShowModal() != wxID_OK )
@ -250,6 +283,7 @@ public:
meander->m_targetLength = constraint.GetValue().Opt();
meander->m_overrideCustomRules = false;
}
}
meander->SetFlags( IS_NEW );
@ -1179,6 +1213,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
m_frame->PushTool( aEvent );
Activate();
LENGTH_TUNING_MODE mode = FromPNSMode( aEvent.Parameter<PNS::ROUTER_MODE>() );
KIGFX::VIEW_CONTROLS* controls = getViewControls();
BOARD* board = m_frame->GetBoard();
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
@ -1242,40 +1277,6 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
break;
}
else if( evt->IsClick( BUT_LEFT ) && m_pickerItem )
{
if( !m_meander )
{
// First click; create a meander
generatorTool->HighlightNet( nullptr );
m_frame->SetActiveLayer( m_pickerItem->GetLayer() );
m_meander = PCB_GENERATOR_MEANDERS::CreateNew( generatorTool, m_frame,
m_pickerItem );
int dummyDist;
int dummyClearance = std::numeric_limits<int>::max() / 2;
VECTOR2I closestPt;
m_pickerItem->GetEffectiveShape()->Collide( cursorPos, dummyClearance,
&dummyDist, &closestPt );
m_meander->SetPosition( closestPt );
m_preview.Add( m_meander );
}
else
{
// Second click; we're done
BOARD_COMMIT commit( m_frame );
m_meander->EditStart( generatorTool, m_board, m_frame, &commit );
m_meander->Update( generatorTool, m_board, m_frame, &commit );
m_meander->EditPush( generatorTool, m_board, m_frame, &commit, _( "Place Meander" ) );
break;
}
}
else if( evt->IsMotion() )
{
if( !m_meander )
@ -1294,12 +1295,12 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
if( !m_pickerItem )
{
m_pickerItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
generatorTool->HighlightNet( m_pickerItem );
generatorTool->HighlightNets( m_pickerItem );
}
else
{
m_pickerItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
generatorTool->UpdateHighlightedNet( m_pickerItem );
generatorTool->UpdateHighlightedNets( m_pickerItem );
}
}
else
@ -1310,6 +1311,41 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
updateMeander();
}
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( m_pickerItem && !m_meander )
{
// First click; create a meander
generatorTool->HighlightNets( nullptr );
m_frame->SetActiveLayer( m_pickerItem->GetLayer() );
m_meander = PCB_GENERATOR_MEANDERS::CreateNew( generatorTool, m_frame,
m_pickerItem, mode );
int dummyDist;
int dummyClearance = std::numeric_limits<int>::max() / 2;
VECTOR2I closestPt;
m_pickerItem->GetEffectiveShape()->Collide( cursorPos, dummyClearance,
&dummyDist, &closestPt );
m_meander->SetPosition( closestPt );
m_meander->SetEnd( closestPt );
m_preview.Add( m_meander );
}
else if( m_pickerItem && m_meander )
{
// Second click; we're done
BOARD_COMMIT commit( m_frame );
m_meander->EditStart( generatorTool, m_board, m_frame, &commit );
m_meander->Update( generatorTool, m_board, m_frame, &commit );
m_meander->EditPush( generatorTool, m_board, m_frame, &commit, _( "Tune" ) );
break;
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
PCB_SELECTION dummy;
@ -1363,7 +1399,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
canvas()->SetStatusPopup( nullptr );
m_statusPopup->Hide();
generatorTool->HighlightNet( nullptr );
generatorTool->HighlightNets( nullptr );
m_preview.Clear();
m_view->Remove( &m_preview );

View File

@ -312,12 +312,6 @@ void PCB_EDIT_FRAME::doReCreateMenuBar()
placeMenu->Add( PCB_ACTIONS::placeText );
placeMenu->Add( PCB_ACTIONS::drawTextBox );
if( ADVANCED_CFG::GetCfg().m_EnableGenerators )
{
placeMenu->AppendSeparator();
placeMenu->Add( PCB_ACTIONS::placeMeanders );
}
placeMenu->AppendSeparator();
placeMenu->Add( PCB_ACTIONS::drawAlignedDimension );
placeMenu->Add( PCB_ACTIONS::drawOrthogonalDimension );
@ -358,9 +352,8 @@ void PCB_EDIT_FRAME::doReCreateMenuBar()
routeMenu->Add( PCB_ACTIONS::routeDiffPair );
routeMenu->AppendSeparator();
routeMenu->Add( PCB_ACTIONS::routerTuneSingleTrace );
routeMenu->Add( PCB_ACTIONS::routerTuneDiffPair );
routeMenu->Add( PCB_ACTIONS::routerTuneDiffPairSkew );
routeMenu->Add( PCB_ACTIONS::tuneLength );
routeMenu->Add( PCB_ACTIONS::tuneSkew );
routeMenu->AppendSeparator();
routeMenu->Add( PCB_ACTIONS::routerSettingsDialog );

View File

@ -88,7 +88,6 @@
#include <tools/zone_filler_tool.h>
#include <tools/pcb_actions.h>
#include <router/router_tool.h>
#include <router/length_tuner_tool.h>
#include <autorouter/autoplace_tool.h>
#include <python/scripting/pcb_scripting_tool.h>
#include <gestfich.h>
@ -637,7 +636,6 @@ void PCB_EDIT_FRAME::setupTools()
m_toolManager->RegisterTool( new ZOOM_TOOL );
m_toolManager->RegisterTool( new PCB_PICKER_TOOL );
m_toolManager->RegisterTool( new ROUTER_TOOL );
m_toolManager->RegisterTool( new LENGTH_TUNER_TOOL );
m_toolManager->RegisterTool( new EDIT_TOOL );
m_toolManager->RegisterTool( new GLOBAL_EDIT_TOOL );
m_toolManager->RegisterTool( new PAD_TOOL );
@ -943,9 +941,8 @@ void PCB_EDIT_FRAME::setupUIConditions()
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeFootprint );
CURRENT_EDIT_TOOL( PCB_ACTIONS::routeSingleTrack);
CURRENT_EDIT_TOOL( PCB_ACTIONS::routeDiffPair );
CURRENT_EDIT_TOOL( PCB_ACTIONS::routerTuneDiffPair );
CURRENT_EDIT_TOOL( PCB_ACTIONS::routerTuneDiffPairSkew );
CURRENT_EDIT_TOOL( PCB_ACTIONS::routerTuneSingleTrace );
CURRENT_EDIT_TOOL( PCB_ACTIONS::tuneLength );
CURRENT_EDIT_TOOL( PCB_ACTIONS::tuneSkew );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawVia );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawZone );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRuleArea );
@ -957,7 +954,6 @@ void PCB_EDIT_FRAME::setupUIConditions()
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeImage );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeText );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawTextBox );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeMeanders );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawAlignedDimension );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawOrthogonalDimension );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawCenterDimension );

View File

@ -46,7 +46,6 @@ set( PCBNEW_PNS_SRCS
pns_walkaround.cpp
router_preview_item.cpp
router_tool.cpp
length_tuner_tool.cpp
)
add_library( pnsrouter STATIC ${PCBNEW_PNS_SRCS} )

View File

@ -1,407 +0,0 @@
/*
* KiRouter - a push-and-(sometimes-)shove PCB router
*
* Copyright (C) 2013-2017 CERN
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <class_draw_panel_gal.h>
#include <dialogs/dialog_unit_entry.h>
#include <kiplatform/ui.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/zone_filler_tool.h>
#include <tools/tool_event_utils.h>
#include <board_design_settings.h>
#include "pns_router.h"
#include "pns_meander_placer.h" // fixme: move settings to separate header
#include "pns_meander_skew_placer.h"
#include "pns_tune_status_popup.h"
#include "length_tuner_tool.h"
#include <bitmaps.h>
using namespace KIGFX;
// Actions, being statically-defined, require specialized I18N handling. We continue to
// use the _() macro so that string harvesting by the I18N framework doesn't have to be
// specialized, but we don't translate on initialization and instead do it in the getters.
#undef _
#define _(s) s
static TOOL_ACTION ACT_StartTuning( "pcbnew.LengthTuner.StartTuning",
AS_CONTEXT,
'X', LEGACY_HK_NAME( "Add New Track" ),
_( "New Track" ), _( "Starts laying a new track." ) );
static TOOL_ACTION ACT_EndTuning( "pcbnew.LengthTuner.EndTuning",
AS_CONTEXT,
WXK_END, LEGACY_HK_NAME( "Stop laying the current track." ),
_( "End Track" ), _( "Stops laying the current meander." ) );
static TOOL_ACTION ACT_SpacingIncrease( "pcbnew.LengthTuner.SpacingIncrease",
AS_CONTEXT,
'1', LEGACY_HK_NAME( "Increase meander spacing by one step." ),
_( "Increase Spacing" ), _( "Increase meander spacing by one step." ),
BITMAPS::router_len_tuner_dist_incr );
static TOOL_ACTION ACT_SpacingDecrease( "pcbnew.LengthTuner.SpacingDecrease",
AS_CONTEXT,
'2', LEGACY_HK_NAME( "Decrease meander spacing by one step." ),
_( "Decrease Spacing" ), _( "Decrease meander spacing by one step." ),
BITMAPS::router_len_tuner_dist_decr );
static TOOL_ACTION ACT_AmplIncrease( "pcbnew.LengthTuner.AmplIncrease",
AS_CONTEXT,
'3', LEGACY_HK_NAME( "Increase meander amplitude by one step." ),
_( "Increase Amplitude" ), _( "Increase meander amplitude by one step." ),
BITMAPS::router_len_tuner_amplitude_incr );
static TOOL_ACTION ACT_AmplDecrease( "pcbnew.LengthTuner.AmplDecrease",
AS_CONTEXT,
'4', LEGACY_HK_NAME( "Decrease meander amplitude by one step." ),
_( "Decrease Amplitude" ), _( "Decrease meander amplitude by one step." ),
BITMAPS::router_len_tuner_amplitude_decr );
#undef _
#define _(s) wxGetTranslation((s))
LENGTH_TUNER_TOOL::LENGTH_TUNER_TOOL() :
TOOL_BASE( "pcbnew.LengthTuner" ),
m_inLengthTuner( false )
{
// set the initial tune mode for the settings dialog,
// in case the dialog is opened before the tool is activated the first time
m_lastTuneMode = PNS::ROUTER_MODE::PNS_MODE_TUNE_SINGLE;
m_inLengthTuner = false;
}
LENGTH_TUNER_TOOL::~LENGTH_TUNER_TOOL()
{
}
bool LENGTH_TUNER_TOOL::Init()
{
m_inLengthTuner = false;
auto tuning =
[&]( const SELECTION& )
{
return m_router->RoutingInProgress();
};
auto& menu = m_menu.GetMenu();
menu.SetTitle( _( "Length Tuner" ) );
menu.SetIcon( BITMAPS::router_len_tuner );
menu.DisplayTitle( true );
menu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways );
menu.AddSeparator();
menu.AddItem( ACT_SpacingIncrease, tuning );
menu.AddItem( ACT_SpacingDecrease, tuning );
menu.AddItem( ACT_AmplIncrease, tuning );
menu.AddItem( ACT_AmplDecrease, tuning );
return true;
}
void LENGTH_TUNER_TOOL::Reset( RESET_REASON aReason )
{
if( aReason == RUN )
TOOL_BASE::Reset( aReason );
}
void LENGTH_TUNER_TOOL::updateStatusPopup( PNS_TUNE_STATUS_POPUP& aPopup )
{
// fixme: wx code not allowed inside tools!
wxPoint p = KIPLATFORM::UI::GetMousePosition();
p.x += 20;
p.y += 20;
aPopup.UpdateStatus( m_router );
aPopup.Move( p );
}
void LENGTH_TUNER_TOOL::performTuning()
{
if( m_startItem )
{
frame()->SetActiveLayer( ToLAYER_ID ( m_startItem->Layers().Start() ) );
if( m_startItem->Net() )
highlightNets( true, { m_startItem->Net() } );
}
controls()->ForceCursorPosition( false );
controls()->SetAutoPan( true );
int layer = m_startItem ? m_startItem->Layer() : static_cast<int>( frame()->GetActiveLayer() );
if( !m_router->StartRouting( m_startSnapPoint, m_startItem, layer ) )
{
frame()->ShowInfoBarMsg( m_router->FailureReason() );
highlightNets( false );
return;
}
BOARD_DESIGN_SETTINGS& bds = board()->GetDesignSettings();
PNS::MEANDER_PLACER_BASE* placer = static_cast<PNS::MEANDER_PLACER_BASE*>( m_router->Placer() );
PNS::MEANDER_SETTINGS* settings = nullptr;
switch( m_lastTuneMode )
{
case PNS::PNS_MODE_TUNE_SINGLE: settings = &bds.m_singleTrackMeanderSettings; break;
case PNS::PNS_MODE_TUNE_DIFF_PAIR: settings = &bds.m_diffPairMeanderSettings; break;
case PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW: settings = &bds.m_skewMeanderSettings; break;
default:
wxFAIL_MSG( wxT( "Unsupported tuning mode." ) );
m_router->StopRouting();
highlightNets( false );
return;
}
if( m_lastTuneMode == PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW )
{
PNS::MEANDER_SKEW_PLACER* skewPlacer = static_cast<PNS::MEANDER_SKEW_PLACER*>( placer );
WX_UNIT_ENTRY_DIALOG dlg( frame(), _( "Skew Tuning" ), _( "Target skew:" ),
skewPlacer->CurrentSkew() );
if( dlg.ShowModal() != wxID_OK )
{
m_router->StopRouting();
highlightNets( false );
return;
}
settings->m_targetLength = dlg.GetValue();
}
else
{
std::shared_ptr<DRC_ENGINE>& drcEngine = bds.m_DRCEngine;
DRC_CONSTRAINT constraint;
constraint = drcEngine->EvalRules( LENGTH_CONSTRAINT, m_startItem->Parent(), nullptr,
ToLAYER_ID( layer ) );
if( constraint.IsNull() )
{
WX_UNIT_ENTRY_DIALOG dlg( frame(), _( "Length Tuning" ), _( "Target length:" ),
100 * PCB_IU_PER_MM );
if( dlg.ShowModal() != wxID_OK )
{
m_router->StopRouting();
highlightNets( false );
return;
}
settings->m_targetLength = dlg.GetValue();
}
else
{
settings->m_targetLength = constraint.GetValue().Opt();
}
}
placer->UpdateSettings( *settings );
frame()->UndoRedoBlock( true );
VECTOR2I end = getViewControls()->GetMousePosition();
// Create an instance of PNS_TUNE_STATUS_POPUP.
PNS_TUNE_STATUS_POPUP statusPopup( frame() );
statusPopup.Popup();
canvas()->SetStatusPopup( statusPopup.GetPanel() );
m_router->Move( end, nullptr );
updateStatusPopup( statusPopup );
auto setCursor =
[&]()
{
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
};
// Set initial cursor
setCursor();
while( TOOL_EVENT* evt = Wait() )
{
setCursor();
if( evt->IsCancelInteractive() || evt->IsActivate() )
{
break;
}
else if( evt->IsMotion() )
{
end = evt->Position();
m_router->Move( end, nullptr );
updateStatusPopup( statusPopup );
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( m_router->FixRoute( evt->Position(), nullptr ) )
break;
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
}
else if( evt->IsAction( &ACT_EndTuning ) )
{
if( m_router->FixRoute( end, nullptr ) )
break;
}
else if( evt->IsAction( &ACT_AmplDecrease ) )
{
placer->AmplitudeStep( -1 );
m_router->Move( end, nullptr );
updateStatusPopup( statusPopup );
}
else if( evt->IsAction( &ACT_AmplIncrease ) )
{
placer->AmplitudeStep( 1 );
m_router->Move( end, nullptr );
updateStatusPopup( statusPopup );
}
else if(evt->IsAction( &ACT_SpacingDecrease ) )
{
placer->SpacingStep( -1 );
m_router->Move( end, nullptr );
updateStatusPopup( statusPopup );
}
else if( evt->IsAction( &ACT_SpacingIncrease ) )
{
placer->SpacingStep( 1 );
m_router->Move( end, nullptr );
updateStatusPopup( statusPopup );
}
// 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 ) )
{
wxBell();
}
else
{
evt->SetPassEvent();
}
}
m_router->StopRouting();
frame()->UndoRedoBlock( false );
canvas()->SetStatusPopup( nullptr );
controls()->SetAutoPan( false );
controls()->ForceCursorPosition( false );
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
highlightNets( false );
}
void LENGTH_TUNER_TOOL::setTransitions()
{
Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneSingleTrace.MakeEvent() );
Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneDiffPair.MakeEvent() );
Go( &LENGTH_TUNER_TOOL::MainLoop, PCB_ACTIONS::routerTuneDiffPairSkew.MakeEvent() );
}
int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
{
if( m_inLengthTuner )
return 0;
REENTRANCY_GUARD guard( &m_inLengthTuner );
// Deselect all items
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
frame()->PushTool( aEvent );
auto setCursor =
[&]()
{
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
};
Activate();
// Must be done after Activate() so that it gets set into the correct context
controls()->ShowCursor( true );
// Set initial cursor
setCursor();
// Router mode must be set after Activate()
m_lastTuneMode = aEvent.Parameter<PNS::ROUTER_MODE>();
m_router->SetMode( m_lastTuneMode );
// Main loop: keep receiving events
while( TOOL_EVENT* evt = Wait() )
{
setCursor();
if( evt->IsCancelInteractive() || evt->IsActivate() )
{
break; // Finish
}
else if( evt->Action() == TA_UNDO_REDO_PRE )
{
m_router->ClearWorld();
}
else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
{
m_router->SyncWorld();
}
else if( evt->IsMotion() )
{
updateStartItem( *evt );
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_StartTuning ) )
{
updateStartItem( *evt );
performTuning();
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
}
else
{
evt->SetPassEvent();
}
}
// Store routing settings till the next invocation
m_savedSizes = m_router->Sizes();
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
frame()->PopTool( aEvent );
return 0;
}

View File

@ -1,55 +0,0 @@
/*
* KiRouter - a push-and-(sometimes-)shove PCB router
*
* Copyright (C) 2013-2017 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Author: Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LENGTH_TUNER_TOOL_H
#define __LENGTH_TUNER_TOOL_H
#include "pns_tool_base.h"
#include "pns_meander.h"
class PNS_TUNE_STATUS_POPUP;
class LENGTH_TUNER_TOOL : public PNS::TOOL_BASE
{
public:
LENGTH_TUNER_TOOL();
~LENGTH_TUNER_TOOL();
/// @copydoc TOOL_BASE::Init()
bool Init() override;
void Reset( RESET_REASON aReason ) override;
int MainLoop( const TOOL_EVENT& aEvent );
void setTransitions() override;
private:
void performTuning();
void updateStatusPopup( PNS_TUNE_STATUS_POPUP& aPopup );
private:
PNS::ROUTER_MODE m_lastTuneMode;
bool m_inLengthTuner;
};
#endif

View File

@ -416,9 +416,8 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
if( !tuneGroup )
{
tuneGroup = new ACTION_GROUP( "group.pcbTune",
{ &PCB_ACTIONS::routerTuneSingleTrace,
&PCB_ACTIONS::routerTuneDiffPair,
&PCB_ACTIONS::routerTuneDiffPairSkew } );
{ &PCB_ACTIONS::tuneLength,
&PCB_ACTIONS::tuneSkew } );
}
m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );

View File

@ -3402,9 +3402,12 @@ void DRAWING_TOOL::setTransitions()
Go( &DRAWING_TOOL::DrawVia, PCB_ACTIONS::drawVia.MakeEvent() );
Go( &DRAWING_TOOL::PlaceImage, PCB_ACTIONS::placeImage.MakeEvent() );
Go( &DRAWING_TOOL::PlaceText, PCB_ACTIONS::placeText.MakeEvent() );
Go( &DRAWING_TOOL::PlaceMeander, PCB_ACTIONS::placeMeanders.MakeEvent() );
Go( &DRAWING_TOOL::DrawRectangle, PCB_ACTIONS::drawTextBox.MakeEvent() );
Go( &DRAWING_TOOL::PlaceImportedGraphics, PCB_ACTIONS::placeImportedGraphics.MakeEvent() );
Go( &DRAWING_TOOL::SetAnchor, PCB_ACTIONS::setAnchor.MakeEvent() );
Go( &DRAWING_TOOL::ToggleHV45Mode, PCB_ACTIONS::toggleHV45Mode.MakeEvent() );
Go( &DRAWING_TOOL::PlaceMeander, PCB_ACTIONS::tuneLength.MakeEvent() );
Go( &DRAWING_TOOL::PlaceMeander, PCB_ACTIONS::tuneSkew.MakeEvent() );
}

View File

@ -250,21 +250,41 @@ int GENERATOR_TOOL::GenEditAction( const TOOL_EVENT& aEvent )
}
void GENERATOR_TOOL::HighlightNet( BOARD_CONNECTED_ITEM* aStartItem )
void GENERATOR_TOOL::HighlightNets( BOARD_CONNECTED_ITEM* aStartItem )
{
if( aStartItem && aStartItem->GetNet() )
highlightNets( true, { aStartItem->GetNet() } );
{
PNS::RULE_RESOLVER* resolver = m_router->GetRuleResolver();
std::set<PNS::NET_HANDLE> nets = { aStartItem->GetNet() };
if( PNS::NET_HANDLE coupledNet = resolver->DpCoupledNet( aStartItem->GetNet() ) )
nets.insert( coupledNet );
highlightNets( true, nets );
}
else
{
highlightNets( false );
}
}
void GENERATOR_TOOL::UpdateHighlightedNet( BOARD_CONNECTED_ITEM* aStartItem )
void GENERATOR_TOOL::UpdateHighlightedNets( BOARD_CONNECTED_ITEM* aStartItem )
{
if( aStartItem && aStartItem->GetNet() )
updateHighlightedNets( { aStartItem->GetNet() } );
{
PNS::RULE_RESOLVER* resolver = m_router->GetRuleResolver();
std::set<PNS::NET_HANDLE> nets = { aStartItem->GetNet() };
if( PNS::NET_HANDLE coupledNet = resolver->DpCoupledNet( aStartItem->GetNet() ) )
nets.insert( coupledNet );
updateHighlightedNets( nets );
}
else
{
highlightNets( false );
}
}

View File

@ -58,8 +58,8 @@ public:
int RegenerateItem( const TOOL_EVENT& aEvent );
int GenEditAction( const TOOL_EVENT& aEvent );
void HighlightNet( BOARD_CONNECTED_ITEM* aStartItem );
void UpdateHighlightedNet( BOARD_CONNECTED_ITEM* aStartItem );
void HighlightNets( BOARD_CONNECTED_ITEM* aStartItem );
void UpdateHighlightedNets( BOARD_CONNECTED_ITEM* aStartItem );
private:
///< Set up handlers for various events.

View File

@ -186,14 +186,6 @@ TOOL_ACTION PCB_ACTIONS::drawTextBox( TOOL_ACTION_ARGS()
.Icon( BITMAPS::add_textbox )
.Flags( AF_ACTIVATE ) );
TOOL_ACTION PCB_ACTIONS::placeMeanders( TOOL_ACTION_ARGS()
.Name( "pcbnew.InteractiveDrawing.placeMeanders" )
.Scope( AS_GLOBAL )
.MenuText( _( "Add Meander" ) )
.Tooltip( _( "Add meander for length tuning" ) )
.Icon( BITMAPS::ps_tune_length )
.Flags( AF_ACTIVATE ) );
TOOL_ACTION PCB_ACTIONS::spacingIncrease( TOOL_ACTION_ARGS()
.Name( "pcbnew.lengthTuner.SpacingIncrease" )
.Scope( AS_GLOBAL )
@ -2284,37 +2276,26 @@ TOOL_ACTION PCB_ACTIONS::selectLayerPair( TOOL_ACTION_ARGS()
.Icon( BITMAPS::select_layer_pair )
.Flags( AF_ACTIVATE ) );
TOOL_ACTION PCB_ACTIONS::routerTuneSingleTrace( TOOL_ACTION_ARGS()
TOOL_ACTION PCB_ACTIONS::tuneLength( TOOL_ACTION_ARGS()
.Name( "pcbnew.LengthTuner.TuneSingleTrack" )
.Scope( AS_GLOBAL )
.DefaultHotkey( '7' )
.DefaultHotkeyAlt( '8' )
// Don't be tempted to remove "Modern Toolset only". It's in the legacy property name.
.LegacyHotkeyName( "Tune Single Track (Modern Toolset only)" )
.MenuText( _( "Tune length of a single track" ) )
.Tooltip( _( "Tune length of a single track" ) )
.MenuText( _( "Tune Length" ) )
.Tooltip( _( "Tune length of a single track or differential pair" ) )
.Icon( BITMAPS::ps_tune_length )
.Flags( AF_ACTIVATE )
.Parameter( PNS::PNS_MODE_TUNE_SINGLE ) );
TOOL_ACTION PCB_ACTIONS::routerTuneDiffPair( TOOL_ACTION_ARGS()
.Name( "pcbnew.LengthTuner.TuneDiffPair" )
.Scope( AS_GLOBAL )
.DefaultHotkey( '8' )
// Don't be tempted to remove "Modern Toolset only". It's in the legacy property name.
.LegacyHotkeyName( "Tune Differential Pair Length (Modern Toolset only)" )
.MenuText( _( "Tune length of a differential pair" ) )
.Tooltip( _( "Tune length of a differential pair" ) )
.Icon( BITMAPS::ps_diff_pair_tune_length )
.Flags( AF_ACTIVATE )
.Parameter( PNS::PNS_MODE_TUNE_DIFF_PAIR ) );
TOOL_ACTION PCB_ACTIONS::routerTuneDiffPairSkew( TOOL_ACTION_ARGS()
TOOL_ACTION PCB_ACTIONS::tuneSkew( TOOL_ACTION_ARGS()
.Name( "pcbnew.LengthTuner.TuneDiffPairSkew" )
.Scope( AS_GLOBAL )
.DefaultHotkey( '9' )
// Don't be tempted to remove "Modern Toolset only". It's in the legacy property name.
.LegacyHotkeyName( "Tune Differential Pair Skew (Modern Toolset only)" )
.MenuText( _( "Tune skew of a differential pair" ) )
.MenuText( _( "Tune Skew of a Differential Pair" ) )
.Tooltip( _( "Tune skew of a differential pair" ) )
.Icon( BITMAPS::ps_diff_pair_tune_phase )
.Flags( AF_ACTIVATE )

View File

@ -198,7 +198,6 @@ public:
static TOOL_ACTION placeImage;
static TOOL_ACTION placeText;
static TOOL_ACTION drawTextBox;
static TOOL_ACTION placeMeanders;
static TOOL_ACTION spacingIncrease;
static TOOL_ACTION spacingDecrease;
static TOOL_ACTION amplIncrease;
@ -243,14 +242,8 @@ public:
/// Activation of the Push and Shove router (differential pair mode)
static TOOL_ACTION routeDiffPair;
/// Activation of the Push and Shove router (tune single line mode)
static TOOL_ACTION routerTuneSingleTrace;
/// Activation of the Push and Shove router (diff pair tuning mode)
static TOOL_ACTION routerTuneDiffPair;
/// Activation of the Push and Shove router (skew tuning mode)
static TOOL_ACTION routerTuneDiffPairSkew;
static TOOL_ACTION tuneLength;
static TOOL_ACTION tuneSkew;
static TOOL_ACTION routerUndoLastSegment;