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 , REDRAW }
 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 SaveCopy (const TOOL_EVENT &aEvent)
 
int Revert (const TOOL_EVENT &aEvent)
 
int PageSettings (const TOOL_EVENT &aEvent)
 
int Plot (const TOOL_EVENT &aEvent)
 
int Search (const TOOL_EVENT &aEvent)
 
int Find (const TOOL_EVENT &aEvent)
 
int FindNext (const TOOL_EVENT &aEvent)
 
int BoardSetup (const TOOL_EVENT &aEvent)
 
int ImportNetlist (const TOOL_EVENT &aEvent)
 
int ImportSpecctraSession (const TOOL_EVENT &aEvent)
 
int ExportSpecctraDSN (const TOOL_EVENT &aEvent)
 
int ExportNetlist (const TOOL_EVENT &aEvent)
 
int GenerateDrillFiles (const TOOL_EVENT &aEvent)
 
int GeneratePosFile (const TOOL_EVENT &aEvent)
 
int GenerateFabFiles (const TOOL_EVENT &aEvent)
 
int RepairBoard (const TOOL_EVENT &aEvent)
 
int UpdatePCBFromSchematic (const TOOL_EVENT &aEvent)
 
int UpdateSchematicFromPCB (const TOOL_EVENT &aEvent)
 
int ShowEeschema (const TOOL_EVENT &aEvent)
 
int ToggleLayersManager (const TOOL_EVENT &aEvent)
 
int ToggleProperties (const TOOL_EVENT &aEvent)
 
int ToggleSearch (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)
 Notify Eeschema about selected items. More...
 
int CrossProbeToSch (const TOOL_EVENT &aEvent)
 Equivalent to the above, but initiated by the user. More...
 
int ExplicitCrossProbeToSch (const TOOL_EVENT &aEvent)
 Assign a netclass to a labelled net. More...
 
int AssignNetclass (const TOOL_EVENT &aEvent)
 
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...
 
bool PlacingFootprint () const
 Re-entrancy checker for above. 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 SetIsBoardEditor (bool aEnabled)
 
bool IsBoardEditor () const
 
virtual bool Is45Limited () const
 Should the tool use its 45° mode option? More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Static Public Member Functions

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

Protected Types

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

Protected Member Functions

void doInteractiveItemPlacement (const TOOL_EVENT &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
 
PCBNEW_SETTINGS::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
 
bool m_isBoardEditor
 
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...
 
void doCrossProbePcbToSch (const TOOL_EVENT &aEvent, bool aForce)
 
void resetTransitions ()
 Clear the current transition map and restores the default one created by setTransitions(). More...
 
void goInternal (TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
 
EDA_ITEMgetModelInt () const
 
TOOLS_HOLDERgetToolHolderInt () const
 

Private Attributes

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

Static Private Attributes

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

Detailed Description

Handle actions specific to the board editor in PcbNew.

Definition at line 42 of file board_editor_control.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

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

IPO_FLIP 

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

IPO_SINGLE_CLICK 

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

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 121 of file pcb_tool_base.h.

121 {
123 IPO_ROTATE = 0x01,
124
126 IPO_FLIP = 0x02,
127
130 IPO_SINGLE_CLICK = 0x04,
131
133 IPO_REPEAT = 0x08
134 };
@ IPO_FLIP
Handle flip action in the loop by calling the item's flip method.
@ IPO_ROTATE
Handle the rotate action in the loop by calling the item's rotate method.
@ IPO_SINGLE_CLICK
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
@ IPO_REPEAT
Allow repeat placement of the item.

◆ MODIFY_MODE

< How to modify a property for selected items.

Enumerator
ON 
OFF 
TOGGLE 

Definition at line 136 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.

REDRAW 

Full drawing refresh.

Definition at line 77 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ BOARD_EDITOR_CONTROL()

BOARD_EDITOR_CONTROL::BOARD_EDITOR_CONTROL ( )

Definition at line 131 of file board_editor_control.cpp.

131 :
132 PCB_TOOL_BASE( "pcbnew.EditorControl" ),
133 m_frame( nullptr ),
134 m_inPlaceFootprint( false ),
135 m_placingFootprint( false ),
136 m_inPlaceTarget( false )
137{
138 m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
140}
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:77

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

◆ ~BOARD_EDITOR_CONTROL()

BOARD_EDITOR_CONTROL::~BOARD_EDITOR_CONTROL ( )

Definition at line 143 of file board_editor_control.cpp.

144{
145}

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(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_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(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), ROUTER_TOOL::RouteSelected(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ AssignNetclass()

int BOARD_EDITOR_CONTROL::AssignNetclass ( const TOOL_EVENT aEvent)

Definition at line 1465 of file board_editor_control.cpp.

1466{
1468
1469 const PCB_SELECTION& selection = selectionTool->RequestSelection(
1470 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1471 {
1472 // Iterate from the back so we don't have to worry about removals.
1473 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
1474 {
1475 if( !dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[ i ] ) )
1476 aCollector.Remove( aCollector[ i ] );
1477 }
1478 },
1479 true /* prompt user regarding locked items */ );
1480
1481 intptr_t netCode = -1;
1482 wxString netName;
1483
1484 for( EDA_ITEM* item : selection )
1485 {
1486 NETINFO_ITEM* net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
1487
1488 if( !net->HasAutoGeneratedNetname() )
1489 {
1490 netCode = net->GetNetCode();
1491 netName = net->GetNetname();
1492 break;
1493 }
1494 }
1495
1496 if( netName.IsEmpty() )
1497 {
1498 m_frame->ShowInfoBarError( _( "Selection contains no items with labeled nets." ) );
1499 return 0;
1500 }
1501
1502 selectionTool->ClearSelection();
1503 m_toolMgr->RunAction( PCB_ACTIONS::selectNet, true, (void*) netCode );
1504 canvas()->ForceRefresh();
1505
1506 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, board()->GetNetClassAssignmentCandidates(),
1507 [this]( const std::vector<wxString>& aNetNames )
1508 {
1510 selTool->ClearSelection();
1511
1512 for( const wxString& curr_netName : aNetNames )
1513 {
1514 int curr_netCode = board()->GetNetInfo().GetNetItem( curr_netName )->GetNetCode();
1515
1516 if( curr_netCode > 0 )
1517 selTool->SelectAllItemsOnNet( curr_netCode );
1518 }
1519
1520 canvas()->ForceRefresh();
1522 } );
1523
1524 if( dlg.ShowModal() == wxID_OK )
1525 {
1527 // Refresh UI that depends on netclasses, such as the properties panel
1529 }
1530
1531 return 0;
1532}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:784
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1546
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:109
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
virtual void UpdateMsgPanel()
Redraw the message panel.
void ForceRefresh()
Force a redraw.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:204
Handle the data for a net.
Definition: netinfo.h:67
bool HasAutoGeneratedNetname()
Definition: netinfo.h:140
const wxString & GetNetname() const
Definition: netinfo.h:125
int GetNetCode() const
Definition: netinfo.h:119
NETINFO_ITEM * GetNetItem(int aNetCode) const
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition: pcb_actions.h:86
The selection tool: currently supports:
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection, filtered according to aClientFilter.
int ClearSelection(const TOOL_EVENT &aEvent)
void SelectAllItemsOnNet(int aNetCode, bool aSelect=true)
Select all items with the given net code.
BOARD * board() const
PCB_DRAW_PANEL_GAL * canvas() const
const PCB_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
#define _(s)

References _, PCB_TOOL_BASE::board(), PCB_TOOL_BASE::canvas(), PCB_SELECTION_TOOL::ClearSelection(), EDA_DRAW_PANEL_GAL::ForceRefresh(), COLLECTOR::GetCount(), NETINFO_ITEM::GetNetCode(), BOARD::GetNetInfo(), NETINFO_LIST::GetNetItem(), NETINFO_ITEM::GetNetname(), TOOL_MANAGER::GetTool(), NETINFO_ITEM::HasAutoGeneratedNetname(), m_frame, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), PCB_SELECTION_TOOL::SelectAllItemsOnNet(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectNet, EDA_BASE_FRAME::ShowInfoBarError(), BOARD::SynchronizeNetsAndNetClasses(), and EDA_DRAW_FRAME::UpdateMsgPanel().

Referenced by setTransitions().

◆ 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}

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD * PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 170 of file pcb_tool_base.h.

170{ return getModel<BOARD>(); }

Referenced by PCB_CONTROL::AppendBoard(), AssignNetclass(), 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::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawShape(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ExportNetlist(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), PCB_TOOL_BASE::footprint(), GROUP_TOOL::Group(), ROUTER_TOOL::handleLayerSwitch(), BOARD_INSPECTION_TOOL::highlightNet(), ROUTER_TOOL::Init(), ROUTER_TOOL::InlineDrag(), 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(), DRAWING_TOOL::PlaceText(), PCB_CONTROL::pruneItemLayers(), EDIT_TOOL::rebuildConnectivity(), ZONE_FILLER_TOOL::rebuildConnectivity(), PAD_TOOL::RecombinePad(), RepairBoard(), FOOTPRINT_EDITOR_CONTROL::RepairFootprint(), PNS::TOOL_BASE::Reset(), PAD_TOOL::Reset(), PCB_CONTROL::Reset(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::unfilledZoneCheck(), GROUP_TOOL::Ungroup(), ROUTER_TOOL::UpdateMessagePanel(), ROUTER_TOOL::updateSizesAfterLayerSwitch(), PCB_CONTROL::ViaDisplayMode(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillDirty(), ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ BoardSetup()

int BOARD_EDITOR_CONTROL::BoardSetup ( const TOOL_EVENT aEvent)

Definition at line 358 of file board_editor_control.cpp.

359{
360 getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
361 return 0;
362}

Referenced by setTransitions().

◆ canvas()

◆ controls()

◆ CrossProbeToSch()

int BOARD_EDITOR_CONTROL::CrossProbeToSch ( const TOOL_EVENT aEvent)

Equivalent to the above, but initiated by the user.

Definition at line 1429 of file board_editor_control.cpp.

1430{
1431 doCrossProbePcbToSch( aEvent, false );
1432
1433 return 0;
1434}
void doCrossProbePcbToSch(const TOOL_EVENT &aEvent, bool aForce)

References doCrossProbePcbToSch().

Referenced by setTransitions().

◆ displayOptions()

◆ doCrossProbePcbToSch()

void BOARD_EDITOR_CONTROL::doCrossProbePcbToSch ( const TOOL_EVENT aEvent,
bool  aForce 
)
private

Definition at line 1445 of file board_editor_control.cpp.

1446{
1447 // Don't get in an infinite loop PCB -> SCH -> PCB -> SCH -> ...
1449 return;
1450
1452 const PCB_SELECTION& selection = selTool->GetSelection();
1453 EDA_ITEM* focusItem = nullptr;
1454
1455 if( aEvent.Matches( EVENTS::PointSelectedEvent ) )
1456 focusItem = selection.GetLastAddedItem();
1457
1458 m_frame->SendSelectItemsToSch( selection.GetItems(), focusItem, aForce );
1459
1460 // Update 3D viewer highlighting
1462}
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:206
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void SendSelectItemsToSch(const std::deque< EDA_ITEM * > &aItems, EDA_ITEM *aFocusItem, bool aForce)
Send a message to the schematic editor to try to find schematic counterparts of specified PCB items a...
PCB_SELECTION & GetSelection()
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:120
EDA_ITEM * GetLastAddedItem() const
Definition: selection.h:125
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:365

References PCB_TOOL_BASE::frame(), SELECTION::GetItems(), SELECTION::GetLastAddedItem(), PCB_BASE_FRAME::GetPcbNewSettings(), PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), PCBNEW_SETTINGS::m_Display, m_frame, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_Live3DRefresh, PCB_EDIT_FRAME::m_probingSchToPcb, TOOL_BASE::m_toolMgr, TOOL_EVENT::Matches(), EVENTS::PointSelectedEvent, PCB_TOOL_BASE::selection(), PCB_EDIT_FRAME::SendSelectItemsToSch(), and PCB_BASE_FRAME::Update3DView().

Referenced by CrossProbeToSch(), and ExplicitCrossProbeToSch().

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const TOOL_EVENT 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 41 of file pcb_tool_base.cpp.

44{
45 using namespace std::placeholders;
46 std::unique_ptr<BOARD_ITEM> newItem;
47
48 frame()->PushTool( aTool );
49
50 BOARD_COMMIT commit( frame() );
51
53
54 Activate();
55 // Must be done after Activate() so that it gets set into the correct context
56 controls()->ShowCursor( true );
57 controls()->ForceCursorPosition( false );
58 // do not capture or auto-pan until we start placing an item
59
60 PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
61
62 // Add a VIEW_GROUP that serves as a preview for the new item
63 PCB_SELECTION preview;
64 view()->Add( &preview );
65
66 aPlacer->m_board = board();
67 aPlacer->m_frame = frame();
68 aPlacer->m_modifiers = 0;
69
70 auto makeNewItem =
71 [&]( VECTOR2I aPosition )
72 {
73 if( frame()->GetModel() )
74 newItem = aPlacer->CreateItem();
75
76 if( newItem )
77 {
78 newItem->SetPosition( aPosition );
79 preview.Add( newItem.get() );
80
81 if( newItem->Type() == PCB_FOOTPRINT_T )
82 {
83 FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
84
85 // footprints have more drawable parts
86 fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
87 }
88 }
89 };
90
91 if( aOptions & IPO_SINGLE_CLICK )
92 makeNewItem( controls()->GetCursorPosition() );
93
94 auto setCursor =
95 [&]()
96 {
97 if( !newItem )
99 else
101 };
102
103 // Set initial cursor
104 setCursor();
105
106 // Main loop: keep receiving events
107 while( TOOL_EVENT* evt = Wait() )
108 {
109 setCursor();
110
111 grid.SetSnap( false ); // Interactive placement tools need to set their own item snaps
112 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
113 VECTOR2I cursorPos = grid.BestSnapAnchor( controls()->GetMousePosition(), nullptr );
114
115 aPlacer->m_modifiers = evt->Modifier();
116
117 auto cleanup =
118 [&] ()
119 {
120 newItem = nullptr;
121 preview.Clear();
122 view()->Update( &preview );
123 controls()->SetAutoPan( false );
124 controls()->CaptureCursor( false );
125 controls()->ShowCursor( true );
126 controls()->ForceCursorPosition( false );
127 };
128
129 if( evt->IsCancelInteractive() )
130 {
131 if( aOptions & IPO_SINGLE_CLICK )
132 {
133 cleanup();
134 frame()->PopTool( aTool );
135 break;
136 }
137 else if( newItem )
138 {
139 cleanup();
140 }
141 else
142 {
143 frame()->PopTool( aTool );
144 break;
145 }
146 }
147 else if( evt->IsActivate() )
148 {
149 if( newItem )
150 cleanup();
151
152 if( evt->IsPointEditor() )
153 {
154 // don't exit (the point editor runs in the background)
155 }
156 else if( evt->IsMoveTool() )
157 {
158 // leave ourselves on the stack so we come back after the move
159 break;
160 }
161 else
162 {
163 frame()->PopTool( aTool );
164 break;
165 }
166 }
167 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
168 {
169 if( !newItem )
170 {
171 // create the item if possible
172 makeNewItem( cursorPos );
173
174 // no item created, so wait for another click
175 if( !newItem )
176 continue;
177
178 controls()->CaptureCursor( true );
179 controls()->SetAutoPan( true );
180 }
181 else
182 {
183 BOARD_ITEM* newBoardItem = newItem.release();
184 EDA_ITEM_FLAGS oldFlags = newBoardItem->GetFlags();
185
186 newBoardItem->ClearFlags();
187
188 if( !aPlacer->PlaceItem( newBoardItem, commit ) )
189 {
190 newBoardItem->SetFlags( oldFlags );
191 newItem.reset( newBoardItem );
192 continue;
193 }
194
195 preview.Clear();
196 commit.Push( aCommitMessage );
197
198 controls()->CaptureCursor( false );
199 controls()->SetAutoPan( false );
200 controls()->ShowCursor( true );
201
202 if( !( aOptions & IPO_REPEAT ) )
203 break;
204
205 if( aOptions & IPO_SINGLE_CLICK )
206 makeNewItem( controls()->GetCursorPosition() );
207
208 setCursor();
209 }
210 }
211 else if( evt->IsClick( BUT_RIGHT ) )
212 {
214 }
215 else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
216 {
218 }
219 else if( newItem && evt->Category() == TC_COMMAND )
220 {
221 /*
222 * Handle any events that can affect the item as we move it around
223 */
224 if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
225 {
226 EDA_ANGLE rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
227 newItem->Rotate( newItem->GetPosition(), rotationAngle );
228 view()->Update( &preview );
229 }
230 else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
231 {
232 newItem->Flip( newItem->GetPosition(), frame()->GetPcbNewSettings()->m_FlipLeftRight );
233 view()->Update( &preview );
234 }
235 else if( evt->IsAction( &PCB_ACTIONS::properties ) )
236 {
237 frame()->OnEditItemRequest( newItem.get() );
238
239 // Notify other tools of the changes
241 }
242 else if( evt->IsAction( &ACTIONS::refreshPreview ) )
243 {
244 preview.Clear();
245 newItem.reset();
246
247 makeNewItem( cursorPos );
248 aPlacer->SnapItem( newItem.get() );
249 view()->Update( &preview );
250 }
251 else
252 {
253 evt->SetPassEvent();
254 }
255 }
256 else if( newItem && evt->IsMotion() )
257 {
258 // track the cursor
259 newItem->SetPosition( cursorPos );
260 aPlacer->SnapItem( newItem.get() );
261
262 // Show a preview of the item
263 view()->Update( &preview );
264 }
265 else
266 {
267 evt->SetPassEvent();
268 }
269 }
270
271 view()->Remove( &preview );
273 controls()->SetAutoPan( false );
274 controls()->CaptureCursor( false );
275 controls()->ForceCursorPosition( false );
276}
static TOOL_ACTION refreshPreview
Definition: actions.h:110
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:70
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:142
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:1393
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
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:57
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:338
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:149
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:126
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
KIGFX::PCB_VIEW * view() const
KIGFX::VIEW_CONTROLS * controls() const
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:42
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:92
virtual void PopTool(const TOOL_EVENT &aEvent)
Pops a tool from the stack.
virtual void PushTool(const TOOL_EVENT &aEvent)
NB: the definition of "tool" is different at the user level.
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:144
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Generic, UI-independent tool event.
Definition: tool_event.h:156
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
void Activate()
Run the tool.
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:57
std::uint32_t EDA_ITEM_FLAGS
EDA_ANGLE GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvent)
Function getEventRotationAngle()
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void SnapItem(BOARD_ITEM *aItem)
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:64
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
@ TC_COMMAND
Definition: tool_event.h:52
@ BUT_LEFT
Definition: tool_event.h:127
@ BUT_RIGHT
Definition: tool_event.h:128
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), KIGFX::VIEW_GROUP::Add(), KIGFX::PCB_VIEW::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), EDA_ITEM::ClearFlags(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVT_UTILS::GetEventRotationAngle(), EDA_ITEM::GetFlags(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), TOOL_BASE::getView(), grid, PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, 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(), EDA_ITEM::SetFlags(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, PCB_ACTIONS::trackViaSizeChanged, KIGFX::PCB_VIEW::Update(), PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

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

◆ DoSetDrillOrigin()

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

Definition at line 1567 of file board_editor_control.cpp.

1569{
1570 aFrame->GetDesignSettings().SetAuxOrigin( VECTOR2I( aPosition ) );
1571 originViewItem->SetPosition( aPosition );
1572 aView->MarkDirty();
1573 aFrame->OnModify();
1574}
void SetAuxOrigin(const VECTOR2I &aOrigin)
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:641
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

References PCB_BASE_FRAME::GetDesignSettings(), KIGFX::VIEW::MarkDirty(), PCB_BASE_FRAME::OnModify(), BOARD_DESIGN_SETTINGS::SetAuxOrigin(), 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 1577 of file board_editor_control.cpp.

1578{
1580
1581 // Deactivate other tools; particularly important if another PICKER is currently running
1582 Activate();
1583
1584 picker->SetClickHandler(
1585 [this] ( const VECTOR2D& pt ) -> bool
1586 {
1589 return false; // drill origin is a one-shot; don't continue with tool
1590 } );
1591
1593
1594 return 0;
1595}
static TOOL_ACTION pickerTool
Definition: actions.h:159
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:282
Generic tool for picking an item.
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71

References TOOL_INTERACTIVE::Activate(), DoSetDrillOrigin(), DRILLORIGIN, 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)

Notify Eeschema about selected items.

Definition at line 1535 of file board_editor_control.cpp.

1536{
1539
1540 if( selection.Empty() )
1541 return 0;
1542
1544
1545 if( !fp )
1546 return 0;
1547
1548 PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1549
1550 auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1551
1553 editor->LoadFootprintFromBoard( fp );
1554 else if( aEvent.IsAction( &PCB_ACTIONS::editLibFpInFpEditor ) )
1555 editor->LoadFootprintFromLibrary( fp->GetFPID() );
1556
1557 editor->Show( true );
1558 editor->Raise(); // Iconize( false );
1559
1560 if( selection.IsHover() )
1562
1563 return 0;
1564}
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:2375
const LIB_ID & GetFPID() const
Definition: footprint.h:212
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:386
static TOOL_ACTION editLibFpInFpEditor
Definition: pcb_actions.h:387
Common, abstract interface for edit frames.
T * FirstOfKind() const
Definition: selection.h:224
bool IsHover() const
Definition: selection.h:83
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
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:81
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41

References PCB_ACTIONS::editFpInFpEditor, PCB_ACTIONS::editLibFpInFpEditor, editor, SELECTION::Empty(), SELECTION::FirstOfKind(), EDIT_TOOL::FootprintFilter(), FRAME_FOOTPRINT_EDITOR, FOOTPRINT::GetFPID(), TOOL_MANAGER::GetTool(), TOOL_EVENT::IsAction(), 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().

◆ ExplicitCrossProbeToSch()

int BOARD_EDITOR_CONTROL::ExplicitCrossProbeToSch ( const TOOL_EVENT aEvent)

Assign a netclass to a labelled net.

Definition at line 1437 of file board_editor_control.cpp.

1438{
1439 doCrossProbePcbToSch( aEvent, true );
1440
1441 return 0;
1442}

References doCrossProbePcbToSch().

Referenced by setTransitions().

◆ ExportNetlist()

int BOARD_EDITOR_CONTROL::ExportNetlist ( const TOOL_EVENT aEvent)

Definition at line 423 of file board_editor_control.cpp.

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

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

Referenced by setTransitions().

◆ ExportSpecctraDSN()

int BOARD_EDITOR_CONTROL::ExportSpecctraDSN ( const TOOL_EVENT aEvent)

Definition at line 394 of file board_editor_control.cpp.

395{
396 wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
397 wxFileName fn;
398
399 if( fullFileName.IsEmpty() )
400 {
401 fn = m_frame->GetBoard()->GetFileName();
402 fn.SetExt( SpecctraDsnFileExtension );
403 }
404 else
405 {
406 fn = fullFileName;
407 }
408
409 fullFileName = wxFileSelector( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
411 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR, frame() );
412
413 if( !fullFileName.IsEmpty() )
414 {
415 m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
416 getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
417 }
418
419 return 0;
420}
const wxString & GetFileName() const
Definition: board.h:306
BOARD * GetBoard() const
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
const std::string SpecctraDsnFileExtension
wxString SpecctraDsnFileWildcard()
@ LAST_PATH_SPECCTRADSN
Definition: project_file.h:52

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

Referenced by setTransitions().

◆ Find()

int BOARD_EDITOR_CONTROL::Find ( const TOOL_EVENT aEvent)

Definition at line 344 of file board_editor_control.cpp.

345{
347 return 0;
348}
void ShowFindDialog()
Show the Find dialog.

References m_frame, and PCB_EDIT_FRAME::ShowFindDialog().

Referenced by setTransitions().

◆ FindNext()

int BOARD_EDITOR_CONTROL::FindNext ( const TOOL_EVENT aEvent)

Definition at line 351 of file board_editor_control.cpp.

352{
354 return 0;
355}
static TOOL_ACTION findPrevious
Definition: actions.h:81
void FindNext(bool reverse=false)
Find the next item using our existing search parameters.

References PCB_EDIT_FRAME::FindNext(), ACTIONS::findPrevious, TOOL_EVENT::IsAction(), and m_frame.

Referenced by setTransitions().

◆ footprint()

◆ frame()

PCB_BASE_EDIT_FRAME * PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 165 of file pcb_tool_base.h.

166 {
167 return getEditFrame<PCB_BASE_EDIT_FRAME>();
168 }

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(), ROUTER_TOOL::CustomTrackWidthDialog(), FOOTPRINT_EDITOR_CONTROL::DeleteFootprint(), EDIT_TOOL::DeleteItems(), PCB_TOOL_BASE::displayOptions(), doCrossProbePcbToSch(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), ROUTER_TOOL::DpDimensionsDialog(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawShape(), 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(), PCB_CONTROL::HighContrastMode(), PCB_CONTROL::HighContrastModeCycle(), BOARD_INSPECTION_TOOL::HighlightItem(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), ImportSpecctraSession(), SCRIPTING_TOOL::Init(), ROUTER_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_TOOL_BASE::Is45Limited(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), PCB_CONTROL::NetColorModeCycle(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCB_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PNS::TOOL_BASE::pickSingleItem(), PlaceFootprint(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PCB_CONTROL::pruneItemLayers(), PAD_TOOL::pushPadSettings(), PCB_CONTROL::RatsnestModeCycle(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), SCRIPTING_TOOL::reloadPlugins(), PCB_POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), PAD_TOOL::Reset(), EDIT_TOOL::Rotate(), ROUTER_TOOL::RouteSelected(), 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(), DRAWING_TOOL::ToggleHV45Mode(), PCB_CONTROL::ToggleRatsnest(), PCB_CONTROL::unfilledZoneCheck(), PCB_POINT_EDITOR::updateItem(), ROUTER_TOOL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), UpdateSchematicFromPCB(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillAll(), and ZONE_FILLER_TOOL::ZoneFillDirty().

◆ GenerateDrillFiles()

int BOARD_EDITOR_CONTROL::GenerateDrillFiles ( const TOOL_EVENT aEvent)

Definition at line 59 of file dialog_gendrill.cpp.

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

Referenced by setTransitions().

◆ GenerateFabFiles()

int BOARD_EDITOR_CONTROL::GenerateFabFiles ( const TOOL_EVENT aEvent)

Definition at line 487 of file board_editor_control.cpp.

488{
489 wxCommandEvent dummy;
490
493 else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
495 else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
497 else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
499 else
500 wxFAIL_MSG( wxT( "GenerateFabFiles(): unexpected request" ) );
501
502 return 0;
503}
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:381
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:380
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:376
static TOOL_ACTION generateReportFile
Definition: pcb_actions.h:379
void RecreateBOMFileFromBoard(wxCommandEvent &aEvent)
Create a BOM file from the current loaded board.
void GenD356File(wxCommandEvent &event)
void GenFootprintsReport(wxCommandEvent &event)
Call DoGenFootprintsReport to create a footprint report file.
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
@ ID_GEN_PLOT_GERBER
Definition: id.h:94
std::vector< FAB_LAYER_COLOR > dummy

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 501 of file dialog_gen_footprint_position.cpp.

502{
503 PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
504 DIALOG_GEN_FOOTPRINT_POSITION dlg( editFrame );
505
506 dlg.ShowModal();
507 return 0;
508}
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 seizure 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(), and ZONE_CREATE_HELPER::setUniquePriority().

◆ 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 }

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

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

◆ getModelInt()

EDA_ITEM * TOOL_BASE::getModelInt ( ) const
privateinherited

Definition at line 54 of file tool_base.cpp.

55{
56 return m_toolMgr->GetModel();
57}
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292

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

Referenced by TOOL_BASE::getModel().

◆ 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(), TOOL_MANAGER::RegisterTool(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getToolHolderInt()

TOOLS_HOLDER * TOOL_BASE::getToolHolderInt ( ) const
privateinherited

Definition at line 48 of file tool_base.cpp.

49{
50 return m_toolMgr->GetToolHolder();
51}
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296

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

Referenced by TOOL_BASE::getEditFrame().

◆ 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:285

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), SCH_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), EE_SELECTION_TOOL::GuessSelectionCandidates(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), ROUTER_TOOL::handleCommonEvents(), EE_SELECTION_TOOL::highlight(), PL_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), PlaceFootprint(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EE_SELECTION_TOOL::Reset(), EE_TOOL_BASE< T >::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), PNS::TOOL_BASE::Reset(), Reset(), DRAWING_TOOL::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_EDITOR_CONTROL::ToggleOPCurrents(), SCH_EDITOR_CONTROL::ToggleOPVoltages(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), PL_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_FIND_REPLACE_TOOL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< T >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_SELECTION_TOOL::view(), PCB_TOOL_BASE::view(), PCB_VIEWER_TOOLS::view(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), 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}
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:287

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), PCB_SELECTION_TOOL::controls(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), COMMON_TOOLS::CursorControl(), EDIT_TOOL::DeleteItems(), 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(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SCH_EDITOR_CONTROL::Paste(), 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(), DRAWING_TOOL::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), DRAWING_TOOL::Reset(), PCB_POINT_EDITOR::Reset(), COMMON_TOOLS::ResetLocalCoords(), ROUTER_TOOL::RouteSelected(), PCB_SELECTION_TOOL::selectCursor(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCB_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

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

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

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

◆ goInternal()

void TOOL_INTERACTIVE::goInternal ( TOOL_STATE_FUNC aState,
const TOOL_EVENT_LIST aConditions 
)
privateinherited

Definition at line 70 of file tool_interactive.cpp.

71{
72 m_toolMgr->ScheduleNextState( this, aState, aConditions );
73}
void ScheduleNextState(TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
Define a state transition.

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

Referenced by TOOL_INTERACTIVE::Go().

◆ ImportNetlist()

int BOARD_EDITOR_CONTROL::ImportNetlist ( const TOOL_EVENT aEvent)

Definition at line 365 of file board_editor_control.cpp.

366{
367 getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
368 return 0;
369}

Referenced by setTransitions().

◆ ImportSpecctraSession()

int BOARD_EDITOR_CONTROL::ImportSpecctraSession ( const TOOL_EVENT aEvent)

Definition at line 372 of file board_editor_control.cpp.

373{
374 wxString fullFileName = frame()->GetBoard()->GetFileName();
375 wxString path;
376 wxString name;
377 wxString ext;
378
379 wxFileName::SplitPath( fullFileName, &path, &name, &ext );
380 name += wxT( "." ) + SpecctraSessionFileExtension;
381
382 fullFileName = wxFileSelector( _( "Specctra Session File" ), path, name,
383 wxT( "." ) + SpecctraSessionFileExtension,
384 SpecctraSessionFileWildcard(), wxFD_OPEN | wxFD_CHANGE_DIR,
385 frame() );
386
387 if( !fullFileName.IsEmpty() )
388 getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
389
390 return 0;
391}
const char * name
Definition: DXF_plotter.cpp:56
const std::string SpecctraSessionFileExtension
wxString SpecctraSessionFileWildcard()

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

Referenced by setTransitions().

◆ Init()

bool BOARD_EDITOR_CONTROL::Init ( )
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 161 of file board_editor_control.cpp.

162{
163 auto activeToolCondition =
164 [this]( const SELECTION& aSel )
165 {
166 return ( !m_frame->ToolStackIsEmpty() );
167 };
168
169 auto inactiveStateCondition =
170 [this]( const SELECTION& aSel )
171 {
172 return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
173 };
174
175 auto placeModuleCondition =
176 [this]( const SELECTION& aSel )
177 {
178 return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
179 };
180
181 auto& ctxMenu = m_menu.GetMenu();
182
183 // "Cancel" goes at the top of the context menu when a tool is active
184 ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
185 ctxMenu.AddSeparator( 1 );
186
187 // "Get and Place Footprint" should be available for Place Footprint tool
188 ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
189 ctxMenu.AddSeparator( 1000 );
190
191 // Finally, add the standard zoom & grid items
192 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
193
194 std::shared_ptr<ZONE_CONTEXT_MENU> zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
195 zoneMenu->SetTool( this );
196
197 std::shared_ptr<LOCK_CONTEXT_MENU> lockMenu = std::make_shared<LOCK_CONTEXT_MENU>( this );
198
199 // Add the PCB control menus to relevant other tools
200
202
203 if( selTool )
204 {
205 TOOL_MENU& toolMenu = selTool->GetToolMenu();
206 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
207
208 // Add "Get and Place Footprint" when Selection tool is in an inactive state
209 menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
210 menu.AddSeparator();
211
212 toolMenu.RegisterSubMenu( zoneMenu );
213 toolMenu.RegisterSubMenu( lockMenu );
214
215 menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
216
217 menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 100 );
218 }
219
220 DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
221
222 if( drawingTool )
223 {
224 TOOL_MENU& toolMenu = drawingTool->GetToolMenu();
225 CONDITIONAL_MENU& menu = toolMenu.GetMenu();
226
227 toolMenu.RegisterSubMenu( zoneMenu );
228
229 // Functor to say if the PCB_EDIT_FRAME is in a given mode
230 // Capture the tool pointer and tool mode by value
231 auto toolActiveFunctor =
232 [=]( DRAWING_TOOL::MODE aMode )
233 {
234 return [=]( const SELECTION& sel )
235 {
236 return drawingTool->GetDrawingMode() == aMode;
237 };
238 };
239
240 menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 300 );
241 }
242
243 return true;
244}
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
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.
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
Definition: drawing_tool.h:51
MODE GetDrawingMode() const
Return the current drawing mode of the DRAWING_TOOL or #MODE::NONE if not currently in any drawing mo...
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:514
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:190
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
bool ToolStackIsEmpty()
Definition: tools_holder.h:128
bool IsCurrentTool(const TOOL_ACTION &aAction) const
TOOL_MENU & GetToolMenu()
Manage a CONDITIONAL_MENU and some number of CONTEXT_MENUs as sub-menus.
Definition: tool_menu.h:43
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:50
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112

References CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), CONDITIONAL_MENU::AddSeparator(), 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::OnlyTypes(), PCB_ZONE_T, PCB_ACTIONS::placeFootprint, TOOL_MENU::RegisterSubMenu(), TOOLS_HOLDER::ToolStackIsEmpty(), and DRAWING_TOOL::ZONE.

◆ Is45Limited()

bool PCB_TOOL_BASE::Is45Limited ( ) const
virtualinherited

Should the tool use its 45° mode option?

Returns
True if set to use 45°

Definition at line 332 of file pcb_tool_base.cpp.

333{
334 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
335
336 if( frame()->IsType( FRAME_PCB_EDITOR ) )
337 return mgr.GetAppSettings<PCBNEW_SETTINGS>()->m_Use45DegreeLimit;
338 else
339 return mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>()->m_Use45Limit;
340}
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References PCB_TOOL_BASE::frame(), FRAME_PCB_EDITOR, SETTINGS_MANAGER::GetAppSettings(), and Pgm().

Referenced by DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), and ZONE_CREATE_HELPER::OnFirstPoint().

◆ IsBoardEditor()

bool PCB_TOOL_BASE::IsBoardEditor ( ) const
inlineinherited

Definition at line 109 of file pcb_tool_base.h.

109{ return m_isBoardEditor; }

References PCB_TOOL_BASE::m_isBoardEditor.

Referenced by BOARD_COMMIT::BOARD_COMMIT().

◆ IsFootprintEditor()

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32{
34}
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 EDIT_TOOL::Drag(), ROUTER_TOOL::handleLayerSwitch(), PCB_SELECTION_TOOL::Main(), TrackWidthDec(), and TrackWidthInc().

◆ LockSelected()

int BOARD_EDITOR_CONTROL::LockSelected ( const TOOL_EVENT aEvent)

Unlock selected items.

Definition at line 1184 of file board_editor_control.cpp.

1185{
1186 return modifyLockSelected( ON );
1187}
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 1196 of file board_editor_control.cpp.

1197{
1199 const PCB_SELECTION& selection = selTool->GetSelection();
1200 BOARD_COMMIT commit( m_frame );
1201
1202 if( selection.Empty() )
1204
1205 // Resolve TOGGLE mode
1206 if( aMode == TOGGLE )
1207 {
1208 aMode = ON;
1209
1210 for( EDA_ITEM* item : selection )
1211 {
1212 BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1213
1214 if( board_item->IsLocked() )
1215 {
1216 aMode = OFF;
1217 break;
1218 }
1219 }
1220 }
1221
1222 bool modified = false;
1223
1224 for( EDA_ITEM* item : selection )
1225 {
1226 BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1227
1228 commit.Modify( board_item );
1229
1230 if( aMode == ON )
1231 {
1232 modified |= !board_item->IsLocked();
1233 board_item->SetLocked( true );
1234 }
1235 else
1236 {
1237 modified |= board_item->IsLocked();
1238 board_item->SetLocked( false );
1239 }
1240 }
1241
1242 if( modified )
1243 {
1244 commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ) );
1245
1247 m_frame->OnModify();
1248 }
1249
1250 return 0;
1251}
virtual void SetLocked(bool aLocked)
Definition: board_item.h:266
virtual bool IsLocked() const
Definition: board_item.cpp:71
static const TOOL_EVENT SelectedEvent
Definition: actions.h:207
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
void OnModify() override
Must be called after a board change to set the modified flag.
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.

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

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

◆ New()

int BOARD_EDITOR_CONTROL::New ( const TOOL_EVENT aEvent)

Definition at line 247 of file board_editor_control.cpp.

248{
250 return 0;
251}
bool Files_io_from_id(int aId)
Read and write board files according to aId.
@ ID_NEW_BOARD
Definition: id.h:76

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

255{
257 return 0;
258}
@ ID_LOAD_FILE
Definition: id.h:75

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

290{
291 PICKED_ITEMS_LIST undoCmd;
293 ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
294
295 undoCmd.PushItem( wrapper );
297
300 dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
301
302 if( dlg.ShowModal() == wxID_OK )
303 {
305 [&]( KIGFX::VIEW_ITEM* aItem ) -> int
306 {
307 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
308
309 if( text && text->HasTextVars() )
310 {
311 text->ClearRenderCache();
312 text->ClearBoundingBoxCache();
314 }
315
316 return 0;
317 } );
318
319 m_frame->OnModify();
320 }
321 else
322 {
324 }
325
326 return 0;
327}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition: base_screen.h:85
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1494
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:597
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:49
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition: page_info.h:40
const double IU_PER_MILS
Definition: base_units.h:78

References KIGFX::GEOMETRY, PCB_BASE_FRAME::GetCanvas(), PCB_DRAW_PANEL_GAL::GetView(), EDA_IU_SCALE::IU_PER_MILS, BASE_SCREEN::m_DrawingSheetFileName, m_frame, MAX_PAGE_SIZE_PCBNEW_MILS, PCB_EDIT_FRAME::OnModify(), PAGESETTINGS, pcbIUScale, PICKED_ITEMS_LIST::PushItem(), KIGFX::REPAINT, PCB_BASE_EDIT_FRAME::RollbackFromUndo(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), DIALOG_PAGES_SETTINGS::SetWksFileName(), text, and KIGFX::VIEW::UpdateAllItemsConditionally().

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.

Definition at line 966 of file board_editor_control.cpp.

967{
969 return 0;
970
972
973 FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
974 bool fromOtherCommand = fp != nullptr;
976 BOARD_COMMIT commit( m_frame );
977 BOARD* board = getModel<BOARD>();
978 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
979
981
982 m_frame->PushTool( aEvent );
983
984 auto setCursor =
985 [&]()
986 {
988 };
989
990 auto cleanup =
991 [&] ()
992 {
994 commit.Revert();
995
996 if( fromOtherCommand )
997 {
999
1000 if( undo )
1001 {
1004 delete undo;
1005 }
1006 }
1007
1008 fp = nullptr;
1009 m_placingFootprint = false;
1010 };
1011
1012 Activate();
1013 // Must be done after Activate() so that it gets set into the correct context
1014 controls->ShowCursor( true );
1015 // Set initial cursor
1016 setCursor();
1017
1018 VECTOR2I cursorPos = controls->GetCursorPosition();
1019 bool ignorePrimePosition = false;
1020 bool reselect = false;
1021
1022 // Prime the pump
1023 if( fp )
1024 {
1025 m_placingFootprint = true;
1026 fp->SetPosition( cursorPos );
1029 }
1030 else if( aEvent.HasPosition() )
1031 {
1032 m_toolMgr->PrimeTool( aEvent.Position() );
1033 }
1034 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
1035 {
1036 m_toolMgr->PrimeTool( { 0, 0 } );
1037 ignorePrimePosition = true;
1038 }
1039
1040 // Main loop: keep receiving events
1041 while( TOOL_EVENT* evt = Wait() )
1042 {
1043 setCursor();
1044 cursorPos = controls->GetCursorPosition( !evt->DisableGridSnapping() );
1045
1046 if( reselect && fp )
1048
1049 if( evt->IsCancelInteractive() )
1050 {
1051 if( fp )
1052 {
1053 cleanup();
1054 }
1055 else
1056 {
1057 m_frame->PopTool( aEvent );
1058 break;
1059 }
1060 }
1061 else if( evt->IsActivate() )
1062 {
1063 if( fp )
1064 cleanup();
1065
1066 if( evt->IsMoveTool() )
1067 {
1068 // leave ourselves on the stack so we come back after the move
1069 break;
1070 }
1071 else
1072 {
1073 frame()->PopTool( aEvent );
1074 break;
1075 }
1076 }
1077 else if( evt->IsClick( BUT_LEFT ) )
1078 {
1079 if( !fp )
1080 {
1081 // Pick the footprint to be placed
1083
1084 if( fp == nullptr )
1085 continue;
1086
1087 // If we started with a hotkey which has a position then warp back to that.
1088 // Otherwise update to the current mouse position pinned inside the autoscroll
1089 // boundaries.
1090 if( evt->IsPrime() && !ignorePrimePosition )
1091 {
1092 cursorPos = evt->Position();
1093 getViewControls()->WarpMouseCursor( cursorPos, true );
1094 }
1095 else
1096 {
1098 cursorPos = getViewControls()->GetMousePosition();
1099 }
1100
1101 m_placingFootprint = true;
1102
1103 fp->SetLink( niluuid );
1104
1105 fp->SetFlags( IS_NEW ); // whatever
1106
1107 // Set parent so that clearance can be loaded
1108 fp->SetParent( board );
1109 m_frame->UpdateUserUnits( fp );
1110
1111 for( PAD* pad : fp->Pads() )
1112 {
1113 pad->SetLocalRatsnestVisible( m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
1114
1115 // Pads in the library all have orphaned nets. Replace with Default.
1116 pad->SetNetCode( 0 );
1117 }
1118
1119 // Put it on FRONT layer,
1120 // (Can be stored flipped if the lib is an archive built from a board)
1121 if( fp->IsFlipped() )
1123
1124 fp->SetOrientation( ANGLE_0 );
1125 fp->SetPosition( cursorPos );
1126
1127 commit.Add( fp );
1129
1131 }
1132 else
1133 {
1135 commit.Push( _( "Place a footprint" ) );
1136 fp = nullptr; // to indicate that there is no footprint that we currently modify
1137 m_placingFootprint = false;
1138 }
1139 }
1140 else if( evt->IsClick( BUT_RIGHT ) )
1141 {
1143 }
1144 else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
1145 {
1146 fp->SetPosition( cursorPos );
1147 selection().SetReferencePoint( cursorPos );
1148 getView()->Update( &selection() );
1149 getView()->Update( fp );
1150 }
1151 else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
1152 {
1153 // Calling 'Properties' action clears the selection, so we need to restore it
1154 reselect = true;
1155 }
1156 else if( fp && ZONE_FILLER_TOOL::IsZoneFillAction( evt ) )
1157 {
1158 wxBell();
1159 }
1160 else
1161 {
1162 evt->SetPassEvent();
1163 }
1164
1165 // Enable autopanning and cursor capture only when there is a footprint to be placed
1166 controls->SetAutoPan( fp != nullptr );
1167 controls->CaptureCursor( fp != nullptr );
1168 }
1169
1170 controls->SetAutoPan( false );
1171 controls->CaptureCursor( false );
1173
1174 return 0;
1175}
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:269
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1688
void SetLink(const KIID &aLink)
Definition: footprint.h:681
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:1820
bool IsFlipped() const
Definition: footprint.h:324
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1600
VECTOR2I GetPosition() const override
Definition: footprint.h:188
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual void PinCursorInsideNonAutoscrollArea(bool aWarpMouseCursor)=0
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:1591
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:62
void ClearListAndDeleteItems(PICKED_ITEMS_LIST *aList)
Definition: undo_redo.cpp:587
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
Definition: undo_redo.cpp:373
FOOTPRINT * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Open a dialog to select a footprint.
void UpdateUserUnits(BOARD_ITEM *aItem, bool *aSelectedItemsModified=nullptr)
Update any references within aItem (or its descendants) to the user units.
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:260
bool HasPosition() const
Definition: tool_event.h:243
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:266
bool IsReactivate() const
Definition: tool_event.h:255
void PrimeTool(const VECTOR2D &aPosition)
"Prime" a tool by sending a cursor left-click event with the mouse position set to the passed in posi...
static bool IsZoneFillAction(const TOOL_EVENT *aEvent)
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:429
#define IS_NEW
New item, just created.
KIID niluuid(0)

References _, TOOL_INTERACTIVE::Activate(), COMMIT::Add(), ANGLE_0, ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), PCB_BASE_EDIT_FRAME::ClearListAndDeleteItems(), PCB_TOOL_BASE::controls(), FOOTPRINT::Flip(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW_CONTROLS::GetMousePosition(), PCB_BASE_FRAME::GetPcbNewSettings(), FOOTPRINT::GetPosition(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), COMMON_SETTINGS::INPUT::immediate_actions, IS_NEW, FOOTPRINT::IsFlipped(), TOOL_EVENT::IsReactivate(), ZONE_FILLER_TOOL::IsZoneFillAction(), PCBNEW_SETTINGS::m_Display, PCBNEW_SETTINGS::m_FlipLeftRight, m_frame, m_inPlaceFootprint, COMMON_SETTINGS::m_Input, TOOL_INTERACTIVE::m_menu, m_placingFootprint, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_ShowGlobalRatsnest, TOOL_BASE::m_toolMgr, niluuid, pad, FOOTPRINT::Pads(), TOOL_EVENT::Parameter(), PENCIL, Pgm(), KIGFX::VIEW_CONTROLS::PinCursorInsideNonAutoscrollArea(), EDA_BASE_FRAME::PopCommandFromUndoList(), TOOLS_HOLDER::PopTool(), TOOL_EVENT::Position(), TOOL_MANAGER::PrimeTool(), 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(), EDA_ITEM::SetFlags(), FOOTPRINT::SetLink(), FOOTPRINT::SetOrientation(), EDA_ITEM::SetParent(), FOOTPRINT::SetPosition(), SELECTION::SetReferencePoint(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), undo, KIGFX::VIEW::Update(), PCB_BASE_FRAME::UpdateUserUnits(), TOOL_INTERACTIVE::Wait(), and KIGFX::VIEW_CONTROLS::WarpMouseCursor().

Referenced by setTransitions().

◆ PlacingFootprint()

bool BOARD_EDITOR_CONTROL::PlacingFootprint ( ) const
inline

Re-entrancy checker for above.

Toggle 'lock' property for selected items.

Definition at line 116 of file board_editor_control.h.

References m_placingFootprint.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), and FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard().

◆ Plot()

int BOARD_EDITOR_CONTROL::Plot ( const TOOL_EVENT aEvent)

Definition at line 330 of file board_editor_control.cpp.

331{
333 return 0;
334}
@ ID_GEN_PLOT
Definition: id.h:91

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

507{
508 int errors = 0;
509 wxString details;
510 bool quiet = aEvent.Parameter<bool>();
511
512 // Repair duplicate IDs and missing nets.
513 std::set<KIID> ids;
514 int duplicates = 0;
515
516 auto processItem =
517 [&]( EDA_ITEM* aItem )
518 {
519 if( ids.count( aItem->m_Uuid ) )
520 {
521 duplicates++;
522 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
523 }
524
525 ids.insert( aItem->m_Uuid );
526
527 BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
528
529 if( cItem && cItem->GetNetCode() )
530 {
531 NETINFO_ITEM* netinfo = cItem->GetNet();
532
533 if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
534 {
535 board()->Add( netinfo );
536
537 details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
538 netinfo->GetNetname() );
539 errors++;
540 }
541 }
542 };
543
544 // Footprint IDs are the most important, so give them the first crack at "claiming" a
545 // particular KIID.
546
547 for( FOOTPRINT* footprint : board()->Footprints() )
548 processItem( footprint );
549
550 // After that the principal use is for DRC marker pointers, which are most likely to pads
551 // or tracks.
552
553 for( FOOTPRINT* footprint : board()->Footprints() )
554 {
555 for( PAD* pad : footprint->Pads() )
556 processItem( pad );
557 }
558
559 for( PCB_TRACK* track : board()->Tracks() )
560 processItem( track );
561
562 // From here out I don't think order matters much.
563
564 for( FOOTPRINT* footprint : board()->Footprints() )
565 {
566 processItem( &footprint->Reference() );
567 processItem( &footprint->Value() );
568
569 for( BOARD_ITEM* item : footprint->GraphicalItems() )
570 processItem( item );
571
572 for( ZONE* zone : footprint->Zones() )
573 processItem( zone );
574
575 for( PCB_GROUP* group : footprint->Groups() )
576 processItem( group );
577 }
578
579 for( BOARD_ITEM* drawing : board()->Drawings() )
580 processItem( drawing );
581
582 for( ZONE* zone : board()->Zones() )
583 processItem( zone );
584
585 for( PCB_MARKER* marker : board()->Markers() )
586 processItem( marker );
587
588 for( PCB_GROUP* group : board()->Groups() )
589 processItem( group );
590
591 if( duplicates )
592 {
593 errors += duplicates;
594 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
595 }
596
597 /*******************************
598 * Your test here
599 */
600
601 /*******************************
602 * Inform the user
603 */
604
605 if( errors )
606 {
607 m_frame->OnModify();
608
609 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
610
611 if( !quiet )
612 DisplayInfoMessage( m_frame, msg, details );
613 }
614 else if( !quiet )
615 {
616 DisplayInfoMessage( m_frame, _( "No board problems found." ) );
617 }
618
619 return 0;
620}
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:772
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1478
FP_GROUPS & Groups()
Definition: footprint.h:179
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:567
FP_ZONES & Zones()
Definition: footprint.h:176
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
FP_TEXT & Reference()
Definition: footprint.h:568
Definition: kiid.h:48
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:352
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

References _, BOARD::Add(), PCB_TOOL_BASE::board(), DisplayInfoMessage(), BOARD::FindNet(), PCB_TOOL_BASE::footprint(), Format(), BOARD_CONNECTED_ITEM::GetNet(), BOARD_CONNECTED_ITEM::GetNetCode(), NETINFO_ITEM::GetNetname(), FOOTPRINT::GraphicalItems(), group, FOOTPRINT::Groups(), m_frame, PCB_EDIT_FRAME::OnModify(), pad, FOOTPRINT::Pads(), TOOL_EVENT::Parameter(), FOOTPRINT::Reference(), FOOTPRINT::Value(), and FOOTPRINT::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 148 of file board_editor_control.cpp.

149{
150 m_frame = getEditFrame<PCB_EDIT_FRAME>();
151
152 if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH || aReason == REDRAW )
153 {
154 m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().GetAuxOrigin() );
155 getView()->Remove( m_placeOrigin.get() );
156 getView()->Add( m_placeOrigin.get() );
157 }
158}
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:349

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

◆ resetTransitions()

void TOOL_INTERACTIVE::resetTransitions ( )
privateinherited

Clear the current transition map and restores the default one created by setTransitions().

Definition at line 63 of file tool_interactive.cpp.

64{
67}
virtual void setTransitions()=0
This method is meant to be overridden in order to specify handlers for events.
void ClearTransitions(TOOL_BASE *aTool)
Clear the state transition map for a tool.

References TOOL_MANAGER::ClearTransitions(), TOOL_BASE::m_toolMgr, and TOOL_INTERACTIVE::setTransitions().

◆ Revert()

int BOARD_EDITOR_CONTROL::Revert ( const TOOL_EVENT aEvent)

Definition at line 282 of file board_editor_control.cpp.

283{
285 return 0;
286}
@ ID_REVERT_BOARD
Definition: pcbnew_id.h:18

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

Referenced by setTransitions().

◆ 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}
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 261 of file board_editor_control.cpp.

262{
264 return 0;
265}
@ ID_SAVE_BOARD
Definition: id.h:77

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

269{
271 return 0;
272}
@ ID_SAVE_BOARD_AS
Definition: id.h:78

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

Referenced by setTransitions().

◆ SaveCopy()

int BOARD_EDITOR_CONTROL::SaveCopy ( const TOOL_EVENT aEvent)

Definition at line 275 of file board_editor_control.cpp.

276{
278 return 0;
279}
@ ID_COPY_BOARD_AS
Definition: pcbnew_id.h:17

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

Referenced by setTransitions().

◆ Search()

int BOARD_EDITOR_CONTROL::Search ( const TOOL_EVENT aEvent)

Definition at line 337 of file board_editor_control.cpp.

338{
340 return 0;
341}

References m_frame, and PCB_EDIT_FRAME::ToggleSearch().

Referenced by setTransitions().

◆ selection() [1/2]

PCB_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 324 of file pcb_tool_base.cpp.

325{
327
328 return selTool->GetSelection();
329}

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

◆ selection() [2/2]

const PCB_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 316 of file pcb_tool_base.cpp.

317{
319
320 return selTool->GetSelection();
321}

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

Referenced by AssignNetclass(), AUTOPLACE_TOOL::autoplaceSelected(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), DRC_TOOL::CrossProbe(), doCrossProbePcbToSch(), BOARD_INSPECTION_TOOL::doHideRatsnestNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), EditFpInFpEditor(), PAD_TOOL::EditPad(), GROUP_TOOL::EnterGroup(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::FilletLines(), EDIT_TOOL::FilletTracks(), 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(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), modifyLockSelected(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::PackAndMoveFootprints(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCB_CONTROL::placeBoardItems(), PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), BOARD_REANNOTATE_TOOL::ReannotateDuplicatesInSelection(), GROUP_TOOL::RemoveFromGroup(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), ROUTER_TOOL::RouteSelected(), DRAWING_TOOL::SetAnchor(), EDIT_TOOL::Swap(), TrackWidthDec(), TrackWidthInc(), GROUP_TOOL::Ungroup(), BOARD_INSPECTION_TOOL::UpdateLocalRatsnest(), PCB_CONTROL::UpdateMessagePanel(), ViaSizeDec(), ViaSizeInc(), ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ 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}
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.
@ CMENU_OFF
Definition: tool_event.h:149

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

Referenced by SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetIsBoardEditor()

void PCB_TOOL_BASE::SetIsBoardEditor ( bool  aEnabled)
inlineinherited

Definition at line 108 of file pcb_tool_base.h.

108{ m_isBoardEditor = aEnabled; }

References PCB_TOOL_BASE::m_isBoardEditor.

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

105{ m_isFootprintEditor = aEnabled; }

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

1599{
1608
1613
1619
1620 if( ADVANCED_CFG::GetCfg().m_ShowPcbnewExportNetlist && m_frame &&
1623
1625 PCB_ACTIONS::generateDrillFiles.MakeEvent() );
1629 PCB_ACTIONS::generateReportFile.MakeEvent() );
1632
1633 // Track & via size control
1638
1639 // Zone actions
1642
1643 // Placing tools
1646
1649
1650 // Cross-select
1656
1657 // Other
1661
1663
1665 ACTIONS::updatePcbFromSchematic.MakeEvent() );
1667 ACTIONS::updateSchematicFromPcb.MakeEvent() );
1674}
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:168
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION findNext
Definition: actions.h:80
static TOOL_ACTION pageSettings
Definition: actions.h:56
static TOOL_ACTION showSearch
Definition: actions.h:77
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:169
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION saveCopy
Definition: actions.h:53
static TOOL_ACTION find
Definition: actions.h:78
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
int ExportNetlist(const TOOL_EVENT &aEvent)
int UnlockSelected(const TOOL_EVENT &aEvent)
Run the drill origin tool for setting the origin for drill and pick-and-place files.
int Save(const TOOL_EVENT &aEvent)
int ImportNetlist(const TOOL_EVENT &aEvent)
int GenerateDrillFiles(const TOOL_EVENT &aEvent)
int ZoneMerge(const TOOL_EVENT &aEvent)
Duplicate a zone onto a layer (prompts for new layer)
int CrossProbeToSch(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
int TogglePythonConsole(const TOOL_EVENT &aEvent)
int UpdatePCBFromSchematic(const TOOL_EVENT &aEvent)
int ShowEeschema(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
int AssignNetclass(const TOOL_EVENT &aEvent)
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
int ExplicitCrossProbeToSch(const TOOL_EVENT &aEvent)
Assign a netclass to a labelled net.
int ToggleSearch(const TOOL_EVENT &aEvent)
int DrillOrigin(const TOOL_EVENT &aEvent)
Low-level access (below undo) to setting the drill origin.
int GenerateFabFiles(const TOOL_EVENT &aEvent)
int ViaSizeDec(const TOOL_EVENT &aEvent)
int RepairBoard(const TOOL_EVENT &aEvent)
int ZoneDuplicate(const TOOL_EVENT &aEvent)
int ToggleLayersManager(const TOOL_EVENT &aEvent)
int ImportSpecctraSession(const TOOL_EVENT &aEvent)
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 BoardSetup(const TOOL_EVENT &aEvent)
int TrackWidthInc(const TOOL_EVENT &aEvent)
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Lock selected items.
int LockSelected(const TOOL_EVENT &aEvent)
Unlock selected items.
int PageSettings(const TOOL_EVENT &aEvent)
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
int FindNext(const TOOL_EVENT &aEvent)
int ViaSizeInc(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
int Find(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
int TrackWidthDec(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int Search(const TOOL_EVENT &aEvent)
int Open(const TOOL_EVENT &aEvent)
int SaveCopy(const TOOL_EVENT &aEvent)
int GeneratePosFile(const TOOL_EVENT &aEvent)
int EditFpInFpEditor(const TOOL_EVENT &aEvent)
Notify Eeschema about selected items.
int ToggleProperties(const TOOL_EVENT &aEvent)
static const TOOL_EVENT ClearedEvent
Definition: actions.h:209
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:208
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:389
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:334
static TOOL_ACTION generateDrillFiles
Definition: pcb_actions.h:377
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:374
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:333
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:336
static TOOL_ACTION showProperties
Definition: pcb_actions.h:390
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:469
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:335
static TOOL_ACTION generatePosFile
Definition: pcb_actions.h:378
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:484
static TOOL_ACTION assignNetClass
Definition: pcb_actions.h:340
static TOOL_ACTION repairBoard
Definition: pcb_actions.h:490
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:351
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:371
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:358
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:487
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:348
static TOOL_ACTION unlock
Definition: pcb_actions.h:471
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:391
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:373
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
Definition: pcb_actions.h:104
static TOOL_ACTION lock
Definition: pcb_actions.h:470
TOOL_ACTION * GetExportNetlistAction()
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
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).

References AssignNetclass(), PCB_ACTIONS::assignNetClass, BoardSetup(), PCB_ACTIONS::boardSetup, EVENTS::ClearedEvent, CrossProbeToSch(), ACTIONS::doNew, DrillOrigin(), PCB_ACTIONS::drillOrigin, EditFpInFpEditor(), PCB_ACTIONS::editFpInFpEditor, PCB_ACTIONS::editLibFpInFpEditor, ExplicitCrossProbeToSch(), ExportNetlist(), ExportSpecctraDSN(), PCB_ACTIONS::exportSpecctraDSN, ACTIONS::find, Find(), ACTIONS::findNext, FindNext(), ACTIONS::findPrevious, PCB_ACTIONS::generateBOM, PCB_ACTIONS::generateD356File, GenerateDrillFiles(), PCB_ACTIONS::generateDrillFiles, GenerateFabFiles(), PCB_ACTIONS::generateGerbers, GeneratePosFile(), PCB_ACTIONS::generatePosFile, PCB_ACTIONS::generateReportFile, ADVANCED_CFG::GetCfg(), PCB_EDIT_FRAME::GetExportNetlistAction(), TOOL_INTERACTIVE::Go(), ImportNetlist(), PCB_ACTIONS::importNetlist, ImportSpecctraSession(), PCB_ACTIONS::importSpecctraSession, PCB_ACTIONS::lock, LockSelected(), m_frame, TOOL_ACTION::MakeEvent(), New(), ACTIONS::open, Open(), ACTIONS::pageSettings, PageSettings(), PlaceFootprint(), PCB_ACTIONS::placeFootprint, ACTIONS::plot, Plot(), EVENTS::PointSelectedEvent, RepairBoard(), PCB_ACTIONS::repairBoard, ACTIONS::revert, Revert(), ACTIONS::save, Save(), ACTIONS::saveAs, SaveAs(), ACTIONS::saveCopy, SaveCopy(), Search(), EVENTS::SelectedEvent, PCB_ACTIONS::selectOnSchematic, ShowEeschema(), PCB_ACTIONS::showEeschema, PCB_ACTIONS::showLayersManager, PCB_ACTIONS::showProperties, PCB_ACTIONS::showPythonConsole, ACTIONS::showSearch, ToggleLayersManager(), PCB_ACTIONS::toggleLock, ToggleLockSelected(), ToggleProperties(), TogglePythonConsole(), ToggleSearch(), TrackWidthDec(), PCB_ACTIONS::trackWidthDec, TrackWidthInc(), PCB_ACTIONS::trackWidthInc, PCB_ACTIONS::unlock, UnlockSelected(), EVENTS::UnselectedEvent, ACTIONS::updatePcbFromSchematic, UpdatePCBFromSchematic(), ACTIONS::updateSchematicFromPcb, 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 664 of file board_editor_control.cpp.

665{
667 return 0;
668}

References m_frame, and PCB_EDIT_FRAME::RunEeschema().

Referenced by setTransitions().

◆ ToggleLayersManager()

int BOARD_EDITOR_CONTROL::ToggleLayersManager ( const TOOL_EVENT aEvent)

Definition at line 671 of file board_editor_control.cpp.

672{
673 getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
674 return 0;
675}

Referenced by setTransitions().

◆ ToggleLockSelected()

int BOARD_EDITOR_CONTROL::ToggleLockSelected ( const TOOL_EVENT aEvent)

Lock selected items.

Definition at line 1178 of file board_editor_control.cpp.

1179{
1180 return modifyLockSelected( TOGGLE );
1181}

References modifyLockSelected(), and TOGGLE.

Referenced by setTransitions().

◆ ToggleProperties()

int BOARD_EDITOR_CONTROL::ToggleProperties ( const TOOL_EVENT aEvent)

Definition at line 678 of file board_editor_control.cpp.

679{
680 getEditFrame<PCB_EDIT_FRAME>()->ToggleProperties();
681 return 0;
682}

Referenced by setTransitions().

◆ TogglePythonConsole()

int BOARD_EDITOR_CONTROL::TogglePythonConsole ( const TOOL_EVENT aEvent)

Definition at line 692 of file board_editor_control.cpp.

693{
695 return 0;
696}
void ScriptingConsoleEnableDisable()
Toggles the scripting console visibility.

References m_frame, and EDA_DRAW_FRAME::ScriptingConsoleEnableDisable().

Referenced by setTransitions().

◆ ToggleSearch()

int BOARD_EDITOR_CONTROL::ToggleSearch ( const TOOL_EVENT aEvent)

Definition at line 685 of file board_editor_control.cpp.

686{
687 getEditFrame<PCB_EDIT_FRAME>()->ToggleSearch();
688 return 0;
689}

Referenced by setTransitions().

◆ TrackWidthDec()

int BOARD_EDITOR_CONTROL::TrackWidthDec ( const TOOL_EVENT aEvent)

Definition at line 780 of file board_editor_control.cpp.

781{
782 BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
784
786 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
787 {
788 BOARD_COMMIT commit( this );
789
790 for( EDA_ITEM* item : selection )
791 {
792 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
793 {
794 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
795
796 // Note: skip first entry which is the current netclass value
797 for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 1; --i )
798 {
799 int candidate = designSettings.m_TrackWidthList[ i ];
800
801 if( candidate < track->GetWidth() )
802 {
803 commit.Modify( track );
804 track->SetWidth( candidate );
805 break;
806 }
807 }
808 }
809 }
810
811 commit.Push( wxT( "Decrease Track Width" ) );
812 return 0;
813 }
814
815 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
816
817 if( routerTool && routerTool->IsToolActive()
818 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
819 {
820 int widthIndex = designSettings.GetDiffPairIndex() - 1;
821
822 // If we get to the lowest entry start over at the highest
823 if( widthIndex < 0 )
824 widthIndex = designSettings.m_DiffPairDimensionsList.size() - 1;
825
826 designSettings.SetDiffPairIndex( widthIndex );
827 designSettings.UseCustomDiffPairDimensions( false );
828
830 }
831 else
832 {
833 int widthIndex = designSettings.GetTrackWidthIndex();
834
835 if( routerTool && routerTool->IsToolActive()
836 && routerTool->Router()->GetState() == PNS::ROUTER::RouterState::ROUTE_TRACK
837 && designSettings.m_UseConnectedTrackWidth && !designSettings.m_TempOverrideTrackWidth )
838 {
839 designSettings.m_TempOverrideTrackWidth = true;
840 }
841 else
842 {
843 widthIndex--;
844 }
845
846 // If we get to the lowest entry start over at the highest
847 if( widthIndex < 0 )
848 widthIndex = designSettings.m_TrackWidthList.size() - 1;
849
850 designSettings.SetTrackWidthIndex( widthIndex );
851 designSettings.UseCustomTrackViaSize( false );
852
854 }
855
856 return 0;
857}
Container for design settings for a BOARD object.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
void SetDiffPairIndex(unsigned aIndex)
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
unsigned GetTrackWidthIndex() const
void UseCustomDiffPairDimensions(bool aEnabled)
Enables/disables custom differential pair dimensions.
std::vector< int > m_TrackWidthList
unsigned GetDiffPairIndex() const
void SetWidth(int aWidth)
Definition: pcb_track.h:107
ROUTER_MODE Mode() const
Definition: pns_router.h:133
RouterState GetState() const
Definition: pns_router.h:135
ROUTER * Router() const
bool IsToolActive() const
Definition: tool_base.cpp:31
@ PNS_MODE_ROUTE_DIFF_PAIR
Definition: pns_router.h:64

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

Referenced by setTransitions().

◆ TrackWidthInc()

int BOARD_EDITOR_CONTROL::TrackWidthInc ( const TOOL_EVENT aEvent)

Definition at line 700 of file board_editor_control.cpp.

701{
702 BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
704
706 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
707 {
708 BOARD_COMMIT commit( this );
709
710 for( EDA_ITEM* item : selection )
711 {
712 if( item->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
713 {
714 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
715
716 // Note: skip first entry which is the current netclass value
717 for( int i = 1; i < (int) designSettings.m_TrackWidthList.size(); ++i )
718 {
719 int candidate = designSettings.m_TrackWidthList[ i ];
720
721 if( candidate > track->GetWidth() )
722 {
723 commit.Modify( track );
724 track->SetWidth( candidate );
725 break;
726 }
727 }
728 }
729 }
730
731 commit.Push( wxT( "Increase Track Width" ) );
732 return 0;
733 }
734
735 ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
736
737 if( routerTool && routerTool->IsToolActive()
738 && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
739 {
740 int widthIndex = designSettings.GetDiffPairIndex() + 1;
741
742 // If we go past the last track width entry in the list, start over at the beginning
743 if( widthIndex >= (int) designSettings.m_DiffPairDimensionsList.size() )
744 widthIndex = 0;
745
746 designSettings.SetDiffPairIndex( widthIndex );
747 designSettings.UseCustomDiffPairDimensions( false );
748
750 }
751 else
752 {
753 int widthIndex = designSettings.GetTrackWidthIndex();
754
755 if( routerTool && routerTool->IsToolActive()
756 && routerTool->Router()->GetState() == PNS::ROUTER::RouterState::ROUTE_TRACK
757 && designSettings.m_UseConnectedTrackWidth && !designSettings.m_TempOverrideTrackWidth )
758 {
759 designSettings.m_TempOverrideTrackWidth = true;
760 }
761 else
762 {
763 widthIndex++;
764 }
765
766 // If we go past the last track width entry in the list, start over at the beginning
767 if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
768 widthIndex = 0;
769
770 designSettings.SetTrackWidthIndex( widthIndex );
771 designSettings.UseCustomTrackViaSize( false );
772
774 }
775
776 return 0;
777}
int GetWidth() const
Definition: pcb_track.h:108

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

Referenced by setTransitions().

◆ UnlockSelected()

int BOARD_EDITOR_CONTROL::UnlockSelected ( const TOOL_EVENT aEvent)

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

Definition at line 1190 of file board_editor_control.cpp.

1191{
1192 return modifyLockSelected( OFF );
1193}

References modifyLockSelected(), and OFF.

Referenced by setTransitions().

◆ UpdatePCBFromSchematic()

int BOARD_EDITOR_CONTROL::UpdatePCBFromSchematic ( const TOOL_EVENT aEvent)

Definition at line 623 of file board_editor_control.cpp.

624{
626
627 if( m_frame->FetchNetlistFromSchematic( netlist, _( "Updating PCB requires a fully annotated "
628 "schematic." ) ) )
629 {
630 DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
631 updateDialog.ShowModal();
632 }
633
634 return 0;
635}
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)

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

638{
639 if( Kiface().IsSingle() )
640 {
641 DisplayErrorMessage( m_frame, _( "Cannot update schematic because Pcbnew is opened in "
642 "stand-alone mode. In order to create or update PCBs "
643 "from schematics, you must launch the KiCad project "
644 "manager and create a project." ) );
645 return 0;
646 }
647
650
651 if( frame )
652 {
653 std::string payload;
654
655 if( wxWindow* blocking_win = frame->Kiway().GetBlockingDialog() )
656 blocking_win->Close( true );
657
659 }
660 return 0;
661}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:620
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:491
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
@ FRAME_SCH
Definition: frame_type.h:34
@ MAIL_SCH_UPDATE
Definition: mail_type.h:47

References _, DisplayErrorMessage(), KIWAY::ExpressMail(), PCB_TOOL_BASE::frame(), FRAME_SCH, KIWAY::GetBlockingDialog(), 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 909 of file board_editor_control.cpp.

910{
911 BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
913
915 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
916 {
917 BOARD_COMMIT commit( this );
918
919 for( EDA_ITEM* item : selection )
920 {
921 if( item->Type() == PCB_VIA_T )
922 {
923 PCB_VIA* via = static_cast<PCB_VIA*>( item );
924
925 for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
926 {
927 VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
928
929 if( candidate.m_Diameter < via->GetWidth() )
930 {
931 commit.Modify( via );
932 via->SetWidth( candidate.m_Diameter );
933 via->SetDrill( candidate.m_Drill );
934 break;
935 }
936 }
937 }
938 }
939
940 commit.Push( "Decrease Via Size" );
941 }
942 else
943 {
944 int sizeIndex = 0; // Assume we only have a single via size entry
945
946 // If there are more, cycle through them backwards
947 if( designSettings.m_ViasDimensionsList.size() > 0 )
948 {
949 sizeIndex = designSettings.GetViaSizeIndex() - 1;
950
951 // If we get to the lowest entry start over at the highest
952 if( sizeIndex < 0 )
953 sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
954 }
955
956 designSettings.SetViaSizeIndex( sizeIndex );
957 designSettings.UseCustomTrackViaSize( false );
958
960 }
961
962 return 0;
963}
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
unsigned GetViaSizeIndex() const
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102

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

861{
862 BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
864
866 && SELECTION_CONDITIONS::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )( selection ) )
867 {
868 BOARD_COMMIT commit( this );
869
870 for( EDA_ITEM* item : selection )
871 {
872 if( item->Type() == PCB_VIA_T )
873 {
874 PCB_VIA* via = static_cast<PCB_VIA*>( item );
875
876 for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
877 {
878 if( candidate.m_Diameter > via->GetWidth() )
879 {
880 commit.Modify( via );
881 via->SetWidth( candidate.m_Diameter );
882 via->SetDrill( candidate.m_Drill );
883 break;
884 }
885 }
886 }
887 }
888
889 commit.Push( wxT( "Increase Via Size" ) );
890 }
891 else
892 {
893 int sizeIndex = designSettings.GetViaSizeIndex() + 1;
894
895 // If we go past the last via entry in the list, start over at the beginning
896 if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
897 sizeIndex = 0;
898
899 designSettings.SetViaSizeIndex( sizeIndex );
900 designSettings.UseCustomTrackViaSize( false );
901
903 }
904
905 return 0;
906}

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

◆ ZoneDuplicate()

int BOARD_EDITOR_CONTROL::ZoneDuplicate ( const TOOL_EVENT aEvent)

Definition at line 1378 of file board_editor_control.cpp.

1379{
1381 const PCB_SELECTION& selection = selTool->GetSelection();
1382
1383 // because this pops up the zone editor, it would be confusing to handle multiple zones,
1384 // so just handle single selections containing exactly one zone
1385 if( selection.Size() != 1 )
1386 return 0;
1387
1388 ZONE* oldZone = dyn_cast<ZONE*>( selection[0] );
1389
1390 if( !oldZone )
1391 return 0;
1392
1393 ZONE_SETTINGS zoneSettings;
1394 zoneSettings << *oldZone;
1395 int dialogResult;
1396
1397 if( oldZone->GetIsRuleArea() )
1398 dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings );
1399 else if( oldZone->IsOnCopperLayer() )
1400 dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1401 else
1402 dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1403
1404 if( dialogResult != wxID_OK )
1405 return 0;
1406
1407 // duplicate the zone
1408 BOARD_COMMIT commit( m_frame );
1409
1410 std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1411 newZone->ClearSelected();
1412 newZone->UnFill();
1413 zoneSettings.ExportSetting( *newZone );
1414
1415 // If the new zone is on the same layer(s) as the initial zone,
1416 // offset it a bit so it can more easily be picked.
1417 if( oldZone->GetIsRuleArea() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
1418 newZone->Move( VECTOR2I( pcbIUScale.IU_PER_MM, pcbIUScale.IU_PER_MM ) );
1419 else if( !oldZone->GetIsRuleArea() && zoneSettings.m_Layers.test( oldZone->GetLayer() ) )
1420 newZone->Move( VECTOR2I( pcbIUScale.IU_PER_MM, pcbIUScale.IU_PER_MM ) );
1421
1422 commit.Add( newZone.release() );
1423 commit.Push( _( "Duplicate zone" ) );
1424
1425 return 0;
1426}
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:70
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aZoneSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
const double IU_PER_MM
Definition: base_units.h:77

References _, COMMIT::Add(), ZONE_SETTINGS::ExportSetting(), ZONE::GetIsRuleArea(), ZONE::GetLayer(), ZONE::GetLayerSet(), PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), InvokeCopperZonesEditor(), InvokeNonCopperZonesEditor(), InvokeRuleAreaEditor(), ZONE::IsOnCopperLayer(), EDA_IU_SCALE::IU_PER_MM, m_frame, ZONE_SETTINGS::m_Layers, TOOL_BASE::m_toolMgr, pcbIUScale, 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 1291 of file board_editor_control.cpp.

1292{
1293 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1294 BOARD* board = getModel<BOARD>();
1295 BOARD_COMMIT commit( m_frame );
1296
1297 if( selection.Size() < 2 )
1298 return 0;
1299
1300 int netcode = -1;
1301
1302 ZONE* firstZone = nullptr;
1303 std::vector<ZONE*> toMerge, merged;
1304
1305 for( EDA_ITEM* item : selection )
1306 {
1307 ZONE* curr_area = dynamic_cast<ZONE*>( item );
1308
1309 if( !curr_area )
1310 continue;
1311
1312 if( !firstZone )
1313 firstZone = curr_area;
1314
1315 netcode = curr_area->GetNetCode();
1316
1317 if( firstZone->GetNetCode() != netcode )
1318 {
1319 wxLogMessage( _( "Some zone netcodes did not match and were not merged." ) );
1320 continue;
1321 }
1322
1323 if( curr_area->GetAssignedPriority() != firstZone->GetAssignedPriority() )
1324 {
1325 wxLogMessage( _( "Some zone priorities did not match and were not merged." ) );
1326 continue;
1327 }
1328
1329 if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1330 {
1331 wxLogMessage( _( "Some zones were rule areas and were not merged." ) );
1332 continue;
1333 }
1334
1335 if( curr_area->GetLayerSet() != firstZone->GetLayerSet() )
1336 {
1337 wxLogMessage( _( "Some zone layer sets did not match and were not merged." ) );
1338 continue;
1339 }
1340
1341 bool intersects = curr_area == firstZone;
1342
1343 for( ZONE* candidate : toMerge )
1344 {
1345 if( intersects )
1346 break;
1347
1348 if( board->TestZoneIntersection( curr_area, candidate ) )
1349 intersects = true;
1350 }
1351
1352 if( !intersects )
1353 {
1354 wxLogMessage( _( "Some zones did not intersect and were not merged." ) );
1355 continue;
1356 }
1357
1358 toMerge.push_back( curr_area );
1359 }
1360
1362
1363 if( !toMerge.empty() )
1364 {
1365 if( mergeZones( m_frame, commit, toMerge, merged ) )
1366 {
1367 commit.Push( wxT( "Merge zones" ) );
1368
1369 for( EDA_ITEM* item : merged )
1371 }
1372 }
1373
1374 return 0;
1375}
static bool mergeZones(EDA_DRAW_FRAME *aFrame, BOARD_COMMIT &aCommit, std::vector< ZONE * > &aOriginZones, std::vector< ZONE * > &aMergedZones)
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:703
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:122
unsigned GetAssignedPriority() const
Definition: zone.h:112

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

Referenced by setTransitions().

Member Data Documentation

◆ m_frame

◆ m_inPlaceFootprint

bool BOARD_EDITOR_CONTROL::m_inPlaceFootprint
private

Definition at line 147 of file board_editor_control.h.

Referenced by PlaceFootprint().

◆ m_inPlaceTarget

bool BOARD_EDITOR_CONTROL::m_inPlaceTarget
private

Definition at line 149 of file board_editor_control.h.

◆ m_isBoardEditor

bool PCB_TOOL_BASE::m_isBoardEditor
protectedinherited

◆ m_isFootprintEditor

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

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

Definition at line 125 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), EDA_3D_CONTROLLER::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< T >::Init(), SCH_DRAWING_TOOLS::Init(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), PICKER_TOOL::Init(), ZOOM_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_SELECTION_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), ROUTER_TOOL::Init(), Init(), DRAWING_TOOL::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PAD_TOOL::Init(), PCB_SELECTION_TOOL::Init(), PCB_TOOL_BASE::Init(), PCB_VIEWER_TOOLS::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDA_3D_CONTROLLER::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_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::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ m_placeOrigin

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

Definition at line 151 of file board_editor_control.h.

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

◆ m_placingFootprint

bool BOARD_EDITOR_CONTROL::m_placingFootprint
private

Definition at line 148 of file board_editor_control.h.

Referenced by PlaceFootprint(), and PlacingFootprint().

◆ 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(), SELECTION_TOOL::AddItemsToSel(), SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDITOR_CONTROL::ChangeLineMode(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), SCH_EDITOR_CONTROL::ClearHighlight(), BOARD_INSPECTION_TOOL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MICROWAVE_TOOL::createInductorBetween(), EE_INSPECTION_TOOL::CrossProbe(), DRC_TOOL::CrossProbe(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), SCH_EDITOR_CONTROL::doCopy(), doCrossProbePcbToSch(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SCH_EDIT_TOOL::DoDelete(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideRatsnestNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PCB_SELECTION_TOOL::doSyncSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::Drag(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), EditFpInFpEditor(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), PCB_SELECTION_TOOL::EnterGroup(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::ExitGroup(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCB_SELECTION_TOOL::grabUnconnected(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), EE_TOOL_BASE< T >::Init(), SCH_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_POINT_EDITOR::Init(), ROUTER_TOOL::Init(), Init(), BOARD_INSPECTION_TOOL::Init(), BOARD_REANNOTATE_TOOL::Init(), CONVERT_TOOL::Init(), DRAWING_TOOL::Init(), EDIT_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), PCB_POINT_EDITOR::Init(), PCB_SELECTION_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), POSITION_RELATIVE_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EDA_3D_CONTROLLER::Main(), CVPCB_CONTROL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), modifyLockSelected(), EDIT_TOOL::MoveExact(), SCH_EDITOR_CONTROL::NextLineMode(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), GERBVIEW_CONTROL::Print(), PCB_CONTROL::Print(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::rebuildConnectivity(), ZONE_FILLER_TOOL::rebuildConnectivity(), EE_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::RecombinePad(), SCH_EDITOR_CONTROL::Redo(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), PCB_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), PAD_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SCH_EDITOR_CONTROL::Revert(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), ROUTER_TOOL::RouteSelected(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), GERBVIEW_SELECTION_TOOL::selectPoint(), PL_SELECTION_TOOL::SelectPoint(), PCB_SELECTION_TOOL::selectPoint(), EE_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(), SCH_EDIT_TOOL::Swap(), EE_SELECTION_TOOL::SyncSelection(), COMMON_TOOLS::ToggleCursor(), COMMON_TOOLS::ToggleCursorStyle(), EDA_3D_CONTROLLER::ToggleVisibility(), TrackWidthDec(), TrackWidthInc(), SCH_MOVE_TOOL::trimDanglingLines(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_EDITOR_CONTROL::Undo(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), GROUP_TOOL::Ungroup(), PCB_SELECTION_TOOL::unrouteSelected(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), BOARD_INSPECTION_TOOL::UpdateLocalRatsnest(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), EE_POINT_EDITOR::updateParentItem(), 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().

◆ WIDTH_STEP

const int BOARD_EDITOR_CONTROL::WIDTH_STEP = 100000
staticprivate

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

Definition at line 153 of file board_editor_control.h.


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