KiCad PCB EDA Suite
ROUTER_TOOL Class Reference

#include <router_tool.h>

Inheritance diagram for ROUTER_TOOL:
PNS::TOOL_BASE PCB_TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 ROUTER_TOOL ()
 
 ~ROUTER_TOOL ()
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
int MainLoop (const TOOL_EVENT &aEvent)
 
int InlineBreakTrack (const TOOL_EVENT &aEvent)
 
bool CanInlineDrag (int aDragMode)
 
int InlineDrag (const TOOL_EVENT &aEvent)
 
int SelectCopperLayerPair (const TOOL_EVENT &aEvent)
 
int DpDimensionsDialog (const TOOL_EVENT &aEvent)
 
int SettingsDialog (const TOOL_EVENT &aEvent)
 
int ChangeRouterMode (const TOOL_EVENT &aEvent)
 
int CustomTrackWidthDialog (const TOOL_EVENT &aEvent)
 
PNS::PNS_MODE GetRouterMode ()
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
ROUTER * Router () const
 
void SetIsFootprintEditor (bool aEnabled)
 Function SetIsFootprintEditor() More...
 
bool IsFootprintEditor () const
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Static Public Member Functions

static void NeighboringSegmentFilter (const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
 

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

bool checkSnap (ITEM *aItem)
 
const VECTOR2I snapToItem (ITEM *aSnapToItem, const VECTOR2I &aP)
 
virtual ITEM * pickSingleItem (const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
 
virtual void highlightNet (bool aEnabled, int aNetcode=-1)
 
virtual void updateStartItem (const TOOL_EVENT &aEvent, bool aIgnorePads=false)
 
virtual void updateEndItem (const TOOL_EVENT &aEvent)
 
void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
FOOTPRINTfootprint () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCB_SELECTIONselection () const
 
PCB_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

SIZES_SETTINGS m_savedSizes
 
ITEM * m_startItem
 
VECTOR2I m_startSnapPoint
 
bool m_startHighlight
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
PCB_GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
bool m_cancelled
 
bool m_isFootprintEditor
 
TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

void performRouting ()
 
void performDragging (int aMode=PNS::DM_ANY)
 
void breakTrack ()
 
void handleCommonEvents (TOOL_EVENT &evt)
 
int handleLayerSwitch (const TOOL_EVENT &aEvent, bool aForceVia)
 
int getStartLayer (const PNS::ITEM *aItem)
 
void switchLayerOnViaPlacement ()
 
int onLayerCommand (const TOOL_EVENT &aEvent)
 
int onViaCommand (const TOOL_EVENT &aEvent)
 
int onTrackViaSizeChanged (const TOOL_EVENT &aEvent)
 
bool prepareInteractive ()
 
bool finishInteractive ()
 
void saveRouterDebugLog ()
 
void updateMessagePanel ()
 

Private Attributes

std::shared_ptr< ACTION_MENUm_diffPairMenu
 
std::shared_ptr< ACTION_MENUm_trackViaMenu
 
int m_lastTargetLayer
 

Detailed Description

Definition at line 28 of file router_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

Handle the rotate action in the loop by calling the item's rotate method.

IPO_FLIP 

Handle flip action in the loop by calling the item's flip method.

IPO_SINGLE_CLICK 

Create an item immediately on placement starting, otherwise show the pencil cursor until the item is created.

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 110 of file pcb_tool_base.h.

110  {
112  IPO_ROTATE = 0x01,
113 
115  IPO_FLIP = 0x02,
116 
119  IPO_SINGLE_CLICK = 0x04,
120 
122  IPO_REPEAT = 0x08
123  };
Handle flip action in the loop by calling the item's flip method.
Allow repeat placement of the item.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
Handle the rotate action in the loop by calling the item's rotate method.

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determine the reason of reset for a tool.

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 77 of file tool_base.h.

78  {
79  RUN,
80  MODEL_RELOAD,
81  GAL_SWITCH
82  };
Model changes (required full reload)
Definition: tool_base.h:80
Tool is invoked after being inactive.
Definition: tool_base.h:79
Rendering engine changes.
Definition: tool_base.h:81

Constructor & Destructor Documentation

◆ ROUTER_TOOL()

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 169 of file router_tool.cpp.

169  :
170  TOOL_BASE( "pcbnew.InteractiveRouter" ),
172 {
173 }
TOOL_BASE(const std::string &aToolName)
int m_lastTargetLayer
Definition: router_tool.h:82

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 419 of file router_tool.cpp.

420 {
421 }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), InlineBreakTrack(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 159 of file pcb_tool_base.h.

159 { return getModel<BOARD>(); }

Referenced by PCB_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), BOARD_INSPECTION_TOOL::ClearHighlight(), EDIT_TOOL::copyToClipboard(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), MICROWAVE_TOOL::createInductorBetween(), CustomTrackWidthDialog(), PCB_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportNetlist(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::filterSelection(), PCB_TOOL_BASE::footprint(), PCB_SELECTION_TOOL::GetBoard(), PCB_SELECTION_TOOL::getCollectorsGuide(), GROUP_TOOL::Group(), handleLayerSwitch(), BOARD_INSPECTION_TOOL::highlightNet(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_CONTROL::LayerNext(), PCB_CONTROL::LayerPrev(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::MoveExact(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), PCB_CONTROL::Paste(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PAD_TOOL::PlacePad(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), BOARD_EDITOR_CONTROL::RepairBoard(), FOOTPRINT_EDITOR_CONTROL::RepairFootprint(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::selectAllItemsOnNet(), PCB_SELECTION_TOOL::selectAllItemsOnSheet(), PCB_SELECTION_TOOL::selectConnectedTracks(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectPoint(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::unfilledZoneCheck(), GROUP_TOOL::Ungroup(), updateMessagePanel(), PCB_CONTROL::ViaDisplayMode(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ breakTrack()

void ROUTER_TOOL::breakTrack ( )
private

Definition at line 1239 of file router_tool.cpp.

1240 {
1243 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:839
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:136

References PNS::ROUTER::BreakSegment(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ITEM::OfKind(), and PNS::ITEM::SEGMENT_T.

Referenced by InlineBreakTrack(), and MainLoop().

◆ CanInlineDrag()

bool ROUTER_TOOL::CanInlineDrag ( int  aDragMode)

Definition at line 1523 of file router_tool.cpp.

1524 {
1526  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1527 
1528  if( selection.Size() == 1 )
1529  {
1530  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1531 
1532  // Note: EDIT_TOOL::Drag temporarily handles items of type PCB_ARC_T on its own using
1533  // DragArcTrack(), so PCB_ARC_T should never occur here.
1535  {
1536  static const KICAD_T footprints[] = { PCB_FOOTPRINT_T, EOT };
1537 
1538  // Footprints cannot be dragged freely.
1539  if( item->IsType( footprints ) )
1540  return !( aDragMode & PNS::DM_FREE_ANGLE );
1541  else
1542  return true;
1543  }
1544  }
1545 
1546  return false;
1547 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
const PCB_SELECTION & selection() const
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
static const KICAD_T DraggableItems[]
A scan list for items that can be dragged.
Definition: collectors.h:313
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
The selection tool: currently supports:
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
EDA_ITEM * Front() const
Definition: selection.h:144

References PNS::DM_FREE_ANGLE, GENERAL_COLLECTOR::DraggableItems, EOT, SELECTION::Front(), TOOL_MANAGER::GetTool(), EDA_ITEM::IsType(), TOOL_BASE::m_toolMgr, NeighboringSegmentFilter(), PCB_FOOTPRINT_T, TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionCursor, and SELECTION::Size().

◆ canvas()

◆ ChangeRouterMode()

int ROUTER_TOOL::ChangeRouterMode ( const TOOL_EVENT aEvent)

Definition at line 1222 of file router_tool.cpp.

1223 {
1224  PNS::PNS_MODE mode = aEvent.Parameter<PNS::PNS_MODE>();
1225  PNS::ROUTING_SETTINGS& settings = m_router->Settings();
1226 
1227  settings.SetMode( mode );
1228 
1229  return 0;
1230 }
Contain all persistent settings of the router, such as the mode, optimization effort,...
void SetMode(PNS_MODE aMode)
Return the optimizer effort. Bigger means cleaner traces, but slower routing.
PNS_MODE
< Routing modes
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181

References PNS::TOOL_BASE::m_router, TOOL_EVENT::Parameter(), PNS::ROUTING_SETTINGS::SetMode(), and PNS::ROUTER::Settings().

Referenced by setTransitions().

◆ checkSnap()

bool TOOL_BASE::checkSnap ( ITEM aItem)
protectedinherited

Definition at line 241 of file pns_tool_base.cpp.

242 {
243  // Sync PNS engine settings with the general PCB editor options.
244  auto& pnss = m_router->Settings();
245 
246  pnss.SetSnapToPads(
247  frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ||
248  frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
249 
250  pnss.SetSnapToTracks(
251  frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL
252  || frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
253 
254  if( aItem )
255  {
256  if( aItem->OfKind( ITEM::VIA_T | ITEM::SEGMENT_T | ITEM::ARC_T ) )
257  return pnss.GetSnapToTracks();
258  else if( aItem->OfKind( ITEM::SOLID_T ) )
259  return pnss.GetSnapToPads();
260  }
261 
262  return false;
263 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetSnapToPads(bool aSnap)
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181

References PNS::ITEM::ARC_T, CAPTURE_ALWAYS, CAPTURE_CURSOR_IN_TRACK_TOOL, PCB_TOOL_BASE::frame(), PNS::TOOL_BASE::m_router, PNS::ITEM::OfKind(), PNS::ITEM::SEGMENT_T, PNS::ROUTING_SETTINGS::SetSnapToPads(), PNS::ROUTER::Settings(), PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

Referenced by PNS::TOOL_BASE::updateEndItem().

◆ controls()

◆ CustomTrackWidthDialog()

int ROUTER_TOOL::CustomTrackWidthDialog ( const TOOL_EVENT aEvent)

Definition at line 1844 of file router_tool.cpp.

1845 {
1847  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1848 
1849  if( sizeDlg.ShowModal() == wxID_OK )
1850  {
1851  bds.UseCustomTrackViaSize( true );
1852 
1853  TOOL_EVENT dummy;
1855  }
1856 
1857  return 0;
1858 }
BOARD * board() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
PCB_BASE_EDIT_FRAME * frame() const
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:71
Generic, UI-independent tool event.
Definition: tool_event.h:152
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
Container for design settings for a BOARD object.

References PCB_TOOL_BASE::board(), dummy(), PCB_TOOL_BASE::frame(), BOARD::GetDesignSettings(), onTrackViaSizeChanged(), and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

Definition at line 294 of file pcb_tool_base.cpp.

295 {
296  return frame()->GetDisplayOptions();
297 }
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCB_BASE_EDIT_FRAME * frame() const

References PCB_TOOL_BASE::frame(), and PCB_BASE_FRAME::GetDisplayOptions().

Referenced by BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), PCB_CONTROL::HighContrastMode(), PCB_CONTROL::HighContrastModeCycle(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PNS::TOOL_BASE::pickSingleItem(), PCB_CONTROL::ToggleRatsnest(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::ViaDisplayMode(), and PCB_CONTROL::ZoneDisplayMode().

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const std::string &  aTool,
INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc.

More complex interactive processes are not supported here, you should implement a customised event loop for those.

Parameters
aItemCreatorthe callable that will attempt to create the item
aCommitMessagethe message used on a successful commit

Definition at line 35 of file pcb_tool_base.cpp.

38 {
39  using namespace std::placeholders;
40  std::unique_ptr<BOARD_ITEM> newItem;
41 
42  frame()->PushTool( aTool );
43  Activate();
44 
45  BOARD_COMMIT commit( frame() );
46 
48 
49  // do not capture or auto-pan until we start placing an item
50  controls()->ShowCursor( true );
51 
52  // Add a VIEW_GROUP that serves as a preview for the new item
53  PCB_SELECTION preview;
54  view()->Add( &preview );
55 
56  aPlacer->m_board = board();
57  aPlacer->m_frame = frame();
58  aPlacer->m_modifiers = 0;
59 
60  auto makeNewItem =
61  [&]( VECTOR2I aPosition )
62  {
63  if( frame()->GetModel() )
64  newItem = aPlacer->CreateItem();
65 
66  if( newItem )
67  {
68  newItem->SetPosition( (wxPoint) aPosition );
69  preview.Add( newItem.get() );
70 
71  if( newItem->Type() == PCB_FOOTPRINT_T )
72  {
73  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
74 
75  // footprints have more drawable parts
76  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
77  }
78  }
79  };
80 
81  if( aOptions & IPO_SINGLE_CLICK )
82  makeNewItem( controls()->GetCursorPosition() );
83 
84  auto setCursor =
85  [&]()
86  {
87  if( !newItem )
89  else
91  };
92 
93  // Set initial cursor
94  setCursor();
95 
96  // Main loop: keep receiving events
97  while( TOOL_EVENT* evt = Wait() )
98  {
99  setCursor();
100 
101  VECTOR2I cursorPos = controls()->GetCursorPosition();
102  aPlacer->m_modifiers = evt->Modifier();
103 
104  auto cleanup =
105  [&] ()
106  {
107  newItem = nullptr;
108  preview.Clear();
109  view()->Update( &preview );
110  controls()->SetAutoPan( false );
111  controls()->CaptureCursor( false );
112  controls()->ShowCursor( true );
113  };
114 
115  if( evt->IsCancelInteractive() )
116  {
117  if( aOptions & IPO_SINGLE_CLICK )
118  {
119  cleanup();
120  frame()->PopTool( aTool );
121  break;
122  }
123  else if( newItem )
124  {
125  cleanup();
126  }
127  else
128  {
129  frame()->PopTool( aTool );
130  break;
131  }
132  }
133  else if( evt->IsActivate() )
134  {
135  if( newItem )
136  cleanup();
137 
138  if( evt->IsPointEditor() )
139  {
140  // don't exit (the point editor runs in the background)
141  }
142  else if( evt->IsMoveTool() )
143  {
144  // leave ourselves on the stack so we come back after the move
145  break;
146  }
147  else
148  {
149  frame()->PopTool( aTool );
150  break;
151  }
152  }
153  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
154  {
155  if( !newItem )
156  {
157  // create the item if possible
158  makeNewItem( cursorPos );
159 
160  // no item created, so wait for another click
161  if( !newItem )
162  continue;
163 
164  controls()->CaptureCursor( true );
165  controls()->SetAutoPan( true );
166  }
167  else
168  {
169  auto oldFlags = newItem->GetFlags();
170  newItem->ClearFlags();
171 
172  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
173  {
174  newItem->SetFlags( oldFlags );
175  continue;
176  }
177 
178  preview.Clear();
179  newItem.release();
180  commit.Push( aCommitMessage );
181 
182  controls()->CaptureCursor( false );
183  controls()->SetAutoPan( false );
184  controls()->ShowCursor( true );
185 
186  if( !( aOptions & IPO_REPEAT ) )
187  break;
188 
189  if( aOptions & IPO_SINGLE_CLICK )
190  makeNewItem( controls()->GetCursorPosition() );
191 
192  setCursor();
193  }
194  }
195  else if( evt->IsClick( BUT_RIGHT ) )
196  {
198  }
199  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
200  {
202  }
203  else if( newItem && evt->Category() == TC_COMMAND )
204  {
205  /*
206  * Handle any events that can affect the item as we move it around
207  */
208  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
209  {
210  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
211  newItem->Rotate( newItem->GetPosition(), rotationAngle );
212  view()->Update( &preview );
213  }
214  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
215  {
216  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
217  view()->Update( &preview );
218  }
219  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
220  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
221  {
222  // Refresh preview after event runs
224  }
225  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
226  {
227  frame()->OnEditItemRequest( newItem.get() );
228 
229  // Notify other tools of the changes
231  }
232  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
233  {
234  preview.Clear();
235  newItem.release();
236 
237  makeNewItem( (wxPoint) cursorPos );
238  aPlacer->SnapItem( newItem.get() );
239  view()->Update( &preview );
240  }
241  else
242  {
243  evt->SetPassEvent();
244  }
245  }
246  else if( newItem && evt->IsMotion() )
247  {
248  // track the cursor
249  newItem->SetPosition( (wxPoint) cursorPos );
250  aPlacer->SnapItem( newItem.get() );
251 
252  // Show a preview of the item
253  view()->Update( &preview );
254  }
255  else
256  {
257  evt->SetPassEvent();
258  }
259  }
260 
261  view()->Remove( &preview );
263  controls()->SetAutoPan( false );
264  controls()->CaptureCursor( false );
265 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:82
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:31
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:300
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:303
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
const PCB_SELECTION & selection() const
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
Generic, UI-independent tool event.
Definition: tool_event.h:152
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
PCBNEW_SETTINGS & Settings()
void Activate()
Run the tool.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings,...
Definition: footprint.cpp:1189
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:64
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:301
static TOOL_ACTION refreshPreview
Definition: actions.h:106
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), PCB_FOOTPRINT_T, PENCIL, PLACE, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::ProcessEvent(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), FOOTPRINT::RunOnChildren(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, PCB_ACTIONS::trackViaSizeChanged, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DRAWING_TOOL::DrawVia(), and PAD_TOOL::PlacePad().

◆ DpDimensionsDialog()

int ROUTER_TOOL::DpDimensionsDialog ( const TOOL_EVENT aEvent)

Definition at line 1192 of file router_tool.cpp.

1193 {
1194  PNS::SIZES_SETTINGS sizes = m_router->Sizes();
1195  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
1196 
1197  if( settingsDlg.ShowModal() == wxID_OK )
1198  {
1199  m_router->UpdateSizes( sizes );
1200  m_savedSizes = sizes;
1201 
1203  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
1204  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
1205  bds.SetCustomDiffPairViaGap( sizes.DiffPairViaGap() );
1206  }
1207 
1208  return 0;
1209 }
void SetCustomDiffPairViaGap(int aGap)
Sets custom via gap for differential pairs (i.e.
SIZES_SETTINGS m_savedSizes
Definition: pns_tool_base.h:68
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:200
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
PCB_BASE_EDIT_FRAME * frame() const
void SetCustomDiffPairWidth(int aWidth)
Sets custom track width for differential pairs (i.e.
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetCustomDiffPairGap(int aGap)
Sets custom gap for differential pairs (i.e.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:554
BOARD * GetBoard() const
Container for design settings for a BOARD object.

References PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairViaGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSizes, BOARD_DESIGN_SETTINGS::SetCustomDiffPairGap(), BOARD_DESIGN_SETTINGS::SetCustomDiffPairViaGap(), BOARD_DESIGN_SETTINGS::SetCustomDiffPairWidth(), PNS::ROUTER::Sizes(), and PNS::ROUTER::UpdateSizes().

Referenced by setTransitions().

◆ finishInteractive()

bool ROUTER_TOOL::finishInteractive ( )
private

Definition at line 1043 of file router_tool.cpp.

1044 {
1045  m_router->StopRouting();
1046 
1047  m_startItem = nullptr;
1048  m_endItem = nullptr;
1049 
1052  controls()->SetAutoPan( false );
1053  controls()->ForceCursorPosition( false );
1054  frame()->UndoRedoBlock( false );
1055  highlightNet( false );
1056 
1057  return true;
1058 }
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void updateMessagePanel()
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
PCB_BASE_EDIT_FRAME * frame() const
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:702
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
KIGFX::VIEW_CONTROLS * controls() const

References ARROW, PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::TOOL_BASE::highlightNet(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::StopRouting(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), and updateMessagePanel().

Referenced by performRouting().

◆ footprint()

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 154 of file pcb_tool_base.h.

155  {
156  return getEditFrame<PCB_BASE_EDIT_FRAME>();
157  }

Referenced by PCB_POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), CustomTrackWidthDialog(), FOOTPRINT_EDITOR_CONTROL::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DpDimensionsDialog(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportSpecctraDSN(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), finishInteractive(), EDIT_TOOL::Flip(), PCB_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), handleLayerSwitch(), BOARD_INSPECTION_TOOL::HighlightItem(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_EDITOR_CONTROL::ImportSpecctraSession(), Init(), SCRIPTING_TOOL::Init(), PCB_SELECTION_TOOL::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PCB_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), SCRIPTING_TOOL::reloadPlugins(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), PCB_SELECTION_TOOL::RequestSelection(), PNS::TOOL_BASE::Reset(), SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_POINT_EDITOR::setEditedPoint(), SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), switchLayerOnViaPlacement(), PCB_CONTROL::unfilledZoneCheck(), updateMessagePanel(), EDIT_TOOL::updateModificationPoint(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ getEditFrame()

template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Return the application window object, casted to requested user type.

Definition at line 184 of file tool_base.h.

185  {
186 #if !defined( QA_TEST ) // Dynamic casts give the linker a seizure in the test framework
187  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
188 #endif
189  return static_cast<T*>( getToolHolderInt() );
190  }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), TOOL_MANAGER::saveViewControls(), and TOOL_MANAGER::ShutdownTool().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), and ZONE_CREATE_HELPER::createZoneFromExisting().

◆ GetName()

const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Return the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

134  {
135  return m_toolName;
136  }
std::string m_toolName
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), TOOL_MANAGER::RegisterTool(), and TOOL_MANAGER::runTool().

◆ GetRouterMode()

PNS::PNS_MODE ROUTER_TOOL::GetRouterMode ( )

Definition at line 1233 of file router_tool.cpp.

1234 {
1235  return m_router->Settings().Mode();
1236 }
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181

References PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), and PNS::ROUTER::Settings().

Referenced by PCB_EDIT_FRAME::setupUIConditions().

◆ getStartLayer()

int ROUTER_TOOL::getStartLayer ( const PNS::ITEM aItem)
private

Definition at line 580 of file router_tool.cpp.

581 {
582  int tl = getView()->GetTopLayer();
583 
584  if( m_startItem )
585  {
586  const LAYER_RANGE& ls = m_startItem->Layers();
587 
588  if( ls.Overlaps( tl ) )
589  return tl;
590  else
591  return ls.Start();
592  }
593 
594  return tl;
595 }
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
int Start() const
Definition: pns_layerset.h:82
virtual int GetTopLayer() const
Definition: view.cpp:828
ITEM * m_startItem
Definition: pns_tool_base.h:69
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
const LAYER_RANGE & Layers() const
Definition: pns_item.h:152

References KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_startItem, LAYER_RANGE::Overlaps(), and LAYER_RANGE::Start().

Referenced by prepareInteractive().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

109  {
110  return m_type;
111  }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37 {
38  return m_toolMgr->GetView();
39 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updateParentItem(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Return the instance of VIEW_CONTROLS object used in the application.

It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.).

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

43 {
44  return m_toolMgr->GetViewControls();
45 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:285

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149 {
150  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151 
152  goInternal( sptr, aConditions );
153 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), PAD_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), DRC_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( TOOL_EVENT evt)
private

Definition at line 554 of file router_tool.cpp.

555 {
556  if( aEvent.Category() == TC_VIEW || aEvent.Category() == TC_MOUSE )
557  {
558  BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
559  m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
560  }
561 
562  if( !aEvent.IsKeyPressed() )
563  return;
564 
565  switch( aEvent.KeyCode() )
566  {
567  case '0':
569  return;
570 
572  aEvent.SetPassEvent( false );
573  break;
574  default:
575  break;
576  }
577 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
bool m_ShowRouterDebugGraphics
Show PNS router debug graphics.
void SetVisibleViewArea(const BOX2I &aExtents)
Definition: pns_router.h:209
ROUTER * m_router
Definition: pns_tool_base.h:78
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
void saveRouterDebugLog()
BOX2D GetVisibleWorldExtents() const
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const Vec & GetSize() const
Definition: box2.h:172
const Vec & GetOrigin() const
Definition: box2.h:176

References TOOL_EVENT::Category(), ADVANCED_CFG::GetCfg(), KIGFX::VIEW::GetGAL(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetSize(), TOOL_BASE::getView(), KIGFX::GAL::GetVisibleWorldExtents(), TOOL_EVENT::IsKeyPressed(), TOOL_EVENT::KeyCode(), PNS::TOOL_BASE::m_router, ADVANCED_CFG::m_ShowRouterDebugGraphics, saveRouterDebugLog(), TOOL_EVENT::SetPassEvent(), PNS::ROUTER::SetVisibleViewArea(), TC_MOUSE, and TC_VIEW.

Referenced by InlineDrag(), performDragging(), and performRouting().

◆ handleLayerSwitch()

int ROUTER_TOOL::handleLayerSwitch ( const TOOL_EVENT aEvent,
bool  aForceVia 
)
private

Definition at line 718 of file router_tool.cpp.

719 {
720  wxCHECK( m_router, 0 );
721 
722  if( !IsToolActive() )
723  return 0;
724 
725  // First see if this is one of the switch layer commands
726  LSEQ layers = LSET( board()->GetEnabledLayers() & LSET::AllCuMask() ).Seq();
728  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
729 
730  if( aEvent.IsAction( &PCB_ACTIONS::layerNext ) )
731  {
732  size_t idx = 0;
733 
734  for( size_t i = 0; i < layers.size(); i++ )
735  {
736  if( layers[i] == m_lastTargetLayer )
737  {
738  idx = i;
739  break;
740  }
741  }
742 
743  idx = ( idx + 1 ) % layers.size();
744  targetLayer = layers[idx];
745  }
746  else if( aEvent.IsAction( &PCB_ACTIONS::layerPrev ) )
747  {
748  size_t idx = 0;
749 
750  for( size_t i = 0; i < layers.size(); i++ )
751  {
752  if( layers[i] == m_lastTargetLayer )
753  {
754  idx = i;
755  break;
756  }
757  }
758 
759  idx = ( idx > 0 ) ? ( idx - 1 ) : ( layers.size() - 1 );
760  targetLayer = layers[idx];
761  }
762  else
763  {
764  targetLayer = getTargetLayerFromEvent( aEvent );
765  }
766 
767  if( targetLayer != UNDEFINED_LAYER )
768  {
769  m_lastTargetLayer = targetLayer;
770 
771  if( targetLayer == currentLayer )
772  return 0;
773 
774  if( !aForceVia && m_router && m_router->SwitchLayer( targetLayer ) )
775  {
776  updateEndItem( aEvent );
777  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
778  return 0;
779  }
780  }
781 
783  const int layerCount = bds.GetCopperLayerCount();
784 
787 
789 
790  VIATYPE viaType = VIATYPE::THROUGH;
791  bool selectLayer = false;
792 
793  // Otherwise it is one of the router-specific via commands
794  if( targetLayer == UNDEFINED_LAYER )
795  {
796  const int actViaFlags = aEvent.Parameter<intptr_t>();
797  selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
798 
799  viaType = getViaTypeFromFlags( actViaFlags );
800 
801  // ask the user for a target layer
802  if( selectLayer )
803  {
804  wxPoint endPoint = (wxPoint) view()->ToScreen( m_endSnapPoint );
805  endPoint = frame()->GetCanvas()->ClientToScreen( endPoint );
806 
807  targetLayer = frame()->SelectOneLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
808  LSET::AllNonCuMask(), endPoint );
809 
810  // Reset the cursor to the end of the track
812 
813  if( targetLayer == UNDEFINED_LAYER ) // cancelled by user
814  return 0;
815  }
816  }
817 
818  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
819  sizes.ClearLayerPairs();
820 
821  if( !m_router->IsPlacingVia() )
822  {
823  // Cannot place microvias or blind vias if not allowed (obvious)
824  if( ( viaType == VIATYPE::BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
825  {
826  WX_INFOBAR* infobar = frame()->GetInfoBar();
827  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
828  _( "Show board setup" ),
829  wxEmptyString );
830 
831  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
832  [&]( wxHyperlinkEvent& aEvent )
833  {
834  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
835  } ) );
836 
837  infobar->RemoveAllButtons();
838  infobar->AddButton( button );
839 
840  infobar->ShowMessageFor( _( "Blind/buried vias must first be enabled in "
841  "Board Setup > Design Rules > Constraints." ),
842  10000, wxICON_ERROR );
843  return false;
844  }
845 
846  if( ( viaType == VIATYPE::MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
847  {
848  WX_INFOBAR* infobar = frame()->GetInfoBar();
849  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
850  _( "Show board setup" ), wxEmptyString );
851 
852  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
853  [&]( wxHyperlinkEvent& aEvent )
854  {
855  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
856  } ) );
857 
858  infobar->RemoveAllButtons();
859  infobar->AddButton( button );
860 
861  infobar->ShowMessageFor( _( "Microvias must first be enabled in "
862  "Board Setup > Design Rules > Constraints." ),
863  10000, wxICON_ERROR );
864  return false;
865  }
866  }
867 
868  // Convert blind/buried via to a through hole one, if it goes through all layers
869  if( viaType == VIATYPE::BLIND_BURIED
870  && ( ( targetLayer == B_Cu && currentLayer == F_Cu )
871  || ( targetLayer == F_Cu && currentLayer == B_Cu ) ) )
872  {
873  viaType = VIATYPE::THROUGH;
874  }
875 
876  if( targetLayer == UNDEFINED_LAYER )
877  {
878  // Implicic layer selection
879 
880  switch( viaType )
881  {
882  case VIATYPE::THROUGH:
883  // use the default layer pair
884  currentLayer = pairTop;
885  targetLayer = pairBottom;
886  break;
887 
888  case VIATYPE::MICROVIA:
889  if( currentLayer == F_Cu || currentLayer == In1_Cu )
890  {
891  // front-side microvia
892  currentLayer = F_Cu;
893  targetLayer = In1_Cu;
894  }
895  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
896  {
897  // back-side microvia
898  currentLayer = B_Cu,
899  targetLayer = (PCB_LAYER_ID) ( layerCount - 2 );
900  }
901  else
902  {
903  wxFAIL_MSG( "Invalid implicit layer pair for microvia (must be on "
904  "or adjacent to an outer layer)." );
905  }
906  break;
907 
909  if( currentLayer == pairTop || currentLayer == pairBottom )
910  {
911  // the current layer is on the defined layer pair,
912  // swap to the other side
913  currentLayer = pairTop;
914  targetLayer = pairBottom;
915  }
916  else
917  {
918  // the current layer is not part of the current layer pair,
919  // so fallback and swap to the top layer of the pair by default
920  targetLayer = pairTop;
921  }
922  break;
923 
924  default:
925  wxFAIL_MSG( "unexpected via type" );
926  break;
927  }
928  }
929 
930  sizes.SetViaDiameter( bds.m_ViasMinSize );
931  sizes.SetViaDrill( bds.m_MinThroughDrill );
932 
933  if( bds.UseNetClassVia() || viaType == VIATYPE::MICROVIA )
934  {
935  PCB_VIA dummyVia( board() );
936  dummyVia.SetViaType( viaType );
937  dummyVia.SetLayerPair( currentLayer, targetLayer );
938 
939  if( !m_router->GetCurrentNets().empty() )
940  dummyVia.SetNetCode( m_router->GetCurrentNets()[0] );
941 
942  DRC_CONSTRAINT constraint;
943 
944  constraint = bds.m_DRCEngine->EvalRules( VIA_DIAMETER_CONSTRAINT, &dummyVia, nullptr,
945  currentLayer );
946 
947  if( !constraint.IsNull() )
948  sizes.SetViaDiameter( constraint.m_Value.Opt() );
949 
950  constraint = bds.m_DRCEngine->EvalRules( HOLE_SIZE_CONSTRAINT, &dummyVia, nullptr,
951  currentLayer );
952 
953  if( !constraint.IsNull() )
954  sizes.SetViaDrill( constraint.m_Value.Opt() );
955  }
956  else
957  {
958  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
959  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
960  }
961 
962  sizes.SetViaType( viaType );
963  sizes.AddLayerPair( currentLayer, targetLayer );
964 
965  m_router->UpdateSizes( sizes );
966 
967  if( !m_router->IsPlacingVia() )
969 
970  m_lastTargetLayer = targetLayer;
971 
972  if( m_router->RoutingInProgress() )
973  updateEndItem( aEvent );
974  else
975  updateStartItem( aEvent );
976 
977  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
978 
979  return 0;
980 }
PCB_LAYER_ID SelectOneLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Show the dialog box for a layer selection.
Definition: sel_layer.cpp:231
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:123
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:246
static TOOL_ACTION layerNext
Definition: pcb_actions.h:287
BOARD * board() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:773
bool IsPlacingVia() const
Definition: pns_router.cpp:792
Ask user to select layer before adding via.
Definition: router_tool.cpp:75
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:764
T Opt() const
Definition: minoptmax.h:35
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
void SetViaDrill(int aDrill)
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:200
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
void ToggleViaPlacement()
Definition: pns_router.cpp:754
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
MINOPTMAX< int > m_Value
Definition: drc_rule.h:143
static VIATYPE getViaTypeFromFlags(int aFlags)
virtual void updateEndItem(const TOOL_EVENT &aEvent)
#define _(s)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:288
static PCB_LAYER_ID getTargetLayerFromEvent(const TOOL_EVENT &aEvent)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
bool UseNetClassVia() const
Return true if netclass values should be used to obtain appropriate via size.
KIGFX::PCB_VIEW * view() const
ROUTER * m_router
Definition: pns_tool_base.h:78
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:427
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
Definition: view.cpp:469
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:287
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:463
void SetViaType(VIATYPE aViaType)
bool IsNull() const
Definition: drc_rule.h:117
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
VIATYPE
Definition: pcb_track.h:60
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:554
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
Definition: layer_ids.h:70
bool IsToolActive() const
Definition: tool_base.cpp:31
bool SwitchLayer(int layer)
Definition: pns_router.cpp:745
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
WX_INFOBAR * GetInfoBar()
void AddLayerPair(int aL1, int aL2)
int m_lastTargetLayer
Definition: router_tool.h:82
bool m_MicroViasAllowed
true to allow micro vias
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void SetViaDiameter(int aDiameter)
std::shared_ptr< DRC_ENGINE > m_DRCEngine
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
Container for design settings for a BOARD object.
int GetCurrentLayer() const
Definition: pns_router.cpp:775

References _, WX_INFOBAR::AddButton(), PNS::SIZES_SETTINGS::AddLayerPair(), LSET::AllCuMask(), LSET::AllNonCuMask(), B_Cu, BLIND_BURIED, PCB_TOOL_BASE::board(), PNS::SIZES_SETTINGS::ClearLayerPairs(), PCB_TOOL_BASE::controls(), F_Cu, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), BOARD_DESIGN_SETTINGS::GetCopperLayerCount(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), EDA_BASE_FRAME::GetInfoBar(), PCB_BASE_FRAME::GetScreen(), getTargetLayerFromEvent(), getViaTypeFromFlags(), HOLE_SIZE_CONSTRAINT, In1_Cu, TOOL_EVENT::IsAction(), DRC_CONSTRAINT::IsNull(), PNS::ROUTER::IsPlacingVia(), TOOL_BASE::IsToolActive(), PCB_ACTIONS::layerNext, PCB_ACTIONS::layerPrev, BOARD_DESIGN_SETTINGS::m_BlindBuriedViaAllowed, BOARD_DESIGN_SETTINGS::m_DRCEngine, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, m_lastTargetLayer, BOARD_DESIGN_SETTINGS::m_MicroViasAllowed, BOARD_DESIGN_SETTINGS::m_MinThroughDrill, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, PNS::TOOL_BASE::m_router, DRC_CONSTRAINT::m_Value, BOARD_DESIGN_SETTINGS::m_ViasMinSize, MICROVIA, PNS::ROUTER::Move(), MINOPTMAX< T >::Opt(), TOOL_EVENT::Parameter(), WX_INFOBAR::RemoveAllButtons(), PNS::ROUTER::RoutingInProgress(), SELECT_LAYER, PCB_BASE_FRAME::SelectOneLayer(), LSET::Seq(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), PCB_VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), PNS::SIZES_SETTINGS::SetViaDiameter(), PNS::SIZES_SETTINGS::SetViaDrill(), PNS::SIZES_SETTINGS::SetViaType(), PCB_VIA::SetViaType(), WX_INFOBAR::ShowMessageFor(), PNS::ROUTER::Sizes(), PNS::ROUTER::SwitchLayer(), THROUGH, PNS::ROUTER::ToggleViaPlacement(), KIGFX::VIEW::ToScreen(), UNDEFINED_LAYER, PNS::TOOL_BASE::updateEndItem(), PNS::ROUTER::UpdateSizes(), PNS::TOOL_BASE::updateStartItem(), BOARD_DESIGN_SETTINGS::UseNetClassVia(), VIA_DIAMETER_CONSTRAINT, and PCB_TOOL_BASE::view().

Referenced by onLayerCommand(), and onViaCommand().

◆ highlightNet()

void TOOL_BASE::highlightNet ( bool  aEnabled,
int  aNetcode = -1 
)
protectedvirtualinherited

Definition at line 216 of file pns_tool_base.cpp.

217 {
219 
220  if( aNetcode >= 0 && aEnabled )
221  {
222  // If the user has previously set the current net to be highlighted,
223  // we assume they want to keep it highlighted after routing
225  && rs->GetHighlightNetCodes().count( aNetcode ) );
226 
227  rs->SetHighlight( true, aNetcode );
228  }
229  else
230  {
231  if( !m_startHighlight )
232  rs->SetHighlight( false );
233 
234  m_startHighlight = false;
235  }
236 
238 }
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsHighlightEnabled() const
Return current highlight setting.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:773

References KIGFX::RENDER_SETTINGS::GetHighlightNetCodes(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), KIGFX::RENDER_SETTINGS::IsHighlightEnabled(), PNS::TOOL_BASE::m_startHighlight, KIGFX::RENDER_SETTINGS::SetHighlight(), and KIGFX::VIEW::UpdateAllLayersColor().

Referenced by finishInteractive(), performDragging(), LENGTH_TUNER_TOOL::performTuning(), and prepareInteractive().

◆ Init()

bool ROUTER_TOOL::Init ( void  )
overridevirtual

Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented from PCB_TOOL_BASE.

Definition at line 424 of file router_tool.cpp.

425 {
427 
428  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
429 
430  wxASSERT( frame );
431 
432  auto& menu = m_menu.GetMenu();
433  menu.SetTitle( _( "Interactive Router" ) );
434 
435  m_trackViaMenu = std::make_shared<TRACK_WIDTH_MENU>( *frame );
436  m_trackViaMenu->SetTool( this );
438 
439  m_diffPairMenu = std::make_shared<DIFF_PAIR_MENU>( *frame );
440  m_diffPairMenu->SetTool( this );
442 
443  auto notRoutingCond =
444  [this]( const SELECTION& )
445  {
446  return !m_router->RoutingInProgress();
447  };
448 
450 
451  menu.AddSeparator();
452 
453  menu.AddItem( PCB_ACTIONS::routeSingleTrack, notRoutingCond );
454  menu.AddItem( PCB_ACTIONS::routeDiffPair, notRoutingCond );
457  menu.AddItem( PCB_ACTIONS::breakTrack, notRoutingCond );
458 
459  menu.AddItem( PCB_ACTIONS::drag45Degree, notRoutingCond );
460  menu.AddItem( PCB_ACTIONS::dragFreeAngle, notRoutingCond );
461 
462 // Add( ACT_AutoEndRoute ); // fixme: not implemented yet. Sorry.
471 
472  menu.AddSeparator();
473 
474  auto diffPairCond =
475  [this]( const SELECTION& )
476  {
478  };
479 
480  menu.AddMenu( m_trackViaMenu.get(), SELECTION_CONDITIONS::ShowAlways );
481  menu.AddMenu( m_diffPairMenu.get(), diffPairCond );
482 
484 
485  menu.AddSeparator();
486 
488 
489  return true;
490 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia("pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", AS_CONTEXT, MD_ALT+'<', LEGACY_HK_NAME("Select Layer and Add Blind/Buried Via"), _("Select Layer and Place Blind/Buried Via..."), _("Select a layer, then add a blind or buried via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static const TOOL_ACTION ACT_SwitchPosture("pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, '/', LEGACY_HK_NAME("Switch Track Posture"), _("Switch Track Posture"), _("Switches posture of the currently routed track."), BITMAPS::change_entry_orient)
static TOOL_ACTION routerUndoLastSegment
Definition: pcb_actions.h:195
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:138
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:137
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
PCB_BASE_EDIT_FRAME * frame() const
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:198
#define _(s)
static const TOOL_ACTION ACT_PlaceBlindVia("pcbnew.InteractiveRouter.PlaceBlindVia", AS_CONTEXT, MD_ALT+MD_SHIFT+ 'V', LEGACY_HK_NAME("Add Blind/Buried Via"), _("Place Blind/Buried Via"), _("Adds a blind or buried via at the end of currently routed track."), BITMAPS::via_buried, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
ROUTER * m_router
Definition: pns_tool_base.h:78
static const TOOL_ACTION ACT_SwitchRounding("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, MD_CTRL+'/', "", _("Track Corner Mode"), _("Switches between sharp and rounded corners when routing tracks."), BITMAPS::switch_corner_rounding_shape)
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:132
static const TOOL_ACTION ACT_SelLayerAndPlaceMicroVia("pcbnew.InteractiveRouter.SelLayerAndPlaceMicroVia", AS_CONTEXT, 0, "", _("Select Layer and Place Micro Via..."), _("Select a layer, then add a micro via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::MICROVIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static const TOOL_ACTION ACT_PlaceMicroVia("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, MD_CTRL+ 'V', LEGACY_HK_NAME("Add MicroVia"), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), BITMAPS::via_microvia, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), BITMAPS::via, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:181
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia("pcbnew.InteractiveRouter.SelLayerAndPlaceVia", AS_CONTEXT, '<', LEGACY_HK_NAME("Select Layer and Add Through Via"), _("Select Layer and Place Through Via..."), _("Select a layer, then add a through-hole via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
The main frame for Pcbnew.
std::shared_ptr< ACTION_MENU > m_trackViaMenu
Definition: router_tool.h:80
int m_lastTargetLayer
Definition: router_tool.h:82
std::shared_ptr< ACTION_MENU > m_diffPairMenu
Definition: router_tool.h:79
bool RoutingInProgress() const
Definition: pns_router.cpp:114
ROUTER_MODE Mode() const
Definition: pns_router.h:131
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:184

References _, ACT_EndTrack, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceMicroVia, ACT_SelLayerAndPlaceThroughVia, ACT_SwitchPosture, ACT_SwitchRounding, EDA_DRAW_FRAME::AddStandardSubMenus(), TOOL_MENU::AddSubMenu(), PCB_ACTIONS::breakTrack, ACTIONS::cancelInteractive, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, PCB_TOOL_BASE::frame(), TOOL_MENU::GetMenu(), m_diffPairMenu, m_lastTargetLayer, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, m_trackViaMenu, PNS::ROUTER::Mode(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routerUndoLastSegment, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), ACTION_MENU::SetTitle(), SELECTION_CONDITIONS::ShowAlways(), and UNDEFINED_LAYER.

◆ InlineBreakTrack()

int ROUTER_TOOL::InlineBreakTrack ( const TOOL_EVENT aEvent)

Definition at line 1782 of file router_tool.cpp.

1783 {
1784  const SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1785 
1786  if( selection.Size() != 1 )
1787  return 0;
1788 
1789  const BOARD_CONNECTED_ITEM* item =
1790  static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1791 
1792  if( item->Type() != PCB_TRACE_T )
1793  return 0;
1794 
1795  Activate();
1796 
1798  m_router->SyncWorld();
1800 
1801  TOOL_MANAGER* toolManager = frame()->GetToolManager();
1802  GAL* gal = toolManager->GetView()->GetGAL();
1803 
1805  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
1806 
1807  if( toolManager->IsContextMenuActive() )
1808  {
1809  // If we're here from a context menu then we need to get the position of the
1810  // cursor when the context menu was invoked. This is used to figure out the
1811  // break point on the track.
1813  }
1814  else
1815  {
1816  // If we're here from a hotkey, then get the current mouse position so we know
1817  // where to break the track.
1818  m_startSnapPoint = snapToItem( m_startItem, controls()->GetCursorPosition() );
1819  }
1820 
1821  if( m_startItem && m_startItem->IsLocked() )
1822  {
1823  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1824  wxOK | wxCANCEL | wxICON_WARNING );
1825  dlg.SetOKLabel( _( "Break Track" ) );
1826  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1827 
1828  if( dlg.ShowModal() == wxID_CANCEL )
1829  return 0;
1830  }
1831 
1832  frame()->UndoRedoBlock( true );
1833  breakTrack();
1834 
1835  if( m_router->RoutingInProgress() )
1836  m_router->StopRouting();
1837 
1838  frame()->UndoRedoBlock( false );
1839 
1840  return 0;
1841 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SyncWorld()
Definition: pns_router.cpp:92
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
void breakTrack()
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_BASE_EDIT_FRAME * frame() const
Master controller class:
Definition: tool_manager.h:54
bool GetGridSnapping() const
const VECTOR2I snapToItem(ITEM *aSnapToItem, const VECTOR2I &aP)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
#define _(s)
const PCB_SELECTION & selection() const
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1567
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool IsContextMenuActive() const
True while processing a context menu.
Definition: tool_manager.h:411
ROUTER * m_router
Definition: pns_tool_base.h:78
bool DisableGridSnapping() const
Definition: tool_event.h:336
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
void StopRouting()
Definition: pns_router.cpp:702
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:331
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
KIGFX::VIEW_CONTROLS * controls() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
The selection tool: currently supports:
bool IsLocked() const
Definition: pns_item.h:225
void Activate()
Run the tool.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
bool RoutingInProgress() const
Definition: pns_router.cpp:114
VECTOR2D GetMenuCursorPos() const
Definition: tool_manager.h:440
NODE * GetWorld() const
Definition: pns_router.h:153
EDA_ITEM * Front() const
Definition: selection.h:144
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
Abstract interface for drawing on a 2D-surface.

References _, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_TOOL_BASE::controls(), TOOL_EVENT::DisableGridSnapping(), KIDIALOG::DoNotShowCheckbox(), PNS::NODE::FindItemByParent(), PCB_TOOL_BASE::frame(), SELECTION::Front(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), TOOL_MANAGER::GetMenuCursorPos(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::GetToolManager(), TOOL_MANAGER::GetView(), PNS::ROUTER::GetWorld(), TOOL_MANAGER::IsContextMenuActive(), PNS::ITEM::IsLocked(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_SHIFT, TOOL_EVENT::Modifier(), PCB_TRACE_T, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), KIDIALOG::ShowModal(), SELECTION::Size(), PNS::TOOL_BASE::snapToItem(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SyncWorld(), EDA_ITEM::Type(), and PCB_BASE_EDIT_FRAME::UndoRedoBlock().

Referenced by setTransitions().

◆ InlineDrag()

int ROUTER_TOOL::InlineDrag ( const TOOL_EVENT aEvent)

Definition at line 1550 of file router_tool.cpp.

1551 {
1552  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1553 
1554  if( selection.Empty() )
1556 
1557  if( selection.Size() != 1 )
1558  return 0;
1559 
1560  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1561 
1562  if( item->Type() != PCB_TRACE_T
1563  && item->Type() != PCB_VIA_T
1564  && item->Type() != PCB_FOOTPRINT_T )
1565  {
1566  return 0;
1567  }
1568 
1569  Activate();
1570 
1572  m_router->SyncWorld();
1573  m_startItem = nullptr;
1574 
1575  PNS::ITEM* startItem = nullptr;
1576  PNS::ITEM_SET itemsToDrag;
1577  const FOOTPRINT* footprint = nullptr;
1578 
1579  if( item->Type() == PCB_FOOTPRINT_T )
1580  {
1581  footprint = static_cast<const FOOTPRINT*>(item);
1582 
1583  for( const PAD* pad : footprint->Pads() )
1584  {
1586 
1587  if( solid )
1588  itemsToDrag.Add( solid );
1589  }
1590  }
1591  else
1592  {
1593  startItem = m_router->GetWorld()->FindItemByParent( item );
1594 
1595  if( startItem )
1596  itemsToDrag.Add( startItem );
1597  }
1598 
1599  GAL* gal = m_toolMgr->GetView()->GetGAL();
1600  VECTOR2I p0 = controls()->GetCursorPosition( false );
1601  VECTOR2I p = p0;
1602 
1604  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
1605 
1606  if( startItem )
1607  {
1608  p = snapToItem( startItem, p0 );
1609  m_startItem = startItem;
1610  }
1611  else if( footprint )
1612  {
1613  // The mouse is going to be moved on grid before dragging begins.
1614  VECTOR2I tweakedMousePos;
1615  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1616 
1617  // Check if user wants to warp the mouse to origin of moved object
1618 
1619  if( editFrame->GetMoveWarpsCursor() )
1620  tweakedMousePos = footprint->GetPosition(); // Use footprint anchor to warp mouse
1621  else
1622  tweakedMousePos = controls()->GetCursorPosition(); // Just use current mouse pos
1623 
1624  // We tweak the mouse position using the value from above, and then use that as the
1625  // start position to prevent the footprint from jumping when we start dragging.
1626  // First we move the visual cross hair cursor...
1627  controls()->ForceCursorPosition( true, tweakedMousePos );
1628  controls()->SetCursorPosition( tweakedMousePos ); // ...then the mouse pointer
1629 
1630  // Now that the mouse is in the right position, get a copy of the position to use later
1631  p = controls()->GetCursorPosition();
1632  }
1633 
1634  int dragMode = aEvent.Parameter<int64_t> ();
1635 
1636  bool dragStarted = m_router->StartDragging( p, itemsToDrag, dragMode );
1637 
1638  if( !dragStarted )
1639  return 0;
1640 
1641  m_gridHelper->SetAuxAxes( true, p );
1642  controls()->ShowCursor( true );
1643  controls()->SetAutoPan( true );
1644  frame()->UndoRedoBlock( true );
1645 
1646  view()->ClearPreview();
1647  view()->InitPreview();
1648 
1649  auto setCursor =
1650  [&]()
1651  {
1653  };
1654 
1655  // Set initial cursor
1656  setCursor();
1657 
1658  // Set the initial visible area
1659  BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
1660  m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
1661 
1662  // Send an initial movement to prime the collision detection
1663  m_router->Move( p, nullptr );
1664 
1665  bool hasMouseMoved = false;
1666 
1667  while( TOOL_EVENT* evt = Wait() )
1668  {
1669  setCursor();
1670 
1671  if( evt->IsCancelInteractive() )
1672  {
1673  break;
1674  }
1675  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1676  {
1677  hasMouseMoved = true;
1678  updateEndItem( *evt );
1680 
1681  if( footprint )
1682  {
1683  VECTOR2I offset = m_endSnapPoint - p;
1684  BOARD_ITEM* previewItem;
1685 
1686  view()->ClearPreview();
1687 
1688  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1689  {
1690  previewItem = static_cast<BOARD_ITEM*>( drawing->Clone() );
1691 
1692  if( drawing->Type() == PCB_FP_SHAPE_T )
1693  {
1694  FP_SHAPE* shape = static_cast<FP_SHAPE*>( previewItem );
1695  wxPoint fp_offset = wxPoint( offset.Rotate( footprint->GetOrientationRadians() ) );
1696  shape->FP_SHAPE::Move( fp_offset );
1697  }
1698  else
1699  {
1700  previewItem->Move( offset );
1701  }
1702 
1703  view()->AddToPreview( previewItem );
1704  view()->Hide( drawing, true );
1705  }
1706 
1707  previewItem = static_cast<BOARD_ITEM*>( footprint->Reference().Clone() );
1708  previewItem->Move( offset );
1709  view()->AddToPreview( previewItem );
1710  view()->Hide( &footprint->Reference() );
1711 
1712  previewItem = static_cast<BOARD_ITEM*>( footprint->Value().Clone() );
1713  previewItem->Move( offset );
1714  view()->AddToPreview( previewItem );
1715  view()->Hide( &footprint->Value() );
1716 
1717  for( ZONE* zone : footprint->Zones() )
1718  {
1719  previewItem = static_cast<BOARD_ITEM*>( zone->Clone() );
1720  previewItem->Move( offset );
1721  view()->AddToPreview( previewItem );
1722  view()->Hide( zone, true );
1723  }
1724  }
1725  }
1726  else if( hasMouseMoved && ( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
1727  {
1728  updateEndItem( *evt );
1730  break;
1731  }
1732  else if( evt->Category() == TC_COMMAND )
1733  {
1734  // disallow editing commands
1735  if( evt->IsAction( &ACTIONS::cut )
1736  || evt->IsAction( &ACTIONS::copy )
1737  || evt->IsAction( &ACTIONS::paste )
1738  || evt->IsAction( &ACTIONS::pasteSpecial ) )
1739  {
1740  wxBell();
1741  }
1742  else
1743  {
1744  evt->SetPassEvent();
1745  }
1746  }
1747  else
1748  {
1749  evt->SetPassEvent();
1750  }
1751 
1752  handleCommonEvents( *evt );
1753  }
1754 
1755  if( footprint )
1756  {
1757  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1758  view()->Hide( drawing, false );
1759 
1760  view()->Hide( &footprint->Reference(), false );
1761  view()->Hide( &footprint->Value(), false );
1762 
1763  for( ZONE* zone : footprint->Zones() )
1764  view()->Hide( zone, false );
1765 
1766  view()->ClearPreview();
1767  view()->ShowPreview( false );
1768  }
1769 
1770  if( m_router->RoutingInProgress() )
1771  m_router->StopRouting();
1772 
1773  m_gridHelper->SetAuxAxes( false );
1774  controls()->SetAutoPan( false );
1775  controls()->ForceCursorPosition( false );
1776  frame()->UndoRedoBlock( false );
1777 
1778  return 0;
1779 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1470
Base class for PNS router board items.
Definition: pns_item.h:55
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_text.cpp:334
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
double GetOrientationRadians() const
Definition: footprint.h:183
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1547
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SyncWorld()
Definition: pns_router.cpp:92
void InitPreview()
Definition: view.cpp:1540
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PADS & Pads()
Definition: footprint.h:159
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:457
void ShowPreview(bool aShow=true)
Definition: view.cpp:1561
FP_TEXT & Reference()
Definition: footprint.h:458
PCB_BASE_EDIT_FRAME * frame() const
FP_ZONES & Zones()
Definition: footprint.h:165
static TOOL_ACTION copy
Definition: actions.h:67
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool GetGridSnapping() const
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
Definition: grid_helper.cpp:67
const VECTOR2I snapToItem(ITEM *aSnapToItem, const VECTOR2I &aP)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
const PCB_SELECTION & selection() const
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1567
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:272
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:152
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:659
FOOTPRINT * footprint() const
void SetVisibleViewArea(const BOX2I &aExtents)
Definition: pns_router.h:209
void ClearPreview()
Definition: view.cpp:1525
static TOOL_ACTION cut
Definition: actions.h:66
KIGFX::PCB_VIEW * view() const
ROUTER * m_router
Definition: pns_tool_base.h:78
DRAWINGS & GraphicalItems()
Definition: footprint.h:162
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
bool DisableGridSnapping() const
Definition: tool_event.h:336
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:427
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
void StopRouting()
Definition: pns_router.cpp:702
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:331
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
Definition: vector2d.h:371
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
KIGFX::VIEW_CONTROLS * controls() const
Common, abstract interface for edit frames.
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:149
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
The selection tool: currently supports:
wxPoint GetPosition() const override
Definition: footprint.h:177
BOX2D GetVisibleWorldExtents() const
bool GetMoveWarpsCursor() const
Indicate that a move operation should warp the mouse pointer to the origin of the move object.
Definition: tools_holder.h:141
void Activate()
Run the tool.
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
const Vec & GetSize() const
Definition: box2.h:172
const Vec & GetOrigin() const
Definition: box2.h:176
bool RoutingInProgress() const
Definition: pns_router.cpp:114
Definition: pad.h:57
NODE * GetWorld() const
Definition: pns_router.h:153
static TOOL_ACTION paste
Definition: actions.h:68
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:144
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
Abstract interface for drawing on a 2D-surface.

References TOOL_INTERACTIVE::Activate(), PNS::ITEM_SET::Add(), KIGFX::VIEW::AddToPreview(), ARROW, BUT_LEFT, KIGFX::VIEW::ClearPreview(), FP_TEXT::Clone(), PCB_TOOL_BASE::controls(), ACTIONS::copy, ACTIONS::cut, TOOL_EVENT::DisableGridSnapping(), SELECTION::Empty(), PNS::NODE::FindItemByParent(), PNS::ROUTER::FixRoute(), PCB_TOOL_BASE::footprint(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), TOOLS_HOLDER::GetMoveWarpsCursor(), FOOTPRINT::GetOrientationRadians(), BOX2< Vec >::GetOrigin(), FOOTPRINT::GetPosition(), BOX2< Vec >::GetSize(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), TOOL_MANAGER::GetView(), KIGFX::GAL::GetVisibleWorldExtents(), PNS::ROUTER::GetWorld(), FOOTPRINT::GraphicalItems(), handleCommonEvents(), KIGFX::VIEW::Hide(), KIGFX::VIEW::InitPreview(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_SHIFT, TOOL_EVENT::Modifier(), PNS::ROUTER::Move(), BOARD_ITEM::Move(), NeighboringSegmentFilter(), pad, FOOTPRINT::Pads(), TOOL_EVENT::Parameter(), ACTIONS::paste, ACTIONS::pasteSpecial, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_TRACE_T, PCB_VIA_T, FOOTPRINT::Reference(), VECTOR2< T >::Rotate(), PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionCursor, KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), PNS::ROUTER::SetVisibleViewArea(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::ShowPreview(), SELECTION::Size(), PNS::TOOL_BASE::snapToItem(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SyncWorld(), TC_COMMAND, EDA_ITEM::Type(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), FOOTPRINT::Value(), PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), and FOOTPRINT::Zones().

Referenced by setTransitions().

◆ IsFootprintEditor()

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ MainLoop()

int ROUTER_TOOL::MainLoop ( const TOOL_EVENT aEvent)

Definition at line 1246 of file router_tool.cpp.

1247 {
1248  PNS::ROUTER_MODE mode = aEvent.Parameter<PNS::ROUTER_MODE>();
1249  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1250 
1251  if( m_router->RoutingInProgress() )
1252  {
1253  if( m_router->Mode() == mode )
1254  return 0;
1255  else
1256  m_router->StopRouting();
1257  }
1258 
1259  // Deselect all items
1261 
1262  std::string tool = aEvent.GetCommandStr().get();
1263  frame->PushTool( tool );
1264  Activate();
1265 
1266  m_router->SetMode( mode );
1267 
1268  VIEW_CONTROLS* ctls = getViewControls();
1269  ctls->ShowCursor( true );
1270  ctls->ForceCursorPosition( false );
1271  m_cancelled = false;
1272 
1273  // Prime the pump
1274  if( aEvent.HasPosition() )
1275  m_toolMgr->PrimeTool( ctls->GetCursorPosition( false ) );
1276 
1277  auto setCursor =
1278  [&]()
1279  {
1281  };
1282 
1283  // Set initial cursor
1284  setCursor();
1285 
1286  // Main loop: keep receiving events
1287  while( TOOL_EVENT* evt = Wait() )
1288  {
1289  setCursor();
1290 
1291  if( evt->IsCancelInteractive() )
1292  {
1293  frame->PopTool( tool );
1294  break;
1295  }
1296  else if( evt->IsActivate() )
1297  {
1298  if( evt->IsMoveTool() )
1299  {
1300  // leave ourselves on the stack so we come back after the move
1301  break;
1302  }
1303  else
1304  {
1305  frame->PopTool( tool );
1306  break;
1307  }
1308  }
1309  else if( evt->Action() == TA_UNDO_REDO_PRE )
1310  {
1311  m_router->ClearWorld();
1312  }
1313  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
1314  {
1315  m_router->SyncWorld();
1316  }
1317  else if( evt->IsMotion() )
1318  {
1319  updateStartItem( *evt );
1320  }
1321  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
1322  {
1323  updateStartItem( *evt, true );
1325  }
1326  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
1327  {
1328  updateStartItem( *evt, true );
1330  }
1331  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
1332  {
1333  updateStartItem( *evt, true );
1334  breakTrack( );
1335  }
1336  else if( evt->IsClick( BUT_LEFT )
1337  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1338  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1339  {
1340  updateStartItem( *evt );
1341 
1342  if( evt->HasPosition() )
1343  {
1344  if( evt->Modifier( MD_SHIFT ) )
1346  else
1347  performRouting();
1348  }
1349  }
1350  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1351  {
1353  }
1354  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1355  {
1357  updateStartItem( *evt );
1358  }
1359  else if( evt->IsKeyPressed() )
1360  {
1361  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1362  // event so we need to process the wxEVT_CHAR event that will follow as long as we
1363  // pass the event.
1364  evt->SetPassEvent();
1365  }
1366  else if( evt->IsClick( BUT_RIGHT ) )
1367  {
1369  }
1370  else
1371  {
1372  evt->SetPassEvent();
1373  }
1374 
1375  if( m_cancelled )
1376  {
1377  frame->PopTool( tool );
1378  break;
1379  }
1380  }
1381 
1382  // Store routing settings till the next invocation
1385 
1386  return 0;
1387 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearViewDecorations()
Definition: pns_router.cpp:730
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:138
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
SIZES_SETTINGS m_savedSizes
Definition: pns_tool_base.h:68
void SyncWorld()
Definition: pns_router.cpp:92
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void PrimeTool(const VECTOR2D &aPosition)
"Prime" a tool by sending a cursor left-click event with the mouse position set to the passed in posi...
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:137
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:200
void breakTrack()
void ClearWorld()
Definition: pns_router.cpp:102
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
void performRouting()
const PCB_SELECTION & selection() const
virtual void PopTool(const std::string &actionName)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
Generic, UI-independent tool event.
Definition: tool_event.h:152
ROUTER * m_router
Definition: pns_tool_base.h:78
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:132
void StopRouting()
Definition: pns_router.cpp:702
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:455
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), BITMAPS::via, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
ROUTER_MODE
Definition: pns_router.h:62
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:293
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:828
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:181
void performDragging(int aMode=PNS::DM_ANY)
bool SwitchLayer(int layer)
Definition: pns_router.cpp:745
The main frame for Pcbnew.
void Activate()
Run the tool.
bool HasPosition() const
Definition: tool_event.h:240
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:114
ROUTER_MODE Mode() const
Definition: pns_router.h:131
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:291
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:184

References ACT_PlaceThroughVia, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_ACTIONS::breakTrack, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), PNS::ROUTER::ClearWorld(), PNS::DM_ANY, PNS::DM_FREE_ANGLE, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), PCB_ACTIONS::layerChanged, PCB_ACTIONS::layerToggle, PNS::TOOL_BASE::m_cancelled, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSizes, TOOL_BASE::m_toolMgr, MD_SHIFT, PNS::ROUTER::Mode(), TOOL_EVENT::Parameter(), PENCIL, performDragging(), performRouting(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::PrimeTool(), TOOLS_HOLDER::PushTool(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetMode(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), PNS::ROUTER::Sizes(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SwitchLayer(), PNS::ROUTER::SyncWorld(), TA_MODEL_CHANGE, TA_UNDO_REDO_POST, TA_UNDO_REDO_PRE, PNS::TOOL_BASE::updateStartItem(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ NeighboringSegmentFilter()

void ROUTER_TOOL::NeighboringSegmentFilter ( const VECTOR2I aPt,
GENERAL_COLLECTOR aCollector 
)
static

Definition at line 1468 of file router_tool.cpp.

1469 {
1470  /*
1471  * If the collection contains a trivial line corner (two connected segments)
1472  * or a non-fanout-via (a via with no more than two connected segments), then
1473  * trim the collection down to a single item (which one won't matter since
1474  * they're all connected).
1475  */
1476 
1477  // First make sure we've got something that *might* match.
1478  int vias = aCollector.CountType( PCB_VIA_T );
1479  int traces = aCollector.CountType( PCB_TRACE_T );
1480  int arcs = aCollector.CountType( PCB_ARC_T );
1481 
1482  if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1483  return;
1484 
1485  // Fetch first PCB_TRACK (via or trace) as our reference
1486  PCB_TRACK* reference = nullptr;
1487 
1488  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1489  reference = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1490 
1491  int refNet = reference->GetNetCode();
1492 
1493  wxPoint refPoint( aPt.x, aPt.y );
1494  EDA_ITEM_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1495 
1496  if( flags & STARTPOINT )
1497  refPoint = reference->GetStart();
1498  else if( flags & ENDPOINT )
1499  refPoint = reference->GetEnd();
1500 
1501  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1502  // the same net.
1503  for( int i = 0; i < aCollector.GetCount(); i++ )
1504  {
1505  PCB_TRACK* neighbor = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1506 
1507  if( neighbor && neighbor != reference )
1508  {
1509  if( neighbor->GetNetCode() != refNet )
1510  return;
1511 
1512  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1513  return;
1514  }
1515  }
1516 
1517  // Selection meets criteria; trim it to the reference item.
1518  aCollector.Empty();
1519  aCollector.Append( reference );
1520 }
void Empty()
Clear the list.
Definition: collector.h:95
#define STARTPOINT
When a line is selected, these flags indicate which.
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
std::uint32_t EDA_ITEM_FLAGS
#define ENDPOINT
ends. (Used to support dragging.)
int CountType(KICAD_T aType)
Count the number of items matching aType.
Definition: collector.h:235
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:105
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
EDA_ITEM_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
Definition: pcb_track.cpp:208
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
const wxPoint & GetStart() const
Definition: pcb_track.h:108

References COLLECTOR::Append(), COLLECTOR::CountType(), COLLECTOR::Empty(), ENDPOINT, COLLECTOR::GetCount(), PCB_TRACK::GetEnd(), BOARD_CONNECTED_ITEM::GetNetCode(), PCB_TRACK::GetStart(), PCB_TRACK::IsPointOnEnds(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, STARTPOINT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CanInlineDrag(), and InlineDrag().

◆ onLayerCommand()

int ROUTER_TOOL::onLayerCommand ( const TOOL_EVENT aEvent)
private

Definition at line 706 of file router_tool.cpp.

707 {
708  return handleLayerSwitch( aEvent, false );
709 }
int handleLayerSwitch(const TOOL_EVENT &aEvent, bool aForceVia)

References handleLayerSwitch().

Referenced by setTransitions().

◆ onTrackViaSizeChanged()

int ROUTER_TOOL::onTrackViaSizeChanged ( const TOOL_EVENT aEvent)
private

Definition at line 1861 of file router_tool.cpp.

1862 {
1863  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1864 
1865  if( !m_router->GetCurrentNets().empty() )
1867 
1868  m_router->UpdateSizes( sizes );
1869 
1870  // Changing the track width can affect the placement, so call the
1871  // move routine without changing the destination
1873 
1875 
1876  return 0;
1877 }
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:764
void updateMessagePanel()
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:200
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:427
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:554
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77

References PNS::ROUTER::GetCurrentNets(), PNS_KICAD_IFACE_BASE::ImportSizes(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::ROUTER::Move(), PNS::ROUTER::Sizes(), updateMessagePanel(), and PNS::ROUTER::UpdateSizes().

Referenced by CustomTrackWidthDialog(), and setTransitions().

◆ onViaCommand()

int ROUTER_TOOL::onViaCommand ( const TOOL_EVENT aEvent)
private

Definition at line 712 of file router_tool.cpp.

713 {
714  return handleLayerSwitch( aEvent, true );
715 }
int handleLayerSwitch(const TOOL_EVENT &aEvent, bool aForceVia)

References handleLayerSwitch().

Referenced by setTransitions().

◆ performDragging()

void ROUTER_TOOL::performDragging ( int  aMode = PNS::DM_ANY)
private

Definition at line 1390 of file router_tool.cpp.

1391 {
1393 
1394  VIEW_CONTROLS* ctls = getViewControls();
1395 
1396  if( m_startItem && m_startItem->IsLocked() )
1397  {
1398  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1399  wxOK | wxCANCEL | wxICON_WARNING );
1400  dlg.SetOKLabel( _( "Drag Anyway" ) );
1401  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1402 
1403  if( dlg.ShowModal() == wxID_CANCEL )
1404  return;
1405  }
1406 
1407  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1408 
1409  if( !dragStarted )
1410  return;
1411 
1412  if( m_startItem && m_startItem->Net() > 0 )
1413  highlightNet( true, m_startItem->Net() );
1414 
1415  ctls->SetAutoPan( true );
1417  frame()->UndoRedoBlock( true );
1418 
1419  while( TOOL_EVENT* evt = Wait() )
1420  {
1421  ctls->ForceCursorPosition( false );
1422 
1423  if( evt->IsMotion() )
1424  {
1425  updateEndItem( *evt );
1427  }
1428  else if( evt->IsClick( BUT_LEFT ) )
1429  {
1431  break;
1432  }
1433  else if( evt->IsClick( BUT_RIGHT ) )
1434  {
1436  }
1437  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1438  {
1439  if( evt->IsCancelInteractive() && !m_startItem )
1440  m_cancelled = true;
1441 
1442  if( evt->IsActivate() && !evt->IsMoveTool() )
1443  m_cancelled = true;
1444 
1445  break;
1446  }
1447  else
1448  {
1449  evt->SetPassEvent();
1450  }
1451 
1452  handleCommonEvents( *evt );
1453  }
1454 
1455  if( m_router->RoutingInProgress() )
1456  m_router->StopRouting();
1457 
1458  m_startItem = nullptr;
1459 
1460  m_gridHelper->SetAuxAxes( false );
1461  frame()->UndoRedoBlock( false );
1462  ctls->SetAutoPan( false );
1463  ctls->ForceCursorPosition( false );
1464  highlightNet( false );
1465 }
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void ClearViewDecorations()
Definition: pns_router.cpp:730
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
Definition: grid_helper.cpp:67
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
#define _(s)
const PCB_SELECTION & selection() const
int Net() const
Definition: pns_item.h:150
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:152
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:659
ROUTER * m_router
Definition: pns_tool_base.h:78
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:427
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:702
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:149
bool IsLocked() const
Definition: pns_item.h:225
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59

References _, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), KIDIALOG::DoNotShowCheckbox(), PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), TOOL_BASE::getViewControls(), handleCommonEvents(), PNS::TOOL_BASE::highlightNet(), PNS::ITEM::IsLocked(), PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ROUTER::Move(), PNS::ITEM::Net(), PNS::ROUTER::RoutingInProgress(), PCB_TOOL_BASE::selection(), KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), TOOL_MENU::ShowContextMenu(), KIDIALOG::ShowModal(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by MainLoop().

◆ performRouting()

void ROUTER_TOOL::performRouting ( )
private

Definition at line 1061 of file router_tool.cpp.

1062 {
1064 
1065  if( !prepareInteractive() )
1066  return;
1067 
1068  auto setCursor =
1069  [&]()
1070  {
1072  };
1073 
1074  // Set initial cursor
1075  setCursor();
1076 
1077  while( TOOL_EVENT* evt = Wait() )
1078  {
1079  setCursor();
1080 
1081  // Don't crash if we missed an operation that canceled routing.
1082  if( !m_router->RoutingInProgress() )
1083  {
1084  if( evt->IsCancelInteractive() )
1085  m_cancelled = true;
1086 
1087  break;
1088  }
1089 
1090  handleCommonEvents( *evt );
1091 
1092  if( evt->IsMotion() )
1093  {
1094  m_router->SetOrthoMode( evt->Modifier( MD_SHIFT ) );
1095  updateEndItem( *evt );
1097  }
1098  else if( evt->IsAction( &PCB_ACTIONS::routerUndoLastSegment ) )
1099  {
1101  updateEndItem( *evt );
1103  }
1104  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
1105  {
1106  updateEndItem( *evt );
1107  bool needLayerSwitch = m_router->IsPlacingVia();
1108  bool forceFinish = evt->Modifier( MD_SHIFT );
1109 
1110  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
1111  {
1112  break;
1113  }
1114 
1115  if( needLayerSwitch )
1117 
1118  // Synchronize the indicated layer
1119  PCB_LAYER_ID routingLayer = ToLAYER_ID( m_router->GetCurrentLayer() );
1120  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1121 
1122  editFrame->SetActiveLayer( routingLayer );
1123 
1124  if( !getView()->IsLayerVisible( routingLayer ) )
1125  {
1126  editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1127  editFrame->GetCanvas()->Refresh();
1128  }
1129 
1130  updateEndItem( *evt );
1132  m_startItem = nullptr;
1133  }
1134  else if( evt->IsAction( &ACT_SwitchRounding ) )
1135  {
1137  updateEndItem( *evt );
1138  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1139  }
1140  else if( evt->IsAction( &ACT_SwitchPosture ) )
1141  {
1142  m_router->FlipPosture();
1143  updateEndItem( *evt );
1144  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1145  }
1146  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
1147  {
1149  controls()->SetAutoPan( false );
1150  {
1152  }
1153  controls()->SetAutoPan( true );
1154  setCursor();
1156  }
1157  else if( evt->IsAction( &ACT_EndTrack ) || evt->IsDblClick( BUT_LEFT ) )
1158  {
1159  // Stop current routing:
1161  break;
1162  }
1163  else if( evt->IsCancelInteractive() || evt->IsActivate()
1164  || evt->IsUndoRedo()
1165  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
1166  {
1167  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
1168  m_cancelled = true;
1169 
1170  if( evt->IsActivate() && !evt->IsMoveTool() )
1171  m_cancelled = true;
1172 
1173  break;
1174  }
1175  else if( evt->IsClick( BUT_RIGHT ) )
1176  {
1178  }
1179  else
1180  {
1181  evt->SetPassEvent();
1182  }
1183  }
1184 
1186  m_router->StopRouting();
1187 
1189 }
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
bool finishInteractive()
static const TOOL_ACTION ACT_SwitchPosture("pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, '/', LEGACY_HK_NAME("Switch Track Posture"), _("Switch Track Posture"), _("Switches posture of the currently routed track."), BITMAPS::change_entry_orient)
static TOOL_ACTION routerUndoLastSegment
Definition: pcb_actions.h:195
void CommitRouting()
Definition: pns_router.cpp:693
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearViewDecorations()
Definition: pns_router.cpp:730
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
bool IsPlacingVia() const
Definition: pns_router.cpp:792
void ToggleRounded()
Definition: pns_router.cpp:801
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static const TOOL_ACTION ACT_CustomTrackWidth("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, 'Q', LEGACY_HK_NAME("Custom Track/Via Size"), _("Custom Track/Via Size..."), _("Shows a dialog for changing the track width and via size."), BITMAPS::width_track)
void updateMessagePanel()
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:819
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
PCB_BASE_EDIT_FRAME * frame() const
void UndoLastSegment()
Definition: pns_router.cpp:684
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
const PCB_SELECTION & selection() const
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:152
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:659
ROUTER * m_router
Definition: pns_tool_base.h:78
void switchLayerOnViaPlacement()
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:427
static const TOOL_ACTION ACT_SwitchRounding("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, MD_CTRL+'/', "", _("Track Corner Mode"), _("Switches between sharp and rounded corners when routing tracks."), BITMAPS::switch_corner_rounding_shape)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:208
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:702
KIGFX::VIEW_CONTROLS * controls() const
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:181
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
The main frame for Pcbnew.
void FlipPosture()
Definition: pns_router.cpp:736
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905
int GetCurrentLayer() const
Definition: pns_router.cpp:775

References ACT_CustomTrackWidth, ACT_EndTrack, ACT_SwitchPosture, ACT_SwitchRounding, ARROW, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), PNS::ROUTER::CommitRouting(), PCB_TOOL_BASE::controls(), finishInteractive(), PNS::ROUTER::FixRoute(), PNS::ROUTER::FlipPosture(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::ROUTER::GetCurrentLayer(), TOOL_BASE::getView(), handleCommonEvents(), PNS::ROUTER::IsPlacingVia(), PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_SHIFT, PNS::ROUTER::Move(), PENCIL, prepareInteractive(), PCB_ACTIONS::properties, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerUndoLastSegment, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetOrthoMode(), TOOL_MENU::ShowContextMenu(), PNS::ROUTER::StopRouting(), switchLayerOnViaPlacement(), PNS::ROUTER::ToggleRounded(), ToLAYER_ID(), PNS::ROUTER::UndoLastSegment(), PNS::TOOL_BASE::updateEndItem(), updateMessagePanel(), and TOOL_INTERACTIVE::Wait().

Referenced by MainLoop().

◆ pickSingleItem()

ITEM * TOOL_BASE::pickSingleItem ( const VECTOR2I aWhere,
int  aNet = -1,
int  aLayer = -1,
bool  aIgnorePads = false,
const std::vector< ITEM * >  aAvoidItems = {} 
)
protectedvirtualinherited

Definition at line 99 of file pns_tool_base.cpp.

101 {
102  int tl = aLayer > 0 ? aLayer : getView()->GetTopLayer();
103 
104  static const int candidateCount = 5;
105  ITEM* prioritized[candidateCount];
106  SEG::ecoord dist[candidateCount];
107 
108  for( int i = 0; i < candidateCount; i++ )
109  {
110  prioritized[i] = nullptr;
111  dist[i] = VECTOR2I::ECOORD_MAX;
112  }
113 
114  ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
115 
116  if( candidates.Empty() )
117  candidates = m_router->QueryHoverItems( aWhere, true );
118 
119  for( ITEM* item : candidates.Items() )
120  {
121  if( !item->IsRoutable() )
122  continue;
123 
124  if( !IsCopperLayer( item->Layers().Start() ) )
125  continue;
126 
127  if( !m_iface->IsAnyLayerVisible( item->Layers() ) )
128  continue;
129 
130  if( alg::contains( aAvoidItems, item ) )
131  continue;
132 
133  // fixme: this causes flicker with live loop removal...
134  //if( item->Parent() && !item->Parent()->ViewIsVisible() )
135  // continue;
136 
137  if( aNet <= 0 || item->Net() == aNet )
138  {
139  if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
140  {
141  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
142  continue;
143 
144  SEG::ecoord d = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
145 
146  if( d < dist[2] )
147  {
148  prioritized[2] = item;
149  dist[2] = d;
150  }
151 
152  if( item->Layers().Overlaps( tl ) && d < dist[0] )
153  {
154  prioritized[0] = item;
155  dist[0] = d;
156  }
157  }
158  else // ITEM::SEGMENT_T | ITEM::ARC_T
159  {
160  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( item );
161  SEG::ecoord d = std::min( ( li->Anchor( 0 ) - aWhere ).SquaredEuclideanNorm(),
162  ( li->Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
163 
164  if( d < dist[3] )
165  {
166  prioritized[3] = item;
167  dist[3] = d;
168  }
169 
170  if( item->Layers().Overlaps( tl ) && d < dist[1] )
171  {
172  prioritized[1] = item;
173  dist[1] = d;
174  }
175  }
176  }
177  else if ( item->Net() == 0 && m_router->Settings().Mode() == RM_MarkObstacles )
178  {
179  // Allow unconnected items as last resort in RM_MarkObstacles mode
180  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
181  continue;
182 
183  if( item->Layers().Overlaps( tl ) )
184  prioritized[4] = item;
185  }
186  }
187 
188  ITEM* rv = nullptr;
189 
191 
192  for( int i = 0; i < candidateCount; i++ )
193  {
194  ITEM* item = prioritized[i];
195 
196  if( highContrast && item && !item->Layers().Overlaps( tl ) )
197  item = nullptr;
198 
199  if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
200  {
201  rv = item;
202  break;
203  }
204  }
205 
206  if( rv )
207  {
208  wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(),
209  tl );
210  }
211 
212  return rv;
213 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, bool aUseClearance=false)
Definition: pns_router.cpp:120
VECTOR2I::extended_type ecoord
Definition: seg.h:43
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:79
virtual int GetTopLayer() const
Definition: view.cpp:828
Inactive layers are shown normally (no high-contrast mode)
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:98
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:787
const PCB_DISPLAY_OPTIONS & displayOptions() const
Ignore collisions, mark obstacles.
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override

References PNS::ITEM::Anchor(), alg::contains(), PCB_TOOL_BASE::displayOptions(), VECTOR2< T >::ECOORD_MAX, PNS::ITEM_SET::Empty(), KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), PNS_KICAD_IFACE::IsAnyLayerVisible(), IsCopperLayer(), PNS::ITEM_SET::Items(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PCB_DISPLAY_OPTIONS::m_ContrastModeDisplay, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), NORMAL, LAYER_RANGE::Overlaps(), PNS::ROUTER::QueryHoverItems(), PNS::RM_MarkObstacles, PNS::ROUTER::Settings(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), and PNS::ITEM::VIA_T.

Referenced by PNS::TOOL_BASE::updateEndItem(), and PNS::TOOL_BASE::updateStartItem().

◆ prepareInteractive()

bool ROUTER_TOOL::prepareInteractive ( )
private

Definition at line 983 of file router_tool.cpp.

984 {
985  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
986  int routingLayer = getStartLayer( m_startItem );
987 
988  if( !IsCopperLayer( routingLayer ) )
989  {
990  editFrame->ShowInfoBarError( _( "Tracks on Copper layers only." ) );
991  return false;
992  }
993 
994  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
995 
996  if( !getView()->IsLayerVisible( routingLayer ) )
997  {
998  editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
999  editFrame->GetCanvas()->Refresh();
1000  }
1001 
1002  if( m_startItem && m_startItem->Net() > 0 )
1003  highlightNet( true, m_startItem->Net() );
1004 
1005  controls()->SetAutoPan( true );
1006 
1007  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1008 
1009  m_iface->ImportSizes( sizes, m_startItem, -1 );
1010  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
1011  frame()->GetScreen()->m_Route_Layer_BOTTOM );
1012 
1013  m_router->UpdateSizes( sizes );
1014 
1015  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
1016  {
1017  // It would make more sense to leave the net highlighted as the higher-contrast mode
1018  // makes the router clearances more visible. However, since we just started routing
1019  // the conversion of the screen from low contrast to high contrast is a bit jarring and
1020  // makes the infobar coming up less noticeable.
1021  highlightNet( false );
1022 
1024  [&]()
1025  {
1027  } );
1028 
1029  controls()->SetAutoPan( false );
1030  return false;
1031  }
1032 
1033  m_endItem = nullptr;
1035 
1037  frame()->UndoRedoBlock( true );
1038 
1039  return true;
1040 }
const wxString & FailureReason() const
Definition: pns_router.h:203
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearViewDecorations()
Definition: pns_router.cpp:730
void updateMessagePanel()
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:200
APPEARANCE_CONTROLS * GetAppearancePanel()
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)
int Net() const
Definition: pns_item.h:150
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:370
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:787
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:554
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
The main frame for Pcbnew.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
int getStartLayer(const PNS::ITEM *aItem)
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905

References _, PNS::ROUTER::ClearViewDecorations(), PCB_TOOL_BASE::controls(), PNS::ROUTER::FailureReason(), PCB_TOOL_BASE::frame(), PCB_BASE_EDIT_FRAME::GetAppearancePanel(), PCB_BASE_FRAME::GetCanvas(), getStartLayer(), TOOL_BASE::getView(), PNS::TOOL_BASE::highlightNet(), PNS_KICAD_IFACE_BASE::ImportSizes(), IsCopperLayer(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ITEM::Net(), EDA_DRAW_PANEL_GAL::Refresh(), PCB_EDIT_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), APPEARANCE_CONTROLS::SetLayerVisible(), EDA_BASE_FRAME::ShowInfoBarError(), PNS::ROUTER::Sizes(), PNS::ROUTER::StartRouting(), ToLAYER_ID(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), updateMessagePanel(), and PNS::ROUTER::UpdateSizes().

Referenced by performRouting().

◆ Reset()

void ROUTER_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Bring the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PNS::TOOL_BASE.

Definition at line 493 of file router_tool.cpp.

494 {
496 
497  if( aReason == RUN )
498  TOOL_BASE::Reset( aReason );
499 }
Tool is invoked after being inactive.
Definition: tool_base.h:79
virtual void Reset(RESET_REASON aReason)=0
Bring the tool to a known, initial state.
int m_lastTargetLayer
Definition: router_tool.h:82

References m_lastTargetLayer, TOOL_BASE::Reset(), TOOL_BASE::RUN, and UNDEFINED_LAYER.

◆ Router()

ROUTER * TOOL_BASE::Router ( ) const
inherited

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88 {
89  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

◆ saveRouterDebugLog()

void ROUTER_TOOL::saveRouterDebugLog ( )
private

Definition at line 504 of file router_tool.cpp.

505 {
506  auto logger = m_router->Logger();
507 
508  if( ! logger )
509  return;
510 
511  wxString cwd = wxGetCwd();
512 
513  wxFileName fname_log( cwd );
514  fname_log.SetName( "pns.log" );
515 
516  wxFileName fname_dump( cwd );
517  fname_dump.SetName( "pns.dump" );
518 
519  wxString msg = wxString::Format( _( "Event file: %s\nBoard dump: %s" ), fname_log.GetFullPath(), fname_log.GetFullPath() );
520 
521  int rv = OKOrCancelDialog( nullptr, _("Save router log"), _("Would you like to save the router\nevent log for debugging purposes?"), msg, _("OK"), _("Cancel") );
522 
523  if( !rv )
524  return;
525 
526  FILE *f = fopen( fname_log.GetFullPath().c_str(), "wb" );
527 
528  // save base router configuration (mode, etc.)
529  fprintf(f, "config %d %d %d\n",
530  m_router->Settings().Mode(),
531  m_router->Settings().RemoveLoops() ? 1 : 0,
532  m_router->Settings().GetFixAllSegments() ? 1 : 0
533  );
534 
535  const auto& events = logger->GetEvents();
536 
537  for( auto evt : events)
538  {
539  fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
540  (const char*) evt.uuid.c_str() );
541  }
542 
543  fclose( f );
544 
545  // Export as *.kicad_pcb format, using a strategy which is specifically chosen
546  // as an example on how it could also be used to send it to the system clipboard.
547 
548  PCB_IO pcb_io;
549 
550  pcb_io.Save( fname_dump.GetFullPath(), m_iface->GetBoard(), nullptr );
551 }
BOARD * GetBoard() const
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
bool RemoveLoops() const
Enable/disable loop (redundant track) removal.
#define _(s)
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:220
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
LOGGER * Logger()
Definition: pns_router.cpp:786
virtual void Save(const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181

References _, Format(), PNS_KICAD_IFACE_BASE::GetBoard(), PNS::ROUTING_SETTINGS::GetFixAllSegments(), PNS::ROUTER::Logger(), PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), OKOrCancelDialog(), PNS::ROUTING_SETTINGS::RemoveLoops(), PCB_IO::Save(), and PNS::ROUTER::Settings().

Referenced by handleCommonEvents().

◆ SelectCopperLayerPair()

int ROUTER_TOOL::SelectCopperLayerPair ( const TOOL_EVENT aEvent)

Definition at line 283 of file sel_layer.cpp.

284 {
285  PCB_SCREEN* screen = frame()->GetScreen();
286 
288  screen->m_Route_Layer_BOTTOM );
289 
290  if( dlg.ShowModal() == wxID_OK )
291  {
292  dlg.GetLayerPair( screen->m_Route_Layer_TOP, screen->m_Route_Layer_BOTTOM );
293 
294  // select the same layer for both layers is allowed (normal in some boards)
295  // but could be a mistake. So display an info message
296  if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM )
297  DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
298  }
299 
300  return 0;
301 }
PCB_BASE_EDIT_FRAME * frame() const
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
#define _(s)
BOARD * GetBoard()
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:275
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
Display a pair PCB copper layers list in a dialog to select a layer pair from these lists.
Definition: sel_layer.cpp:254

References _, DisplayInfoMessage(), PCB_TOOL_BASE::frame(), GetBoard(), SELECT_COPPER_LAYERS_PAIR_DIALOG::GetLayerPair(), PCB_BASE_FRAME::GetScreen(), PCB_SCREEN::m_Route_Layer_BOTTOM, and PCB_SCREEN::m_Route_Layer_TOP.

Referenced by setTransitions().

◆ selection() [1/2]

const PCB_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 305 of file pcb_tool_base.cpp.

306 {
308 
309  return selTool->GetSelection();
310 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
The selection tool: currently supports:

References PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), GROUP_TOOL::EnterGroup(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), GROUP_TOOL::Group(), BOARD_INSPECTION_TOOL::highlightNet(), InlineBreakTrack(), InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), BOARD_REANNOTATE_TOOL::ReannotateDuplicatesInSelection(), GROUP_TOOL::RemoveFromGroup(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), PCB_SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), GROUP_TOOL::Ungroup(), PCB_CONTROL::UpdateMessagePanel(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCB_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 313 of file pcb_tool_base.cpp.

314 {
316 
317  return selTool->GetSelection();
318 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
The selection tool: currently supports:

References PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Assign a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 76 of file tool_interactive.cpp.

77 {
78  if( aMenu )
79  aMenu->SetTool( this );
80  else
81  aTrigger = CMENU_OFF;
82 
83  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
84 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Set behavior of the tool's context popup menu.

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and ACTION_MENU::SetTool().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetIsFootprintEditor()

void PCB_TOOL_BASE::SetIsFootprintEditor ( bool  aEnabled)
inlineinherited

Function SetIsFootprintEditor()

Toggles edit footprint mode. When enabled, one may select parts of footprints individually (graphics, pads, etc.), so they can be modified.

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 103 of file pcb_tool_base.h.

103 { m_isFootprintEditor = aEnabled; }
bool m_isFootprintEditor

References PCB_TOOL_BASE::m_isFootprintEditor.

◆ SettingsDialog()

int ROUTER_TOOL::SettingsDialog ( const TOOL_EVENT aEvent)

Definition at line 1212 of file router_tool.cpp.

1213 {
1214  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
1215 
1216  settingsDlg.ShowModal();
1217 
1218  return 0;
1219 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181

References PCB_TOOL_BASE::frame(), PNS::TOOL_BASE::m_router, and PNS::ROUTER::Settings().

Referenced by setTransitions().

◆ setTransitions()

void ROUTER_TOOL::setTransitions ( )
overridevirtual

This method is meant to be overridden in order to specify handlers for events.

It is called every time tool is reset or finished.

Reimplemented from PCB_TOOL_BASE.

Definition at line 1941 of file router_tool.cpp.

1942 {
1944 
1954 
1961 
1996 
1999 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:286
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:281
int onLayerCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerNext
Definition: pcb_actions.h:287
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:257
int MainLoop(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:129
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia("pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", AS_CONTEXT, MD_ALT+'<', LEGACY_HK_NAME("Select Layer and Add Blind/Buried Via"), _("Select Layer and Place Blind/Buried Via..."), _("Select a layer, then add a blind or buried via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:260
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:261
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:199
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:262
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:263
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:276
int InlineDrag(const TOOL_EVENT &aEvent)
static const TOOL_ACTION ACT_CustomTrackWidth("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, 'Q', LEGACY_HK_NAME("Custom Track/Via Size"), _("Custom Track/Via Size..."), _("Shows a dialog for changing the track width and via size."), BITMAPS::width_track)
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:203
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:303
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:258
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:279
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
int ChangeRouterMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:266
static TOOL_ACTION layerTop
Definition: pcb_actions.h:255
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:278
int onViaCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:198
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:268
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:288
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:280
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:273
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:285
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:284
static const TOOL_ACTION ACT_PlaceBlindVia("pcbnew.InteractiveRouter.PlaceBlindVia", AS_CONTEXT, MD_ALT+MD_SHIFT+ 'V', LEGACY_HK_NAME("Add Blind/Buried Via"), _("Place Blind/Buried Via"), _("Adds a blind or buried via at the end of currently routed track."), BITMAPS::via_buried, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:265
int SettingsDialog(const TOOL_EVENT &aEvent)
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:205
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:270
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:208
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:283
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:282
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:135
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:272
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:275
static const TOOL_ACTION ACT_SelLayerAndPlaceMicroVia("pcbnew.InteractiveRouter.SelLayerAndPlaceMicroVia", AS_CONTEXT, 0, "", _("Select Layer and Place Micro Via..."), _("Select a layer, then add a micro via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::MICROVIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static const TOOL_ACTION ACT_PlaceMicroVia("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, MD_CTRL+ 'V', LEGACY_HK_NAME("Add MicroVia"), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), BITMAPS::via_microvia, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), BITMAPS::via, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:277
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:181
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:269
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:264
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia("pcbnew.InteractiveRouter.SelLayerAndPlaceVia", AS_CONTEXT, '<', LEGACY_HK_NAME("Select Layer and Add Through Via"), _("Select Layer and Place Through Via..."), _("Select a layer, then add a through-hole via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
int InlineBreakTrack(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:271
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:283
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:259
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:274
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:256
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:204
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:267
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:184

References ACT_CustomTrackWidth, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceMicroVia, ACT_SelLayerAndPlaceThroughVia, ChangeRouterMode(), CustomTrackWidthDialog(), DpDimensionsDialog(), TOOL_INTERACTIVE::Go(), InlineBreakTrack(), PCB_ACTIONS::inlineBreakTrack, InlineDrag(), PCB_ACTIONS::layerBottom, PCB_ACTIONS::layerInner1, PCB_ACTIONS::layerInner10, PCB_ACTIONS::layerInner11, PCB_ACTIONS::layerInner12, PCB_ACTIONS::layerInner13, PCB_ACTIONS::layerInner14, PCB_ACTIONS::layerInner15, PCB_ACTIONS::layerInner16, PCB_ACTIONS::layerInner17, PCB_ACTIONS::layerInner18, PCB_ACTIONS::layerInner19, PCB_ACTIONS::layerInner2, PCB_ACTIONS::layerInner20, PCB_ACTIONS::layerInner21, PCB_ACTIONS::layerInner22, PCB_ACTIONS::layerInner23, PCB_ACTIONS::layerInner24, PCB_ACTIONS::layerInner25, PCB_ACTIONS::layerInner26, PCB_ACTIONS::layerInner27, PCB_ACTIONS::layerInner28, PCB_ACTIONS::layerInner29, PCB_ACTIONS::layerInner3, PCB_ACTIONS::layerInner30, PCB_ACTIONS::layerInner4, PCB_ACTIONS::layerInner5, PCB_ACTIONS::layerInner6, PCB_ACTIONS::layerInner7, PCB_ACTIONS::layerInner8, PCB_ACTIONS::layerInner9, PCB_ACTIONS::layerNext, PCB_ACTIONS::layerPrev, PCB_ACTIONS::layerTop, MainLoop(), TOOL_ACTION::MakeEvent(), onLayerCommand(), onTrackViaSizeChanged(), onViaCommand(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerDiffPairDialog, PCB_ACTIONS::routerHighlightMode, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routerShoveMode, PCB_ACTIONS::routerWalkaroundMode, PCB_ACTIONS::routeSingleTrack, SelectCopperLayerPair(), PCB_ACTIONS::selectLayerPair, SettingsDialog(), and PCB_ACTIONS::trackViaSizeChanged.

◆ snapToItem()

const VECTOR2I TOOL_BASE::snapToItem ( ITEM aSnapToItem,
const VECTOR2I aP 
)
protectedinherited

Definition at line 358 of file pns_tool_base.cpp.

359 {
360  if( !aItem || !m_iface->IsItemVisible( aItem ) )
361  {
362  return m_gridHelper->Align( aP );
363  }
364 
365  switch( aItem->Kind() )
366  {
367  case ITEM::SOLID_T:
368  return static_cast<SOLID*>( aItem )->Pos();
369 
370  case ITEM::VIA_T:
371  return static_cast<VIA*>( aItem )->Pos();
372 
373  case ITEM::SEGMENT_T:
374  case ITEM::ARC_T:
375  {
376  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
377  VECTOR2I A = li->Anchor( 0 );
378  VECTOR2I B = li->Anchor( 1 );
379  SEG::ecoord w_sq = SEG::Square( li->Width() / 2 );
380  SEG::ecoord distA_sq = ( aP - A ).SquaredEuclideanNorm();
381  SEG::ecoord distB_sq = ( aP - B ).SquaredEuclideanNorm();
382 
383  if( distA_sq < w_sq || distB_sq < w_sq )
384  {
385  return ( distA_sq < distB_sq ) ? A : B;
386  }
387  else if( aItem->Kind() == ITEM::SEGMENT_T )
388  {
389  // TODO(snh): Clean this up
390  SEGMENT* seg = static_cast<SEGMENT*>( li );
391  return m_gridHelper->AlignToSegment( aP, seg->Seg() );
392  }
393  else if( aItem->Kind() == ITEM::ARC_T )
394  {
395  ARC* arc = static_cast<ARC*>( li );
396  return m_gridHelper->AlignToArc( aP, *static_cast<const SHAPE_ARC*>( arc->Shape() ) );
397  }
398 
399  break;
400  }
401 
402  default:
403  break;
404  }
405 
406  return m_gridHelper->Align( aP );
407 }
VECTOR2I::extended_type ecoord
Definition: seg.h:43
usual segment : line with rounded ends
static SEG::ecoord Square(int a)
Definition: seg.h:122
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
bool IsItemVisible(const PNS::ITEM *aItem) const override
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)

References GRID_HELPER::Align(), PCB_GRID_HELPER::AlignToArc(), PCB_GRID_HELPER::AlignToSegment(), PNS::ITEM::Anchor(), PNS::ITEM::ARC_T, PNS_KICAD_IFACE::IsItemVisible(), PNS::ITEM::Kind(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_iface, PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::ARC::Shape(), PNS::ITEM::SOLID_T, SEG::Square(), PNS::ITEM::VIA_T, and PNS::LINKED_ITEM::Width().

Referenced by InlineBreakTrack(), InlineDrag(), PNS::TOOL_BASE::updateEndItem(), and PNS::TOOL_BASE::updateStartItem().

◆ switchLayerOnViaPlacement()

void ROUTER_TOOL::switchLayerOnViaPlacement ( )
private

Definition at line 598 of file router_tool.cpp.

599 {
600  int al = frame()->GetActiveLayer();
601  int cl = m_router->GetCurrentLayer();
602 
603  if( cl != al )
604  {
605  m_router->SwitchLayer( al );
606  }
607 
608  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
609 
610  if( !newLayer )
611  newLayer = m_router->Sizes().GetLayerTop();
612 
613  m_router->SwitchLayer( *newLayer );
614  m_lastTargetLayer = *newLayer;
615 }
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:200
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
ROUTER * m_router
Definition: pns_tool_base.h:78
bool SwitchLayer(int layer)
Definition: pns_router.cpp:745
boost::optional< T > OPT
Definition: optional.h:7
int m_lastTargetLayer
Definition: router_tool.h:82
OPT< int > PairedLayer(int aLayerId)
int GetCurrentLayer() const
Definition: pns_router.cpp:775

References PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PNS::ROUTER::GetCurrentLayer(), PNS::SIZES_SETTINGS::GetLayerTop(), m_lastTargetLayer, PNS::TOOL_BASE::m_router, PNS::SIZES_SETTINGS::PairedLayer(), PNS::ROUTER::Sizes(), and PNS::ROUTER::SwitchLayer().

Referenced by performRouting().

◆ updateEndItem()

void TOOL_BASE::updateEndItem ( const TOOL_EVENT aEvent)
protectedvirtualinherited

Definition at line 292 of file pns_tool_base.cpp.

293 {
294  int layer;
295  GAL* gal = m_toolMgr->GetView()->GetGAL();
296 
298  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
299 
300  controls()->ForceCursorPosition( false );
301  VECTOR2I mousePos = controls()->GetMousePosition();
302 
303  if( m_router->Settings().Mode() != RM_MarkObstacles &&
304  ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
305  {
306  m_endSnapPoint = snapToItem( nullptr, mousePos );
308  m_endItem = nullptr;
309 
310  return;
311  }
312 
313  if( m_router->IsPlacingVia() )
314  layer = -1;
315  else
316  layer = m_router->GetCurrentLayer();
317 
318  ITEM* endItem = nullptr;
319 
320  std::vector<int> nets = m_router->GetCurrentNets();
321 
322  for( int net : nets )
323  {
324  endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
325 
326  if( endItem )
327  break;
328  }
329 
330  if( m_gridHelper->GetSnap() && checkSnap( endItem ) )
331  {
332  m_endItem = endItem;
333  m_endSnapPoint = snapToItem( endItem, mousePos );
334  }
335  else
336  {
337  m_endItem = nullptr;
338  m_endSnapPoint = m_gridHelper->Align( mousePos );
339  }
340 
342 
343  if( m_endItem )
344  {
345  wxLogTrace( "PNS", "%s, layer : %d",
346  m_endItem->KindStr().c_str(),
347  m_endItem->Layers().Start() );
348  }
349 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
bool GetSnap() const
Definition: grid_helper.h:65
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool IsPlacingVia() const
Definition: pns_router.cpp:792
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:764
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
int Start() const
Definition: pns_layerset.h:82
std::string KindStr() const
Returns the kind of the item, as string.
Definition: pns_item.cpp:126
bool GetGridSnapping() const
const VECTOR2I snapToItem(ITEM *aSnapToItem, const VECTOR2I &aP)
bool checkSnap(ITEM *aItem)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
bool DisableGridSnapping() const
Definition: tool_event.h:336
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:331
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
Ignore collisions, mark obstacles.
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:181
const LAYER_RANGE & Layers() const
Definition: pns_item.h:152
Abstract interface for drawing on a 2D-surface.
int GetCurrentLayer() const
Definition: pns_router.cpp:775

References GRID_HELPER::Align(), PNS::TOOL_BASE::checkSnap(), PCB_TOOL_BASE::controls(), TOOL_EVENT::DisableGridSnapping(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), KIGFX::VIEW_CONTROLS::GetMousePosition(), GRID_HELPER::GetSnap(), TOOL_MANAGER::GetView(), PNS::ROUTER::IsPlacingVia(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_SHIFT, PNS::ROUTING_SETTINGS::Mode(), TOOL_EVENT::Modifier(), PNS::TOOL_BASE::pickSingleItem(), PNS::RM_MarkObstacles, GRID_HELPER::SetSnap(), PNS::ROUTER::Settings(), GRID_HELPER::SetUseGrid(), PNS::TOOL_BASE::snapToItem(), and LAYER_RANGE::Start().

Referenced by handleLayerSwitch(), InlineDrag(), performDragging(), and performRouting().

◆ updateMessagePanel()

void ROUTER_TOOL::updateMessagePanel ( )
private

Definition at line 1880 of file router_tool.cpp.

1881 {
1882  if( !m_router->RoutingInProgress() )
1883  {
1884  frame()->SetMsgPanel( board() );
1885  return;
1886  }
1887 
1888  MSG_PANEL_ITEMS items;
1889  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1892 
1893  if( m_startItem && m_startItem->Net() > 0 )
1894  {
1895  wxString description = isDiffPair ? _( "Routing Diff Pair: %s" ) : _( "Routing Track: %s" );
1896 
1897  NETINFO_ITEM* netInfo = board()->FindNet( m_startItem->Net() );
1898  wxASSERT( netInfo );
1899 
1900  items.emplace_back( wxString::Format( description, netInfo->GetNetname() ),
1901  wxString::Format( _( "Net Class: %s" ), netInfo->GetNetClassName() ) );
1902  }
1903  else
1904  {
1905  items.emplace_back( _( "Routing Track" ), _( "(no net)" ) );
1906  }
1907 
1908  EDA_UNITS units = frame()->GetUserUnits();
1909 
1910  int width = isDiffPair ? sizes.DiffPairWidth() : sizes.TrackWidth();
1911  items.emplace_back( wxString::Format( _( "Track Width: %s" ),
1912  MessageTextFromValue( units, width ) ),
1913  wxString::Format( _( "(from %s)" ), sizes.GetWidthSource() ) );
1914 
1915  if( m_startItem )
1916  {
1918  dummy.SetNet( m_startItem->Net() );
1919 
1920  PNS::CONSTRAINT constraint;
1921 
1922  if( resolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, &dummy, nullptr,
1923  m_router->GetCurrentLayer(), &constraint ) )
1924  {
1925  items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
1926  MessageTextFromValue( units, constraint.m_Value.Min() ) ),
1927  wxString::Format( _( "(from %s)" ), constraint.m_RuleName ) );
1928  }
1929  }
1930 
1931  if( isDiffPair )
1932  {
1933  items.emplace_back( _( "Diff Pair Gap" ),
1934  MessageTextFromValue( units, sizes.DiffPairGap() ) );
1935  }
1936 
1937  frame()->SetMsgPanel( items );
1938 }
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1343
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
PNS::RULE_RESOLVER * GetRuleResolver() override
BOARD * board() const
wxString GetNetClassName() const
Definition: netinfo.h:108
wxString m_RuleName
Definition: pns_node.h:72
T Min() const
Definition: minoptmax.h:33
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:200
PCB_BASE_EDIT_FRAME * frame() const
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:71
#define _(s)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
int Net() const
Definition: pns_item.h:150
ITEM * m_startItem
Definition: pns_tool_base.h:69
const wxString & GetNetname() const
Definition: netinfo.h:119
ROUTER * m_router
Definition: pns_tool_base.h:78
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
EDA_UNITS
Definition: eda_units.h:38
Handle the data for a net.
Definition: netinfo.h:64
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
MINOPTMAX< int > m_Value
Definition: pns_node.h:70
bool RoutingInProgress() const
Definition: pns_router.cpp:114
static FILENAME_RESOLVER * resolver
Definition: export_idf.cpp:57
ROUTER_MODE Mode() const
Definition: pns_router.h:131
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
int GetCurrentLayer() const
Definition: pns_router.cpp:775

References _, PCB_TOOL_BASE::board(), PNS::CT_CLEARANCE, dummy(), BOARD::FindNet(), Format(), PCB_TOOL_BASE::frame(), PNS::ROUTER::GetCurrentLayer(), NETINFO_ITEM::GetNetClassName(), NETINFO_ITEM::GetNetname(), PNS_KICAD_IFACE_BASE::GetRuleResolver(), EDA_BASE_FRAME::GetUserUnits(), PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::CONSTRAINT::m_RuleName, PNS::TOOL_BASE::m_startItem, PNS::CONSTRAINT::m_Value, MessageTextFromValue(), MINOPTMAX< T >::Min(), PNS::ROUTER::Mode(), PNS::ITEM::Net(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, resolver, PNS::ROUTER::RoutingInProgress(), EDA_DRAW_FRAME::SetMsgPanel(), and PNS::ROUTER::Sizes().

Referenced by finishInteractive(), onTrackViaSizeChanged(), performRouting(), and prepareInteractive().

◆ updateStartItem()

void TOOL_BASE::updateStartItem ( const TOOL_EVENT aEvent,
bool  aIgnorePads = false 
)
protectedvirtualinherited

Definition at line 266 of file pns_tool_base.cpp.

267 {
268  int tl = getView()->GetTopLayer();
269  VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
270  VECTOR2I p;
271  GAL* gal = m_toolMgr->GetView()->GetGAL();
272 
273  controls()->ForceCursorPosition( false );
275  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
276 
277  if( aEvent.IsMotion() || aEvent.IsClick() )
278  p = aEvent.Position();
279  else
280  p = cp;
281 
282  m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );
283 
285  m_startItem = nullptr;
286 
289 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:199
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool IsMotion() const
Definition: tool_event.h:295
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
bool GetUseGrid() const
Definition: grid_helper.h:68
bool GetGridSnapping() const
const VECTOR2I snapToItem(ITEM *aSnapToItem, const VECTOR2I &aP)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
virtual int GetTopLayer() const
Definition: view.cpp:828
ITEM * m_startItem
Definition: pns_tool_base.h:69
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
bool DisableGridSnapping() const
Definition: tool_event.h:336
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:331
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
KIGFX::VIEW_CONTROLS * controls() const
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:263
const LAYER_RANGE & Layers() const
Definition: pns_item.h:152
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
Abstract interface for drawing on a 2D-surface.

References PCB_TOOL_BASE::controls(), TOOL_EVENT::DisableGridSnapping(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), KIGFX::VIEW::GetTopLayer(), GRID_HELPER::GetUseGrid(), TOOL_BASE::getView(), TOOL_MANAGER::GetView(), TOOL_EVENT::IsClick(), TOOL_EVENT::IsMotion(), PNS::ITEM::Layers(), P