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 ()
 
bool RoutingInProgress ()
 Returns whether routing is currently active. More...
 
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
 
bool Is45Limited () const
 Should the tool use its 45° mode option? More...
 
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 116 of file pcb_tool_base.h.

116  {
118  IPO_ROTATE = 0x01,
119 
121  IPO_FLIP = 0x02,
122 
125  IPO_SINGLE_CLICK = 0x04,
126 
128  IPO_REPEAT = 0x08
129  };
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:90

◆ ~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 165 of file pcb_tool_base.h.

165 { 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 1251 of file router_tool.cpp.

1252 {
1255 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:845
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 1536 of file router_tool.cpp.

1537 {
1539  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1540 
1541  if( selection.Size() == 1 )
1542  {
1543  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1544 
1545  // Note: EDIT_TOOL::Drag temporarily handles items of type PCB_ARC_T on its own using
1546  // DragArcTrack(), so PCB_ARC_T should never occur here.
1548  {
1549  static const KICAD_T footprints[] = { PCB_FOOTPRINT_T, EOT };
1550 
1551  // Footprints cannot be dragged freely.
1552  if( item->IsType( footprints ) )
1553  return !( aDragMode & PNS::DM_FREE_ANGLE );
1554  else
1555  return true;
1556  }
1557  }
1558 
1559  return false;
1560 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
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:104
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:145

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 1228 of file router_tool.cpp.

1229 {
1230  PNS::PNS_MODE mode = aEvent.Parameter<PNS::PNS_MODE>();
1231  PNS::ROUTING_SETTINGS& settings = m_router->Settings();
1232 
1233  settings.SetMode( mode );
1234 
1235  return 0;
1236 }
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:432
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 1878 of file router_tool.cpp.

1879 {
1881  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1882 
1883  if( sizeDlg.ShowModal() == wxID_OK )
1884  {
1885  bds.UseCustomTrackViaSize( true );
1886 
1887  TOOL_EVENT dummy;
1889  }
1890 
1891  return 0;
1892 }
BOARD * board() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
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:72
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

◆ 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 37 of file pcb_tool_base.cpp.

40 {
41  using namespace std::placeholders;
42  std::unique_ptr<BOARD_ITEM> newItem;
43 
44  frame()->PushTool( aTool );
45 
46  BOARD_COMMIT commit( frame() );
47 
49 
50  Activate();
51  // Must be done after Activate() so that it gets set into the correct context
52  controls()->ShowCursor( true );
53  // do not capture or auto-pan until we start placing an item
54 
55  PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
56 
57  // Add a VIEW_GROUP that serves as a preview for the new item
58  PCB_SELECTION preview;
59  view()->Add( &preview );
60 
61  aPlacer->m_board = board();
62  aPlacer->m_frame = frame();
63  aPlacer->m_modifiers = 0;
64 
65  auto makeNewItem =
66  [&]( VECTOR2I aPosition )
67  {
68  if( frame()->GetModel() )
69  newItem = aPlacer->CreateItem();
70 
71  if( newItem )
72  {
73  newItem->SetPosition( (wxPoint) aPosition );
74  preview.Add( newItem.get() );
75 
76  if( newItem->Type() == PCB_FOOTPRINT_T )
77  {
78  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
79 
80  // footprints have more drawable parts
81  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
82  }
83  }
84  };
85 
86  if( aOptions & IPO_SINGLE_CLICK )
87  makeNewItem( controls()->GetCursorPosition() );
88 
89  auto setCursor =
90  [&]()
91  {
92  if( !newItem )
94  else
96  };
97 
98  // Set initial cursor
99  setCursor();
100 
101  // Main loop: keep receiving events
102  while( TOOL_EVENT* evt = Wait() )
103  {
104  setCursor();
105 
106  grid.SetSnap( false ); // Interactive placement tools need to set their own item snaps
107  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
108  VECTOR2I cursorPos = grid.BestSnapAnchor( controls()->GetMousePosition(), nullptr );
109 
110  aPlacer->m_modifiers = evt->Modifier();
111 
112  auto cleanup =
113  [&] ()
114  {
115  newItem = nullptr;
116  preview.Clear();
117  view()->Update( &preview );
118  controls()->SetAutoPan( false );
119  controls()->CaptureCursor( false );
120  controls()->ShowCursor( true );
121  };
122 
123  if( evt->IsCancelInteractive() )
124  {
125  if( aOptions & IPO_SINGLE_CLICK )
126  {
127  cleanup();
128  frame()->PopTool( aTool );
129  break;
130  }
131  else if( newItem )
132  {
133  cleanup();
134  }
135  else
136  {
137  frame()->PopTool( aTool );
138  break;
139  }
140  }
141  else if( evt->IsActivate() )
142  {
143  if( newItem )
144  cleanup();
145 
146  if( evt->IsPointEditor() )
147  {
148  // don't exit (the point editor runs in the background)
149  }
150  else if( evt->IsMoveTool() )
151  {
152  // leave ourselves on the stack so we come back after the move
153  break;
154  }
155  else
156  {
157  frame()->PopTool( aTool );
158  break;
159  }
160  }
161  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
162  {
163  if( !newItem )
164  {
165  // create the item if possible
166  makeNewItem( cursorPos );
167 
168  // no item created, so wait for another click
169  if( !newItem )
170  continue;
171 
172  controls()->CaptureCursor( true );
173  controls()->SetAutoPan( true );
174  }
175  else
176  {
177  auto oldFlags = newItem->GetFlags();
178  newItem->ClearFlags();
179 
180  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
181  {
182  newItem->SetFlags( oldFlags );
183  continue;
184  }
185 
186  preview.Clear();
187  newItem.release();
188  commit.Push( aCommitMessage );
189 
190  controls()->CaptureCursor( false );
191  controls()->SetAutoPan( false );
192  controls()->ShowCursor( true );
193 
194  if( !( aOptions & IPO_REPEAT ) )
195  break;
196 
197  if( aOptions & IPO_SINGLE_CLICK )
198  makeNewItem( controls()->GetCursorPosition() );
199 
200  setCursor();
201  }
202  }
203  else if( evt->IsClick( BUT_RIGHT ) )
204  {
206  }
207  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
208  {
210  }
211  else if( newItem && evt->Category() == TC_COMMAND )
212  {
213  /*
214  * Handle any events that can affect the item as we move it around
215  */
216  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
217  {
218  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
219  newItem->Rotate( newItem->GetPosition(), rotationAngle );
220  view()->Update( &preview );
221  }
222  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
223  {
224  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
225  view()->Update( &preview );
226  }
227  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
228  {
229  frame()->OnEditItemRequest( newItem.get() );
230 
231  // Notify other tools of the changes
233  }
234  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
235  {
236  preview.Clear();
237  newItem.release();
238 
239  makeNewItem( (wxPoint) cursorPos );
240  aPlacer->SnapItem( newItem.get() );
241  view()->Update( &preview );
242  }
243  else
244  {
245  evt->SetPassEvent();
246  }
247  }
248  else if( newItem && evt->IsMotion() )
249  {
250  // track the cursor
251  newItem->SetPosition( (wxPoint) cursorPos );
252  aPlacer->SnapItem( newItem.get() );
253 
254  // Show a preview of the item
255  view()->Update( &preview );
256  }
257  else
258  {
259  evt->SetPassEvent();
260  }
261  }
262 
263  view()->Remove( &preview );
265  controls()->SetAutoPan( false );
266  controls()->CaptureCursor( false );
267 }
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:83
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:32
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:301
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:57
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.
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:1280
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 refreshPreview
Definition: actions.h:106

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(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), TOOL_BASE::getView(), grid, 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_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 1198 of file router_tool.cpp.

1199 {
1200  PNS::SIZES_SETTINGS sizes = m_router->Sizes();
1201  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
1202 
1203  if( settingsDlg.ShowModal() == wxID_OK )
1204  {
1205  m_router->UpdateSizes( sizes );
1206  m_savedSizes = sizes;
1207 
1209  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
1210  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
1211  bds.SetCustomDiffPairViaGap( sizes.DiffPairViaGap() );
1212  }
1213 
1214  return 0;
1215 }
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:590
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:560
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 1051 of file router_tool.cpp.

1052 {
1053  m_router->StopRouting();
1054 
1055  m_startItem = nullptr;
1056  m_endItem = nullptr;
1057 
1060  controls()->SetAutoPan( false );
1061  controls()->ForceCursorPosition( false );
1062  frame()->UndoRedoBlock( false );
1063  highlightNet( false );
1064 
1065  return true;
1066 }
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:708
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 160 of file pcb_tool_base.h.

161  {
162  return getEditFrame<PCB_BASE_EDIT_FRAME>();
163  }

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_TOOL_BASE::Is45Limited(), 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 1239 of file router_tool.cpp.

1240 {
1241  return m_router->Settings().Mode();
1242 }
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 581 of file router_tool.cpp.

582 {
583  int tl = getView()->GetTopLayer();
584 
585  if( m_startItem )
586  {
587  const LAYER_RANGE& ls = m_startItem->Layers();
588 
589  if( ls.Overlaps( tl ) )
590  return tl;
591  else
592  return ls.Start();
593  }
594 
595  return tl;
596 }
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:821
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(), PCB_TOOL_BASE::doInteractiveItemPlacement(), 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(), EE_SELECTION_TOOL::GetNode(), 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(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_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(), PL_POINT_EDITOR::setEditedPoint(), EE_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(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), setTransitions(), SCRIPTING_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::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_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), DRC_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_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 555 of file router_tool.cpp.

556 {
557  if( aEvent.Category() == TC_VIEW || aEvent.Category() == TC_MOUSE )
558  {
559  BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
560  m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
561  }
562 
563  if( !aEvent.IsKeyPressed() )
564  return;
565 
566  switch( aEvent.KeyCode() )
567  {
568  case '0':
570  return;
571 
573  aEvent.SetPassEvent( false );
574  break;
575  default:
576  break;
577  }
578 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
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 719 of file router_tool.cpp.

720 {
721  wxCHECK( m_router, 0 );
722 
723  if( !IsToolActive() )
724  return 0;
725 
726  // First see if this is one of the switch layer commands
727  LSEQ layers = LSET( board()->GetEnabledLayers() & LSET::AllCuMask() ).Seq();
729  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
730 
731  if( aEvent.IsAction( &PCB_ACTIONS::layerNext ) )
732  {
733  size_t idx = 0;
734 
735  for( size_t i = 0; i < layers.size(); i++ )
736  {
737  if( layers[i] == m_lastTargetLayer )
738  {
739  idx = i;
740  break;
741  }
742  }
743 
744  idx = ( idx + 1 ) % layers.size();
745  targetLayer = layers[idx];
746  }
747  else if( aEvent.IsAction( &PCB_ACTIONS::layerPrev ) )
748  {
749  size_t idx = 0;
750 
751  for( size_t i = 0; i < layers.size(); i++ )
752  {
753  if( layers[i] == m_lastTargetLayer )
754  {
755  idx = i;
756  break;
757  }
758  }
759 
760  idx = ( idx > 0 ) ? ( idx - 1 ) : ( layers.size() - 1 );
761  targetLayer = layers[idx];
762  }
763  else
764  {
765  targetLayer = getTargetLayerFromEvent( aEvent );
766  }
767 
768  if( targetLayer != UNDEFINED_LAYER )
769  {
770  m_lastTargetLayer = targetLayer;
771 
772  if( targetLayer == currentLayer )
773  return 0;
774 
775  if( !aForceVia && m_router && m_router->SwitchLayer( targetLayer ) )
776  {
777  updateEndItem( aEvent );
778  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
779  return 0;
780  }
781  }
782 
784  const int layerCount = bds.GetCopperLayerCount();
785 
788 
790 
791  VIATYPE viaType = VIATYPE::THROUGH;
792  bool selectLayer = false;
793 
794  // Otherwise it is one of the router-specific via commands
795  if( targetLayer == UNDEFINED_LAYER )
796  {
797  const int actViaFlags = aEvent.Parameter<intptr_t>();
798  selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
799 
800  viaType = getViaTypeFromFlags( actViaFlags );
801 
802  // ask the user for a target layer
803  if( selectLayer )
804  {
805  wxPoint endPoint = (wxPoint) view()->ToScreen( m_endSnapPoint );
806  endPoint = frame()->GetCanvas()->ClientToScreen( endPoint );
807 
808  targetLayer = frame()->SelectOneLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
809  LSET::AllNonCuMask(), endPoint );
810 
811  // Reset the cursor to the end of the track
813 
814  if( targetLayer == UNDEFINED_LAYER ) // cancelled by user
815  return 0;
816  }
817  }
818 
819  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
820  sizes.ClearLayerPairs();
821 
822  if( !m_router->IsPlacingVia() )
823  {
824  // Cannot place microvias or blind vias if not allowed (obvious)
825  if( ( viaType == VIATYPE::BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
826  {
827  WX_INFOBAR* infobar = frame()->GetInfoBar();
828  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
829  _( "Show board setup" ),
830  wxEmptyString );
831 
832  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
833  [&]( wxHyperlinkEvent& aEvent )
834  {
835  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
836  } ) );
837 
838  infobar->RemoveAllButtons();
839  infobar->AddButton( button );
840 
841  infobar->ShowMessageFor( _( "Blind/buried vias must first be enabled in "
842  "Board Setup > Design Rules > Constraints." ),
843  10000, wxICON_ERROR, WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
844  return false;
845  }
846 
847  if( ( viaType == VIATYPE::MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
848  {
849  WX_INFOBAR* infobar = frame()->GetInfoBar();
850  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
851  _( "Show board setup" ), wxEmptyString );
852 
853  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
854  [&]( wxHyperlinkEvent& aEvent )
855  {
856  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
857  } ) );
858 
859  infobar->RemoveAllButtons();
860  infobar->AddButton( button );
861 
862  infobar->ShowMessageFor( _( "Microvias must first be enabled in "
863  "Board Setup > Design Rules > Constraints." ),
864  10000, wxICON_ERROR, WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
865  return false;
866  }
867  }
868 
869  // Convert blind/buried via to a through hole one, if it goes through all layers
870  if( viaType == VIATYPE::BLIND_BURIED
871  && ( ( targetLayer == B_Cu && currentLayer == F_Cu )
872  || ( targetLayer == F_Cu && currentLayer == B_Cu ) ) )
873  {
874  viaType = VIATYPE::THROUGH;
875  }
876 
877  if( targetLayer == UNDEFINED_LAYER )
878  {
879  // Implicic layer selection
880 
881  switch( viaType )
882  {
883  case VIATYPE::THROUGH:
884  // use the default layer pair
885  currentLayer = pairTop;
886  targetLayer = pairBottom;
887  break;
888 
889  case VIATYPE::MICROVIA:
890  if( currentLayer == F_Cu || currentLayer == In1_Cu )
891  {
892  // front-side microvia
893  currentLayer = F_Cu;
894 
895  if( layerCount > 2 ) // Ensure the inner layer In1_Cu exists
896  targetLayer = In1_Cu;
897  else
898  targetLayer = B_Cu;
899  }
900  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
901  {
902  // back-side microvia
903  currentLayer = B_Cu,
904  targetLayer = (PCB_LAYER_ID) ( layerCount - 2 );
905  }
906  else
907  {
908  wxFAIL_MSG( "Invalid implicit layer pair for microvia (must be on "
909  "or adjacent to an outer layer)." );
910  }
911  break;
912 
914  if( currentLayer == pairTop || currentLayer == pairBottom )
915  {
916  // the current layer is on the defined layer pair,
917  // swap to the other side
918  currentLayer = pairTop;
919  targetLayer = pairBottom;
920  }
921  else
922  {
923  // the current layer is not part of the current layer pair,
924  // so fallback and swap to the top layer of the pair by default
925  targetLayer = pairTop;
926  }
927  break;
928 
929  default:
930  wxFAIL_MSG( "unexpected via type" );
931  break;
932  }
933  }
934 
935  sizes.SetViaDiameter( bds.m_ViasMinSize );
936  sizes.SetViaDrill( bds.m_MinThroughDrill );
937 
938  if( bds.UseNetClassVia() || viaType == VIATYPE::MICROVIA )
939  {
940  PCB_VIA dummyVia( board() );
941  dummyVia.SetViaType( viaType );
942  dummyVia.SetLayerPair( currentLayer, targetLayer );
943 
944  if( !m_router->GetCurrentNets().empty() )
945  dummyVia.SetNetCode( m_router->GetCurrentNets()[0] );
946 
947  DRC_CONSTRAINT constraint;
948 
949  constraint = bds.m_DRCEngine->EvalRules( VIA_DIAMETER_CONSTRAINT, &dummyVia, nullptr,
950  currentLayer );
951 
952  if( !constraint.IsNull() )
953  sizes.SetViaDiameter( constraint.m_Value.Opt() );
954 
955  constraint = bds.m_DRCEngine->EvalRules( HOLE_SIZE_CONSTRAINT, &dummyVia, nullptr,
956  currentLayer );
957 
958  if( !constraint.IsNull() )
959  sizes.SetViaDrill( constraint.m_Value.Opt() );
960  }
961  else
962  {
963  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
964  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
965  }
966 
967  sizes.SetViaType( viaType );
968  sizes.AddLayerPair( currentLayer, targetLayer );
969 
970  m_router->UpdateSizes( sizes );
971 
972  if( !m_router->IsPlacingVia() )
974 
975  m_lastTargetLayer = targetLayer;
976 
977  if( m_router->RoutingInProgress() )
978  {
979  updateEndItem( aEvent );
981  }
982  else
983  {
984  updateStartItem( aEvent );
985  }
986 
987  return 0;
988 }
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:274
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 AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:245
static TOOL_ACTION layerNext
Definition: pcb_actions.h:285
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:798
Ask user to select layer before adding via.
Definition: router_tool.cpp:75
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:770
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 ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:128
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:590
void ToggleViaPlacement()
Definition: pns_router.cpp:760
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:145
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:504
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:286
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:432
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:466
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:465
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:560
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:65
Definition: layer_ids.h:71
bool IsToolActive() const
Definition: tool_base.cpp:31
bool SwitchLayer(int layer)
Definition: pns_router.cpp:751
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:90
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:781

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(), WX_INFOBAR::DRC_VIOLATION, 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:208
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:766

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 ( )
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:192
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:195
#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:178
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:88
int m_lastTargetLayer
Definition: router_tool.h:90
std::shared_ptr< ACTION_MENU > m_diffPairMenu
Definition: router_tool.h:87
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:181

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 1816 of file router_tool.cpp.

1817 {
1818  const SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1819 
1820  if( selection.Size() != 1 )
1821  return 0;
1822 
1823  const BOARD_CONNECTED_ITEM* item =
1824  static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1825 
1826  if( item->Type() != PCB_TRACE_T )
1827  return 0;
1828 
1829  Activate();
1830 
1832  m_router->SyncWorld();
1834 
1835  TOOL_MANAGER* toolManager = frame()->GetToolManager();
1836  GAL* gal = toolManager->GetView()->GetGAL();
1837 
1839  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
1840 
1841  if( toolManager->IsContextMenuActive() )
1842  {
1843  // If we're here from a context menu then we need to get the position of the
1844  // cursor when the context menu was invoked. This is used to figure out the
1845  // break point on the track.
1847  }
1848  else
1849  {
1850  // If we're here from a hotkey, then get the current mouse position so we know
1851  // where to break the track.
1852  m_startSnapPoint = snapToItem( m_startItem, controls()->GetCursorPosition() );
1853  }
1854 
1855  if( m_startItem && m_startItem->IsLocked() )
1856  {
1857  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1858  wxOK | wxCANCEL | wxICON_WARNING );
1859  dlg.SetOKLabel( _( "Break Track" ) );
1860  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1861 
1862  if( dlg.ShowModal() == wxID_CANCEL )
1863  return 0;
1864  }
1865 
1866  frame()->UndoRedoBlock( true );
1867  breakTrack();
1868 
1869  if( m_router->RoutingInProgress() )
1870  m_router->StopRouting();
1871 
1872  frame()->UndoRedoBlock( false );
1873 
1874  return 0;
1875 }
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:190
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:1573
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:341
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
void StopRouting()
Definition: pns_router.cpp:708
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:336
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:104
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:145
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 1563 of file router_tool.cpp.

1564 {
1565  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1566 
1567  if( selection.Empty() )
1569 
1570  if( selection.Size() != 1 )
1571  return 0;
1572 
1573  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
1574 
1575  if( item->Type() != PCB_TRACE_T
1576  && item->Type() != PCB_VIA_T
1577  && item->Type() != PCB_FOOTPRINT_T )
1578  {
1579  return 0;
1580  }
1581 
1582  // If we overrode locks, we want to clear the flag from the source item before SyncWorld is
1583  // called so that virtual vias are not generated for the (now unlocked) track segment. Note in
1584  // this case the lock can't be reliably re-applied, because there is no guarantee that the end
1585  // state of the drag results in the same number of segments so it's not clear which segment to
1586  // apply the lock state to.
1587  bool wasLocked = false;
1588 
1589  if( item->IsLocked() )
1590  {
1591  wasLocked = true;
1592  item->SetLocked( false );
1593  }
1594 
1595  Activate();
1596 
1598  m_router->SyncWorld();
1599  m_startItem = nullptr;
1600 
1601  PNS::ITEM* startItem = nullptr;
1602  PNS::ITEM_SET itemsToDrag;
1603  const FOOTPRINT* footprint = nullptr;
1604 
1605  if( item->Type() == PCB_FOOTPRINT_T )
1606  {
1607  footprint = static_cast<const FOOTPRINT*>(item);
1608 
1609  for( const PAD* pad : footprint->Pads() )
1610  {
1612 
1613  if( solid )
1614  itemsToDrag.Add( solid );
1615  }
1616  }
1617  else
1618  {
1619  startItem = m_router->GetWorld()->FindItemByParent( item );
1620 
1621  if( startItem )
1622  itemsToDrag.Add( startItem );
1623  }
1624 
1625  GAL* gal = m_toolMgr->GetView()->GetGAL();
1626  VECTOR2I p0 = controls()->GetCursorPosition( false );
1627  VECTOR2I p = p0;
1628 
1630  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
1631 
1632  if( startItem )
1633  {
1634  p = snapToItem( startItem, p0 );
1635  m_startItem = startItem;
1636  }
1637  else if( footprint )
1638  {
1639  // The mouse is going to be moved on grid before dragging begins.
1640  VECTOR2I tweakedMousePos;
1641  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1642 
1643  // Check if user wants to warp the mouse to origin of moved object
1644 
1645  if( editFrame->GetMoveWarpsCursor() )
1646  tweakedMousePos = footprint->GetPosition(); // Use footprint anchor to warp mouse
1647  else
1648  tweakedMousePos = controls()->GetCursorPosition(); // Just use current mouse pos
1649 
1650  // We tweak the mouse position using the value from above, and then use that as the
1651  // start position to prevent the footprint from jumping when we start dragging.
1652  // First we move the visual cross hair cursor...
1653  controls()->ForceCursorPosition( true, tweakedMousePos );
1654  controls()->SetCursorPosition( tweakedMousePos ); // ...then the mouse pointer
1655 
1656  // Now that the mouse is in the right position, get a copy of the position to use later
1657  p = controls()->GetCursorPosition();
1658  }
1659 
1660  int dragMode = aEvent.Parameter<int64_t> ();
1661 
1662  bool dragStarted = m_router->StartDragging( p, itemsToDrag, dragMode );
1663 
1664  if( !dragStarted )
1665  {
1666  if( wasLocked )
1667  item->SetLocked( true );
1668 
1669  return 0;
1670  }
1671 
1672  m_gridHelper->SetAuxAxes( true, p );
1673  controls()->ShowCursor( true );
1674  controls()->SetAutoPan( true );
1675  frame()->UndoRedoBlock( true );
1676 
1677  view()->ClearPreview();
1678  view()->InitPreview();
1679 
1680  auto setCursor =
1681  [&]()
1682  {
1684  };
1685 
1686  // Set initial cursor
1687  setCursor();
1688 
1689  // Set the initial visible area
1690  BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
1691  m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
1692 
1693  // Send an initial movement to prime the collision detection
1694  m_router->Move( p, nullptr );
1695 
1696  bool hasMouseMoved = false;
1697 
1698  while( TOOL_EVENT* evt = Wait() )
1699  {
1700  setCursor();
1701 
1702  if( evt->IsCancelInteractive() )
1703  {
1704  if( wasLocked )
1705  item->SetLocked( true );
1706 
1707  break;
1708  }
1709  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1710  {
1711  hasMouseMoved = true;
1712  updateEndItem( *evt );
1714 
1715  if( footprint )
1716  {
1717  VECTOR2I offset = m_endSnapPoint - p;
1718  BOARD_ITEM* previewItem;
1719 
1720  view()->ClearPreview();
1721 
1722  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1723  {
1724  previewItem = static_cast<BOARD_ITEM*>( drawing->Clone() );
1725 
1726  if( drawing->Type() == PCB_FP_SHAPE_T )
1727  {
1728  FP_SHAPE* shape = static_cast<FP_SHAPE*>( previewItem );
1729  wxPoint fp_offset = wxPoint( offset.Rotate( footprint->GetOrientationRadians() ) );
1730  shape->FP_SHAPE::Move( fp_offset );
1731  }
1732  else
1733  {
1734  previewItem->Move( offset );
1735  }
1736 
1737  view()->AddToPreview( previewItem );
1738  view()->Hide( drawing, true );
1739  }
1740 
1741  previewItem = static_cast<BOARD_ITEM*>( footprint->Reference().Clone() );
1742  previewItem->Move( offset );
1743  view()->AddToPreview( previewItem );
1744  view()->Hide( &footprint->Reference() );
1745 
1746  previewItem = static_cast<BOARD_ITEM*>( footprint->Value().Clone() );
1747  previewItem->Move( offset );
1748  view()->AddToPreview( previewItem );
1749  view()->Hide( &footprint->Value() );
1750 
1751  for( ZONE* zone : footprint->Zones() )
1752  {
1753  previewItem = static_cast<BOARD_ITEM*>( zone->Clone() );
1754  previewItem->Move( offset );
1755  view()->AddToPreview( previewItem );
1756  view()->Hide( zone, true );
1757  }
1758  }
1759  }
1760  else if( hasMouseMoved && ( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
1761  {
1762  updateEndItem( *evt );
1764  break;
1765  }
1766  else if( evt->Category() == TC_COMMAND )
1767  {
1768  // disallow editing commands
1769  if( evt->IsAction( &ACTIONS::cut )
1770  || evt->IsAction( &ACTIONS::copy )
1771  || evt->IsAction( &ACTIONS::paste )
1772  || evt->IsAction( &ACTIONS::pasteSpecial ) )
1773  {
1774  wxBell();
1775  }
1776  else
1777  {
1778  evt->SetPassEvent();
1779  }
1780  }
1781  else
1782  {
1783  evt->SetPassEvent();
1784  }
1785 
1786  handleCommonEvents( *evt );
1787  }
1788 
1789  if( footprint )
1790  {
1791  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1792  view()->Hide( drawing, false );
1793 
1794  view()->Hide( &footprint->Reference(), false );
1795  view()->Hide( &footprint->Value(), false );
1796 
1797  for( ZONE* zone : footprint->Zones() )
1798  view()->Hide( zone, false );
1799 
1800  view()->ClearPreview();
1801  view()->ShowPreview( false );
1802  }
1803 
1804  if( m_router->RoutingInProgress() )
1805  m_router->StopRouting();
1806 
1807  m_gridHelper->SetAuxAxes( false );
1808  controls()->SetAutoPan( false );
1809  controls()->ForceCursorPosition( false );
1810  frame()->UndoRedoBlock( false );
1811 
1812  return 0;
1813 }
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:1479
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:192
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:49
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1556
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:1549
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:190
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
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
Definition: board_item.h:221
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
virtual bool IsLocked() const
Definition: board_item.cpp:64
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:168
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:499
void ShowPreview(bool aShow=true)
Definition: view.cpp:1570
FP_TEXT & Reference()
Definition: footprint.h:500
PCB_BASE_EDIT_FRAME * frame() const
FP_ZONES & Zones()
Definition: footprint.h:174
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:1573
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:236
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
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:665
FOOTPRINT * footprint() const
void SetVisibleViewArea(const BOX2I &aExtents)
Definition: pns_router.h:209
void ClearPreview()
Definition: view.cpp:1534
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:171
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:341
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:98
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:708
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:336
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:104
The selection tool: currently supports:
wxPoint GetPosition() const override
Definition: footprint.h:186
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:145
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(), BOARD_ITEM::IsLocked(), 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(), BOARD_ITEM::SetLocked(), 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().

◆ Is45Limited()

bool PCB_TOOL_BASE::Is45Limited ( ) const
inherited

◆ 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 1258 of file router_tool.cpp.

1259 {
1260  PNS::ROUTER_MODE mode = aEvent.Parameter<PNS::ROUTER_MODE>();
1261  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1263 
1264  if( m_router->RoutingInProgress() )
1265  {
1266  if( m_router->Mode() == mode )
1267  return 0;
1268  else
1269  m_router->StopRouting();
1270  }
1271 
1272  // Deselect all items
1274 
1275  std::string tool = aEvent.GetCommandStr().get();
1276  frame->PushTool( tool );
1277 
1278  auto setCursor =
1279  [&]()
1280  {
1282  };
1283 
1284  Activate();
1285  // Must be done after Activate() so that it gets set into the correct context
1286  controls->ShowCursor( true );
1287  controls->ForceCursorPosition( false );
1288  // Set initial cursor
1289  setCursor();
1290 
1291  m_router->SetMode( mode );
1292  m_cancelled = false;
1293 
1294  // Prime the pump
1295  if( aEvent.HasPosition() )
1297 
1298  // Main loop: keep receiving events
1299  while( TOOL_EVENT* evt = Wait() )
1300  {
1301  if( !evt->IsDrag() )
1302  setCursor();
1303 
1304  if( evt->IsCancelInteractive() )
1305  {
1306  frame->PopTool( tool );
1307  break;
1308  }
1309  else if( evt->IsActivate() )
1310  {
1311  if( evt->IsMoveTool() )
1312  {
1313  // leave ourselves on the stack so we come back after the move
1314  break;
1315  }
1316  else
1317  {
1318  frame->PopTool( tool );
1319  break;
1320  }
1321  }
1322  else if( evt->Action() == TA_UNDO_REDO_PRE )
1323  {
1324  m_router->ClearWorld();
1325  }
1326  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
1327  {
1328  m_router->SyncWorld();
1329  }
1330  else if( evt->IsMotion() )
1331  {
1332  updateStartItem( *evt );
1333  }
1334  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
1335  {
1336  updateStartItem( *evt, true );
1338  }
1339  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
1340  {
1341  updateStartItem( *evt, true );
1343  }
1344  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
1345  {
1346  updateStartItem( *evt, true );
1347  breakTrack( );
1348  }
1349  else if( evt->IsClick( BUT_LEFT )
1350  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1351  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1352  {
1353  updateStartItem( *evt );
1354 
1355  if( evt->HasPosition() )
1356  {
1357  if( evt->Modifier( MD_SHIFT ) )
1359  else
1360  performRouting();
1361  }
1362  }
1363  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1364  {
1366  }
1367  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1368  {
1370  updateStartItem( *evt );
1371  }
1372  else if( evt->IsKeyPressed() )
1373  {
1374  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1375  // event so we need to process the wxEVT_CHAR event that will follow as long as we
1376  // pass the event.
1377  evt->SetPassEvent();
1378  }
1379  else if( evt->IsClick( BUT_RIGHT ) )
1380  {
1382  }
1383  else
1384  {
1385  evt->SetPassEvent();
1386  }
1387 
1388  if( m_cancelled )
1389  {
1390  frame->PopTool( tool );
1391  break;
1392  }
1393  }
1394 
1395  // Store routing settings till the next invocation
1398 
1399  return 0;
1400 }
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:736
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:432
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:708
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
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:291
KIGFX::VIEW_CONTROLS * controls() const
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:834
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
void performDragging(int aMode=PNS::DM_ANY)
bool SwitchLayer(int layer)
Definition: pns_router.cpp:751
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:289
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:181

References ACT_PlaceThroughVia, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_ACTIONS::breakTrack, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), PNS::ROUTER::ClearWorld(), PCB_TOOL_BASE::controls(), 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 1481 of file router_tool.cpp.

1482 {
1483  /*
1484  * If the collection contains a trivial line corner (two connected segments)
1485  * or a non-fanout-via (a via with no more than two connected segments), then
1486  * trim the collection down to a single item (which one won't matter since
1487  * they're all connected).
1488  */
1489 
1490  // First make sure we've got something that *might* match.
1491  int vias = aCollector.CountType( PCB_VIA_T );
1492  int traces = aCollector.CountType( PCB_TRACE_T );
1493  int arcs = aCollector.CountType( PCB_ARC_T );
1494 
1495  if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1496  return;
1497 
1498  // Fetch first PCB_TRACK (via or trace) as our reference
1499  PCB_TRACK* reference = nullptr;
1500 
1501  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1502  reference = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1503 
1504  int refNet = reference->GetNetCode();
1505 
1506  wxPoint refPoint( aPt.x, aPt.y );
1507  EDA_ITEM_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1508 
1509  if( flags & STARTPOINT )
1510  refPoint = reference->GetStart();
1511  else if( flags & ENDPOINT )
1512  refPoint = reference->GetEnd();
1513 
1514  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1515  // the same net.
1516  for( int i = 0; i < aCollector.GetCount(); i++ )
1517  {
1518  PCB_TRACK* neighbor = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1519 
1520  if( neighbor && neighbor != reference )
1521  {
1522  if( neighbor->GetNetCode() != refNet )
1523  return;
1524 
1525  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1526  return;
1527  }
1528  }
1529 
1530  // Selection meets criteria; trim it to the reference item.
1531  aCollector.Empty();
1532  aCollector.Append( reference );
1533 }
void Empty()
Clear the list.
Definition: collector.h:90
#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:228
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:100
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
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 707 of file router_tool.cpp.

708 {
709  return handleLayerSwitch( aEvent, false );
710 }
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 1895 of file router_tool.cpp.

1896 {
1897  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1898 
1899  if( !m_router->GetCurrentNets().empty() )
1901 
1902  m_router->UpdateSizes( sizes );
1903 
1904  // Changing the track width can affect the placement, so call the
1905  // move routine without changing the destination
1907 
1909 
1910  return 0;
1911 }
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:770
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:560
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 713 of file router_tool.cpp.

714 {
715  return handleLayerSwitch( aEvent, true );
716 }
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 1403 of file router_tool.cpp.

1404 {
1406 
1407  VIEW_CONTROLS* ctls = getViewControls();
1408 
1409  if( m_startItem && m_startItem->IsLocked() )
1410  {
1411  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1412  wxOK | wxCANCEL | wxICON_WARNING );
1413  dlg.SetOKLabel( _( "Drag Anyway" ) );
1414  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1415 
1416  if( dlg.ShowModal() == wxID_CANCEL )
1417  return;
1418  }
1419 
1420  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1421 
1422  if( !dragStarted )
1423  return;
1424 
1425  if( m_startItem && m_startItem->Net() > 0 )
1426  highlightNet( true, m_startItem->Net() );
1427 
1428  ctls->SetAutoPan( true );
1430  frame()->UndoRedoBlock( true );
1431 
1432  while( TOOL_EVENT* evt = Wait() )
1433  {
1434  ctls->ForceCursorPosition( false );
1435 
1436  if( evt->IsMotion() )
1437  {
1438  updateEndItem( *evt );
1440  }
1441  else if( evt->IsClick( BUT_LEFT ) )
1442  {
1444  break;
1445  }
1446  else if( evt->IsClick( BUT_RIGHT ) )
1447  {
1449  }
1450  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1451  {
1452  if( evt->IsCancelInteractive() && !m_startItem )
1453  m_cancelled = true;
1454 
1455  if( evt->IsActivate() && !evt->IsMoveTool() )
1456  m_cancelled = true;
1457 
1458  break;
1459  }
1460  else
1461  {
1462  evt->SetPassEvent();
1463  }
1464 
1465  handleCommonEvents( *evt );
1466  }
1467 
1468  if( m_router->RoutingInProgress() )
1469  m_router->StopRouting();
1470 
1471  m_startItem = nullptr;
1472 
1473  m_gridHelper->SetAuxAxes( false );
1474  frame()->UndoRedoBlock( false );
1475  ctls->SetAutoPan( false );
1476  ctls->ForceCursorPosition( false );
1477  highlightNet( false );
1478 }
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:736
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:665
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:708
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 1069 of file router_tool.cpp.

1070 {
1072 
1073  if( !prepareInteractive() )
1074  return;
1075 
1076  auto setCursor =
1077  [&]()
1078  {
1080  };
1081 
1082  // Set initial cursor
1083  setCursor();
1084 
1085  while( TOOL_EVENT* evt = Wait() )
1086  {
1087  setCursor();
1088 
1089  // Don't crash if we missed an operation that canceled routing.
1090  if( !m_router->RoutingInProgress() )
1091  {
1092  if( evt->IsCancelInteractive() )
1093  m_cancelled = true;
1094 
1095  break;
1096  }
1097 
1098  handleCommonEvents( *evt );
1099 
1100  if( evt->IsMotion() )
1101  {
1102  updateEndItem( *evt );
1104  }
1105  else if( evt->IsAction( &PCB_ACTIONS::routerUndoLastSegment ) )
1106  {
1108  updateEndItem( *evt );
1110  }
1111  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
1112  {
1113  updateEndItem( *evt );
1114  bool needLayerSwitch = m_router->IsPlacingVia();
1115  bool forceFinish = evt->Modifier( MD_SHIFT );
1116 
1117  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
1118  {
1119  break;
1120  }
1121 
1122  if( needLayerSwitch )
1124 
1125  // Synchronize the indicated layer
1126  PCB_LAYER_ID routingLayer = ToLAYER_ID( m_router->GetCurrentLayer() );
1127  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1128 
1129  editFrame->SetActiveLayer( routingLayer );
1130 
1131  if( !getView()->IsLayerVisible( routingLayer ) )
1132  {
1133  editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1134  editFrame->GetCanvas()->Refresh();
1135  }
1136 
1137  updateEndItem( *evt );
1139  m_startItem = nullptr;
1140  }
1141  else if( evt->IsAction( &ACT_SwitchRounding ) )
1142  {
1144  updateEndItem( *evt );
1145  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1146  }
1147  else if( evt->IsAction( &ACT_SwitchPosture ) )
1148  {
1149  m_router->FlipPosture();
1150  updateEndItem( *evt );
1151  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1152  }
1153  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
1154  {
1156  controls()->SetAutoPan( false );
1157  {
1159  }
1160  controls()->SetAutoPan( true );
1161  setCursor();
1163  }
1164  else if( evt->IsAction( &ACT_EndTrack ) || evt->IsDblClick( BUT_LEFT ) )
1165  {
1166  // Stop current routing:
1168  break;
1169  }
1170  else if( evt->IsCancelInteractive() || evt->IsActivate()
1171  || evt->IsUndoRedo()
1172  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
1173  {
1174  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
1175  m_cancelled = true;
1176 
1177  if( evt->IsActivate() && !evt->IsMoveTool() )
1178  m_cancelled = true;
1179 
1180  break;
1181  }
1182  else if( evt->IsClick( BUT_RIGHT ) )
1183  {
1185  }
1186  else
1187  {
1188  evt->SetPassEvent();
1189  }
1190  }
1191 
1193 
1195 }
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:192
void CommitRouting()
Definition: pns_router.cpp:699
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:736
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:798
void ToggleRounded()
Definition: pns_router.cpp:807
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()
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:690
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:665
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:205
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.
KIGFX::VIEW_CONTROLS * controls() const
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
The main frame for Pcbnew.
void FlipPosture()
Definition: pns_router.cpp:742
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:781

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(), TOOL_MENU::ShowContextMenu(), 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:821
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:99
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:796
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 991 of file router_tool.cpp.

992 {
993  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
994  int routingLayer = getStartLayer( m_startItem );
995 
996  if( !IsCopperLayer( routingLayer ) )
997  {
998  editFrame->ShowInfoBarError( _( "Tracks on Copper layers only." ) );
999  return false;
1000  }
1001 
1002  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
1003 
1004  if( !getView()->IsLayerVisible( routingLayer ) )
1005  {
1006  editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1007  editFrame->GetCanvas()->Refresh();
1008  }
1009 
1010  if( m_startItem && m_startItem->Net() > 0 )
1011  highlightNet( true, m_startItem->Net() );
1012 
1013  controls()->SetAutoPan( true );
1014 
1015  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1016 
1017  m_iface->ImportSizes( sizes, m_startItem, -1 );
1018  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
1019  frame()->GetScreen()->m_Route_Layer_BOTTOM );
1020 
1021  m_router->UpdateSizes( sizes );
1022 
1023  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
1024  {
1025  // It would make more sense to leave the net highlighted as the higher-contrast mode
1026  // makes the router clearances more visible. However, since we just started routing
1027  // the conversion of the screen from low contrast to high contrast is a bit jarring and
1028  // makes the infobar coming up less noticeable.
1029  highlightNet( false );
1030 
1032  [&]()
1033  {
1035  } );
1036 
1037  controls()->SetAutoPan( false );
1038  return false;
1039  }
1040 
1041  m_endItem = nullptr;
1043 
1045  frame()->UndoRedoBlock( true );
1046 
1047  return true;
1048 }
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:736
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
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
#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:796
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:560
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 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:90

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

◆ Router()

ROUTER * TOOL_BASE::Router ( ) const
inherited

◆ RoutingInProgress()

bool ROUTER_TOOL::RoutingInProgress ( )

Returns whether routing is currently active.

Returns
True if actively routing, false if not routing or tool is activated and idle.

Definition at line 1245 of file router_tool.cpp.

1246 {
1247  return m_router->RoutingInProgress();
1248 }
ROUTER * m_router
Definition: pns_tool_base.h:78
bool RoutingInProgress() const
Definition: pns_router.cpp:114

References PNS::TOOL_BASE::m_router, and PNS::ROUTER::RoutingInProgress().

Referenced by PCB_SELECTION_TOOL::Main().

◆ 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 %d\n",
530  m_router->Settings().Mode(),
531  m_router->Settings().RemoveLoops() ? 1 : 0,
532  m_router->Settings().GetFixAllSegments() ? 1 : 0,
534  );
535 
536  const auto& events = logger->GetEvents();
537 
538  for( auto evt : events)
539  {
540  fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
541  (const char*) evt.uuid.c_str() );
542  }
543 
544  fclose( f );
545 
546  // Export as *.kicad_pcb format, using a strategy which is specifically chosen
547  // as an example on how it could also be used to send it to the system clipboard.
548 
549  PCB_IO pcb_io;
550 
551  pcb_io.Save( fname_dump.GetFullPath(), m_iface->GetBoard(), nullptr );
552 }
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:252
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
CORNER_MODE GetCornerMode() const
LOGGER * Logger()
Definition: pns_router.cpp:792
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::GetCornerMode(), 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 326 of file sel_layer.cpp.

327 {
328  PCB_SCREEN* screen = frame()->GetScreen();
329 
331  screen->m_Route_Layer_BOTTOM );
332 
333  if( dlg.ShowModal() == wxID_OK )
334  {
335  dlg.GetLayerPair( screen->m_Route_Layer_TOP, screen->m_Route_Layer_BOTTOM );
336 
337  // select the same layer for both layers is allowed (normal in some boards)
338  // but could be a mistake. So display an info message
339  if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM )
340  DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
341  }
342 
343  return 0;
344 }
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:307
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:297

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 307 of file pcb_tool_base.cpp.

308 {
310 
311  return selTool->GetSelection();
312 }
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(), DRC_TOOL::CrossProbe(), 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 315 of file pcb_tool_base.cpp.

316 {
318 
319  return selTool->GetSelection();
320 }
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 1218 of file router_tool.cpp.

1219 {
1220  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
1221 
1222  settingsDlg.ShowModal();
1223 
1224  return 0;
1225 }
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 1975 of file router_tool.cpp.

1976 {
1978 
1988 
1995 
2030 
2033 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:284
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:279
int onLayerCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerNext
Definition: pcb_actions.h:285
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:255
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:258
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:259
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:196
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:260
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:261
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:274
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:200
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:301
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:256
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:277
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:264
static TOOL_ACTION layerTop
Definition: pcb_actions.h:253
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:276
int onViaCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:195
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:266
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:286
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:278
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:271
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:283
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:282
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:263
int SettingsDialog(const TOOL_EVENT &aEvent)
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:202
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:268
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:205
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:281
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:280
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:135
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:270
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:273
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:275
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:267
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:262
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:269
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:326
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:257
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:272
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:254
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:201
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:265
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:181

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
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 599 of file router_tool.cpp.

600 {
601  int al = frame()->GetActiveLayer();
602  int cl = m_router->GetCurrentLayer();
603 
604  if( cl != al )
605  {
606  m_router->SwitchLayer( al );
607  }
608 
609  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
610 
611  if( !newLayer )
612  newLayer = m_router->Sizes().GetLayerTop();
613 
614  m_router->SwitchLayer( *newLayer );
615  m_lastTargetLayer = *newLayer;
616 }
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:751
boost::optional< T > OPT
Definition: optional.h:7
int m_lastTargetLayer
Definition: router_tool.h:90
OPT< int > PairedLayer(int aLayerId)
int GetCurrentLayer() const
Definition: pns_router.cpp:781

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:798
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:770
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
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:341
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:336
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:781

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 1914 of file router_tool.cpp.

1915 {
1916  if( !m_router->RoutingInProgress() )
1917  {
1918  frame()->SetMsgPanel( board() );
1919  return;
1920  }
1921 
1922  std::vector<MSG_PANEL_ITEM> items;
1923  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1926 
1927  if( m_startItem && m_startItem->Net() > 0 )
1928  {
1929  wxString description = isDiffPair ? _( "Routing Diff Pair: %s" ) : _( "Routing Track: %s" );
1930 
1931  NETINFO_ITEM* netInfo = board()->FindNet( m_startItem->Net() );
1932  wxASSERT( netInfo );
1933 
1934  items.emplace_back( wxString::Format( description, netInfo->GetNetname() ),
1935  wxString::Format( _( "Net Class: %s" ), netInfo->GetNetClassName() ) );
1936  }
1937  else
1938  {
1939  items.emplace_back( _( "Routing Track" ), _( "(no net)" ) );
1940  }
1941 
1942  EDA_UNITS units = frame()->GetUserUnits();
1943 
1944  int width = isDiffPair ? sizes.DiffPairWidth() : sizes.TrackWidth();
1945  items.emplace_back( wxString::Format( _( "Track Width: %s" ),
1946  MessageTextFromValue( units, width ) ),
1947  wxString::Format( _( "(from %s)" ), sizes.GetWidthSource() ) );
1948 
1949  if( m_startItem )
1950  {
1952  dummy.SetNet( m_startItem->Net() );
1953 
1954  PNS::CONSTRAINT constraint;
1955 
1956  if( resolver->QueryConstraint( PNS::CONSTRAINT_TYPE::CT_CLEARANCE, &dummy, nullptr,
1957  m_router->GetCurrentLayer(), &constraint ) )
1958  {
1959  items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
1960  MessageTextFromValue( units, constraint.m_Value.Min() ) ),
1961  wxString::Format( _( "(from %s)" ), constraint.m_RuleName ) );
1962  }
1963  }
1964 
1965  if( isDiffPair )
1966  {
1967  items.emplace_back( _( "Diff Pair Gap" ),
1968  MessageTextFromValue( units, sizes.DiffPairGap() ) );
1969  }
1970 
1971  frame()->SetMsgPanel( items );
1972 }
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1325
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:72
#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
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:781

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 );
274