KiCad PCB EDA Suite
BOARD_EDITOR_CONTROL Class Reference

Handle actions specific to the board editor in PcbNew. More...

#include <board_editor_control.h>

Inheritance diagram for BOARD_EDITOR_CONTROL:
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

 BOARD_EDITOR_CONTROL ()
 
 ~BOARD_EDITOR_CONTROL ()
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
int New (const TOOL_EVENT &aEvent)
 
int Open (const TOOL_EVENT &aEvent)
 
int Save (const TOOL_EVENT &aEvent)
 
int SaveAs (const TOOL_EVENT &aEvent)
 
int SaveCopyAs (const TOOL_EVENT &aEvent)
 
int PageSettings (const TOOL_EVENT &aEvent)
 
int Plot (const TOOL_EVENT &aEvent)
 
int Find (const TOOL_EVENT &aEvent)
 
int FindNext (const TOOL_EVENT &aEvent)
 
int BoardSetup (const TOOL_EVENT &aEvent)
 
int ImportNetlist (const TOOL_EVENT &aEvent)
 
int ImportSpecctraSession (const TOOL_EVENT &aEvent)
 
int ExportSpecctraDSN (const TOOL_EVENT &aEvent)
 
int ExportNetlist (const TOOL_EVENT &aEvent)
 
int GenerateDrillFiles (const TOOL_EVENT &aEvent)
 
int GeneratePosFile (const TOOL_EVENT &aEvent)
 
int GenerateFabFiles (const TOOL_EVENT &aEvent)
 
int RepairBoard (const TOOL_EVENT &aEvent)
 
int UpdatePCBFromSchematic (const TOOL_EVENT &aEvent)
 
int UpdateSchematicFromPCB (const TOOL_EVENT &aEvent)
 
int ShowEeschema (const TOOL_EVENT &aEvent)
 
int ToggleLayersManager (const TOOL_EVENT &aEvent)
 
int TogglePythonConsole (const TOOL_EVENT &aEvent)
 
int TrackWidthInc (const TOOL_EVENT &aEvent)
 
int TrackWidthDec (const TOOL_EVENT &aEvent)
 
int ViaSizeInc (const TOOL_EVENT &aEvent)
 
int ViaSizeDec (const TOOL_EVENT &aEvent)
 
int ZoneMerge (const TOOL_EVENT &aEvent)
 Duplicate a zone onto a layer (prompts for new layer) More...
 
int ZoneDuplicate (const TOOL_EVENT &aEvent)
 
int EditFpInFpEditor (const TOOL_EVENT &aEvent)
 
int PlaceTarget (const TOOL_EVENT &aEvent)
 Allow user to place a layer alignment target. More...
 
int PlaceFootprint (const TOOL_EVENT &aEvent)
 Display a dialog to select a footprint to be added and allows the user to set its position. More...
 
int ToggleLockSelected (const TOOL_EVENT &aEvent)
 Lock selected items. More...
 
int LockSelected (const TOOL_EVENT &aEvent)
 Unlock selected items. More...
 
int UnlockSelected (const TOOL_EVENT &aEvent)
 Run the drill origin tool for setting the origin for drill and pick-and-place files. More...
 
int DrillOrigin (const TOOL_EVENT &aEvent)
 Low-level access (below undo) to setting the drill origin. More...
 
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 DoSetDrillOrigin (KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
 

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

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

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 Types

enum  MODIFY_MODE { ON, OFF, TOGGLE }
 < How to modify a property for selected items. More...
 

Private Member Functions

int modifyLockSelected (MODIFY_MODE aMode)
 Set up handlers for various events. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 

Private Attributes

PCB_EDIT_FRAMEm_frame
 
bool m_inPlaceFootprint
 
bool m_inPlaceTarget
 
std::unique_ptr< KIGFX::ORIGIN_VIEWITEMm_placeOrigin
 

Static Private Attributes

static const int WIDTH_STEP = 100000
 How does line width change after one -/+ key press. More...
 

Detailed Description

Handle actions specific to the board editor in PcbNew.

Definition at line 42 of file board_editor_control.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.

◆ MODIFY_MODE

< How to modify a property for selected items.

Enumerator
ON 
OFF 
TOGGLE 

Definition at line 123 of file board_editor_control.h.

◆ 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

◆ BOARD_EDITOR_CONTROL()

BOARD_EDITOR_CONTROL::BOARD_EDITOR_CONTROL ( )

Definition at line 176 of file board_editor_control.cpp.

176  :
177  PCB_TOOL_BASE( "pcbnew.EditorControl" ),
178  m_frame( nullptr ),
179  m_inPlaceFootprint( false ),
180  m_inPlaceTarget( false )
181 {
182  m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
184 }
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:77
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS, and m_placeOrigin.

◆ ~BOARD_EDITOR_CONTROL()

BOARD_EDITOR_CONTROL::~BOARD_EDITOR_CONTROL ( )

Definition at line 187 of file board_editor_control.cpp.

188 {
189 }

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(), DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::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(), ROUTER_TOOL::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(), PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), 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(), ROUTER_TOOL::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(), 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(), ROUTER_TOOL::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(), PlaceFootprint(), PAD_TOOL::PlacePad(), PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), 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(), ROUTER_TOOL::updateMessagePanel(), PCB_CONTROL::ViaDisplayMode(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ BoardSetup()

int BOARD_EDITOR_CONTROL::BoardSetup ( const TOOL_EVENT aEvent)

Definition at line 368 of file board_editor_control.cpp.

369 {
370  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
371  return 0;
372 }

Referenced by setTransitions().

◆ canvas()

◆ controls()

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

Definition at line 302 of file pcb_tool_base.cpp.

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

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

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

◆ doInteractiveItemPlacement()

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

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

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

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

Definition at line 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::viaSizeInc )
228  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
229  {
230  // Refresh preview after event runs
232  }
233  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
234  {
235  frame()->OnEditItemRequest( newItem.get() );
236 
237  // Notify other tools of the changes
239  }
240  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
241  {
242  preview.Clear();
243  newItem.release();
244 
245  makeNewItem( (wxPoint) cursorPos );
246  aPlacer->SnapItem( newItem.get() );
247  view()->Update( &preview );
248  }
249  else
250  {
251  evt->SetPassEvent();
252  }
253  }
254  else if( newItem && evt->IsMotion() )
255  {
256  // track the cursor
257  newItem->SetPosition( (wxPoint) cursorPos );
258  aPlacer->SnapItem( newItem.get() );
259 
260  // Show a preview of the item
261  view()->Update( &preview );
262  }
263  else
264  {
265  evt->SetPassEvent();
266  }
267  }
268 
269  view()->Remove( &preview );
271  controls()->SetAutoPan( false );
272  controls()->CaptureCursor( false );
273 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:82
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:31
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:296
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:299
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
const PCB_SELECTION & selection() const
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
Generic, UI-independent tool event.
Definition: tool_event.h:152
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
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:1236
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:64
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:297
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_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

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

◆ DoSetDrillOrigin()

void BOARD_EDITOR_CONTROL::DoSetDrillOrigin ( KIGFX::VIEW aView,
PCB_BASE_FRAME aFrame,
EDA_ITEM aItem,
const VECTOR2D aPoint 
)
static

Definition at line 1480 of file board_editor_control.cpp.

1482 {
1483  aFrame->GetDesignSettings().m_AuxOrigin = (wxPoint) aPosition;
1484  originViewItem->SetPosition( (wxPoint) aPosition );
1485  aView->MarkDirty();
1486  aFrame->OnModify();
1487 }
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
wxPoint m_AuxOrigin
origin for plot exports
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

References PCB_BASE_FRAME::GetDesignSettings(), BOARD_DESIGN_SETTINGS::m_AuxOrigin, KIGFX::VIEW::MarkDirty(), PCB_BASE_FRAME::OnModify(), and EDA_ITEM::SetPosition().

Referenced by DrillOrigin(), and PCB_BASE_EDIT_FRAME::PutDataInPreviousState().

◆ DrillOrigin()

int BOARD_EDITOR_CONTROL::DrillOrigin ( const TOOL_EVENT aEvent)

Low-level access (below undo) to setting the drill origin.

Definition at line 1490 of file board_editor_control.cpp.

1491 {
1492  std::string tool = aEvent.GetCommandStr().get();
1494 
1495  // Deactivate other tools; particularly important if another PICKER is currently running
1496  Activate();
1497 
1498  picker->SetClickHandler(
1499  [this] ( const VECTOR2D& pt ) -> bool
1500  {
1502  DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
1503  return false; // drill origin is a one-shot; don't continue with tool
1504  } );
1505 
1506  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1507 
1508  return 0;
1509 }
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:179
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
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
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
static TOOL_ACTION pickerTool
Definition: actions.h:155
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Generic tool for picking an item.
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
void Activate()
Run the tool.

References TOOL_INTERACTIVE::Activate(), DoSetDrillOrigin(), DRILLORIGIN, TOOL_EVENT::GetCommandStr(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), m_frame, m_placeOrigin, TOOL_BASE::m_toolMgr, ACTIONS::pickerTool, TOOL_MANAGER::RunAction(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), and PICKER_TOOL_BASE::SetClickHandler().

Referenced by setTransitions().

◆ EditFpInFpEditor()

int BOARD_EDITOR_CONTROL::EditFpInFpEditor ( const TOOL_EVENT aEvent)

Definition at line 1451 of file board_editor_control.cpp.

1452 {
1455 
1456  if( selection.Empty() )
1457  return 0;
1458 
1460 
1461  if( !fp )
1462  return 0;
1463 
1464  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1465 
1466  auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1467 
1468  editor->LoadFootprintFromBoard( fp );
1469 
1470  editor->Show( true );
1471  editor->Raise(); // Iconize( false );
1472 
1473  if( selection.IsHover() )
1475 
1476  return 0;
1477 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
bool IsHover() const
Definition: selection.h:73
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
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:382
const PCB_SELECTION & selection() const
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
Common, abstract interface for edit frames.
The selection tool: currently supports:
T * FirstOfKind() const
Definition: selection.h:155
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
A selection filter which prunes the selection to contain only items of type #PCB_MODULE_T.
Definition: edit_tool.cpp:2291

References editor, SELECTION::Empty(), SELECTION::FirstOfKind(), EDIT_TOOL::FootprintFilter(), FRAME_FOOTPRINT_EDITOR, TOOL_MANAGER::GetTool(), SELECTION::IsHover(), KIWAY_HOLDER::Kiway(), TOOL_BASE::m_toolMgr, KIWAY::Player(), PCB_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), and PCB_ACTIONS::selectionClear.

Referenced by setTransitions().

◆ ExportNetlist()

int BOARD_EDITOR_CONTROL::ExportNetlist ( const TOOL_EVENT aEvent)

Definition at line 433 of file board_editor_control.cpp.

434 {
435  wxCHECK( m_frame, 0 );
436 
437  wxFileName fn = m_frame->Prj().GetProjectFullName();
438 
439  // Use a different file extension for the board netlist so the schematic netlist file
440  // is accidentally overwritten.
441  fn.SetExt( "pcb_net" );
442 
443  wxFileDialog dlg( m_frame, _( "Export Board Netlist" ), fn.GetPath(), fn.GetFullName(),
444  _( "KiCad board netlist files" ) + AddFileExtListToFilter( { "pcb_net" } ),
445  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
446 
447  dlg.SetExtraControlCreator( &NETLIST_OPTIONS_HELPER::Create );
448 
449  if( dlg.ShowModal() == wxID_CANCEL )
450  return 0;
451 
452  fn = dlg.GetPath();
453 
454  if( !fn.IsDirWritable() )
455  {
456  wxString msg;
457 
458  msg.Printf( _( "Path `%s` is read only." ), fn.GetPath() );
459  wxMessageDialog( m_frame, msg, _( "I/O Error" ), wxOK | wxCENTER | wxICON_EXCLAMATION );
460  return 0;
461  }
462 
463  const NETLIST_OPTIONS_HELPER* noh =
464  dynamic_cast<const NETLIST_OPTIONS_HELPER*>( dlg.GetExtraControl() );
465  wxCHECK( noh, 0 );
466 
468 
469  for( const FOOTPRINT* footprint : board()->Footprints() )
470  {
471  COMPONENT* component = new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
473  { footprint->m_Uuid } );
474 
475  for( const PAD* pad : footprint->Pads() )
476  {
477  const wxString& netname = pad->GetShortNetname();
478 
479  if( !netname.IsEmpty() )
480  {
481  component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(),
482  pad->GetPinType() );
483  }
484  }
485 
486  netlist.AddComponent( component );
487  }
488 
489  FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
490 
491  netlist.Format( "pcb_netlist", &formatter, 0, noh->GetNetlistOptions() );
492 
493  return 0;
494 }
const wxString & GetValue() const
Definition: footprint.h:452
BOARD * board() const
const KIID_PATH & GetPath() const
Definition: footprint.h:203
PADS & Pads()
Definition: footprint.h:168
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:206
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
FOOTPRINT * footprint() const
const wxString & GetReference() const
Definition: footprint.h:430
#define _(s)
const LIB_ID & GetFPID() const
Definition: footprint.h:194
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:116
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84
const KIID m_Uuid
Definition: eda_item.h:475
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
Definition: pcb_netlist.h:103
Used for text file output.
Definition: richio.h:456
static wxWindow * Create(wxWindow *aParent)
Definition: pad.h:57
Helper widget to add controls to a wxFileDialog to set netlist configuration options.
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.

References _, AddFileExtListToFilter(), COMPONENT::AddNet(), PCB_TOOL_BASE::board(), COMPONENT, NETLIST_OPTIONS_HELPER::Create(), PCB_TOOL_BASE::footprint(), FOOTPRINT::GetFPID(), NETLIST_OPTIONS_HELPER::GetNetlistOptions(), FOOTPRINT::GetPath(), PROJECT::GetProjectFullName(), FOOTPRINT::GetReference(), FOOTPRINT::GetValue(), m_frame, EDA_ITEM::m_Uuid, netlist, pad, FOOTPRINT::Pads(), and KIWAY_HOLDER::Prj().

Referenced by setTransitions().

◆ ExportSpecctraDSN()

int BOARD_EDITOR_CONTROL::ExportSpecctraDSN ( const TOOL_EVENT aEvent)

Definition at line 404 of file board_editor_control.cpp.

405 {
406  wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
407  wxFileName fn;
408 
409  if( fullFileName.IsEmpty() )
410  {
411  fn = m_frame->GetBoard()->GetFileName();
412  fn.SetExt( SpecctraDsnFileExtension );
413  }
414  else
415  {
416  fn = fullFileName;
417  }
418 
419  fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
421  wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR, frame() );
422 
423  if( !fullFileName.IsEmpty() )
424  {
425  m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
426  getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
427  }
428 
429  return 0;
430 }
const wxString & GetFileName() const
Definition: board.h:228
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)
const std::string SpecctraDsnFileExtension
wxString SpecctraDsnFileWildcard()
BOARD * GetBoard() const
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.

References _, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), PCB_EDIT_FRAME::GetLastPath(), LAST_PATH_SPECCTRADSN, m_frame, PCB_EDIT_FRAME::SetLastPath(), SpecctraDsnFileExtension, and SpecctraDsnFileWildcard().

Referenced by setTransitions().

◆ Find()

int BOARD_EDITOR_CONTROL::Find ( const TOOL_EVENT aEvent)

Definition at line 354 of file board_editor_control.cpp.

355 {
357  return 0;
358 }
void ShowFindDialog()
Show the Find dialog.

References m_frame, and PCB_EDIT_FRAME::ShowFindDialog().

Referenced by setTransitions().

◆ FindNext()

int BOARD_EDITOR_CONTROL::FindNext ( const TOOL_EVENT aEvent)

Definition at line 361 of file board_editor_control.cpp.

362 {
363  m_frame->FindNext();
364  return 0;
365 }
void FindNext()
Find the next item using our existing search parameters.

References PCB_EDIT_FRAME::FindNext(), and m_frame.

Referenced by setTransitions().

◆ 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(), ROUTER_TOOL::CustomTrackWidthDialog(), FOOTPRINT_EDITOR_CONTROL::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), ROUTER_TOOL::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(), ExportSpecctraDSN(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), ROUTER_TOOL::finishInteractive(), EDIT_TOOL::Flip(), PCB_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), ROUTER_TOOL::handleLayerSwitch(), BOARD_INSPECTION_TOOL::HighlightItem(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), ImportSpecctraSession(), ROUTER_TOOL::Init(), SCRIPTING_TOOL::Init(), PCB_SELECTION_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_TOOL_BASE::Is45Limited(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PCB_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCB_CONTROL::placeBoardItems(), PlaceFootprint(), PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::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(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_POINT_EDITOR::setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), PCB_CONTROL::unfilledZoneCheck(), ROUTER_TOOL::updateMessagePanel(), EDIT_TOOL::updateModificationPoint(), UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ GenerateDrillFiles()

int BOARD_EDITOR_CONTROL::GenerateDrillFiles ( const TOOL_EVENT aEvent)

Definition at line 58 of file dialog_gendrill.cpp.

59 {
60  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
61  DIALOG_GENDRILL dlg( editFrame, editFrame );
62 
63  dlg.ShowModal();
64  return 0;
65 }
The main frame for Pcbnew.

Referenced by setTransitions().

◆ GenerateFabFiles()

int BOARD_EDITOR_CONTROL::GenerateFabFiles ( const TOOL_EVENT aEvent)

Definition at line 497 of file board_editor_control.cpp.

498 {
499  wxCommandEvent dummy;
500 
501  if( aEvent.IsAction( &PCB_ACTIONS::generateGerbers ) )
503  else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
505  else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
507  else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
509  else
510  wxFAIL_MSG( "GenerateFabFiles(): unexpected request" );
511 
512  return 0;
513 }
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:334
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
void RecreateBOMFileFromBoard(wxCommandEvent &aEvent)
Create a BOM file from the current loaded board.
static TOOL_ACTION generateReportFile
Definition: pcb_actions.h:337
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:338
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
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
void GenFootprintsReport(wxCommandEvent &event)
Call DoGenFootprintsReport to create a footprint report file.
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:339
void GenD356File(wxCommandEvent &event)

References dummy(), PCB_EDIT_FRAME::GenD356File(), PCB_ACTIONS::generateBOM, PCB_ACTIONS::generateD356File, PCB_ACTIONS::generateGerbers, PCB_ACTIONS::generateReportFile, PCB_EDIT_FRAME::GenFootprintsReport(), ID_GEN_PLOT_GERBER, TOOL_EVENT::IsAction(), m_frame, PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), and PCB_EDIT_FRAME::ToPlotter().

Referenced by setTransitions().

◆ GeneratePosFile()

int BOARD_EDITOR_CONTROL::GeneratePosFile ( const TOOL_EVENT aEvent)

Definition at line 495 of file gen_footprints_placefile.cpp.

496 {
497  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
498  DIALOG_GEN_FOOTPRINT_POSITION dlg( editFrame );
499 
500  dlg.ShowModal();
501  return 0;
502 }
The main frame for Pcbnew.
The dialog to create footprint position files and choose options (one or 2 files, units and force all...

Referenced by setTransitions().

◆ 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().

◆ 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(), DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), ROUTER_TOOL::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(), ROUTER_TOOL::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(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), PlaceTarget(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), 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(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

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

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), ROUTER_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(), 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_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), PCB_CONTROL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), DRC_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), 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().

◆ ImportNetlist()

int BOARD_EDITOR_CONTROL::ImportNetlist ( const TOOL_EVENT aEvent)

Definition at line 375 of file board_editor_control.cpp.

376 {
377  getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
378  return 0;
379 }

Referenced by setTransitions().

◆ ImportSpecctraSession()

int BOARD_EDITOR_CONTROL::ImportSpecctraSession ( const TOOL_EVENT aEvent)

Definition at line 382 of file board_editor_control.cpp.

383 {
384  wxString fullFileName = frame()->GetBoard()->GetFileName();
385  wxString path;
386  wxString name;
387  wxString ext;
388 
389  wxFileName::SplitPath( fullFileName, &path, &name, &ext );
390  name += wxT( "." ) + SpecctraSessionFileExtension;
391 
392  fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
393  wxT( "." ) + SpecctraSessionFileExtension,
394  SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
395  frame() );
396 
397  if( !fullFileName.IsEmpty() )
398  getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
399 
400  return 0;
401 }
const wxString & GetFileName() const
Definition: board.h:228
PCB_BASE_EDIT_FRAME * frame() const
wxString SpecctraSessionFileWildcard()
#define _(s)
const std::string SpecctraSessionFileExtension
const char * name
Definition: DXF_plotter.cpp:56
BOARD * GetBoard() const

References _, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetBoard(), BOARD::GetFileName(), name, path, SpecctraSessionFileExtension, and SpecctraSessionFileWildcard().

Referenced by setTransitions().

◆ Init()

bool BOARD_EDITOR_CONTROL::Init ( void  )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 205 of file board_editor_control.cpp.

206 {
207  auto activeToolCondition =
208  [this]( const SELECTION& aSel )
209  {
210  return ( !m_frame->ToolStackIsEmpty() );
211  };
212 
213  auto inactiveStateCondition =
214  [this]( const SELECTION& aSel )
215  {
216  return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
217  };
218 
219  auto placeModuleCondition =
220  [this]( const SELECTION& aSel )
221  {
222  return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
223  };
224 
225  auto& ctxMenu = m_menu.GetMenu();
226 
227  // "Cancel" goes at the top of the context menu when a tool is active
228  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
229  ctxMenu.AddSeparator( 1 );
230 
231  // "Get and Place Footprint" should be available for Place Footprint tool
232  ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
233  ctxMenu.AddSeparator( 1000 );
234 
235  // Finally, add the standard zoom & grid items
236  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
237 
238  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
239  zoneMenu->SetTool( this );
240 
241  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
242  lockMenu->SetTool( this );
243 
244  // Add the PCB control menus to relevant other tools
245 
247 
248  if( selTool )
249  {
250  auto& toolMenu = selTool->GetToolMenu();
251  auto& menu = toolMenu.GetMenu();
252 
253  // Add "Get and Place Footprint" when Selection tool is in an inactive state
254  menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
255  menu.AddSeparator();
256 
257  toolMenu.AddSubMenu( zoneMenu );
258  toolMenu.AddSubMenu( lockMenu );
259 
260  menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
261 
262  menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_T ), 200 );
263  }
264 
265  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
266 
267  if( drawingTool )
268  {
269  auto& toolMenu = drawingTool->GetToolMenu();
270  auto& menu = toolMenu.GetMenu();
271 
272  toolMenu.AddSubMenu( zoneMenu );
273 
274  // Functor to say if the PCB_EDIT_FRAME is in a given mode
275  // Capture the tool pointer and tool mode by value
276  auto toolActiveFunctor =
277  [=]( DRAWING_TOOL::MODE aMode )
278  {
279  return [=]( const SELECTION& sel )
280  {
281  return drawingTool->GetDrawingMode() == aMode;
282  };
283  };
284 
285  menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
286  }
287 
288  return true;
289 }
bool IsCurrentTool(const TOOL_ACTION &aAction) const
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
TOOL_MENU & GetToolMenu()
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:466
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
Definition: drawing_tool.h:50
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
class ZONE, a copper pour area
Definition: typeinfo.h:105
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:160
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
The selection tool: currently supports:
MODE GetDrawingMode() const
Return the current drawing mode of the DRAWING_TOOL or #MODE::NONE if not currently in any drawing mo...
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.

References CONDITIONAL_MENU::AddItem(), ACTIONS::cancelInteractive, PCB_ACTIONS::getAndPlace, DRAWING_TOOL::GetDrawingMode(), TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOL_INTERACTIVE::GetToolMenu(), TOOLS_HOLDER::IsCurrentTool(), m_frame, TOOL_INTERACTIVE::m_menu, TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::NotEmpty(), SELECTION_CONDITIONS::OnlyType(), PCB_ZONE_T, PCB_ACTIONS::placeFootprint, TOOLS_HOLDER::ToolStackIsEmpty(), and DRAWING_TOOL::ZONE.

◆ 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 ROUTER_TOOL::handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), TrackWidthDec(), and TrackWidthInc().

◆ LockSelected()

int BOARD_EDITOR_CONTROL::LockSelected ( const TOOL_EVENT aEvent)

Unlock selected items.

Definition at line 1117 of file board_editor_control.cpp.

1118 {
1119  return modifyLockSelected( ON );
1120 }
int modifyLockSelected(MODIFY_MODE aMode)
Set up handlers for various events.

References modifyLockSelected(), and ON.

Referenced by setTransitions().

◆ modifyLockSelected()

int BOARD_EDITOR_CONTROL::modifyLockSelected ( MODIFY_MODE  aMode)
private

Set up handlers for various events.

Definition at line 1129 of file board_editor_control.cpp.

1130 {
1132  const PCB_SELECTION& selection = selTool->GetSelection();
1133  BOARD_COMMIT commit( m_frame );
1134 
1135  if( selection.Empty() )
1137 
1138  // Resolve TOGGLE mode
1139  if( aMode == TOGGLE )
1140  {
1141  aMode = ON;
1142 
1143  for( EDA_ITEM* item : selection )
1144  {
1145  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1146 
1147  if( board_item->IsLocked() )
1148  {
1149  aMode = OFF;
1150  break;
1151  }
1152  }
1153  }
1154 
1155  bool modified = false;
1156 
1157  for( EDA_ITEM* item : selection )
1158  {
1159  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1160 
1161  commit.Modify( board_item );
1162 
1163  if( aMode == ON )
1164  {
1165  modified |= !board_item->IsLocked();
1166  board_item->SetLocked( true );
1167  }
1168  else
1169  {
1170  modified |= board_item->IsLocked();
1171  board_item->SetLocked( false );
1172  }
1173  }
1174 
1175  if( modified )
1176  {
1177  commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ) );
1178 
1181  m_frame->OnModify();
1182  }
1183 
1184  return 0;
1185 }
void OnModify() override
Must be called after a board change to set the modified flag.
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
Definition: board_item.h:252
virtual bool IsLocked() const
Definition: board_item.cpp:78
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
const PCB_SELECTION & selection() const
#define _(s)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
virtual void UpdateMsgPanel()
Redraw the message panel.

References _, SELECTION::Empty(), PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), BOARD_ITEM::IsLocked(), m_frame, TOOL_BASE::m_toolMgr, COMMIT::Modify(), OFF, ON, PCB_EDIT_FRAME::OnModify(), TOOL_MANAGER::PostEvent(), BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), EVENTS::SelectedEvent, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionCursor, BOARD_ITEM::SetLocked(), TOGGLE, and EDA_DRAW_FRAME::UpdateMsgPanel().

Referenced by LockSelected(), ToggleLockSelected(), and UnlockSelected().

◆ New()

int BOARD_EDITOR_CONTROL::New ( const TOOL_EVENT aEvent)

Definition at line 292 of file board_editor_control.cpp.

293 {
295  return 0;
296 }
bool Files_io_from_id(int aId)
Read and write board files according to aId.

References PCB_EDIT_FRAME::Files_io_from_id(), ID_NEW_BOARD, and m_frame.

Referenced by setTransitions().

◆ Open()

int BOARD_EDITOR_CONTROL::Open ( const TOOL_EVENT aEvent)

Definition at line 299 of file board_editor_control.cpp.

300 {
302  return 0;
303 }
bool Files_io_from_id(int aId)
Read and write board files according to aId.

References PCB_EDIT_FRAME::Files_io_from_id(), ID_LOAD_FILE, and m_frame.

Referenced by setTransitions().

◆ PageSettings()

int BOARD_EDITOR_CONTROL::PageSettings ( const TOOL_EVENT aEvent)

Definition at line 327 of file board_editor_control.cpp.

328 {
329  PICKED_ITEMS_LIST undoCmd;
330  DS_PROXY_UNDO_ITEM* undoItem = new DS_PROXY_UNDO_ITEM( m_frame );
331  ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
332 
333  undoCmd.PushItem( wrapper );
335 
338  dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
339 
340  if( dlg.ShowModal() != wxID_OK )
342 
343  return 0;
344 }
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:578
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:179
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition: page_info.h:40
A holder to handle information on schematic or board items.
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition: base_screen.h:85
#define IU_PER_MILS
Definition: plotter.cpp:136

References IU_PER_MILS, BASE_SCREEN::m_DrawingSheetFileName, m_frame, MAX_PAGE_SIZE_PCBNEW_MILS, PAGESETTINGS, PICKED_ITEMS_LIST::PushItem(), PCB_BASE_EDIT_FRAME::RollbackFromUndo(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), and DIALOG_PAGES_SETTINGS::SetWksFileName().

Referenced by setTransitions().

◆ PlaceFootprint()

int BOARD_EDITOR_CONTROL::PlaceFootprint ( const TOOL_EVENT aEvent)

Display a dialog to select a footprint to be added and allows the user to set its position.

Toggle 'lock' property for selected items.

Definition at line 932 of file board_editor_control.cpp.

933 {
934  if( m_inPlaceFootprint )
935  return 0;
936 
938 
939  FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
941  BOARD_COMMIT commit( m_frame );
942  BOARD* board = getModel<BOARD>();
943 
945 
946  std::string tool = aEvent.GetCommandStr().get();
947  m_frame->PushTool( tool );
948 
949  auto setCursor =
950  [&]()
951  {
953  };
954 
955  Activate();
956  // Must be done after Activate() so that it gets set into the correct context
957  controls->ShowCursor( true );
958  // Set initial cursor
959  setCursor();
960 
961  VECTOR2I cursorPos = controls->GetCursorPosition();
962  bool reselect = false;
963  bool fromOtherCommand = fp != nullptr;
964 
965  // Prime the pump
966  if( fp )
967  {
968  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
971  }
972  else if( !aEvent.IsReactivate() )
973  {
975  }
976 
977  // Main loop: keep receiving events
978  while( TOOL_EVENT* evt = Wait() )
979  {
980  setCursor();
981  cursorPos = controls->GetCursorPosition( !evt->DisableGridSnapping() );
982 
983  if( reselect && fp )
985 
986  auto cleanup =
987  [&] ()
988  {
990  commit.Revert();
991 
992  if( fromOtherCommand )
993  {
995 
996  if( undo )
997  {
999  undo->ClearListAndDeleteItems();
1000  delete undo;
1001  }
1002  }
1003 
1004  fp = nullptr;
1005  };
1006 
1007  if( evt->IsCancelInteractive() )
1008  {
1009  if( fp )
1010  cleanup();
1011  else
1012  {
1013  m_frame->PopTool( tool );
1014  break;
1015  }
1016  }
1017  else if( evt->IsActivate() )
1018  {
1019  if( fp )
1020  cleanup();
1021 
1022  if( evt->IsMoveTool() )
1023  {
1024  // leave ourselves on the stack so we come back after the move
1025  break;
1026  }
1027  else
1028  {
1029  frame()->PopTool( tool );
1030  break;
1031  }
1032  }
1033  else if( evt->IsClick( BUT_LEFT ) )
1034  {
1035  if( !fp )
1036  {
1037  // Pick the footprint to be placed
1039 
1040  if( fp == nullptr )
1041  continue;
1042 
1043  fp->SetLink( niluuid );
1044 
1045  fp->SetFlags(IS_NEW ); // whatever
1046 
1047  // Set parent so that clearance can be loaded
1048  fp->SetParent( board );
1049 
1050  for( PAD* pad : fp->Pads() )
1051  {
1052  pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest );
1053 
1054  // Pads in the library all have orphaned nets. Replace with Default.
1055  pad->SetNetCode( 0 );
1056  }
1057 
1058  // Put it on FRONT layer,
1059  // (Can be stored flipped if the lib is an archive built from a board)
1060  if( fp->IsFlipped() )
1061  fp->Flip( fp->GetPosition(), m_frame->Settings().m_FlipLeftRight );
1062 
1063  fp->SetOrientation( 0 );
1064  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1065 
1066  commit.Add( fp );
1068  controls->SetCursorPosition( cursorPos, false );
1069  }
1070  else
1071  {
1073  commit.Push( _( "Place a footprint" ) );
1074  fp = nullptr; // to indicate that there is no footprint that we currently modify
1075  }
1076  }
1077  else if( evt->IsClick( BUT_RIGHT ) )
1078  {
1080  }
1081  else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
1082  {
1083  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1084  selection().SetReferencePoint( cursorPos );
1085  getView()->Update( &selection() );
1086  getView()->Update( fp );
1087  }
1088  else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
1089  {
1090  // Calling 'Properties' action clears the selection, so we need to restore it
1091  reselect = true;
1092  }
1093  else
1094  {
1095  evt->SetPassEvent();
1096  }
1097 
1098  // Enable autopanning and cursor capture only when there is a footprint to be placed
1099  controls->SetAutoPan( fp != nullptr );
1100  controls->CaptureCursor( fp != nullptr );
1101  }
1102 
1103  controls->SetAutoPan( false );
1104  controls->CaptureCursor( false );
1106 
1107  return 0;
1108 }
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.
KIID niluuid(0)
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.
BOARD * board() const
#define IS_NEW
New item, just created.
FOOTPRINT * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Open a dialog to select a footprint.
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 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
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
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 PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
Definition: undo_redo.cpp:375
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:116
PADS & Pads()
Definition: footprint.h:168
PCB_BASE_EDIT_FRAME * frame() const
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:186
const PCB_SELECTION & selection() const
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1618
Generic, UI-independent tool event.
Definition: tool_event.h:152
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1428
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
A holder to handle information on schematic or board items.
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.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
bool IsFlipped() const
Definition: footprint.h:270
void SetLink(const KIID &aLink)
Definition: footprint.h:537
KIGFX::VIEW_CONTROLS * controls() const
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:62
PCBNEW_SETTINGS & Settings()
wxPoint GetPosition() const override
Definition: footprint.h:186
bool IsReactivate() const
Definition: tool_event.h:252
void Activate()
Run the tool.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
Definition: pad.h:57
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1499
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
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:123
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1518

References _, TOOL_INTERACTIVE::Activate(), COMMIT::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), PCB_TOOL_BASE::controls(), ACTIONS::cursorClick, FOOTPRINT::Flip(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetDisplayOptions(), FOOTPRINT::GetPosition(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), IS_NEW, FOOTPRINT::IsFlipped(), TOOL_EVENT::IsReactivate(), PCBNEW_SETTINGS::m_FlipLeftRight, m_frame, m_inPlaceFootprint, TOOL_INTERACTIVE::m_menu, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, TOOL_BASE::m_toolMgr, niluuid, pad, FOOTPRINT::Pads(), TOOL_EVENT::Parameter(), PENCIL, EDA_BASE_FRAME::PopCommandFromUndoList(), TOOLS_HOLDER::PopTool(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), ACTIONS::refreshPreview, BOARD_COMMIT::Revert(), TOOL_MANAGER::RunAction(), PCB_BASE_FRAME::SelectFootprintFromLibTree(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), EDA_ITEM::SetFlags(), FOOTPRINT::SetLink(), FOOTPRINT::SetOrientation(), EDA_ITEM::SetParent(), FOOTPRINT::SetPosition(), SELECTION::SetReferencePoint(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), undo, KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ PlaceTarget()

int BOARD_EDITOR_CONTROL::PlaceTarget ( const TOOL_EVENT aEvent)

Allow user to place a layer alignment target.

Definition at line 1188 of file board_editor_control.cpp.

1189 {
1190  if( m_inPlaceTarget )
1191  return 0;
1192 
1194 
1195  KIGFX::VIEW* view = getView();
1197  BOARD* board = getModel<BOARD>();
1198  PCB_TARGET* target = new PCB_TARGET( board );
1199 
1200  // Init the new item attributes
1201  target->SetLayer( Edge_Cuts );
1203  target->SetSize( Millimeter2iu( 5 ) );
1204  VECTOR2I cursorPos = controls->GetCursorPosition();
1205  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1206 
1207  // Add a VIEW_GROUP that serves as a preview for the new item
1208  KIGFX::VIEW_GROUP preview( view );
1209  preview.Add( target );
1210  view->Add( &preview );
1211 
1213 
1214  std::string tool = aEvent.GetCommandStr().get();
1215  m_frame->PushTool( tool );
1216  Activate();
1217 
1218  auto setCursor =
1219  [&]()
1220  {
1222  };
1223 
1224  // Set initial cursor
1225  setCursor();
1226 
1227  // Main loop: keep receiving events
1228  while( TOOL_EVENT* evt = Wait() )
1229  {
1230  setCursor();
1231  cursorPos = controls->GetCursorPosition( !evt->DisableGridSnapping() );
1232 
1233  if( evt->IsCancelInteractive() )
1234  {
1235  frame()->PopTool( tool );
1236  break;
1237  }
1238  else if( evt->IsActivate() )
1239  {
1240  if( evt->IsMoveTool() )
1241  {
1242  // leave ourselves on the stack so we come back after the move
1243  break;
1244  }
1245  else
1246  {
1247  frame()->PopTool( tool );
1248  break;
1249  }
1250  }
1251  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1252  {
1253  target->SetWidth( target->GetWidth() + WIDTH_STEP );
1254  view->Update( &preview );
1255  }
1256  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
1257  {
1258  int width = target->GetWidth();
1259 
1260  if( width > WIDTH_STEP )
1261  {
1262  target->SetWidth( width - WIDTH_STEP );
1263  view->Update( &preview );
1264  }
1265  }
1266  else if( evt->IsClick( BUT_LEFT ) )
1267  {
1268  assert( target->GetSize() > 0 );
1269  assert( target->GetWidth() > 0 );
1270 
1271  BOARD_COMMIT commit( m_frame );
1272  commit.Add( target );
1273  commit.Push( "Place a layer alignment target" );
1274 
1275  preview.Remove( target );
1276 
1277  // Create next PCB_TARGET
1278  target = new PCB_TARGET( *target );
1279  preview.Add( target );
1280  }
1281  else if( evt->IsClick( BUT_RIGHT ) )
1282  {
1284  }
1285  else if( evt->IsMotion() )
1286  {
1287  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1288  view->Update( &preview );
1289  }
1290  else
1291  {
1292  evt->SetPassEvent();
1293  }
1294  }
1295 
1296  preview.Clear();
1297  delete target;
1298  view->Remove( &preview );
1299 
1301 
1302  return 0;
1303 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
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.
BOARD * board() const
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:167
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
void SetSize(int aSize)
Definition: pcb_target.h:61
int GetSize() const
Definition: pcb_target.h:62
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 PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:589
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:170
PCB_BASE_EDIT_FRAME * frame() const
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
int GetWidth() const
Definition: pcb_target.h:65
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
virtual void PopTool(const std::string &actionName)
static const int WIDTH_STEP
How does line width change after one -/+ key press.
void SetPosition(const wxPoint &aPos) override
Definition: pcb_target.h:55
Generic, UI-independent tool event.
Definition: tool_event.h:152
KIGFX::PCB_VIEW * view() const
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:46
An interface for classes handling user events controlling the view behavior such as zooming,...
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
KIGFX::VIEW_CONTROLS * controls() const
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetWidth(int aWidth)
Definition: pcb_target.h:64
void Activate()
Run the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
static constexpr int Millimeter2iu(double mm)
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.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_GROUP::Clear(), PCB_TOOL_BASE::controls(), PCB_ACTIONS::decWidth, Edge_Cuts, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetLineThickness(), PCB_TARGET::GetSize(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), PCB_TARGET::GetWidth(), PCB_ACTIONS::incWidth, m_frame, m_inPlaceTarget, TOOL_INTERACTIVE::m_menu, TOOL_BASE::m_toolMgr, Millimeter2iu(), TOOLS_HOLDER::PopTool(), TOOLS_HOLDER::PushTool(), KIGFX::PCB_VIEW::Remove(), KIGFX::VIEW_GROUP::Remove(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, EDA_DRAW_PANEL_GAL::SetCurrentCursor(), BOARD_ITEM::SetLayer(), PCB_TARGET::SetPosition(), PCB_TARGET::SetSize(), PCB_TARGET::SetWidth(), TOOL_MENU::ShowContextMenu(), KIGFX::PCB_VIEW::Update(), PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), WIDTH_STEP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ Plot()

int BOARD_EDITOR_CONTROL::Plot ( const TOOL_EVENT aEvent)

Definition at line 347 of file board_editor_control.cpp.

348 {
350  return 0;
351 }
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
Definition: id.h:96

References ID_GEN_PLOT, m_frame, and PCB_EDIT_FRAME::ToPlotter().

Referenced by setTransitions().

◆ RepairBoard()

int BOARD_EDITOR_CONTROL::RepairBoard ( const TOOL_EVENT aEvent)

Definition at line 516 of file board_editor_control.cpp.

517 {
518  int errors = 0;
519  wxString details;
520  bool quiet = aEvent.Parameter<bool>();
521 
522  // Repair duplicate IDs and missing nets.
523  std::set<KIID> ids;
524  int duplicates = 0;
525 
526  auto processItem =
527  [&]( EDA_ITEM* aItem )
528  {
529  if( ids.count( aItem->m_Uuid ) )
530  {
531  duplicates++;
532  const_cast<KIID&>( aItem->m_Uuid ) = KIID();
533  }
534 
535  ids.insert( aItem->m_Uuid );
536 
537  BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
538 
539  if( cItem && cItem->GetNetCode() )
540  {
541  NETINFO_ITEM* netinfo = cItem->GetNet();
542 
543  if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
544  {
545  board()->Add( netinfo );
546 
547  details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
548  netinfo->GetNetname() );
549  errors++;
550  }
551  }
552  };
553 
554  // Footprint IDs are the most important, so give them the first crack at "claiming" a
555  // particular KIID.
556 
557  for( FOOTPRINT* footprint : board()->Footprints() )
558  processItem( footprint );
559 
560  // After that the principal use is for DRC marker pointers, which are most likely to pads
561  // or tracks.
562 
563  for( FOOTPRINT* footprint : board()->Footprints() )
564  {
565  for( PAD* pad : footprint->Pads() )
566  processItem( pad );
567  }
568 
569  for( PCB_TRACK* track : board()->Tracks() )
570  processItem( track );
571 
572  // From here out I don't think order matters much.
573 
574  for( FOOTPRINT* footprint : board()->Footprints() )
575  {
576  processItem( &footprint->Reference() );
577  processItem( &footprint->Value() );
578 
579  for( BOARD_ITEM* item : footprint->GraphicalItems() )
580  processItem( item );
581 
582  for( ZONE* zone : footprint->Zones() )
583  processItem( zone );
584 
585  for( PCB_GROUP* group : footprint->Groups() )
586  processItem( group );
587  }
588 
589  for( BOARD_ITEM* drawing : board()->Drawings() )
590  processItem( drawing );
591 
592  for( ZONE* zone : board()->Zones() )
593  processItem( zone );
594 
595  for( PCB_MARKER* marker : board()->Markers() )
596  processItem( marker );
597 
598  for( PCB_GROUP* group : board()->Groups() )
599  processItem( group );
600 
601  if( duplicates )
602  {
603  errors += duplicates;
604  details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
605  }
606 
607  /*******************************
608  * Your test here
609  */
610 
611  /*******************************
612  * Inform the user
613  */
614 
615  if( errors )
616  {
617  m_frame->OnModify();
618 
619  wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
620 
621  if( !quiet )
622  DisplayInfoMessage( m_frame, msg, details );
623  }
624  else if( !quiet )
625  {
626  DisplayInfoMessage( m_frame, _( "No board problems found." ) );
627  }
628 
629  return 0;
630 }
void OnModify() override
Must be called after a board change to set the modified flag.
ZONES & Zones()
Definition: board.h:239
BOARD * board() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:253
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
MARKERS & Markers()
Definition: board.h:242
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
PADS & Pads()
Definition: footprint.h:168
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:466
FP_TEXT & Reference()
Definition: footprint.h:467
FP_ZONES & Zones()
Definition: footprint.h:174
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:607
Definition: kiid.h:44
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
FOOTPRINTS & Footprints()
Definition: board.h:233
FOOTPRINT * footprint() const
const wxString & GetNetname() const
Definition: netinfo.h:119
#define _(s)
DRAWINGS & GraphicalItems()
Definition: footprint.h:171
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
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
FP_GROUPS & Groups()
Definition: footprint.h:177
Handle the data for a net.
Definition: netinfo.h:64
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
Definition: pad.h:57
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:299
DRAWINGS & Drawings()
Definition: board.h:236
TRACKS & Tracks()
Definition: board.h:230

References _, BOARD::Add(), PCB_TOOL_BASE::board(), DisplayInfoMessage(), BOARD::Drawings(), PCB_TOOL_BASE::footprint(), BOARD::Footprints(), Format(), BOARD_CONNECTED_ITEM::GetNet(), BOARD_CONNECTED_ITEM::GetNetCode(), NETINFO_ITEM::GetNetname(), FOOTPRINT::GraphicalItems(), group, FOOTPRINT::Groups(), BOARD::Groups(), m_frame, BOARD::Markers(), PCB_EDIT_FRAME::OnModify(), pad, FOOTPRINT::Pads(), TOOL_EVENT::Parameter(), FOOTPRINT::Reference(), BOARD::Tracks(), FOOTPRINT::Value(), FOOTPRINT::Zones(), and BOARD::Zones().

Referenced by setTransitions().

◆ Reset()

void BOARD_EDITOR_CONTROL::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 PCB_TOOL_BASE.

Definition at line 192 of file board_editor_control.cpp.

193 {
194  m_frame = getEditFrame<PCB_EDIT_FRAME>();
195 
196  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
197  {
198  m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin );
199  getView()->Remove( m_placeOrigin.get() );
200  getView()->Add( m_placeOrigin.get() );
201  }
202 }
Model changes (required full reload)
Definition: tool_base.h:80
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:353
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:323
Rendering engine changes.
Definition: tool_base.h:81

References KIGFX::VIEW::Add(), TOOL_BASE::GAL_SWITCH, TOOL_BASE::getView(), m_frame, m_placeOrigin, TOOL_BASE::MODEL_RELOAD, and KIGFX::VIEW::Remove().

◆ 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().

◆ Save()

int BOARD_EDITOR_CONTROL::Save ( const TOOL_EVENT aEvent)

Definition at line 306 of file board_editor_control.cpp.

307 {
309  return 0;
310 }
bool Files_io_from_id(int aId)
Read and write board files according to aId.

References PCB_EDIT_FRAME::Files_io_from_id(), ID_SAVE_BOARD, and m_frame.

Referenced by setTransitions().

◆ SaveAs()

int BOARD_EDITOR_CONTROL::SaveAs ( const TOOL_EVENT aEvent)

Definition at line 313 of file board_editor_control.cpp.

314 {
316  return 0;
317 }
bool Files_io_from_id(int aId)
Read and write board files according to aId.

References PCB_EDIT_FRAME::Files_io_from_id(), ID_SAVE_BOARD_AS, and m_frame.

Referenced by setTransitions().

◆ SaveCopyAs()

int BOARD_EDITOR_CONTROL::SaveCopyAs ( const TOOL_EVENT aEvent)

Definition at line 320 of file board_editor_control.cpp.

321 {
323  return 0;
324 }
bool Files_io_from_id(int aId)
Read and write board files according to aId.

References PCB_EDIT_FRAME::Files_io_from_id(), ID_COPY_BOARD_AS, and m_frame.

Referenced by setTransitions().

◆ selection() [1/2]

const PCB_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 313 of file pcb_tool_base.cpp.

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

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), 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(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), modifyLockSelected(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCB_CONTROL::placeBoardItems(), PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), 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(), TrackWidthDec(), TrackWidthInc(), GROUP_TOOL::Ungroup(), PCB_CONTROL::UpdateMessagePanel(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), ViaSizeDec(), ViaSizeInc(), ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCB_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 321 of file pcb_tool_base.cpp.

322 {
324 
325  return selTool->GetSelection();
326 }
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.

◆ setTransitions()

void BOARD_EDITOR_CONTROL::setTransitions ( )
overrideprivatevirtual

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 1512 of file board_editor_control.cpp.

1513 {
1514  Go( &BOARD_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1515  Go( &BOARD_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1516  Go( &BOARD_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1520  Go( &BOARD_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1521 
1522  Go( &BOARD_EDITOR_CONTROL::Find, ACTIONS::find.MakeEvent() );
1524 
1528  PCB_ACTIONS::importSpecctraSession.MakeEvent() );
1530 
1531  if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame &&
1534 
1536  PCB_ACTIONS::generateDrillFiles.MakeEvent() );
1540  PCB_ACTIONS::generateReportFile.MakeEvent() );
1543 
1544  // Track & via size control
1549 
1550  // Zone actions
1553 
1554  // Placing tools
1558 
1560 
1561  // Other
1565 
1567  ACTIONS::updatePcbFromSchematic.MakeEvent() );
1569  ACTIONS::updateSchematicFromPcb.MakeEvent() );
1574 }
int Open(const TOOL_EVENT &aEvent)
int LockSelected(const TOOL_EVENT &aEvent)
Unlock selected items.
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:421
int Find(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:423
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:334
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:344
static TOOL_ACTION pageSettings
Definition: actions.h:56
int TrackWidthInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:436
static TOOL_ACTION lock
Definition: pcb_actions.h:422
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:296
int Plot(const TOOL_EVENT &aEvent)
int GeneratePosFile(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:295
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:346
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:345
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:163
int ImportNetlist(const TOOL_EVENT &aEvent)
static TOOL_ACTION find
Definition: actions.h:76
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).
static TOOL_ACTION generateReportFile
Definition: pcb_actions.h:337
int PageSettings(const TOOL_EVENT &aEvent)
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:338
static TOOL_ACTION saveCopyAs
Definition: actions.h:53
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:294
int DrillOrigin(const TOOL_EVENT &aEvent)
Low-level access (below undo) to setting the drill origin.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:164
int EditFpInFpEditor(const TOOL_EVENT &aEvent)
int ViaSizeInc(const TOOL_EVENT &aEvent)
int UpdatePCBFromSchematic(const TOOL_EVENT &aEvent)
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:329
int UnlockSelected(const TOOL_EVENT &aEvent)
Run the drill origin tool for setting the origin for drill and pick-and-place files.
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION doNew
Definition: actions.h:44
int BoardSetup(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:306
int SaveAs(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
static TOOL_ACTION plot
Definition: actions.h:58
int RepairBoard(const TOOL_EVENT &aEvent)
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:439
int FindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION generatePosFile
Definition: pcb_actions.h:336
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:158
int ShowEeschema(const TOOL_EVENT &aEvent)
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:316
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:331
int ExportNetlist(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:309
TOOL_ACTION * GetExportNetlistAction()
int ImportSpecctraSession(const TOOL_EVENT &aEvent)
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:339
int ZoneMerge(const TOOL_EVENT &aEvent)
Duplicate a zone onto a layer (prompts for new layer)
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:160
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:332
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION repairBoard
Definition: pcb_actions.h:442
int PlaceFootprint(const TOOL_EVENT &aEvent)
Display a dialog to select a footprint to be added and allows the user to set its position.
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Lock selected items.
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
int TogglePythonConsole(const TOOL_EVENT &aEvent)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
int GenerateDrillFiles(const TOOL_EVENT &aEvent)
int ToggleLayersManager(const TOOL_EVENT &aEvent)
int ViaSizeDec(const TOOL_EVENT &aEvent)
int GenerateFabFiles(const TOOL_EVENT &aEvent)
int TrackWidthDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION findNext
Definition: actions.h:78
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:297
int PlaceTarget(const TOOL_EVENT &aEvent)
Allow user to place a layer alignment target.
static TOOL_ACTION generateDrillFiles
Definition: pcb_actions.h:335
int SaveCopyAs(const TOOL_EVENT &aEvent)

References BoardSetup(), PCB_ACTIONS::boardSetup, ACTIONS::doNew, DrillOrigin(), PCB_ACTIONS::drillOrigin, EditFpInFpEditor(), PCB_ACTIONS::editFpInFpEditor, ExportNetlist(), ExportSpecctraDSN(), PCB_ACTIONS::exportSpecctraDSN, Find(), ACTIONS::find, FindNext(), ACTIONS::findNext, PCB_ACTIONS::generateBOM, PCB_ACTIONS::generateD356File, GenerateDrillFiles(), PCB_ACTIONS::generateDrillFiles, GenerateFabFiles(), PCB_ACTIONS::generateGerbers, GeneratePosFile(), PCB_ACTIONS::generatePosFile, PCB_ACTIONS::generateReportFile, ADVANCED_CFG::GetCfg(), PCB_EDIT_FRAME::GetExportNetlistAction(), TOOL_INTERACTIVE::Go(), ImportNetlist(), PCB_ACTIONS::importNetlist, ImportSpecctraSession(), PCB_ACTIONS::importSpecctraSession, PCB_ACTIONS::lock, LockSelected(), m_frame, TOOL_ACTION::MakeEvent(), New(), ACTIONS::open, Open(), ACTIONS::pageSettings, PageSettings(), PlaceFootprint(), PCB_ACTIONS::placeFootprint, PlaceTarget(), PCB_ACTIONS::placeTarget, ACTIONS::plot, Plot(), RepairBoard(), PCB_ACTIONS::repairBoard, ACTIONS::save, Save(), ACTIONS::saveAs, SaveAs(), ACTIONS::saveCopyAs, SaveCopyAs(), ShowEeschema(), PCB_ACTIONS::showEeschema, PCB_ACTIONS::showLayersManager, PCB_ACTIONS::showPythonConsole, ToggleLayersManager(), PCB_ACTIONS::toggleLock, ToggleLockSelected(), TogglePythonConsole(), TrackWidthDec(), PCB_ACTIONS::trackWidthDec, TrackWidthInc(), PCB_ACTIONS::trackWidthInc, PCB_ACTIONS::unlock, UnlockSelected(), UpdatePCBFromSchematic(), ACTIONS::updatePcbFromSchematic, UpdateSchematicFromPCB(), ACTIONS::updateSchematicFromPcb, ViaSizeDec(), PCB_ACTIONS::viaSizeDec, ViaSizeInc(), PCB_ACTIONS::viaSizeInc, ZoneDuplicate(), PCB_ACTIONS::zoneDuplicate, ZoneMerge(), and PCB_ACTIONS::zoneMerge.

◆ ShowEeschema()

int BOARD_EDITOR_CONTROL::ShowEeschema ( const TOOL_EVENT aEvent)

Definition at line 670 of file board_editor_control.cpp.

671 {
672  m_frame->RunEeschema();
673  return 0;
674 }

References m_frame, and PCB_EDIT_FRAME::RunEeschema().

Referenced by setTransitions().

◆ ToggleLayersManager()

int BOARD_EDITOR_CONTROL::ToggleLayersManager ( const TOOL_EVENT aEvent)

Definition at line 677 of file board_editor_control.cpp.

678 {
679  getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
680  return 0;
681 }

Referenced by setTransitions().

◆ ToggleLockSelected()

int BOARD_EDITOR_CONTROL::ToggleLockSelected ( const TOOL_EVENT aEvent)

Lock selected items.

Definition at line 1111 of file board_editor_control.cpp.

1112 {
1113  return modifyLockSelected( TOGGLE );
1114 }
int modifyLockSelected(MODIFY_MODE aMode)
Set up handlers for various events.

References modifyLockSelected(), and TOGGLE.

Referenced by setTransitions().

◆ TogglePythonConsole()

int BOARD_EDITOR_CONTROL::TogglePythonConsole ( const TOOL_EVENT aEvent)

Definition at line 684 of file board_editor_control.cpp.

685 {
687  return 0;
688 }
void ScriptingConsoleEnableDisable()
Toggles the scripting console visibility.

References m_frame, and EDA_DRAW_FRAME::ScriptingConsoleEnableDisable().

Referenced by setTransitions().

◆ TrackWidthDec()

int BOARD_EDITOR_CONTROL::TrackWidthDec ( const TOOL_EVENT aEvent)

Definition at line 758 of file board_editor_control.cpp.

759 {
760  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
761  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
763 
765  {
766  BOARD_COMMIT commit( this );
767 
768  for( EDA_ITEM* item : selection )
769  {
770  if( item->Type() == PCB_TRACE_T )
771  {
772  PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
773 
774  for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 0; --i )
775  {
776  int candidate = designSettings.m_TrackWidthList[ i ];
777 
778  if( candidate < track->GetWidth() )
779  {
780  commit.Modify( track );
781  track->SetWidth( candidate );
782  break;
783  }
784  }
785  }
786  }
787 
788  commit.Push( "Decrease Track Width" );
789  return 0;
790  }
791 
792  ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
793 
794  if( routerTool && routerTool->IsToolActive()
795  && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
796  {
797  int widthIndex = designSettings.GetDiffPairIndex() - 1;
798 
799  // If we get to the lowest entry start over at the highest
800  if( widthIndex < 0 )
801  widthIndex = designSettings.m_DiffPairDimensionsList.size() - 1;
802 
803  designSettings.SetDiffPairIndex( widthIndex );
804  designSettings.UseCustomDiffPairDimensions( false );
805 
807  }
808  else
809  {
810  int widthIndex = designSettings.GetTrackWidthIndex() - 1;
811 
812  // If we get to the lowest entry start over at the highest
813  if( widthIndex < 0 )
814  widthIndex = designSettings.m_TrackWidthList.size() - 1;
815 
816  designSettings.SetTrackWidthIndex( widthIndex );
817  designSettings.UseCustomTrackViaSize( false );
818 
820  }
821 
822  return 0;
823 }
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
std::vector< int > m_TrackWidthList
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void UseCustomDiffPairDimensions(bool aEnabled)
Enables/disables custom differential pair dimensions.
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:299
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
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
const PCB_SELECTION & selection() const
unsigned GetTrackWidthIndex() const
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
void SetDiffPairIndex(unsigned aIndex)
void SetWidth(int aWidth)
Definition: pcb_track.h:101
bool IsToolActive() const
Definition: tool_base.cpp:31
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
unsigned GetDiffPairIndex() const
ROUTER * Router() const
ROUTER_MODE Mode() const
Definition: pns_router.h:131
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
Container for design settings for a BOARD object.

References EOT, BOARD_DESIGN_SETTINGS::GetDiffPairIndex(), TOOL_MANAGER::GetTool(), BOARD_DESIGN_SETTINGS::GetTrackWidthIndex(), TOOL_BASE::IsToolActive(), BOARD_DESIGN_SETTINGS::m_DiffPairDimensionsList, m_frame, TOOL_BASE::m_toolMgr, BOARD_DESIGN_SETTINGS::m_TrackWidthList, PNS::ROUTER::Mode(), COMMIT::Modify(), SELECTION_CONDITIONS::OnlyTypes(), PCB_TRACE_T, PCB_VIA_T, PNS::PNS_MODE_ROUTE_DIFF_PAIR, BOARD_COMMIT::Push(), PNS::TOOL_BASE::Router(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), BOARD_DESIGN_SETTINGS::SetDiffPairIndex(), BOARD_DESIGN_SETTINGS::SetTrackWidthIndex(), PCB_TRACK::SetWidth(), TOOLS_HOLDER::ToolStackIsEmpty(), PCB_ACTIONS::trackViaSizeChanged, BOARD_DESIGN_SETTINGS::UseCustomDiffPairDimensions(), and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

◆ TrackWidthInc()

int BOARD_EDITOR_CONTROL::TrackWidthInc ( const TOOL_EVENT aEvent)

Definition at line 692 of file board_editor_control.cpp.

693 {
694  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
695  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
697 
699  {
700  BOARD_COMMIT commit( this );
701 
702  for( EDA_ITEM* item : selection )
703  {
704  if( item->Type() == PCB_TRACE_T )
705  {
706  PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
707 
708  for( int candidate : designSettings.m_TrackWidthList )
709  {
710  if( candidate > track->GetWidth() )
711  {
712  commit.Modify( track );
713  track->SetWidth( candidate );
714  break;
715  }
716  }
717  }
718  }
719 
720  commit.Push( "Increase Track Width" );
721  return 0;
722  }
723 
724  ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
725 
726  if( routerTool && routerTool->IsToolActive()
727  && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
728  {
729  int widthIndex = designSettings.GetDiffPairIndex() + 1;
730 
731  // If we go past the last track width entry in the list, start over at the beginning
732  if( widthIndex >= (int) designSettings.m_DiffPairDimensionsList.size() )
733  widthIndex = 0;
734 
735  designSettings.SetDiffPairIndex( widthIndex );
736  designSettings.UseCustomDiffPairDimensions( false );
737 
739  }
740  else
741  {
742  int widthIndex = designSettings.GetTrackWidthIndex() + 1;
743 
744  // If we go past the last track width entry in the list, start over at the beginning
745  if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
746  widthIndex = 0;
747 
748  designSettings.SetTrackWidthIndex( widthIndex );
749  designSettings.UseCustomTrackViaSize( false );
750 
752  }
753 
754  return 0;
755 }
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
std::vector< int > m_TrackWidthList
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void UseCustomDiffPairDimensions(bool aEnabled)
Enables/disables custom differential pair dimensions.
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:299
int GetWidth() const
Definition: pcb_track.h:102
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
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
const PCB_SELECTION & selection() const
unsigned GetTrackWidthIndex() const
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
void SetDiffPairIndex(unsigned aIndex)
void SetWidth(int aWidth)
Definition: pcb_track.h:101
bool IsToolActive() const
Definition: tool_base.cpp:31
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
unsigned GetDiffPairIndex() const
ROUTER * Router() const
ROUTER_MODE Mode() const
Definition: pns_router.h:131
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
Container for design settings for a BOARD object.

References EOT, BOARD_DESIGN_SETTINGS::GetDiffPairIndex(), TOOL_MANAGER::GetTool(), BOARD_DESIGN_SETTINGS::GetTrackWidthIndex(), PCB_TRACK::GetWidth(), TOOL_BASE::IsToolActive(), BOARD_DESIGN_SETTINGS::m_DiffPairDimensionsList, m_frame, TOOL_BASE::m_toolMgr, BOARD_DESIGN_SETTINGS::m_TrackWidthList, PNS::ROUTER::Mode(), COMMIT::Modify(), SELECTION_CONDITIONS::OnlyTypes(), PCB_TRACE_T, PCB_VIA_T, PNS::PNS_MODE_ROUTE_DIFF_PAIR, BOARD_COMMIT::Push(), PNS::TOOL_BASE::Router(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), BOARD_DESIGN_SETTINGS::SetDiffPairIndex(), BOARD_DESIGN_SETTINGS::SetTrackWidthIndex(), PCB_TRACK::SetWidth(), TOOLS_HOLDER::ToolStackIsEmpty(), PCB_ACTIONS::trackViaSizeChanged, BOARD_DESIGN_SETTINGS::UseCustomDiffPairDimensions(), and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

◆ UnlockSelected()

int BOARD_EDITOR_CONTROL::UnlockSelected ( const TOOL_EVENT aEvent)

Run the drill origin tool for setting the origin for drill and pick-and-place files.

Definition at line 1123 of file board_editor_control.cpp.

1124 {
1125  return modifyLockSelected( OFF );
1126 }
int modifyLockSelected(MODIFY_MODE aMode)
Set up handlers for various events.

References modifyLockSelected(), and OFF.

Referenced by setTransitions().

◆ UpdatePCBFromSchematic()

int BOARD_EDITOR_CONTROL::UpdatePCBFromSchematic ( const TOOL_EVENT aEvent)

Definition at line 633 of file board_editor_control.cpp.

634 {
636 
637  if( m_frame->FetchNetlistFromSchematic( netlist, _( "Updating PCB requires a fully annotated "
638  "schematic." ) ) )
639  {
640  DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
641  updateDialog.ShowModal();
642  }
643 
644  return 0;
645 }
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:206
#define _(s)

References _, PCB_EDIT_FRAME::FetchNetlistFromSchematic(), m_frame, and netlist.

Referenced by setTransitions().

◆ UpdateSchematicFromPCB()

int BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB ( const TOOL_EVENT aEvent)

Definition at line 647 of file board_editor_control.cpp.

648 {
649  if( Kiface().IsSingle() )
650  {
652  m_frame, _( "Cannot update schematic because Pcbnew is opened in stand-alone "
653  "mode. In order to create or update PCBs from schematics, you "
654  "must launch the KiCad project manager and create a project." ) );
655  return 0;
656  }
657 
658  m_frame->RunEeschema();
660 
661  if( frame )
662  {
663  std::string payload;
665  }
666  return 0;
667 }
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:284
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:382
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:476
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)

References _, DisplayErrorMessage(), KIWAY::ExpressMail(), PCB_TOOL_BASE::frame(), FRAME_SCH, Kiface(), KIWAY_HOLDER::Kiway(), m_frame, MAIL_SCH_UPDATE, KIWAY::Player(), and PCB_EDIT_FRAME::RunEeschema().

Referenced by setTransitions().

◆ ViaSizeDec()

int BOARD_EDITOR_CONTROL::ViaSizeDec ( const TOOL_EVENT aEvent)

Definition at line 875 of file board_editor_control.cpp.

876 {
877  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
878  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
880 
882  {
883  BOARD_COMMIT commit( this );
884 
885  for( EDA_ITEM* item : selection )
886  {
887  if( item->Type() == PCB_VIA_T )
888  {
889  PCB_VIA* via = static_cast<PCB_VIA*>( item );
890 
891  for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
892  {
893  VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
894 
895  if( candidate.m_Diameter < via->GetWidth() )
896  {
897  commit.Modify( via );
898  via->SetWidth( candidate.m_Diameter );
899  via->SetDrill( candidate.m_Drill );
900  break;
901  }
902  }
903  }
904  }
905 
906  commit.Push( "Decrease Via Size" );
907  }
908  else
909  {
910  int sizeIndex = 0; // Assume we only have a single via size entry
911 
912  // If there are more, cycle through them backwards
913  if( designSettings.m_ViasDimensionsList.size() > 0 )
914  {
915  sizeIndex = designSettings.GetViaSizeIndex() - 1;
916 
917  // If we get to the lowest entry start over at the highest
918  if( sizeIndex < 0 )
919  sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
920  }
921 
922  designSettings.SetViaSizeIndex( sizeIndex );
923  designSettings.UseCustomTrackViaSize( false );
924 
926  }
927 
928  return 0;
929 }
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
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
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
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
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
const PCB_SELECTION & selection() const
unsigned GetViaSizeIndex() const
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
std::vector< VIA_DIMENSION > m_ViasDimensionsList
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
Container for design settings for a BOARD object.

References EOT, TOOL_MANAGER::GetTool(), BOARD_DESIGN_SETTINGS::GetViaSizeIndex(), VIA_DIMENSION::m_Diameter, VIA_DIMENSION::m_Drill, m_frame, TOOL_BASE::m_toolMgr, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, COMMIT::Modify(), SELECTION_CONDITIONS::OnlyTypes(), PCB_TRACE_T, PCB_VIA_T, BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), BOARD_DESIGN_SETTINGS::SetViaSizeIndex(), TOOLS_HOLDER::ToolStackIsEmpty(), PCB_ACTIONS::trackViaSizeChanged, BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize(), and via.

Referenced by setTransitions().

◆ ViaSizeInc()

int BOARD_EDITOR_CONTROL::ViaSizeInc ( const TOOL_EVENT aEvent)

Definition at line 826 of file board_editor_control.cpp.

827 {
828  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
829  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
831 
833  {
834  BOARD_COMMIT commit( this );
835 
836  for( EDA_ITEM* item : selection )
837  {
838  if( item->Type() == PCB_VIA_T )
839  {
840  PCB_VIA* via = static_cast<PCB_VIA*>( item );
841 
842  for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
843  {
844  if( candidate.m_Diameter > via->GetWidth() )
845  {
846  commit.Modify( via );
847  via->SetWidth( candidate.m_Diameter );
848  via->SetDrill( candidate.m_Drill );
849  break;
850  }
851  }
852  }
853  }
854 
855  commit.Push( "Increase Via Size" );
856  }
857  else
858  {
859  int sizeIndex = designSettings.GetViaSizeIndex() + 1;
860 
861  // If we go past the last via entry in the list, start over at the beginning
862  if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
863  sizeIndex = 0;
864 
865  designSettings.SetViaSizeIndex( sizeIndex );
866  designSettings.UseCustomTrackViaSize( false );
867 
869  }
870 
871  return 0;
872 }
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
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
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
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
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
const PCB_SELECTION & selection() const
unsigned GetViaSizeIndex() const
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
std::vector< VIA_DIMENSION > m_ViasDimensionsList
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
Container for design settings for a BOARD object.

References EOT, TOOL_MANAGER::GetTool(), BOARD_DESIGN_SETTINGS::GetViaSizeIndex(), VIA_DIMENSION::m_Diameter, VIA_DIMENSION::m_Drill, m_frame, TOOL_BASE::m_toolMgr, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, COMMIT::Modify(), SELECTION_CONDITIONS::OnlyTypes(), PCB_TRACE_T, PCB_VIA_T, BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), BOARD_DESIGN_SETTINGS::SetViaSizeIndex(), TOOLS_HOLDER::ToolStackIsEmpty(), PCB_ACTIONS::trackViaSizeChanged, BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize(), and via.

Referenced by setTransitions().

◆ view()

◆ Wait()

TOOL_EVENT * TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pause execution of a given tool until one or more events matching aConditions arrives.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), 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(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), PL_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), PlaceTarget(), DRAWING_TOOL::PlaceText(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ ZoneDuplicate()

int BOARD_EDITOR_CONTROL::ZoneDuplicate ( const TOOL_EVENT aEvent)

Definition at line 1400 of file board_editor_control.cpp.

1401 {
1403  const PCB_SELECTION& selection = selTool->GetSelection();
1404 
1405  // because this pops up the zone editor, it would be confusing to handle multiple zones,
1406  // so just handle single selections containing exactly one zone
1407  if( selection.Size() != 1 )
1408  return 0;
1409 
1410  ZONE* oldZone = dyn_cast<ZONE*>( selection[0] );
1411 
1412  if( !oldZone )
1413  return 0;
1414 
1415  ZONE_SETTINGS zoneSettings;
1416  zoneSettings << *oldZone;
1417  int dialogResult;
1418 
1419  if( oldZone->GetIsRuleArea() )
1420  dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings );
1421  else if( oldZone->IsOnCopperLayer() )
1422  dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1423  else
1424  dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1425 
1426  if( dialogResult != wxID_OK )
1427  return 0;
1428 
1429  // duplicate the zone
1430  BOARD_COMMIT commit( m_frame );
1431 
1432  std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1433  newZone->ClearSelected();
1434  newZone->UnFill();
1435  zoneSettings.ExportSetting( *newZone );
1436 
1437  // If the new zone is on the same layer(s) as the initial zone,
1438  // offset it a bit so it can more easily be picked.
1439  if( oldZone->GetIsRuleArea() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
1440  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1441  else if( !oldZone->GetIsRuleArea() && zoneSettings.m_Layers.test( oldZone->GetLayer() ) )
1442  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1443 
1444  commit.Add( newZone.release() );
1445  commit.Push( _( "Duplicate zone" ) );
1446 
1447  return 0;
1448 }
static constexpr double IU_PER_MM
Mock up a conversion function.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
const PCB_SELECTION & selection() const
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
#define _(s)
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
The selection tool: currently supports:
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.

References _, COMMIT::Add(), ZONE_SETTINGS::ExportSetting(), PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), InvokeCopperZonesEditor(), InvokeNonCopperZonesEditor(), InvokeRuleAreaEditor(), IU_PER_MM, m_frame, ZONE_SETTINGS::m_Layers, TOOL_BASE::m_toolMgr, BOARD_COMMIT::Push(), PCB_TOOL_BASE::selection(), and SELECTION::Size().

Referenced by setTransitions().

◆ ZoneMerge()

int BOARD_EDITOR_CONTROL::ZoneMerge ( const TOOL_EVENT aEvent)

Duplicate a zone onto a layer (prompts for new layer)

Definition at line 1342 of file board_editor_control.cpp.

1343 {
1344  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1345  BOARD* board = getModel<BOARD>();
1346  BOARD_COMMIT commit( m_frame );
1347 
1348  if( selection.Size() < 2 )
1349  return 0;
1350 
1351  int netcode = -1;
1352 
1353  ZONE* firstZone = nullptr;
1354  std::vector<ZONE*> toMerge, merged;
1355 
1356  for( EDA_ITEM* item : selection )
1357  {
1358  ZONE* curr_area = dynamic_cast<ZONE*>( item );
1359 
1360  if( !curr_area )
1361  continue;
1362 
1363  if( !firstZone )
1364  firstZone = curr_area;
1365 
1366  netcode = curr_area->GetNetCode();
1367 
1368  if( firstZone->GetNetCode() != netcode )
1369  continue;
1370 
1371  if( curr_area->GetPriority() != firstZone->GetPriority() )
1372  continue;
1373 
1374  if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1375  continue;
1376 
1377  if( curr_area->GetLayer() != firstZone->GetLayer() )
1378  continue;
1379 
1380  if( !board->TestZoneIntersection( curr_area, firstZone ) )
1381  continue;
1382 
1383  toMerge.push_back( curr_area );
1384  }
1385 
1387 
1388  if( mergeZones( commit, toMerge, merged ) )
1389  {
1390  commit.Push( "Merge zones" );
1391 
1392  for( EDA_ITEM* item : merged )
1394  }
1395 
1396  return 0;
1397 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
BOARD * board() const
unsigned GetPriority() const
Definition: zone.h:122
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:733
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
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
const PCB_SELECTION & selection() const
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: zone.cpp:218
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:62
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
The selection tool: currently supports:
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE * > &aOriginZones, std::vector< ZONE * > &aMergedZones)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100

References PCB_TOOL_BASE::board(), ZONE::GetIsRuleArea(), ZONE::GetLayer(), BOARD_CONNECTED_ITEM::GetNetCode(), ZONE::GetPriority(), TOOL_MANAGER::GetTool(), m_frame, TOOL_BASE::m_toolMgr, mergeZones(), BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, SELECTION::Size(), and BOARD::TestZoneIntersection().

Referenced by setTransitions().

Member Data Documentation

◆ m_frame

◆ m_inPlaceFootprint

bool BOARD_EDITOR_CONTROL::m_inPlaceFootprint
private

Definition at line 132 of file board_editor_control.h.

Referenced by PlaceFootprint().

◆ m_inPlaceTarget

bool BOARD_EDITOR_CONTROL::m_inPlaceTarget
private

Definition at line 133 of file board_editor_control.h.

Referenced by PlaceTarget().

◆ m_isFootprintEditor

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

The functions below are not yet implemented - their interface may change.

Definition at line 125 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), ROUTER_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), PL_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_CONTROL::Init(), PCB_VIEWER_TOOLS::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PL_SELECTION_TOOL::Init(), SCH_DRAWING_TOOLS::Init(), Init(), GERBVIEW_SELECTION_TOOL::Init(), EDA_3D_CONTROLLER::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), PCB_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PICKER_TOOL::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_PICKER_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PL_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_placeOrigin

std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> BOARD_EDITOR_CONTROL::m_placeOrigin
private

Definition at line 135 of file board_editor_control.h.

Referenced by BOARD_EDITOR_CONTROL(), DrillOrigin(), and Reset().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 209 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), PCB_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), BOARD_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), PL_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PL_EDIT_TOOL::Copy(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), PL_SELECTION_TOOL::disambiguateCursor(), EE_SELECTION_TOOL::disambiguateCursor(), PCB_SELECTION_TOOL::disambiguateCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), EditFpInFpEditor(), SYMBOL_EDITOR_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_REANNOTATE_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), CONVERT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), GLOBAL_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), PL_POINT_EDITOR::Init(), BOARD_INSPECTION_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_POINT_EDITOR::Init(), Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), modifyLockSelected(), EDIT_TOOL::MoveExact(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), PL_SELECTION_TOOL::onDisambiguationExpire(), EE_SELECTION_TOOL::onDisambiguationExpire(), PCB_SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_CONTROL::Print(), GERBVIEW_CONTROL::Print(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), PCB_SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), PCB_SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), PCB_SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_SELECTION_TOOL::selectSameSheet(), PCB_SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), TrackWidthDec(), TrackWidthInc(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GROUP_TOOL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PCB_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), ViaSizeDec(), ViaSizeInc(), TOOL_INTERACTIVE::Wait(), ZoneDuplicate(), and ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 213 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

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

Definition at line 206 of file tool_base.h.

Referenced by TOOL_BASE::GetType(), and BOARD_COMMIT::Push().

◆ WIDTH_STEP

const int BOARD_EDITOR_CONTROL::WIDTH_STEP = 100000
staticprivate

How does line width change after one -/+ key press.

Definition at line 137 of file board_editor_control.h.

Referenced by PlaceTarget().


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