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 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
 
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
 Pointer to the currently used edit frame. More...
 
std::unique_ptr< KIGFX::ORIGIN_VIEWITEMm_placeOrigin
 Place & drill origin marker. More...
 

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 111 of file pcb_tool_base.h.

111  {
113  IPO_ROTATE = 0x01,
114 
116  IPO_FLIP = 0x02,
117 
120  IPO_SINGLE_CLICK = 0x04,
121 
123  IPO_REPEAT = 0x08
124  };
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 120 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 78 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ BOARD_EDITOR_CONTROL()

BOARD_EDITOR_CONTROL::BOARD_EDITOR_CONTROL ( )

Definition at line 174 of file board_editor_control.cpp.

174  :
175  PCB_TOOL_BASE( "pcbnew.EditorControl" ),
176  m_frame( nullptr )
177 {
178  m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>(
179  KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
181 }
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:78
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

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

◆ ~BOARD_EDITOR_CONTROL()

BOARD_EDITOR_CONTROL::~BOARD_EDITOR_CONTROL ( )

Definition at line 184 of file board_editor_control.cpp.

185 {
186 }

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:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
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(), BOARD_INSPECTION_TOOL::HighlightNetTool(), 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:215

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 160 of file pcb_tool_base.h.

160 { 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(), 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(), GROUP_TOOL::Ungroup(), 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 350 of file board_editor_control.cpp.

351 {
352  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
353  return 0;
354 }

Referenced by setTransitions().

◆ canvas()

◆ controls()

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

Definition at line 290 of file pcb_tool_base.cpp.

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

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

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

◆ doInteractiveItemPlacement()

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

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

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

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

Definition at line 35 of file pcb_tool_base.cpp.

38 {
39  using namespace std::placeholders;
40  std::unique_ptr<BOARD_ITEM> newItem;
41 
42  frame()->PushTool( aTool );
43  Activate();
44 
45  BOARD_COMMIT commit( frame() );
46 
48 
49  // do not capture or auto-pan until we start placing an item
50  controls()->ShowCursor( true );
51 
52  // Add a VIEW_GROUP that serves as a preview for the new item
53  PCB_SELECTION preview;
54  view()->Add( &preview );
55 
56  aPlacer->m_board = board();
57  aPlacer->m_frame = frame();
58  aPlacer->m_modifiers = 0;
59 
60  auto makeNewItem =
61  [&]( VECTOR2I aPosition )
62  {
63  if( frame()->GetModel() )
64  newItem = aPlacer->CreateItem();
65 
66  if( newItem )
67  {
68  newItem->SetPosition( (wxPoint) aPosition );
69  preview.Add( newItem.get() );
70 
71  if( newItem->Type() == PCB_FOOTPRINT_T )
72  {
73  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
74 
75  // footprints have more drawable parts
76  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
77  }
78  }
79  };
80 
81  if( aOptions & IPO_SINGLE_CLICK )
82  makeNewItem( controls()->GetCursorPosition() );
83 
84  auto setCursor =
85  [&]()
86  {
87  if( !newItem )
89  else
91  };
92 
93  // Set initial cursor
94  setCursor();
95 
96  // Main loop: keep receiving events
97  while( TOOL_EVENT* evt = Wait() )
98  {
99  setCursor();
100 
101  VECTOR2I cursorPos = controls()->GetCursorPosition();
102  aPlacer->m_modifiers = evt->Modifier();
103 
104  auto cleanup =
105  [&] ()
106  {
107  newItem = nullptr;
108  preview.Clear();
109  view()->Update( &preview );
110  controls()->SetAutoPan( false );
111  controls()->CaptureCursor( false );
112  controls()->ShowCursor( true );
113  };
114 
115  if( evt->IsCancelInteractive() )
116  {
117  if( aOptions & IPO_SINGLE_CLICK )
118  {
119  cleanup();
120  frame()->PopTool( aTool );
121  break;
122  }
123  else if( newItem )
124  cleanup();
125  else
126  {
127  frame()->PopTool( aTool );
128  break;
129  }
130  }
131  else if( evt->IsActivate() )
132  {
133  if( newItem )
134  cleanup();
135 
136  if( evt->IsPointEditor() )
137  {
138  // don't exit (the point editor runs in the background)
139  }
140  else if( evt->IsMoveTool() )
141  {
142  // leave ourselves on the stack so we come back after the move
143  break;
144  }
145  else
146  {
147  frame()->PopTool( aTool );
148  break;
149  }
150  }
151  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
152  {
153  if( !newItem )
154  {
155  // create the item if possible
156  makeNewItem( cursorPos );
157 
158  // no item created, so wait for another click
159  if( !newItem )
160  continue;
161 
162  controls()->CaptureCursor( true );
163  controls()->SetAutoPan( true );
164  }
165  else
166  {
167  auto oldFlags = newItem->GetFlags();
168  newItem->ClearFlags();
169 
170  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
171  {
172  newItem->SetFlags( oldFlags );
173  continue;
174  }
175 
176  preview.Clear();
177  newItem.release();
178  commit.Push( aCommitMessage );
179 
180  controls()->CaptureCursor( false );
181  controls()->SetAutoPan( false );
182  controls()->ShowCursor( true );
183 
184  if( !( aOptions & IPO_REPEAT ) )
185  break;
186 
187  if( aOptions & IPO_SINGLE_CLICK )
188  makeNewItem( controls()->GetCursorPosition() );
189 
190  setCursor();
191  }
192  }
193  else if( evt->IsClick( BUT_RIGHT ) )
194  {
196  }
197  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
198  {
200  }
201  else if( newItem && evt->Category() == TC_COMMAND )
202  {
203  /*
204  * Handle any events that can affect the item as we move it around
205  */
206  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
207  {
208  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
209  newItem->Rotate( newItem->GetPosition(), rotationAngle );
210  view()->Update( &preview );
211  }
212  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
213  {
214  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
215  view()->Update( &preview );
216  }
217  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
218  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
219  {
220  // Refresh preview after event runs
222  }
223  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
224  {
225  frame()->OnEditItemRequest( newItem.get() );
226 
227  // Notify other tools of the changes
229  }
230  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
231  {
232  preview.Clear();
233  newItem.release();
234 
235  makeNewItem( (wxPoint) cursorPos );
236  aPlacer->SnapItem( newItem.get() );
237  view()->Update( &preview );
238  }
239  else
240  {
241  evt->SetPassEvent();
242  }
243  }
244  else if( newItem && evt->IsMotion() )
245  {
246  // track the cursor
247  newItem->SetPosition( (wxPoint) cursorPos );
248  aPlacer->SnapItem( newItem.get() );
249 
250  // Show a preview of the item
251  view()->Update( &preview );
252  }
253  else
254  {
255  evt->SetPassEvent();
256  }
257  }
258 
259  view()->Remove( &preview );
261 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
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:96
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
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:302
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:215
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:121
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:305
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:206
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:77
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:144
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:173
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:109
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:1175
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:65
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:303
static TOOL_ACTION refreshPreview
Definition: actions.h:109
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

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

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

◆ DoSetDrillOrigin()

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

Definition at line 1443 of file board_editor_control.cpp.

1445 {
1446  aFrame->GetDesignSettings().m_AuxOrigin = (wxPoint) aPosition;
1447  originViewItem->SetPosition( (wxPoint) aPosition );
1448  aView->MarkDirty();
1449  aFrame->OnModify();
1450 }
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:598

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

1454 {
1455  std::string tool = aEvent.GetCommandStr().get();
1457 
1458  // Deactivate other tools; particularly important if another PICKER is currently running
1459  Activate();
1460 
1461  picker->SetClickHandler(
1462  [this] ( const VECTOR2D& pt ) -> bool
1463  {
1465  DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
1466  return false; // drill origin is a one-shot; don't continue with tool
1467  } );
1468 
1469  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1470 
1471  return 0;
1472 }
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:177
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
static TOOL_ACTION pickerTool
Definition: actions.h:158
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
Generic tool for picking an item.
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:69
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
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 1414 of file board_editor_control.cpp.

1415 {
1418 
1419  if( selection.Empty() )
1420  return 0;
1421 
1423 
1424  if( !fp )
1425  return 0;
1426 
1427  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1428 
1429  auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1430 
1431  editor->LoadFootprintFromBoard( fp );
1432 
1433  editor->Show( true );
1434  editor->Raise(); // Iconize( false );
1435 
1436  if( selection.IsHover() )
1438 
1439  return 0;
1440 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
bool IsHover() const
Definition: selection.h:72
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:357
const PCB_SELECTION & selection() const
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
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:214
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:2266

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

412 {
413  wxCHECK( m_frame, 0 );
414 
415  wxFileName fn = m_frame->Prj().GetProjectFullName();
416 
417  // Use a different file extension for the board netlist so the schematic netlist file
418  // is accidently overwritten.
419  fn.SetExt( "pcb_net" );
420 
421  wxFileDialog dlg( m_frame, _( "Export Board Netlist" ), fn.GetPath(), fn.GetFullName(),
422  _( "KiCad board netlist files" ) + wxT( " (*.pcb_net)|*.pcb_net" ),
423  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
424 
425  dlg.SetExtraControlCreator( &NETLIST_OPTIONS_HELPER::Create );
426 
427  if( dlg.ShowModal() == wxID_CANCEL )
428  return 0;
429 
430  fn = dlg.GetPath();
431 
432  if( !fn.IsDirWritable() )
433  {
434  wxString msg;
435 
436  msg.Printf( _( "Path `%s` is read only." ), fn.GetPath() );
437  wxMessageDialog( m_frame, msg, _( "I/O Error" ), wxOK | wxCENTER | wxICON_EXCLAMATION );
438  return 0;
439  }
440 
441  const NETLIST_OPTIONS_HELPER* noh =
442  dynamic_cast<const NETLIST_OPTIONS_HELPER*>( dlg.GetExtraControl() );
443  wxCHECK( noh, 0 );
444 
446 
447  for( const FOOTPRINT* footprint : board()->Footprints() )
448  {
449  COMPONENT* component = new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
451  { footprint->m_Uuid } );
452 
453  for( const PAD* pad : footprint->Pads() )
454  {
455  const wxString& netname = pad->GetShortNetname();
456 
457  if( !netname.IsEmpty() )
458  {
459  component->AddNet( pad->GetName(), netname, pad->GetPinFunction(),
460  pad->GetPinType() );
461  }
462  }
463 
464  netlist.AddComponent( component );
465  }
466 
467  FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
468 
469  netlist.Format( "pcb_netlist", &formatter, 0, noh->GetNetlistOptions() );
470 
471  return 0;
472 }
const wxString & GetValue() const
Definition: footprint.h:454
BOARD * board() const
const KIID_PATH & GetPath() const
Definition: footprint.h:199
PADS & Pads()
Definition: footprint.h:164
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:205
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
FOOTPRINT * footprint() const
const wxString & GetReference() const
Definition: footprint.h:432
const LIB_ID & GetFPID() const
Definition: footprint.h:190
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:117
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:83
const KIID m_Uuid
Definition: eda_item.h:525
#define _(s)
Definition: 3d_actions.cpp:33
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
Definition: pcb_netlist.h:102
Used for text file output.
Definition: richio.h:453
static wxWindow * Create(wxWindow *aParent)
Definition: pad.h:60
Helper widget to add controls to a wxFileDialog to set netlist configuration options.

References _, 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 384 of file board_editor_control.cpp.

385 {
386  wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
387  wxFileName fn;
388 
389  if( fullFileName.IsEmpty() )
390  {
391  fn = m_frame->GetBoard()->GetFileName();
392  fn.SetExt( SpecctraDsnFileExtension );
393  }
394  else
395  fn = fullFileName;
396 
397  fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
399  frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
400 
401  if( !fullFileName.IsEmpty() )
402  {
403  m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
404  getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
405  }
406 
407  return 0;
408 }
const wxString & GetFileName() const
Definition: board.h:300
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
PCB_BASE_EDIT_FRAME * frame() const
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
Definition: gestfich.cpp:52
const std::string SpecctraDsnFileExtension
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
#define _(s)
Definition: 3d_actions.cpp:33
wxString SpecctraDsnFileWildcard()
BOARD * GetBoard() const
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.

References _, EDA_FILE_SELECTOR(), 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().

◆ footprint()

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 155 of file pcb_tool_base.h.

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

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(), PCB_SELECTION_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), 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(), 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(), UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ GenerateDrillFiles()

int BOARD_EDITOR_CONTROL::GenerateDrillFiles ( const TOOL_EVENT aEvent)

Definition at line 54 of file dialog_gendrill.cpp.

55 {
56  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
57  DIALOG_GENDRILL dlg( editFrame, editFrame );
58 
59  dlg.ShowModal();
60  return 0;
61 }
The main frame for Pcbnew.

Referenced by setTransitions().

◆ GenerateFabFiles()

int BOARD_EDITOR_CONTROL::GenerateFabFiles ( const TOOL_EVENT aEvent)

Definition at line 475 of file board_editor_control.cpp.

476 {
477  wxCommandEvent dummy;
478 
479  if( aEvent.IsAction( &PCB_ACTIONS::generateGerbers ) )
481  else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
483  else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
485  else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
487  else
488  wxFAIL_MSG( "GenerateFabFiles(): unexpected request" );
489 
490  return 0;
491 }
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:336
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 LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
static TOOL_ACTION generateReportFile
Definition: pcb_actions.h:339
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:340
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:70
void GenFootprintsReport(wxCommandEvent &event)
Call DoGenFootprintsReport to create a footprint report file.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:341
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 456 of file gen_footprints_placefile.cpp.

457 {
458  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
459  DIALOG_GEN_FOOTPRINT_POSITION dlg( editFrame );
460 
461  dlg.ShowModal();
462  return 0;
463 }
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 185 of file tool_base.h.

186  {
187 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
188  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
189 #endif
190  return static_cast<T*>( getToolHolderInt() );
191  }
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 121 of file tool_base.h.

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

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

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

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 197 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 134 of file tool_base.h.

135  {
136  return m_toolName;
137  }
std::string m_toolName
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

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

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 109 of file tool_base.h.

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

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:289
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

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(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindComponentAndItem(), 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(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), PlaceTarget(), 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:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:291

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(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), 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(), 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 128 of file tool_interactive.h.

130 {
131  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
132 
133  goInternal( sptr, aConditions );
134 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

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(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_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_DRAWING_TOOLS::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::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(), setTransitions(), BOARD_INSPECTION_TOOL::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 357 of file board_editor_control.cpp.

358 {
359  getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
360  return 0;
361 }

Referenced by setTransitions().

◆ ImportSpecctraSession()

int BOARD_EDITOR_CONTROL::ImportSpecctraSession ( const TOOL_EVENT aEvent)

Definition at line 364 of file board_editor_control.cpp.

365 {
366  wxString fullFileName = frame()->GetBoard()->GetFileName();
367  wxString path;
368  wxString name;
369  wxString ext;
370 
371  wxFileName::SplitPath( fullFileName, &path, &name, &ext );
372  name += wxT( ".ses" );
373 
374  fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), path, name,
375  wxT( ".ses" ), wxT( "*.ses" ), frame(), wxFD_OPEN, false );
376 
377  if( !fullFileName.IsEmpty() )
378  getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
379 
380  return 0;
381 }
const wxString & GetFileName() const
Definition: board.h:300
PCB_BASE_EDIT_FRAME * frame() const
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
Definition: gestfich.cpp:52
const char * name
Definition: DXF_plotter.cpp:59
#define _(s)
Definition: 3d_actions.cpp:33
BOARD * GetBoard() const

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

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

203 {
204  auto activeToolCondition =
205  [ this ] ( const SELECTION& aSel )
206  {
207  return ( !m_frame->ToolStackIsEmpty() );
208  };
209 
210  auto inactiveStateCondition =
211  [ this ] ( const SELECTION& aSel )
212  {
213  return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
214  };
215 
216  auto placeModuleCondition =
217  [ this ] ( const SELECTION& aSel )
218  {
219  return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
220  };
221 
222  auto& ctxMenu = m_menu.GetMenu();
223 
224  // "Cancel" goes at the top of the context menu when a tool is active
225  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
226  ctxMenu.AddSeparator( 1 );
227 
228  // "Get and Place Footprint" should be available for Place Footprint tool
229  ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
230  ctxMenu.AddSeparator( 1000 );
231 
232  // Finally, add the standard zoom & grid items
233  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
234 
235  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
236  zoneMenu->SetTool( this );
237 
238  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
239  lockMenu->SetTool( this );
240 
241  // Add the PCB control menus to relevant other tools
242 
244 
245  if( selTool )
246  {
247  auto& toolMenu = selTool->GetToolMenu();
248  auto& menu = toolMenu.GetMenu();
249 
250  // Add "Get and Place Footprint" when Selection tool is in an inactive state
251  menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
252  menu.AddSeparator();
253 
254  toolMenu.AddSubMenu( zoneMenu );
255  toolMenu.AddSubMenu( lockMenu );
256 
257  menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
258 
259  menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_T ), 200 );
260  }
261 
262  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
263 
264  if( drawingTool )
265  {
266  auto& toolMenu = drawingTool->GetToolMenu();
267  auto& menu = toolMenu.GetMenu();
268 
269  toolMenu.AddSubMenu( zoneMenu );
270 
271  // Functor to say if the PCB_EDIT_FRAME is in a given mode
272  // Capture the tool pointer and tool mode by value
273  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
274  {
275  return [=]( const SELECTION& sel )
276  {
277  return drawingTool->GetDrawingMode() == aMode;
278  };
279  };
280 
281  menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
282  }
283 
284  return true;
285 }
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:215
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
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:117
class ZONE, a copper pour area
Definition: typeinfo.h:105
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:164
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.

◆ 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:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
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 1086 of file board_editor_control.cpp.

1087 {
1088  return modifyLockSelected( ON );
1089 }
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 1098 of file board_editor_control.cpp.

1099 {
1101  const PCB_SELECTION& selection = selTool->GetSelection();
1102  BOARD_COMMIT commit( m_frame );
1103 
1104  if( selection.Empty() )
1106 
1107  // Resolve TOGGLE mode
1108  if( aMode == TOGGLE )
1109  {
1110  aMode = ON;
1111 
1112  for( EDA_ITEM* item : selection )
1113  {
1114  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1115 
1116  if( board_item->IsLocked() )
1117  {
1118  aMode = OFF;
1119  break;
1120  }
1121  }
1122  }
1123 
1124  bool modified = false;
1125 
1126  for( EDA_ITEM* item : selection )
1127  {
1128  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1129 
1130  commit.Modify( board_item );
1131 
1132  if( aMode == ON )
1133  {
1134  modified |= !board_item->IsLocked();
1135  board_item->SetLocked( true );
1136  }
1137  else
1138  {
1139  modified |= board_item->IsLocked();
1140  board_item->SetLocked( false );
1141  }
1142  }
1143 
1144  if( modified )
1145  {
1146  commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ) );
1148  m_frame->OnModify();
1149  }
1150 
1151  return 0;
1152 }
void OnModify() override
Must be called after a board change to set the modified flag.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
Definition: board_item.h:257
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:206
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
const PCB_SELECTION & selection() const
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
virtual bool IsLocked() const
Definition: board_item.h:249
#define _(s)
Definition: 3d_actions.cpp:33
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:60

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::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionCursor, BOARD_ITEM::SetLocked(), and TOGGLE.

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

◆ New()

int BOARD_EDITOR_CONTROL::New ( const TOOL_EVENT aEvent)

Definition at line 288 of file board_editor_control.cpp.

289 {
291  return 0;
292 }
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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 295 of file board_editor_control.cpp.

296 {
298  return 0;
299 }
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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 323 of file board_editor_control.cpp.

324 {
325  PICKED_ITEMS_LIST undoCmd;
326  DS_PROXY_UNDO_ITEM* undoItem = new DS_PROXY_UNDO_ITEM( m_frame );
327  ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
328 
329  undoCmd.PushItem( wrapper );
331 
334  dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
335 
336  if( dlg.ShowModal() != wxID_OK )
338 
339  return 0;
340 }
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:577
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:177
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:89
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition: page_info.h:40
A holder to handle information on schematic or board items.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
#define IU_PER_MILS
Definition: plotter.cpp:137

References IU_PER_MILS, m_frame, BASE_SCREEN::m_PageLayoutDescrFileName, 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 912 of file board_editor_control.cpp.

913 {
914  FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
916  BOARD_COMMIT commit( m_frame );
917  BOARD* board = getModel<BOARD>();
918 
920  controls->ShowCursor( true );
921 
922  std::string tool = aEvent.GetCommandStr().get();
923  m_frame->PushTool( tool );
924  Activate();
925 
926  VECTOR2I cursorPos = controls->GetCursorPosition();
927  bool reselect = false;
928  bool fromOtherCommand = fp != nullptr;
929 
930  // Prime the pump
931  if( fp )
932  {
933  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
936  }
937  else if( !aEvent.IsReactivate() )
939 
940  auto setCursor =
941  [&]()
942  {
944  };
945 
946  // Set initial cursor
947  setCursor();
948 
949  // Main loop: keep receiving events
950  while( TOOL_EVENT* evt = Wait() )
951  {
952  setCursor();
953  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
954 
955  if( reselect && fp )
957 
958  auto cleanup =
959  [&] ()
960  {
962  commit.Revert();
963 
964  if( fromOtherCommand )
965  {
967 
968  if( undo )
969  {
971  undo->ClearListAndDeleteItems();
972  delete undo;
973  }
974  }
975 
976  fp = NULL;
977  };
978 
979  if( evt->IsCancelInteractive() )
980  {
981  if( fp )
982  cleanup();
983  else
984  {
985  m_frame->PopTool( tool );
986  break;
987  }
988  }
989  else if( evt->IsActivate() )
990  {
991  if( fp )
992  cleanup();
993 
994  if( evt->IsMoveTool() )
995  {
996  // leave ourselves on the stack so we come back after the move
997  break;
998  }
999  else
1000  {
1001  frame()->PopTool( tool );
1002  break;
1003  }
1004  }
1005  else if( evt->IsClick( BUT_LEFT ) )
1006  {
1007  if( !fp )
1008  {
1009  // Pick the footprint to be placed
1011 
1012  if( fp == NULL )
1013  continue;
1014 
1015  fp->SetLink( niluuid );
1016 
1017  fp->SetFlags(IS_NEW ); // whatever
1018 
1019  // Set parent so that clearance can be loaded
1020  fp->SetParent( board );
1021 
1022  for( PAD* pad : fp->Pads() )
1023  {
1024  pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest );
1025 
1026  // Pads in the library all have orphaned nets. Replace with Default.
1027  pad->SetNetCode( 0 );
1028  }
1029 
1030  // Put it on FRONT layer,
1031  // (Can be stored flipped if the lib is an archive built from a board)
1032  if( fp->IsFlipped() )
1033  fp->Flip( fp->GetPosition(), m_frame->Settings().m_FlipLeftRight );
1034 
1035  fp->SetOrientation( 0 );
1036  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1037 
1038  commit.Add( fp );
1040  controls->SetCursorPosition( cursorPos, false );
1041  }
1042  else
1043  {
1045  commit.Push( _( "Place a footprint" ) );
1046  fp = NULL; // to indicate that there is no footprint that we currently modify
1047  }
1048  }
1049  else if( evt->IsClick( BUT_RIGHT ) )
1050  {
1052  }
1053  else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
1054  {
1055  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1056  selection().SetReferencePoint( cursorPos );
1057  getView()->Update( &selection() );
1058  getView()->Update( fp );
1059  }
1060  else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
1061  {
1062  // Calling 'Properties' action clears the selection, so we need to restore it
1063  reselect = true;
1064  }
1065  else
1066  {
1067  evt->SetPassEvent();
1068  }
1069 
1070  // Enable autopanning and cursor capture only when there is a footprint to be placed
1071  controls->SetAutoPan( !!fp );
1072  controls->CaptureCursor( !!fp );
1073  }
1074 
1076  return 0;
1077 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
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
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:215
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:121
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
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:373
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:166
PADS & Pads()
Definition: footprint.h:164
PCB_BASE_EDIT_FRAME * frame() const
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:264
const PCB_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
#define NULL
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:443
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1557
Generic, UI-independent tool event.
Definition: tool_event.h:173
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1367
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,...
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.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
bool IsFlipped() const
Definition: footprint.h:272
void SetLink(const KIID &aLink)
Definition: footprint.h:538
KIGFX::VIEW_CONTROLS * controls() const
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:66
PCBNEW_SETTINGS & Settings()
wxPoint GetPosition() const override
Definition: footprint.h:182
bool IsReactivate() const
Definition: tool_event.h:273
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:60
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1438
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
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
static TOOL_ACTION refreshPreview
Definition: actions.h:109
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:126
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:1503

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, TOOL_INTERACTIVE::m_menu, PCB_DISPLAY_OPTIONS::m_ShowGlobalRatsnest, TOOL_BASE::m_toolMgr, MD_ALT, niluuid, NULL, 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 1155 of file board_editor_control.cpp.

1156 {
1157  KIGFX::VIEW* view = getView();
1159  BOARD* board = getModel<BOARD>();
1160  PCB_TARGET* target = new PCB_TARGET( board );
1161 
1162  // Init the new item attributes
1163  target->SetLayer( Edge_Cuts );
1165  target->SetSize( Millimeter2iu( 5 ) );
1166  VECTOR2I cursorPos = controls->GetCursorPosition();
1167  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1168 
1169  // Add a VIEW_GROUP that serves as a preview for the new item
1170  KIGFX::VIEW_GROUP preview( view );
1171  preview.Add( target );
1172  view->Add( &preview );
1173 
1175 
1176  std::string tool = aEvent.GetCommandStr().get();
1177  m_frame->PushTool( tool );
1178  Activate();
1179 
1180  auto setCursor =
1181  [&]()
1182  {
1184  };
1185 
1186  // Set initial cursor
1187  setCursor();
1188 
1189  // Main loop: keep receiving events
1190  while( TOOL_EVENT* evt = Wait() )
1191  {
1192  setCursor();
1193  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
1194 
1195  if( evt->IsCancelInteractive() )
1196  {
1197  frame()->PopTool( tool );
1198  break;
1199  }
1200  else if( evt->IsActivate() )
1201  {
1202  if( evt->IsMoveTool() )
1203  {
1204  // leave ourselves on the stack so we come back after the move
1205  break;
1206  }
1207  else
1208  {
1209  frame()->PopTool( tool );
1210  break;
1211  }
1212  }
1213  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1214  {
1215  target->SetWidth( target->GetWidth() + WIDTH_STEP );
1216  view->Update( &preview );
1217  }
1218  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
1219  {
1220  int width = target->GetWidth();
1221 
1222  if( width > WIDTH_STEP )
1223  {
1224  target->SetWidth( width - WIDTH_STEP );
1225  view->Update( &preview );
1226  }
1227  }
1228  else if( evt->IsClick( BUT_LEFT ) )
1229  {
1230  assert( target->GetSize() > 0 );
1231  assert( target->GetWidth() > 0 );
1232 
1233  BOARD_COMMIT commit( m_frame );
1234  commit.Add( target );
1235  commit.Push( "Place a layer alignment target" );
1236 
1237  preview.Remove( target );
1238 
1239  // Create next PCB_TARGET
1240  target = new PCB_TARGET( *target );
1241  preview.Add( target );
1242  }
1243  else if( evt->IsClick( BUT_RIGHT ) )
1244  {
1246  }
1247  else if( evt->IsMotion() )
1248  {
1249  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1250  view->Update( &preview );
1251  }
1252  else
1253  {
1254  evt->SetPassEvent();
1255  }
1256  }
1257 
1258  preview.Clear();
1259  delete target;
1260  view->Remove( &preview );
1261 
1263  return 0;
1264 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
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:174
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:194
void SetSize(int aSize)
Definition: pcb_target.h:66
int GetSize() const
Definition: pcb_target.h:67
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:215
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:141
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
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:177
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:70
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:60
Generic, UI-independent tool event.
Definition: tool_event.h:173
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
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
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:69
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:67
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, TOOL_INTERACTIVE::m_menu, TOOL_BASE::m_toolMgr, MD_ALT, 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 343 of file board_editor_control.cpp.

344 {
346  return 0;
347 }
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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 494 of file board_editor_control.cpp.

495 {
496  int errors = 0;
497  wxString details;
498 
499  /*******************************
500  * Repair duplicate IDs and missing nets
501  */
502 
503  std::set<KIID> ids;
504  int duplicates = 0;
505 
506  auto processItem =
507  [&]( EDA_ITEM* aItem )
508  {
509  if( ids.count( aItem->m_Uuid ) )
510  {
511  duplicates++;
512  const_cast<KIID&>( aItem->m_Uuid ) = KIID();
513  }
514 
515  ids.insert( aItem->m_Uuid );
516 
517  BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
518 
519  if( cItem && cItem->GetNetCode() )
520  {
521  NETINFO_ITEM* netinfo = cItem->GetNet();
522 
523  if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
524  {
525  board()->Add( netinfo );
526 
527  details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
528  netinfo->GetNetname() );
529  errors++;
530  }
531  }
532  };
533 
534  // Footprint IDs are the most important, so give them the first crack at "claiming" a
535  // particular KIID.
536 
537  for( FOOTPRINT* footprint : board()->Footprints() )
538  processItem( footprint );
539 
540  // After that the principal use is for DRC marker pointers, which are most likely to pads
541  // or tracks.
542 
543  for( FOOTPRINT* footprint : board()->Footprints() )
544  {
545  for( PAD* pad : footprint->Pads() )
546  processItem( pad );
547  }
548 
549  for( TRACK* track : board()->Tracks() )
550  processItem( track );
551 
552  // From here out I don't think order matters much.
553 
554  for( FOOTPRINT* footprint : board()->Footprints() )
555  {
556  processItem( &footprint->Reference() );
557  processItem( &footprint->Value() );
558 
559  for( BOARD_ITEM* item : footprint->GraphicalItems() )
560  processItem( item );
561 
562  for( ZONE* zone : footprint->Zones() )
563  processItem( zone );
564 
565  for( PCB_GROUP* group : footprint->Groups() )
566  processItem( group );
567  }
568 
569  for( BOARD_ITEM* drawing : board()->Drawings() )
570  processItem( drawing );
571 
572  for( ZONE* zone : board()->Zones() )
573  processItem( zone );
574 
575  for( PCB_MARKER* marker : board()->Markers() )
576  processItem( marker );
577 
578  for( PCB_GROUP* group : board()->Groups() )
579  processItem( group );
580 
581  if( duplicates )
582  {
583  errors += duplicates;
584  details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
585  }
586 
587  /*******************************
588  * Your test here
589  */
590 
591  /*******************************
592  * Inform the user
593  */
594 
595  if( errors )
596  {
597  m_frame->OnModify();
598 
599  wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
600  DisplayInfoMessage( m_frame, msg, details );
601  }
602  else
603  {
604  DisplayInfoMessage( m_frame, _( "No board problems found." ) );
605  }
606 
607  return 0;
608 }
void OnModify() override
Must be called after a board change to set the modified flag.
ZONES & Zones()
Definition: board.h:311
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:82
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:325
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
MARKERS & Markers()
Definition: board.h:314
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
PADS & Pads()
Definition: footprint.h:164
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:468
FP_TEXT & Reference()
Definition: footprint.h:469
FP_ZONES & Zones()
Definition: footprint.h:170
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:563
Definition: kiid.h:44
FOOTPRINTS & Footprints()
Definition: board.h:305
FOOTPRINT * footprint() const
const wxString & GetNetname() const
Definition: netinfo.h:119
DRAWINGS & GraphicalItems()
Definition: footprint.h:167
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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:173
Handle the data for a net.
Definition: netinfo.h:64
#define _(s)
Definition: 3d_actions.cpp:33
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
Definition: pad.h:60
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:280
DRAWINGS & Drawings()
Definition: board.h:308
TRACKS & Tracks()
Definition: board.h:302
Definition: track.h:83

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(), 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 189 of file board_editor_control.cpp.

190 {
191  m_frame = getEditFrame<PCB_EDIT_FRAME>();
192 
193  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
194  {
195  m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin );
196  getView()->Remove( m_placeOrigin.get() );
197  getView()->Add( m_placeOrigin.get() );
198  }
199 }
Model changes (required full reload)
Definition: tool_base.h:81
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:352
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:322
Rendering engine changes.
Definition: tool_base.h:82

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:215
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 302 of file board_editor_control.cpp.

303 {
305  return 0;
306 }
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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 309 of file board_editor_control.cpp.

310 {
312  return 0;
313 }
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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 316 of file board_editor_control.cpp.

317 {
319  return 0;
320 }
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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 301 of file pcb_tool_base.cpp.

302 {
304 
305  return selTool->GetSelection();
306 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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(), 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 309 of file pcb_tool_base.cpp.

310 {
312 
313  return selTool->GetSelection();
314 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:215
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 104 of file pcb_tool_base.h.

104 { 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 1475 of file board_editor_control.cpp.

1476 {
1477  Go( &BOARD_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1478  Go( &BOARD_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1479  Go( &BOARD_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1483  Go( &BOARD_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1484 
1489 
1490  if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame &&
1493 
1500 
1501  // Track & via size control
1506 
1507  // Zone actions
1510 
1511  // Placing tools
1515 
1517 
1518  // Other
1522 
1529 }
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 New(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:423
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:336
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:346
static TOOL_ACTION pageSettings
Definition: actions.h:59
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:302
int Plot(const TOOL_EVENT &aEvent)
int GeneratePosFile(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:301
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:348
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:347
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:166
int ImportNetlist(const TOOL_EVENT &aEvent)
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:339
int PageSettings(const TOOL_EVENT &aEvent)
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:340
static TOOL_ACTION saveCopyAs
Definition: actions.h:56
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:300
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:167
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:331
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:53
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION doNew
Definition: actions.h:47
int BoardSetup(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:312
int SaveAs(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
static TOOL_ACTION plot
Definition: actions.h:61
int RepairBoard(const TOOL_EVENT &aEvent)
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:439
static TOOL_ACTION generatePosFile
Definition: pcb_actions.h:338
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:162
int ShowEeschema(const TOOL_EVENT &aEvent)
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:318
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:333
int ExportNetlist(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:315
TOOL_ACTION * GetExportNetlistAction()
int ImportSpecctraSession(const TOOL_EVENT &aEvent)
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:341
int ZoneMerge(const TOOL_EVENT &aEvent)
Duplicate a zone onto a layer (prompts for new layer)
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:164
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:334
static TOOL_ACTION saveAs
Definition: actions.h:55
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.h:123
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)
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:303
int PlaceTarget(const TOOL_EVENT &aEvent)
Allow user to place a layer alignment target.
static TOOL_ACTION generateDrillFiles
Definition: pcb_actions.h:337
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, 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(), PageSettings(), ACTIONS::pageSettings, PlaceFootprint(), PCB_ACTIONS::placeFootprint, PlaceTarget(), PCB_ACTIONS::placeTarget, Plot(), ACTIONS::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 648 of file board_editor_control.cpp.

649 {
650  m_frame->RunEeschema();
651  return 0;
652 }
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.

References m_frame, and PCB_EDIT_FRAME::RunEeschema().

Referenced by setTransitions().

◆ ToggleLayersManager()

int BOARD_EDITOR_CONTROL::ToggleLayersManager ( const TOOL_EVENT aEvent)

Definition at line 655 of file board_editor_control.cpp.

656 {
657  getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
658  return 0;
659 }

Referenced by setTransitions().

◆ ToggleLockSelected()

int BOARD_EDITOR_CONTROL::ToggleLockSelected ( const TOOL_EVENT aEvent)

Lock selected items.

Definition at line 1080 of file board_editor_control.cpp.

1081 {
1082  return modifyLockSelected( TOGGLE );
1083 }
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 662 of file board_editor_control.cpp.

663 {
664 #if defined( KICAD_SCRIPTING_WXPYTHON )
665  m_frame->ScriptingConsoleEnableDisable();
666 #endif
667  return 0;
668 }
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.

References m_frame.

Referenced by setTransitions().

◆ TrackWidthDec()

int BOARD_EDITOR_CONTROL::TrackWidthDec ( const TOOL_EVENT aEvent)

Definition at line 738 of file board_editor_control.cpp.

739 {
740  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
741  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
743 
745  {
746  BOARD_COMMIT commit( this );
747 
748  for( EDA_ITEM* item : selection )
749  {
750  if( item->Type() == PCB_TRACE_T )
751  {
752  TRACK* track = (TRACK*) item;
753 
754  for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 0; --i )
755  {
756  int candidate = designSettings.m_TrackWidthList[ i ];
757 
758  if( candidate < track->GetWidth() )
759  {
760  commit.Modify( track );
761  track->SetWidth( candidate );
762  break;
763  }
764  }
765  }
766  }
767 
768  commit.Push( "Decrease Track Width" );
769  return 0;
770  }
771 
772  ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
773 
774  if( routerTool && routerTool->IsToolActive()
775  && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
776  {
777  int widthIndex = designSettings.GetDiffPairIndex() - 1;
778 
779  // If we get to the lowest entry start over at the highest
780  if( widthIndex < 0 )
781  widthIndex = designSettings.m_DiffPairDimensionsList.size() - 1;
782 
783  designSettings.SetDiffPairIndex( widthIndex );
784  designSettings.UseCustomDiffPairDimensions( false );
785 
787  }
788  else
789  {
790  int widthIndex = designSettings.GetTrackWidthIndex() - 1;
791 
792  // If we get to the lowest entry start over at the highest
793  if( widthIndex < 0 )
794  widthIndex = designSettings.m_TrackWidthList.size() - 1;
795 
796  designSettings.SetTrackWidthIndex( widthIndex );
797  designSettings.UseCustomTrackViaSize( false );
798 
800  }
801 
802  return 0;
803 }
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:215
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:141
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:305
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 TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void SetWidth(int aWidth)
Definition: track.h:109
const PCB_SELECTION & selection() const
unsigned GetTrackWidthIndex() const
bool ToolStackIsEmpty()
Definition: tools_holder.h:117
void SetDiffPairIndex(unsigned aIndex)
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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:150
class 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
Definition: track.h:83
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(), 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 672 of file board_editor_control.cpp.

673 {
674  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
675  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
677 
679  {
680  BOARD_COMMIT commit( this );
681 
682  for( EDA_ITEM* item : selection )
683  {
684  if( item->Type() == PCB_TRACE_T )
685  {
686  TRACK* track = (TRACK*) item;
687 
688  for( int candidate : designSettings.m_TrackWidthList )
689  {
690  if( candidate > track->GetWidth() )
691  {
692  commit.Modify( track );
693  track->SetWidth( candidate );
694  break;
695  }
696  }
697  }
698  }
699 
700  commit.Push( "Increase Track Width" );
701  return 0;
702  }
703 
704  ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
705 
706  if( routerTool && routerTool->IsToolActive()
707  && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
708  {
709  int widthIndex = designSettings.GetDiffPairIndex() + 1;
710 
711  // If we go past the last track width entry in the list, start over at the beginning
712  if( widthIndex >= (int) designSettings.m_DiffPairDimensionsList.size() )
713  widthIndex = 0;
714 
715  designSettings.SetDiffPairIndex( widthIndex );
716  designSettings.UseCustomDiffPairDimensions( false );
717 
719  }
720  else
721  {
722  int widthIndex = designSettings.GetTrackWidthIndex() + 1;
723 
724  // If we go past the last track width entry in the list, start over at the beginning
725  if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
726  widthIndex = 0;
727 
728  designSettings.SetTrackWidthIndex( widthIndex );
729  designSettings.UseCustomTrackViaSize( false );
730 
732  }
733 
734  return 0;
735 }
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:215
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:141
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:305
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 TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void SetWidth(int aWidth)
Definition: track.h:109
const PCB_SELECTION & selection() const
unsigned GetTrackWidthIndex() const
bool ToolStackIsEmpty()
Definition: tools_holder.h:117
void SetDiffPairIndex(unsigned aIndex)
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int GetWidth() const
Definition: track.h:110
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:150
class 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
Definition: track.h:83
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(), 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(), 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 1092 of file board_editor_control.cpp.

1093 {
1094  return modifyLockSelected( OFF );
1095 }
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 611 of file board_editor_control.cpp.

612 {
614 
615  if( m_frame->FetchNetlistFromSchematic( netlist, _( "Updating PCB requires a fully annotated "
616  "schematic." ) ) )
617  {
618  DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
619  updateDialog.ShowModal();
620  }
621 
622  return 0;
623 }
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:205
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
#define _(s)
Definition: 3d_actions.cpp:33

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

626 {
627  if( Kiface().IsSingle() )
628  {
630  m_frame, _( "Cannot update schematic because Pcbnew is opened in stand-alone "
631  "mode. In order to create or update PCBs from schematics, you "
632  "must launch the KiCad project manager and create a project." ) );
633  return 0;
634  }
635 
636  m_frame->RunEeschema();
638 
639  if( frame )
640  {
641  std::string payload;
643  }
644  return 0;
645 }
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:265
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:357
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:451
PCB_BASE_EDIT_FRAME * frame() const
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
#define _(s)
Definition: 3d_actions.cpp:33

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

856 {
857  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
858  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
860 
862  {
863  BOARD_COMMIT commit( this );
864 
865  for( EDA_ITEM* item : selection )
866  {
867  if( item->Type() == PCB_VIA_T )
868  {
869  VIA* via = (VIA*) item;
870 
871  for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
872  {
873  VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
874 
875  if( candidate.m_Diameter < via->GetWidth() )
876  {
877  commit.Modify( via );
878  via->SetWidth( candidate.m_Diameter );
879  via->SetDrill( candidate.m_Drill );
880  break;
881  }
882  }
883  }
884  }
885 
886  commit.Push( "Decrease Via Size" );
887  }
888  else
889  {
890  int sizeIndex = 0; // Assume we only have a single via size entry
891 
892  // If there are more, cycle through them backwards
893  if( designSettings.m_ViasDimensionsList.size() > 0 )
894  {
895  sizeIndex = designSettings.GetViaSizeIndex() - 1;
896 
897  // If we get to the lowest entry start over at the highest
898  if( sizeIndex < 0 )
899  sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
900  }
901 
902  designSettings.SetViaSizeIndex( sizeIndex );
903  designSettings.UseCustomTrackViaSize( false );
904 
906  }
907 
908  return 0;
909 }
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
Definition: track.h:343
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:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:305
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 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:117
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
std::vector< VIA_DIMENSION > m_ViasDimensionsList
class 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 806 of file board_editor_control.cpp.

807 {
808  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
809  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
811 
813  {
814  BOARD_COMMIT commit( this );
815 
816  for( EDA_ITEM* item : selection )
817  {
818  if( item->Type() == PCB_VIA_T )
819  {
820  VIA* via = (VIA*) item;
821 
822  for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
823  {
824  if( candidate.m_Diameter > via->GetWidth() )
825  {
826  commit.Modify( via );
827  via->SetWidth( candidate.m_Diameter );
828  via->SetDrill( candidate.m_Drill );
829  break;
830  }
831  }
832  }
833  }
834 
835  commit.Push( "Increase Via Size" );
836  }
837  else
838  {
839  int sizeIndex = designSettings.GetViaSizeIndex() + 1;
840 
841  // If we go past the last via entry in the list, start over at the beginning
842  if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
843  sizeIndex = 0;
844 
845  designSettings.SetViaSizeIndex( sizeIndex );
846  designSettings.UseCustomTrackViaSize( false );
847 
849  }
850 
851  return 0;
852 }
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
Definition: track.h:343
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:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:305
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 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:117
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
std::vector< VIA_DIMENSION > m_ViasDimensionsList
class 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:215
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 1363 of file board_editor_control.cpp.

1364 {
1366  const PCB_SELECTION& selection = selTool->GetSelection();
1367 
1368  // because this pops up the zone editor, it would be confusing to handle multiple zones,
1369  // so just handle single selections containing exactly one zone
1370  if( selection.Size() != 1 )
1371  return 0;
1372 
1373  ZONE* oldZone = dyn_cast<ZONE*>( selection[0] );
1374 
1375  if( !oldZone )
1376  return 0;
1377 
1378  ZONE_SETTINGS zoneSettings;
1379  zoneSettings << *oldZone;
1380  int dialogResult;
1381 
1382  if( oldZone->GetIsRuleArea() )
1383  dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings );
1384  else if( oldZone->IsOnCopperLayer() )
1385  dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1386  else
1387  dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1388 
1389  if( dialogResult != wxID_OK )
1390  return 0;
1391 
1392  // duplicate the zone
1393  BOARD_COMMIT commit( m_frame );
1394 
1395  std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1396  newZone->ClearSelected();
1397  newZone->UnFill();
1398  zoneSettings.ExportSetting( *newZone );
1399 
1400  // If the new zone is on the same layer(s) as the the initial zone,
1401  // offset it a bit so it can more easily be picked.
1402  if( oldZone->GetIsRuleArea() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
1403  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1404  else if( !oldZone->GetIsRuleArea() && zoneSettings.m_Layers.test( oldZone->GetLayer() ) )
1405  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1406 
1407  commit.Add( newZone.release() );
1408  commit.Push( _( "Duplicate zone" ) );
1409 
1410  return 0;
1411 }
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:215
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.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
#define _(s)
Definition: 3d_actions.cpp:33
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
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 1305 of file board_editor_control.cpp.

1306 {
1307  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1308  BOARD* board = getModel<BOARD>();
1309  BOARD_COMMIT commit( m_frame );
1310 
1311  if( selection.Size() < 2 )
1312  return 0;
1313 
1314  int netcode = -1;
1315 
1316  ZONE* firstZone = nullptr;
1317  std::vector<ZONE*> toMerge, merged;
1318 
1319  for( auto item : selection )
1320  {
1321  ZONE* curr_area = dynamic_cast<ZONE*>( item );
1322 
1323  if( !curr_area )
1324  continue;
1325 
1326  if( !firstZone )
1327  firstZone = curr_area;
1328 
1329  netcode = curr_area->GetNetCode();
1330 
1331  if( firstZone->GetNetCode() != netcode )
1332  continue;
1333 
1334  if( curr_area->GetPriority() != firstZone->GetPriority() )
1335  continue;
1336 
1337  if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1338  continue;
1339 
1340  if( curr_area->GetLayer() != firstZone->GetLayer() )
1341  continue;
1342 
1343  if( !board->TestZoneIntersection( curr_area, firstZone ) )
1344  continue;
1345 
1346  toMerge.push_back( curr_area );
1347  }
1348 
1350 
1351  if( mergeZones( commit, toMerge, merged ) )
1352  {
1353  commit.Push( "Merge zones" );
1354 
1355  for( auto item : merged )
1357  }
1358 
1359  return 0;
1360 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
BOARD * board() const
unsigned GetPriority() const
Definition: zone.h:122
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:730
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
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:216
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
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:66
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
The selection tool: currently supports:
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE * > &aOriginZones, std::vector< ZONE * > &aMergedZones)

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_isFootprintEditor

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

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

Definition at line 106 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(), GERBVIEW_SELECTION_TOOL::Init(), 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(), 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(), 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

Place & drill origin marker.

Definition at line 129 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 210 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 215 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(), 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(), SCH_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(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), EE_SELECTION_TOOL::GetNode(), 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(), EE_SELECTION_TOOL::GuessSelectionCandidates(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), BOARD_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), GROUP_TOOL::Init(), CONVERT_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_CONTROL::Init(), PL_POINT_EDITOR::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), Init(), PCB_POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), BOARD_INSPECTION_TOOL::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(), 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::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(), 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 214 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 207 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 131 of file board_editor_control.h.

Referenced by PlaceTarget().


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