KiCad PCB EDA Suite
LENGTH_TUNER_TOOL Class Reference

#include <length_tuner_tool.h>

Inheritance diagram for LENGTH_TUNER_TOOL:
PNS::TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 LENGTH_TUNER_TOOL ()
 
 ~LENGTH_TUNER_TOOL ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int TuneSingleTrace (const TOOL_EVENT &aEvent)
 
int TuneDiffPair (const TOOL_EVENT &aEvent)
 
int TuneDiffPairSkew (const TOOL_EVENT &aEvent)
 
void SetTransitions () override
 Function SetTransitions() This method is meant to be overridden in order to specify handlers for events. More...
 
const ROUTING_SETTINGS & PNSSettings () const
 
ROUTER * Router () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
virtual bool Init ()
 Function Init() Init() is called once upon a registration of the tool. More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 

Static Public Attributes

static TOOL_ACTION ACT_RouterOptions
 

Protected Member Functions

const VECTOR2I snapToItem (bool aEnabled, ITEM *aItem, VECTOR2I aP)
 
virtual ITEM * pickSingleItem (const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1)
 
virtual void highlightNet (bool aEnabled, int aNetcode=-1)
 
virtual void updateStartItem (TOOL_EVENT &aEvent)
 
virtual void updateEndItem (const TOOL_EVENT &aEvent)
 
void deleteTraces (ITEM *aStartItem, bool aWholeTrack)
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

MSG_PANEL_ITEMS m_panelItems
 
ROUTING_SETTINGS m_savedSettings
 Stores routing settings between router invocations. More...
 
SIZES_SETTINGS m_savedSizes
 Stores sizes settings between router invocations. More...
 
ITEM * m_startItem
 
int m_startLayer
 
VECTOR2I m_startSnapPoint
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
PCB_EDIT_FRAMEm_frame
 
KIGFX::VIEW_CONTROLSm_ctls
 
BOARDm_board
 
GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

void performTuning ()
 
int mainLoop (PNS::ROUTER_MODE aMode)
 
void updateStatusPopup (PNS_TUNE_STATUS_POPUP &aPopup)
 
int routerOptionsDialog (const TOOL_EVENT &aEvent)
 
int meanderSettingsDialog (const TOOL_EVENT &aEvent)
 

Private Attributes

PNS::MEANDER_SETTINGS m_savedMeanderSettings
 

Detailed Description

Definition at line 31 of file length_tuner_tool.h.

Member Enumeration Documentation

enum TOOL_BASE::RESET_REASON
inherited

Determines 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 80 of file tool_base.h.

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

Constructor & Destructor Documentation

LENGTH_TUNER_TOOL::LENGTH_TUNER_TOOL ( )

Definition at line 70 of file length_tuner_tool.cpp.

70  :
71  TOOL_BASE( "pcbnew.LengthTuner" )
72 {
73 }
TOOL_BASE(const std::string &aToolName)
LENGTH_TUNER_TOOL::~LENGTH_TUNER_TOOL ( )

Definition at line 104 of file length_tuner_tool.cpp.

105 {
106 }

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

Referenced by MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), and ROUTER_TOOL::SettingsDialog().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 54 of file tool_base.cpp.

References TOOL_BASE::m_toolMgr, TOOL_BASE::m_toolSettings, and TOOL_BASE::TOOL_SETTINGS.

Referenced by TOOL_MANAGER::RegisterTool().

55 {
56  m_toolMgr = aManager;
57  m_toolSettings = TOOL_SETTINGS( this );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
friend class TOOL_SETTINGS
Definition: tool_base.h:160
void TOOL_BASE::deleteTraces ( ITEM aStartItem,
bool  aWholeTrack 
)
protectedinherited

Definition at line 284 of file pns_tool_base.cpp.

References PNS::TOPOLOGY::AssembleTrivialPath(), PNS::NODE::Branch(), PNS::ROUTER::CommitRouting(), PNS::ROUTER::GetWorld(), PNS::ITEM_SET::Items(), PNS::TOOL_BASE::m_router, and PNS::NODE::Remove().

Referenced by ROUTER_TOOL::mainLoop().

285 {
286  NODE *node = m_router->GetWorld()->Branch();
287 
288  if( !aStartItem )
289  return;
290 
291  if( !aWholeTrack )
292  {
293  node->Remove( aStartItem );
294  }
295  else
296  {
297  TOPOLOGY topo( node );
298  ITEM_SET path = topo.AssembleTrivialPath( aStartItem );
299 
300  for( auto ent : path.Items() )
301  node->Remove( ent.item );
302  }
303 
304  m_router->CommitRouting( node );
305 }
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:109
NODE * GetWorld() const
Definition: pns_router.h:134
ROUTER * m_router
Definition: pns_tool_base.h:85
void Remove(SOLID *aSolid)
Function Remove()
Definition: pns_node.cpp:729
void CommitRouting(NODE *aNode)
Definition: pns_router.cpp:324
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 193 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), and TOOL_SETTINGS::getConfigBase().

194  {
195  return static_cast<T*>( getEditFrameInt() );
196  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:42
TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

References TOOL_BASE::m_toolId.

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

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 144 of file tool_base.h.

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), EDIT_TOOL::MeasureTool(), CONTEXT_MENU::onMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 204 of file tool_base.h.

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), ZONE_CREATE_HELPER::createZoneFromExisting(), and ZONE_CREATE_HELPER::performZoneCutout().

205  {
206  EDA_ITEM* m = getModelInt();
207 
208  return static_cast<T*>( m );
209  }
T
enum T contains all this lexer's tokens.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:48
const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns 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.

References TOOL_BASE::m_toolName.

Referenced by TOOL_SETTINGS::getKeyName(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), and TOOL_MANAGER::RegisterTool().

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:219
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 72 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

Referenced by ROUTER_TOOL::Init(), SELECTION_TOOL::selectable(), and ROUTER_TOOL::~ROUTER_TOOL().

73 {
74  return m_toolSettings;
75 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::InvokeTool(), and TOOL_MANAGER::runTool().

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:212
KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 30 of file tool_base.cpp.

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), PCBNEW_CONTROL::HighContrastMode(), PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EDIT_TOOL::Main(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), MODULE_EDITOR_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), SELECTION_TOOL::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateEditedPoint(), PNS::TOOL_BASE::updateEndItem(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneUnfill(), PCB_EDITOR_CONTROL::ZoneUnfillAll(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), and SELECTION_TOOL::~SELECTION_TOOL().

31 {
32  return m_toolMgr->GetView();
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:243
KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited
template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 122 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by Reset(), ZOOM_TOOL::SetTransitions(), SetTransitions(), ROUTER_TOOL::SetTransitions(), PAD_TOOL::SetTransitions(), MICROWAVE_TOOL::SetTransitions(), POINT_EDITOR::SetTransitions(), COMMON_TOOLS::SetTransitions(), PLACEMENT_TOOL::SetTransitions(), PCBNEW_CONTROL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), PICKER_TOOL::SetTransitions(), PCB_EDITOR_CONTROL::SetTransitions(), SELECTION_TOOL::SetTransitions(), EDIT_TOOL::SetTransitions(), and DRAWING_TOOL::SetTransitions().

124 {
125  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
126 
127  goInternal( sptr, aConditions );
128 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
void TOOL_BASE::highlightNet ( bool  aEnabled,
int  aNetcode = -1 
)
protectedvirtualinherited

Definition at line 198 of file pns_tool_base.cpp.

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

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

199 {
201 
202  if( aNetcode >= 0 && aEnabled )
203  rs->SetHighlight( true, aNetcode );
204  else
205  rs->SetHighlight( false );
206 
208 }
Class RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output ...
Definition: painter.h:56
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:673
void SetHighlight(bool aEnabled, int aNetcode=-1)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
Definition: painter.h:139
virtual bool TOOL_BASE::Init ( )
inlinevirtualinherited

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

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

Reimplemented in SELECTION_TOOL, DRAWING_TOOL, EDIT_TOOL, PCB_EDITOR_CONTROL, POINT_EDITOR, MICROWAVE_TOOL, PAD_TOOL, PLACEMENT_TOOL, and ROUTER_TOOL.

Definition at line 93 of file tool_base.h.

Referenced by TOOL_MANAGER::InitTools().

94  {
95  return true;
96  }
int LENGTH_TUNER_TOOL::mainLoop ( PNS::ROUTER_MODE  aMode)
private

Definition at line 239 of file length_tuner_tool.cpp.

References ACT_StartTuning, TOOL_INTERACTIVE::Activate(), BUT_LEFT, ID_NO_TOOL_SELECTED, PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSettings, PNS::TOOL_BASE::m_savedSizes, TOOL_BASE::m_toolMgr, performTuning(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, TOOL_INTERACTIVE::SetContextMenu(), PNS::ROUTER::SetMode(), KIGFX::VIEW_CONTROLS::SetSnapping(), PNS::ROUTER::Settings(), PCB_BASE_FRAME::SetToolID(), KIGFX::VIEW_CONTROLS::ShowCursor(), PNS::ROUTER::Sizes(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateStartItem(), and TOOL_INTERACTIVE::Wait().

Referenced by TuneDiffPair(), TuneDiffPairSkew(), and TuneSingleTrace().

240 {
241  // Deselect all items
243 
244  Activate();
245 
246  m_router->SetMode( aMode );
247 
248  m_ctls->SetSnapping( true );
249  m_ctls->ShowCursor( true );
250  m_frame->UndoRedoBlock( true );
251 
252  std::unique_ptr<TUNER_TOOL_MENU> ctxMenu( new TUNER_TOOL_MENU );
253  SetContextMenu( ctxMenu.get() );
254 
255  // Main loop: keep receiving events
256  while( OPT_TOOL_EVENT evt = Wait() )
257  {
258  if( evt->IsCancel() || evt->IsActivate() )
259  {
260  break; // Finish
261  }
262  else if( evt->IsMotion() )
263  {
264  updateStartItem( *evt );
265  }
266  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_StartTuning ) )
267  {
268  updateStartItem( *evt );
269  performTuning();
270  }
271  }
272 
273  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
274  m_frame->UndoRedoBlock( false );
275 
276  // Store routing settings till the next invocation
279 
280  return 0;
281 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
static TOOL_ACTION ACT_StartTuning("pcbnew.LengthTuner.StartTuning", AS_CONTEXT, 'X', _("New Track"), _("Starts laying a new track."))
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:72
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:197
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
ROUTER * m_router
Definition: pns_tool_base.h:85
void SetContextMenu(CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:71
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:484
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
void Activate()
Function Activate() Runs the tool.
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:178
virtual void updateStartItem(TOOL_EVENT &aEvent)
int LENGTH_TUNER_TOOL::meanderSettingsDialog ( const TOOL_EVENT aEvent)
private

Definition at line 297 of file length_tuner_tool.cpp.

References PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, m_savedMeanderSettings, PNS::MEANDER_PLACER_BASE::MeanderSettings(), PNS::ROUTER::Mode(), PNS::ROUTER::Placer(), and PNS::MEANDER_PLACER_BASE::UpdateSettings().

Referenced by SetTransitions().

298 {
300 
301  if( !placer )
302  return 0;
303 
304  PNS::MEANDER_SETTINGS settings = placer->MeanderSettings();
305  DIALOG_PNS_LENGTH_TUNING_SETTINGS settingsDlg( m_frame, settings, m_router->Mode() );
306 
307  if( settingsDlg.ShowModal() )
308  placer->UpdateSettings( settings );
309 
311 
312  return 0;
313 }
Class MEANDER_PLACER_BASE.
PLACEMENT_ALGO * Placer()
Definition: pns_router.h:207
Class MEANDER_SETTINGS.
Definition: pns_meander.h:57
virtual void UpdateSettings(const MEANDER_SETTINGS &aSettings)
PNS::MEANDER_SETTINGS m_savedMeanderSettings
ROUTER * m_router
Definition: pns_tool_base.h:85
ROUTER_MODE Mode() const
Definition: pns_router.h:116
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
virtual const MEANDER_SETTINGS & MeanderSettings() const
Function MeanderSettings()
void LENGTH_TUNER_TOOL::performTuning ( )
private

Definition at line 131 of file length_tuner_tool.cpp.

References ACT_AmplDecrease, ACT_AmplIncrease, ACT_EndTuning, ACT_SpacingDecrease, ACT_SpacingIncrease, PNS::MEANDER_PLACER_BASE::AmplitudeStep(), BUT_LEFT, PNS::ROUTER::FailureReason(), PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PNS::TOOL_BASE::highlightNet(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, m_savedMeanderSettings, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ROUTER::Move(), PNS::ITEM::Net(), PNS::ROUTER::Placer(), WX_STATUS_POPUP::Popup(), PCB_EDIT_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), PNS::MEANDER_PLACER_BASE::SpacingStep(), LAYER_RANGE::Start(), PNS::ROUTER::StartRouting(), PNS::ROUTER::StopRouting(), ToLAYER_ID(), PNS::MEANDER_PLACER_BASE::UpdateSettings(), updateStatusPopup(), and TOOL_INTERACTIVE::Wait().

Referenced by mainLoop().

132 {
133  if( m_startItem )
134  {
136 
137  if( m_startItem->Net() >= 0 )
138  highlightNet( true, m_startItem->Net() );
139  }
140 
141  m_ctls->ForceCursorPosition( false );
142  m_ctls->SetAutoPan( true );
143 
145  {
146  wxMessageBox( m_router->FailureReason(), _( "Error" ) );
147  highlightNet( false );
148  return;
149  }
150 
151  PNS::MEANDER_PLACER_BASE* placer = static_cast<PNS::MEANDER_PLACER_BASE*>(
152  m_router->Placer() );
153 
155 
156  VECTOR2I end( m_startSnapPoint );
157 
158  PNS_TUNE_STATUS_POPUP statusPopup( m_frame );
159  statusPopup.Popup();
160 
161  m_router->Move( end, NULL );
162  updateStatusPopup( statusPopup );
163 
164  while( OPT_TOOL_EVENT evt = Wait() )
165  {
166  if( evt->IsCancel() || evt->IsActivate() )
167  break;
168  else if( evt->IsMotion() )
169  {
170  end = evt->Position();
171  m_router->Move( end, NULL );
172  updateStatusPopup( statusPopup );
173  }
174  else if( evt->IsClick( BUT_LEFT ) )
175  {
176  if( m_router->FixRoute( evt->Position(), NULL ) )
177  break;
178  }
179  else if( evt->IsAction( &ACT_EndTuning ) )
180  {
181  if( m_router->FixRoute( end, NULL ) )
182  break;
183  }
184  else if( evt->IsAction( &ACT_AmplDecrease ) )
185  {
186  placer->AmplitudeStep( -1 );
187  m_router->Move( end, NULL );
188  }
189  else if( evt->IsAction( &ACT_AmplIncrease ) )
190  {
191  placer->AmplitudeStep( 1 );
192  m_router->Move( end, NULL );
193  }
194  else if(evt->IsAction( &ACT_SpacingDecrease ) )
195  {
196  placer->SpacingStep( -1 );
197  m_router->Move( end, NULL );
198  }
199  else if( evt->IsAction( &ACT_SpacingIncrease ) )
200  {
201  placer->SpacingStep( 1 );
202  m_router->Move( end, NULL );
203  }
204  }
205 
207  highlightNet( false );
208 }
static TOOL_ACTION ACT_SpacingDecrease("pcbnew.LengthTuner.SpacingDecrease", AS_CONTEXT, '2', _("Decrease spacing"), _("Decrease meander spacing by one step."))
Class MEANDER_PLACER_BASE.
static TOOL_ACTION ACT_AmplDecrease("pcbnew.LengthTuner.AmplDecrease", AS_CONTEXT, '4', _("Decrease amplitude"), _("Decrease meander amplitude by one step."))
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
virtual void SetActiveLayer(LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
Definition: pcbframe.cpp:893
const wxString & FailureReason() const
Definition: pns_router.h:205
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:75
static TOOL_ACTION ACT_SpacingIncrease("pcbnew.LengthTuner.SpacingIncrease", AS_CONTEXT, '1', _("Increase spacing"), _("Increase meander spacing by one step."))
PLACEMENT_ALGO * Placer()
Definition: pns_router.h:207
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void updateStatusPopup(PNS_TUNE_STATUS_POPUP &aPopup)
virtual void UpdateSettings(const MEANDER_SETTINGS &aSettings)
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
PNS::MEANDER_SETTINGS m_savedMeanderSettings
ITEM * m_startItem
Definition: pns_tool_base.h:73
bool FixRoute(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:341
ROUTER * m_router
Definition: pns_tool_base.h:85
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
int Start() const
Definition: pns_layerset.h:83
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:202
virtual void SpacingStep(int aSign)
Function SpacingStep()
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:156
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
static TOOL_ACTION ACT_AmplIncrease("pcbnew.LengthTuner.AmplIncrease", AS_CONTEXT, '3', _("Increase amplitude"), _("Increase meander amplitude by one step."))
void StopRouting()
Definition: pns_router.cpp:366
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:766
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
static TOOL_ACTION ACT_EndTuning("pcbnew.LengthTuner.EndTuning", AS_CONTEXT, WXK_END, _("End Track"), _("Stops laying the current meander."))
int Net() const
Function Net()
Definition: pns_item.h:177
virtual void AmplitudeStep(int aSign)
Function AmplitudeStep()
ITEM * TOOL_BASE::pickSingleItem ( const VECTOR2I aWhere,
int  aNet = -1,
int  aLayer = -1 
)
protectedvirtualinherited

Definition at line 125 of file pns_tool_base.cpp.

References PCB_BASE_FRAME::GetDisplayOptions(), KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), IsCopperLayer(), PNS::ITEM_SET::Items(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_router, LAYER_RANGE::Overlaps(), PNS::ROUTER::QueryHoverItems(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), and PNS::ITEM::VIA_T.

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

126 {
127  int tl = getView()->GetTopLayer();
128 
129  if( aLayer > 0 )
130  tl = aLayer;
131 
132  ITEM* prioritized[4];
133 
134  for( int i = 0; i < 4; i++ )
135  prioritized[i] = 0;
136 
137  ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
138 
139  for( ITEM* item : candidates.Items() )
140  {
141  if( !IsCopperLayer( item->Layers().Start() ) )
142  continue;
143 
144  // fixme: this causes flicker with live loop removal...
145  //if( item->Parent() && !item->Parent()->ViewIsVisible() )
146  // continue;
147 
148  if( aNet < 0 || item->Net() == aNet )
149  {
150  if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
151  {
152  if( !prioritized[2] )
153  prioritized[2] = item;
154  if( item->Layers().Overlaps( tl ) )
155  prioritized[0] = item;
156  }
157  else
158  {
159  if( !prioritized[3] )
160  prioritized[3] = item;
161  if( item->Layers().Overlaps( tl ) )
162  prioritized[1] = item;
163  }
164  }
165  }
166 
167  ITEM* rv = NULL;
168  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
169  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions();
170 
171  for( int i = 0; i < 4; i++ )
172  {
173  ITEM* item = prioritized[i];
174 
175  if( displ_opts->m_ContrastModeDisplay )
176  if( item && !item->Layers().Overlaps( tl ) )
177  item = NULL;
178 
179  if( item )
180  {
181  rv = item;
182  break;
183  }
184  }
185 
186  if( rv && aLayer >= 0 && !rv->Layers().Overlaps( aLayer ) )
187  rv = NULL;
188 
189  if( rv )
190  {
191  wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
192  }
193 
194  return rv;
195 }
int GetTopLayer() const
Definition: view.cpp:738
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:125
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
ROUTER * m_router
Definition: pns_tool_base.h:85
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
const ROUTING_SETTINGS& PNS::TOOL_BASE::PNSSettings ( ) const
inlineinherited

Definition at line 54 of file pns_tool_base.h.

Referenced by EDIT_TOOL::invokeInlineRouter().

55  {
56  return m_savedSettings;
57  }
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:71
void LENGTH_TUNER_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Function Reset() Brings 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 109 of file length_tuner_tool.cpp.

References TOOL_INTERACTIVE::Go(), TOOL_BASE::Reset(), PCB_ACTIONS::routerActivateTuneDiffPair, PCB_ACTIONS::routerActivateTuneDiffPairSkew, PCB_ACTIONS::routerActivateTuneSingleTrace, TuneDiffPair(), TuneDiffPairSkew(), and TuneSingleTrace().

110 {
111  TOOL_BASE::Reset( aReason );
112 
116 }
int TuneSingleTrace(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerActivateTuneSingleTrace
Activation of the Push and Shove router (tune single line mode)
Definition: pcb_actions.h:175
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
virtual void Reset(RESET_REASON aReason)=0
Function Reset() Brings the tool to a known, initial state.
static TOOL_ACTION routerActivateTuneDiffPairSkew
Activation of the Push and Shove router (skew tuning mode)
Definition: pcb_actions.h:181
static TOOL_ACTION routerActivateTuneDiffPair
Activation of the Push and Shove router (diff pair tuning mode)
Definition: pcb_actions.h:178
int TuneDiffPairSkew(const TOOL_EVENT &aEvent)
int TuneDiffPair(const TOOL_EVENT &aEvent)
ROUTER * TOOL_BASE::Router ( ) const
inherited

Definition at line 308 of file pns_tool_base.cpp.

References PNS::TOOL_BASE::m_router.

309 {
310  return m_router;
311 }
ROUTER * m_router
Definition: pns_tool_base.h:85
int LENGTH_TUNER_TOOL::routerOptionsDialog ( const TOOL_EVENT aEvent)
private

Definition at line 284 of file length_tuner_tool.cpp.

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

Referenced by SetTransitions().

285 {
286  DIALOG_PNS_SETTINGS settingsDlg( m_frame, m_router->Settings() );
287 
288  if( settingsDlg.ShowModal() == wxID_OK )
289  {
290  // FIXME: do we need an explicit update?
291  }
292 
293  return 0;
294 }
ROUTER * m_router
Definition: pns_tool_base.h:85
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:178
void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 78 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

79 {
80  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
81 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

Assigns 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 67 of file tool_interactive.cpp.

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

Referenced by SELECTION_TOOL::disambiguationMenu(), mainLoop(), ROUTER_TOOL::mainLoop(), and TOOL_MENU::ShowContextMenu().

68 {
69  if( aMenu )
70  aMenu->SetTool( this );
71  else
72  aTrigger = CMENU_OFF;
73 
74  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
75 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void LENGTH_TUNER_TOOL::SetTransitions ( )
overridevirtual

Function SetTransitions() 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 TOOL_BASE.

Definition at line 232 of file length_tuner_tool.cpp.

References PNS::TOOL_BASE::ACT_RouterOptions, ACT_Settings, TOOL_INTERACTIVE::Go(), TOOL_ACTION::MakeEvent(), meanderSettingsDialog(), and routerOptionsDialog().

233 {
236 }
static TOOL_ACTION ACT_RouterOptions
Definition: pns_tool_base.h:47
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int meanderSettingsDialog(const TOOL_EVENT &aEvent)
int routerOptionsDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION ACT_Settings("pcbnew.LengthTuner.Settings", AS_CONTEXT, 'L', _("Length Tuning Settings"), _("Sets the length tuning parameters for currently routed item."))
TOOL_EVENT MakeEvent() const
Function HasHotKey() Checks if the action has a hot key assigned.
Definition: tool_action.h:104
const VECTOR2I TOOL_BASE::snapToItem ( bool  aEnabled,
ITEM aItem,
VECTOR2I  aP 
)
protectedinherited

Definition at line 314 of file pns_tool_base.cpp.

References SEG::A, GRID_HELPER::Align(), GRID_HELPER::AlignToSegment(), SEG::B, PNS::ITEM::Kind(), PNS::TOOL_BASE::m_gridHelper, PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, PNS::ITEM::VIA_T, and PNS::SEGMENT::Width().

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

315 {
316  VECTOR2I anchor;
317 
318  if( !aItem || !aEnabled )
319  {
320  return m_gridHelper->Align( aP );
321  }
322 
323  switch( aItem->Kind() )
324  {
325  case ITEM::SOLID_T:
326  anchor = static_cast<SOLID*>( aItem )->Pos();
327  break;
328 
329  case ITEM::VIA_T:
330  anchor = static_cast<VIA*>( aItem )->Pos();
331  break;
332 
333  case ITEM::SEGMENT_T:
334  {
335  SEGMENT* seg = static_cast<SEGMENT*>( aItem );
336  const SEG& s = seg->Seg();
337  int w = seg->Width();
338 
339 
340  if( ( aP - s.A ).EuclideanNorm() < w / 2 )
341  anchor = s.A;
342  else if( ( aP - s.B ).EuclideanNorm() < w / 2 )
343  anchor = s.B;
344  else
345  anchor = m_gridHelper->AlignToSegment( aP, s );
346 
347  break;
348  }
349 
350  default:
351  break;
352  }
353 
354  return anchor;
355 }
VECTOR2I & B
Definition: seg.h:52
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:83
VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
VECTOR2I & A
Definition: seg.h:51
Definition: seg.h:37
Struct SEGMENT is a simple container used when filling areas with segments.
Definition: class_zone.h:57
int LENGTH_TUNER_TOOL::TuneDiffPair ( const TOOL_EVENT aEvent)

Definition at line 218 of file length_tuner_tool.cpp.

References ID_TRACK_BUTT, PNS::TOOL_BASE::m_frame, mainLoop(), PNS::PNS_MODE_TUNE_DIFF_PAIR, and PCB_BASE_FRAME::SetToolID().

Referenced by Reset().

219 {
220  m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Diff Pair Length" ) );
222 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
int mainLoop(PNS::ROUTER_MODE aMode)
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
int LENGTH_TUNER_TOOL::TuneDiffPairSkew ( const TOOL_EVENT aEvent)

Definition at line 225 of file length_tuner_tool.cpp.

References ID_TRACK_BUTT, PNS::TOOL_BASE::m_frame, mainLoop(), PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW, and PCB_BASE_FRAME::SetToolID().

Referenced by Reset().

226 {
227  m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Diff Pair Skew" ) );
229 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
int mainLoop(PNS::ROUTER_MODE aMode)
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
int LENGTH_TUNER_TOOL::TuneSingleTrace ( const TOOL_EVENT aEvent)

Definition at line 211 of file length_tuner_tool.cpp.

References ID_TRACK_BUTT, PNS::TOOL_BASE::m_frame, mainLoop(), PNS::PNS_MODE_TUNE_SINGLE, and PCB_BASE_FRAME::SetToolID().

Referenced by Reset().

212 {
213  m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Trace Length" ) );
215 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
int mainLoop(PNS::ROUTER_MODE aMode)
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
void TOOL_BASE::updateEndItem ( const TOOL_EVENT aEvent)
protectedvirtualinherited

Definition at line 239 of file pns_tool_base.cpp.

References KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), KIGFX::VIEW_CONTROLS::GetMousePosition(), TOOL_BASE::getView(), PNS::ROUTER::IsPlacingVia(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_router, MD_SHIFT, TOOL_EVENT::Modifier(), PNS::TOOL_BASE::pickSingleItem(), PNS::TOOL_BASE::snapToItem(), LAYER_RANGE::Start(), and KIGFX::VIEW::ToWorld().

Referenced by ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::onViaCommand(), ROUTER_TOOL::performDragging(), and ROUTER_TOOL::performRouting().

240 {
242  VECTOR2I p = getView()->ToWorld( mp );
243  int layer;
244  bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
245 
246  if( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 )
247  {
248  m_endSnapPoint = snapToItem( snapEnabled, nullptr, p );
250  m_endItem = nullptr;
251 
252  return;
253  }
254 
255  if( m_router->IsPlacingVia() )
256  layer = -1;
257  else
258  layer = m_router->GetCurrentLayer();
259 
260  ITEM* endItem = nullptr;
261 
262  std::vector<int> nets = m_router->GetCurrentNets();
263 
264  for( int net : nets )
265  {
266  endItem = pickSingleItem( p, net, layer );
267 
268  if( endItem )
269  break;
270  }
271 
272  VECTOR2I cursorPos = snapToItem( snapEnabled, endItem, p );
273  m_ctls->ForceCursorPosition( true, cursorPos );
274  m_endItem = endItem;
275  m_endSnapPoint = cursorPos;
276 
277  if( m_endItem )
278  {
279  wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
280  }
281 }
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates...
Definition: view.cpp:439
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:311
bool IsPlacingVia() const
Definition: pns_router.cpp:466
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:426
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
ROUTER * m_router
Definition: pns_tool_base.h:85
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
int Start() const
Definition: pns_layerset.h:83
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:78
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1)
int GetCurrentLayer() const
Definition: pns_router.cpp:435
const std::string KindStr() const
Function KindStr()
Definition: pns_item.cpp:63
virtual VECTOR2I GetMousePosition() const =0
Function GetMousePosition() Returns the current mouse pointer position in screen coordinates.
void TOOL_BASE::updateStartItem ( TOOL_EVENT aEvent)
protectedvirtualinherited

Definition at line 211 of file pns_tool_base.cpp.

References KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), TOOL_EVENT::IsClick(), TOOL_EVENT::IsMotion(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, MD_SHIFT, TOOL_EVENT::Modifier(), LAYER_RANGE::Overlaps(), PNS::TOOL_BASE::pickSingleItem(), TOOL_EVENT::Position(), and PNS::TOOL_BASE::snapToItem().

Referenced by mainLoop(), and ROUTER_TOOL::mainLoop().

212 {
213  int tl = getView()->GetTopLayer();
215  VECTOR2I p;
216 
217  bool snapEnabled = true;
218 
219  if( aEvent.IsMotion() || aEvent.IsClick() )
220  {
221  snapEnabled = !aEvent.Modifier( MD_SHIFT );
222  p = aEvent.Position();
223  }
224  else
225  {
226  p = cp;
227  }
228 
230 
231  if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
232  m_startItem = nullptr;
233 
234  m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
236 }
int GetTopLayer() const
Definition: view.cpp:738
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
bool IsMotion() const
Definition: tool_event.h:290
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:75
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:311
const VECTOR2D & Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:248
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
ITEM * m_startItem
Definition: pns_tool_base.h:73
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1)
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:268
void LENGTH_TUNER_TOOL::updateStatusPopup ( PNS_TUNE_STATUS_POPUP aPopup)
private

Definition at line 119 of file length_tuner_tool.cpp.

References PNS::TOOL_BASE::m_router, WX_STATUS_POPUP::Move(), PNS_TUNE_STATUS_POPUP::UpdateStatus(), wxPoint::x, and wxPoint::y.

Referenced by performTuning().

120 {
121  wxPoint p = wxGetMousePosition();
122 
123  p.x += 20;
124  p.y += 20;
125 
126  aPopup.UpdateStatus( m_router );
127  aPopup.Move( p );
128 }
virtual void Move(const wxPoint &aWhere)
ROUTER * m_router
Definition: pns_tool_base.h:85
void UpdateStatus(PNS::ROUTER *aRouter)
OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 55 of file tool_interactive.cpp.

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

Referenced by MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::DeleteItemCursor(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), performTuning(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), and DRAWING_TOOL::SetAnchor().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
boost::optional< TOOL_EVENT > ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

Member Data Documentation

TOOL_ACTION TOOL_BASE::ACT_RouterOptions
staticinherited
GRID_HELPER* PNS::TOOL_BASE::m_gridHelper
protectedinherited
PNS_KICAD_IFACE* PNS::TOOL_BASE::m_iface
protectedinherited
MSG_PANEL_ITEMS PNS::TOOL_BASE::m_panelItems
protectedinherited

Definition at line 69 of file pns_tool_base.h.

PNS::MEANDER_SETTINGS LENGTH_TUNER_TOOL::m_savedMeanderSettings
private

Definition at line 53 of file length_tuner_tool.h.

Referenced by meanderSettingsDialog(), and performTuning().

ROUTING_SETTINGS PNS::TOOL_BASE::m_savedSettings
protectedinherited

Stores routing settings between router invocations.

Definition at line 71 of file pns_tool_base.h.

Referenced by ROUTER_TOOL::Init(), mainLoop(), ROUTER_TOOL::mainLoop(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::SettingsDialog(), and ROUTER_TOOL::~ROUTER_TOOL().

SIZES_SETTINGS PNS::TOOL_BASE::m_savedSizes
protectedinherited

Stores sizes settings between router invocations.

Definition at line 72 of file pns_tool_base.h.

Referenced by ROUTER_TOOL::DpDimensionsDialog(), mainLoop(), ROUTER_TOOL::mainLoop(), and PNS::TOOL_BASE::Reset().

int PNS::TOOL_BASE::m_startLayer
protectedinherited

Definition at line 74 of file pns_tool_base.h.

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

VECTOR2I PNS::TOOL_BASE::m_startSnapPoint
protectedinherited
TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and EDIT_TOOL::getModificationPoint().

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PCBNEW_CONTROL::AppendBoard(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), SELECTION_TOOL::clearSelection(), MODULE_EDITOR_TOOLS::CopyItems(), PAD_TOOL::copyPadSettings(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), EDIT_TOOL::getModificationPoint(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::Init(), PLACEMENT_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), SELECTION_TOOL::SelectItem(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SELECTION_TOOL::UnselectItem(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfill().

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName

(eg. pcbnew.InteractiveSelection).

Definition at line 219 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 221 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 212 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


The documentation for this class was generated from the following files: