KiCad PCB EDA Suite
PCB_EDITOR_CONTROL Class Reference

Class PCB_EDITOR_CONTROL. More...

#include <pcb_editor_control.h>

Inheritance diagram for PCB_EDITOR_CONTROL:
PCB_TOOL TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 PCB_EDITOR_CONTROL ()
 
 ~PCB_EDITOR_CONTROL ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
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)
 
int ZoneDuplicate (const TOOL_EVENT &aEvent)
 

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

More...
 
int PlaceTarget (const TOOL_EVENT &aEvent)
 Function PlaceTarget() Allows user to place a layer alignment target. More...
 
int PlaceModule (const TOOL_EVENT &aEvent)
 Function PlaceModule() Displays a dialog to select a module to be added and allows the user to set its position. More...
 
int ToggleLockSelected (const TOOL_EVENT &aEvent)
 

Toggles 'lock' property for selected items.

More...
 
int LockSelected (const TOOL_EVENT &aEvent)
 

Locks selected items.

More...
 
int UnlockSelected (const TOOL_EVENT &aEvent)
 

Unlocks selected items.

More...
 
int CrossProbePcbToSch (const TOOL_EVENT &aEvent)
 

Notifies eeschema about the selected item.

More...
 
int CrossProbeSchToPcb (const TOOL_EVENT &aEvent)
 

Reacts to selection change in eeschema.

More...
 
int DrillOrigin (const TOOL_EVENT &aEvent)
 

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

More...
 
int HighlightNet (const TOOL_EVENT &aEvent)
 

Highlights net belonging to the item under the cursor.

More...
 
int HighlightNetCursor (const TOOL_EVENT &aEvent)
 

Launches a tool to pick the item whose net is going to be highlighted.

More...
 
int UpdateSelectionRatsnest (const TOOL_EVENT &aEvent)
 

Updates ratsnest for selected items.

More...
 
int HideSelectionRatsnest (const TOOL_EVENT &aEvent)
 

Hides ratsnest for selected items. Called when there are no items selected.

More...
 
int ShowLocalRatsnest (const TOOL_EVENT &aEvent)
 

Shows local ratsnest of a component

More...
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Static Public Member Functions

static bool SetDrillOrigin (KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *aItem, const VECTOR2D &aPoint)
 

UI-level access (including undo) to setting the drill origin

More...
 
static bool DoSetDrillOrigin (KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *aItem, const VECTOR2D &aPoint)
 

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

More...
 

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS {
  IPO_ROTATE = 1, IPO_FLIP = 2, IPO_PROPERTIES = 4, IPO_SINGLE_CLICK = 8,
  IPO_REPEAT = 16
}
 

Protected Member Functions

void doInteractiveItemPlacement (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_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const SELECTIONselection () const
 
SELECTIONselection ()
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

bool m_editModules
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Types

enum  MODIFY_MODE { ON, OFF, TOGGLE }
 

How to modify a property for selected items.

More...
 

Private Member Functions

void ratsnestTimer (wxTimerEvent &aEvent)
 

Event handler to recalculate dynamic ratsnest

More...
 
void calculateSelectionRatsnest ()
 

Recalculates dynamic ratsnest for the current selection

More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
int modifyLockSelected (MODIFY_MODE aMode)
 

Private Attributes

PCB_EDIT_FRAMEm_frame
 

Pointer to the currently used edit frame.

More...
 
TOOL_MENU m_menu
 Menu model displayed by the tool. More...
 
std::unique_ptr< KIGFX::ORIGIN_VIEWITEMm_placeOrigin
 

Place & drill origin marker.

More...
 
bool m_probingSchToPcb
 

Flag to ignore a single crossprobe message from eeschema.

More...
 
bool m_slowRatsnest
 

Flag to indicate whether the current selection ratsnest is slow to calculate.

More...
 
wxTimer m_ratsnestTimer
 

Timer that start ratsnest calculation when it is slow to compute.

More...
 

Static Private Attributes

static const int WIDTH_STEP = 100000
 

Detailed Description

Class PCB_EDITOR_CONTROL.

Handles actions specific to the board editor in pcbnew.

Definition at line 42 of file pcb_editor_control.h.

Member Enumeration Documentation

enum PCB_TOOL::INTERACTIVE_PLACEMENT_OPTIONS
protectedinherited
Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 105 of file pcb_tool.h.

How to modify a property for selected items.

Enumerator
ON 
OFF 
TOGGLE 

Definition at line 148 of file pcb_editor_control.h.

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

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

Constructor & Destructor Documentation

PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL ( )

Definition at line 231 of file pcb_editor_control.cpp.

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

231  :
232  PCB_TOOL( "pcbnew.EditorControl" ),
233  m_frame( nullptr ),
234  m_menu( *this )
235 {
236  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
238  m_probingSchToPcb = false;
239  m_slowRatsnest = false;
240 }
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:70
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
bool m_probingSchToPcb
Flag to ignore a single crossprobe message from eeschema.
TOOL_MENU m_menu
Menu model displayed by the tool.
bool m_slowRatsnest
Flag to indicate whether the current selection ratsnest is slow to calculate.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
PCB_EDITOR_CONTROL::~PCB_EDITOR_CONTROL ( )

Definition at line 243 of file pcb_editor_control.cpp.

244 {
245 }

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

Referenced by EDIT_TOOL::copyToClipboard(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PlaceModule(), PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), ROUTER_TOOL::SettingsDialog(), and ShowLocalRatsnest().

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

Function attachManager()

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

Definition at line 59 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
friend class TOOL_SETTINGS
Definition: tool_base.h:155
BOARD* PCB_TOOL::board ( ) const
inlineprotectedinherited

Definition at line 136 of file pcb_tool.h.

Referenced by PCBNEW_CONTROL::AppendBoard(), calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), POINT_EDITOR::finishItem(), SELECTION_TOOL::getCollectorsGuide(), ROUTER_TOOL::getNetclassDimensions(), PCBNEW_CONTROL::GraphicDisplayMode(), PAD_TOOL::haveFootprints(), highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), ROUTER_TOOL::mainLoop(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PCBNEW_CONTROL::placeBoardItems(), MODULE_EDITOR_TOOLS::PlacePad(), PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), TrackWidthDec(), TrackWidthInc(), PCBNEW_CONTROL::ViaDisplayMode(), ViaSizeDec(), ViaSizeInc(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillAll(), ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

136 { return getModel<BOARD>(); }
void PCB_EDITOR_CONTROL::calculateSelectionRatsnest ( )
private

Recalculates dynamic ratsnest for the current selection

Definition at line 1169 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), BOARD::GetConnectivity(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, and PCB_TOOL::selection().

Referenced by ratsnestTimer(), and UpdateSelectionRatsnest().

1170 {
1171  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1172  auto& selection = selectionTool->GetSelection();
1173  auto connectivity = board()->GetConnectivity();
1174 
1175  std::vector<BOARD_ITEM*> items;
1176  items.reserve( selection.Size() );
1177 
1178  for( auto item : selection )
1179  items.push_back( static_cast<BOARD_ITEM*>( item ) );
1180 
1181  connectivity->ComputeDynamicRatsnest( items );
1182 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
BOARD * board() const
Definition: pcb_tool.h:136
PCB_DRAW_PANEL_GAL * PCB_TOOL::canvas ( ) const
protectedinherited
int PCB_EDITOR_CONTROL::CrossProbePcbToSch ( const TOOL_EVENT aEvent)

Notifies eeschema about the selected item.

Definition at line 831 of file pcb_editor_control.cpp.

References SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), m_frame, m_probingSchToPcb, TOOL_BASE::m_toolMgr, PCB_TOOL::selection(), and PCB_EDIT_FRAME::SendMessageToEESCHEMA().

Referenced by setTransitions().

832 {
833  if( m_probingSchToPcb )
834  {
835  m_probingSchToPcb = false;
836  return 0;
837  }
838 
840  const SELECTION& selection = selTool->GetSelection();
841 
842  if( selection.Size() == 1 )
843  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
844 
845  return 0;
846 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
SELECTION & GetSelection()
Function GetSelection()
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
void SendMessageToEESCHEMA(BOARD_ITEM *objectToSync)
Function SendMessageToEESCHEMA sends a message to the schematic editor so that it may move its cursor...
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
bool m_probingSchToPcb
Flag to ignore a single crossprobe message from eeschema.
int PCB_EDITOR_CONTROL::CrossProbeSchToPcb ( const TOOL_EVENT aEvent)

Reacts to selection change in eeschema.

Definition at line 849 of file pcb_editor_control.cpp.

References EDA_DRAW_FRAME::GetGalCanvas(), BOARD_ITEM::GetPosition(), EDA_DRAW_FRAME::GetToolId(), TOOL_BASE::getView(), PCB_ACTIONS::highlightNet, ID_PCB_HIGHLIGHT_BUTT, m_frame, m_probingSchToPcb, TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), PCB_PAD_T, EDA_DRAW_PANEL_GAL::Refresh(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW::SetCenter(), and EDA_ITEM::Type().

Referenced by setTransitions().

850 {
851  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
852 
853  if( item )
854  {
855  m_probingSchToPcb = true;
856  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
858 
859  // If it is a pad and the net highlighting tool is enabled, highlight the net
860  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
861  {
862  int net = static_cast<D_PAD*>( item )->GetNetCode();
864  }
865  else
866  // Otherwise simply select the corresponding item
867  {
869  // Ensure the display is refreshed, because in some installs
870  // the refresh is done only when the gal canvas has the focus, and
871  // that is not the case when crossprobing from Eeschema:
873  }
874  }
875 
876  return 0;
877 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:587
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
virtual const wxPoint GetPosition() const =0
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:385
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int GetToolId() const
Definition: draw_frame.h:488
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
bool m_probingSchToPcb
Flag to ignore a single crossprobe message from eeschema.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:895
PCB_DISPLAY_OPTIONS * PCB_TOOL::displayOptions ( ) const
protectedinherited

Definition at line 209 of file pcb_tool.cpp.

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

Referenced by PCBNEW_CONTROL::GraphicDisplayMode(), PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), PCBNEW_CONTROL::PadDisplayMode(), PNS::TOOL_BASE::pickSingleItem(), PCBNEW_CONTROL::TrackDisplayMode(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

210 {
211  return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
212 }
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:135
void PCB_TOOL::doInteractiveItemPlacement ( 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 39 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), PCB_TOOL::board(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

42 {
43  using namespace std::placeholders;
44  std::unique_ptr<BOARD_ITEM> newItem;
45 
46  Activate();
47 
48  BOARD_COMMIT commit( frame() );
49 
51 
52  // do not capture or auto-pan until we start placing an item
53  controls()->ShowCursor( true );
54  controls()->SetSnapping( true );
55 
56  // Add a VIEW_GROUP that serves as a preview for the new item
57  SELECTION preview;
58  view()->Add( &preview );
59 
60  aPlacer->m_board = board();
61  aPlacer->m_frame = frame();
62 
63  if( aOptions & IPO_SINGLE_CLICK )
64  {
65  VECTOR2I cursorPos = controls()->GetCursorPosition();
66 
67  newItem = aPlacer->CreateItem();
68  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
69 
70  preview.Add( newItem.get() );
71  }
72 
73  // Main loop: keep receiving events
74  while( OPT_TOOL_EVENT evt = Wait() )
75  {
76  VECTOR2I cursorPos = controls()->GetCursorPosition();
77 
79  {
80  if( newItem )
81  {
82  // Delete the old item and have another try
83  newItem = nullptr;
84 
85  preview.Clear();
86 
87  if( aOptions & IPO_SINGLE_CLICK )
88  break;
89 
90  controls()->SetAutoPan( false );
91  controls()->CaptureCursor( false );
92  controls()->ShowCursor( true );
93  }
94  else
95  {
96  break;
97  }
98 
99  if( evt->IsActivate() ) // now finish unconditionally
100  break;
101  }
102 
103  else if( evt->IsClick( BUT_LEFT ) )
104  {
105  if( !newItem )
106  {
107  // create the item if possible
108  newItem = aPlacer->CreateItem();
109 
110  // no item created, so wait for another click
111  if( !newItem )
112  continue;
113 
114  controls()->CaptureCursor( true );
115  controls()->SetAutoPan( true );
116 
117  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
118 
119  preview.Add( newItem.get() );
120 
121  if( newItem->Type() == PCB_MODULE_T )
122  {
123  auto module = dyn_cast<MODULE*>( newItem.get() );
124 
125  // modules have more drawable parts
126  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
127  }
128  }
129  else
130  {
131  newItem->ClearFlags();
132  preview.Remove( newItem.get() );
133 
134  aPlacer->PlaceItem( newItem.get(), commit );
135 
136  if( newItem->Type() == PCB_MODULE_T )
137  {
138  auto module = dyn_cast<MODULE*>( newItem.get() );
139  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
140  }
141 
142  newItem.release();
143  commit.Push( aCommitMessage );
144 
145  controls()->CaptureCursor( false );
146  controls()->SetAutoPan( false );
147  controls()->ShowCursor( true );
148 
149  if( !( aOptions & IPO_REPEAT ) )
150  break;
151 
152  if( aOptions & IPO_SINGLE_CLICK )
153  {
155 
156  newItem = aPlacer->CreateItem();
157  newItem->SetPosition( wxPoint( pos.x, pos.y ) );
158 
159  preview.Add( newItem.get() );
160  }
161  }
162  }
163 
164  else if( newItem && evt->Category() == TC_COMMAND )
165  {
166  /*
167  * Handle any events that can affect the item as we move
168  * it around, eg rotate and flip
169  */
170 
171  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
172  {
173  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
174  *frame(), *evt );
175  newItem->Rotate( newItem->GetPosition(), rotationAngle );
176  view()->Update( &preview );
177  }
178  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
179  {
180  newItem->Flip( newItem->GetPosition() );
181  view()->Update( &preview );
182  }
183  }
184 
185  else if( newItem && evt->IsMotion() )
186  {
187  // track the cursor
188  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
189  aPlacer->SnapItem( newItem.get() );
190 
191  // Show a preview of the item
192  view()->Update( &preview );
193  }
194  }
195 
196  view()->Remove( &preview );
197 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Definition: pcb_tool.cpp:239
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:84
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:81
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
PCB_EDIT_FRAME * m_frame
Definition: pcb_tool.h:58
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:64
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
virtual void SnapItem(BOARD_ITEM *aItem)
Definition: pcb_tool.cpp:234
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:134
class MODULE, a footprint
Definition: typeinfo.h:89
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:135
MODULE * module() const
Definition: pcb_tool.h:137
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:102
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:133
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool...
Definition: tool_base.h:144
void Activate()
Function Activate() Runs the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:48
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
BOARD * board() const
Definition: pcb_tool.h:136
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:79
bool PCB_EDITOR_CONTROL::DoSetDrillOrigin ( KIGFX::VIEW aView,
PCB_BASE_FRAME aFrame,
BOARD_ITEM aItem,
const VECTOR2D aPoint 
)
static

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

Definition at line 880 of file pcb_editor_control.cpp.

References KIGFX::VIEW::MarkDirty(), PCB_BASE_FRAME::OnModify(), PCB_BASE_FRAME::SetAuxOrigin(), BOARD_ITEM::SetPosition(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

882 {
883  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
884  originViewItem->SetPosition( wxPoint( aPosition.x, aPosition.y ) );
885  aView->MarkDirty();
886  aFrame->OnModify();
887  return true;
888 }
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
void SetAuxOrigin(const wxPoint &aPoint) override
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:603
int PCB_EDITOR_CONTROL::DrillOrigin ( const TOOL_EVENT aEvent)

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

Definition at line 899 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), ID_PCB_PLACE_OFFSET_COORD_BUTT, m_frame, m_placeOrigin, TOOL_BASE::m_toolMgr, PICKER_TOOL::SetClickHandler(), SetDrillOrigin(), PCB_BASE_FRAME::SetToolID(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

900 {
901  Activate();
902 
904  assert( picker );
905 
906  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) );
907  picker->SetClickHandler( std::bind( SetDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
908  picker->Activate();
909  Wait();
910 
911  return 0;
912 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:97
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Generic tool for picking a point.
Definition: picker_tool.h:34
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
void Activate()
Function Activate() Runs the tool.
static bool SetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *aItem, const VECTOR2D &aPoint)
UI-level access (including undo) to setting the drill origin
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 98 of file pcb_tool.h.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PAD_TOOL::Init(), and EDIT_TOOL::MeasureTool().

99  {
100  return m_editModules;
101  }
bool m_editModules
Definition: pcb_tool.h:143
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited

Definition at line 135 of file pcb_tool.h.

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), PAD_TOOL::applyPadSettings(), PCB_TOOL::canvas(), EDIT_TOOL::changeTrackWidthOnClick(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::displayOptions(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ROUTER_TOOL::finishInteractive(), getMicrowaveItemCreator(), highlightNet(), PICKER_TOOL::Init(), PAD_TOOL::Init(), EDIT_TOOL::Init(), SELECTION_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PasteItemsFromClipboard(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), MODULE_EDITOR_TOOLS::PlacePad(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::RouteDiffPair(), ROUTER_TOOL::RouteSingleTrace(), ROUTER_TOOL::SettingsDialog(), ROUTER_TOOL::switchLayerOnViaPlacement(), LENGTH_TUNER_TOOL::TuneDiffPair(), LENGTH_TUNER_TOOL::TuneDiffPairSkew(), LENGTH_TUNER_TOOL::TuneSingleTrace(), POINT_EDITOR::updateItem(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

135 { return getEditFrame<PCB_EDIT_FRAME>(); }
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 188 of file tool_base.h.

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

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

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

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

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

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

Definition at line 144 of file tool_base.h.

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

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

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

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

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

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

Definition at line 77 of file tool_base.cpp.

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

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

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

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

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

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PlaceModule(), PlaceTarget(), Reset(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

36 {
37  return m_toolMgr->GetView();
38 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Function getViewControls()

Returns 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 41 of file tool_base.cpp.

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

Referenced by POINT_EDITOR::addCorner(), PCBNEW_CONTROL::CursorControl(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), HighlightNet(), HighlightNetCursor(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), PlaceModule(), PlaceTarget(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), EDIT_TOOL::updateModificationPoint(), COMMON_TOOLS::ZoomCenter(), and COMMON_TOOLS::ZoomInOut().

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

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

Definition at line 135 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), COMMON_TOOLS::setTransitions(), GERBVIEW_CONTROL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), and DRAWING_TOOL::setTransitions().

137 {
138  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
139 
140  goInternal( sptr, aConditions );
141 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
int PCB_EDITOR_CONTROL::HideSelectionRatsnest ( const TOOL_EVENT aEvent)

Hides ratsnest for selected items. Called when there are no items selected.

Definition at line 1152 of file pcb_editor_control.cpp.

References m_slowRatsnest.

Referenced by setTransitions().

1153 {
1154  getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
1155  m_slowRatsnest = false;
1156  return 0;
1157 }
bool m_slowRatsnest
Flag to indicate whether the current selection ratsnest is slow to calculate.
int PCB_EDITOR_CONTROL::HighlightNet ( const TOOL_EVENT aEvent)

Highlights net belonging to the item under the cursor.

Definition at line 1024 of file pcb_editor_control.cpp.

References KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_MANAGER::GetView(), TOOL_BASE::getViewControls(), highlightNet(), TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), KIGFX::RENDER_SETTINGS::SetHighlight(), and KIGFX::VIEW::UpdateAllLayersColor().

Referenced by setTransitions().

1025 {
1026  int netcode = aEvent.Parameter<intptr_t>();
1027 
1028  if( netcode > 0 )
1029  {
1031  render->SetHighlight( true, netcode );
1033  }
1034  else
1035  {
1036  // No net code specified, pick the net code belonging to the item under the cursor
1037  highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
1038  }
1039 
1040  return 0;
1041 }
Class RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output ...
Definition: painter.h:56
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition, bool aUseSelection=false)
Function highlightNet() Looks for a BOARD_CONNECTED_ITEM in a given spot, and if one is found - it en...
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:743
void SetHighlight(bool aEnabled, int aNetcode=-1)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
Definition: painter.h:140
int PCB_EDITOR_CONTROL::HighlightNetCursor ( const TOOL_EVENT aEvent)

Launches a tool to pick the item whose net is going to be highlighted.

Definition at line 1044 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), TOOL_MANAGER::GetTool(), EDA_DRAW_FRAME::GetToolId(), TOOL_BASE::getViewControls(), highlightNet(), PCB_ACTIONS::highlightNetSelection, ID_PCB_HIGHLIGHT_BUTT, TOOL_EVENT::IsAction(), m_frame, TOOL_BASE::m_toolMgr, PICKER_TOOL::SetClickHandler(), PICKER_TOOL::SetSnapping(), PCB_BASE_FRAME::SetToolID(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

1045 {
1046  // If the keyboard hotkey was triggered, the behavior is as follows:
1047  // If we are already in the highlight tool, behave the same as a left click.
1048  // If we are not, highlight the net of the selected item(s), or if there is
1049  // no selection, then behave like a Ctrl+Left Click.
1051  {
1052  bool use_selection = ( m_frame->GetToolId() != ID_PCB_HIGHLIGHT_BUTT );
1053  highlightNet( m_toolMgr, getViewControls()->GetMousePosition(),
1054  use_selection );
1055  }
1056 
1057  Activate();
1058 
1059  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1060  assert( picker );
1061 
1062  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
1063  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1, false ) );
1064  picker->SetSnapping( false );
1065  picker->Activate();
1066  Wait();
1067 
1068  return 0;
1069 }
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:56
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:97
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
Generic tool for picking a point.
Definition: picker_tool.h:34
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static TOOL_ACTION highlightNetSelection
Definition: pcb_actions.h:387
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int GetToolId() const
Definition: draw_frame.h:488
void Activate()
Function Activate() Runs the tool.
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition, bool aUseSelection=false)
Function highlightNet() Looks for a BOARD_CONNECTED_ITEM in a given spot, and if one is found - it en...
bool PCB_EDITOR_CONTROL::Init ( )
overridevirtual

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

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

Reimplemented from TOOL_BASE.

Definition at line 261 of file pcb_editor_control.cpp.

References CONDITIONAL_MENU::AddItem(), TOOL_MENU::AddStandardSubMenus(), ACTIONS::cancelInteractive, PCB_ACTIONS::findMove, DRAWING_TOOL::GetDrawingMode(), TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), EDA_DRAW_FRAME::GetToolId(), DRAWING_TOOL::GetToolMenu(), SELECTION_TOOL::GetToolMenu(), ID_NO_TOOL_SELECTED, ID_PCB_MODULE_BUTT, m_frame, m_menu, m_ratsnestTimer, TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::OnlyType(), SELECTION_CONDITIONS::OnlyTypes(), PCB_ZONE_AREA_T, ratsnestTimer(), GENERAL_COLLECTOR::Tracks, and DRAWING_TOOL::ZONE.

262 {
263  auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
264  return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
265  };
266 
267  auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
268  return ( m_frame->GetToolId() == ID_NO_TOOL_SELECTED && aSel.Size() == 0 );
269  };
270 
271  auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
272  return ( m_frame->GetToolId() == ID_PCB_MODULE_BUTT && aSel.GetSize() == 0 );
273  };
274 
275  auto& ctxMenu = m_menu.GetMenu();
276 
277  // "Cancel" goes at the top of the context menu when a tool is active
278  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1000 );
279  ctxMenu.AddSeparator( activeToolCondition, 1000 );
280 
281  // "Get and Place Footprint" should be available for Place Footprint tool
282  ctxMenu.AddItem( PCB_ACTIONS::findMove, placeModuleCondition, 1000 );
283  ctxMenu.AddSeparator( placeModuleCondition, 1000 );
284 
285  // Finally, add the standard zoom & grid items
286  m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
287 
288  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
289  zoneMenu->SetTool( this );
290 
291  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
292  lockMenu->SetTool( this );
293 
294  // Add the PCB control menus to relevant other tools
295 
297 
298  if( selTool )
299  {
300  auto& toolMenu = selTool->GetToolMenu();
301  auto& menu = toolMenu.GetMenu();
302 
303  // Add "Get and Place Footprint" when Selection tool is in an inactive state
304  menu.AddItem( PCB_ACTIONS::findMove, inactiveStateCondition );
305  menu.AddSeparator( inactiveStateCondition );
306 
307  toolMenu.AddSubMenu( zoneMenu );
308  toolMenu.AddSubMenu( lockMenu );
309 
310  menu.AddMenu( zoneMenu.get(), false,
312 
313  menu.AddMenu( lockMenu.get(), false,
315  }
316 
317  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
318 
319  if( drawingTool )
320  {
321  auto& toolMenu = drawingTool->GetToolMenu();
322  auto& menu = toolMenu.GetMenu();
323 
324  toolMenu.AddSubMenu( zoneMenu );
325 
326  // Functor to say if the PCB_EDIT_FRAME is in a given mode
327  // Capture the tool pointer and tool mode by value
328  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
329  {
330  return [=]( const SELECTION& sel )
331  {
332  return drawingTool->GetDrawingMode() == aMode;
333  };
334  };
335 
336  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
337  }
338 
339  m_ratsnestTimer.SetOwner( this );
340  Connect( m_ratsnestTimer.GetId(), wxEVT_TIMER,
341  wxTimerEventHandler( PCB_EDITOR_CONTROL::ratsnestTimer ), NULL, this );
342 
343  return true;
344 }
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:305
MODE GetDrawingMode() const
Function GetDrawingMode.
Class SELECTION_TOOL.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
wxTimer m_ratsnestTimer
Timer that start ratsnest calculation when it is slow to compute.
TOOL_MENU & GetToolMenu()
Get the DRAWING_TOOL top-level context menu
Definition: drawing_tool.h:62
void AddStandardSubMenus(EDA_DRAW_FRAME &aFrame)
Function CreateBasicMenu.
Definition: tool_menu.cpp:95
Class DRAWING_TOOL.
Definition: drawing_tool.h:49
static SELECTION_CONDITION OnlyTypes(const std::vector< KICAD_T > &aTypes)
Function OnlyTypes Creates a functor that tests if the selected items are only of given types...
void ratsnestTimer(wxTimerEvent &aEvent)
Event handler to recalculate dynamic ratsnest
MODE
The possible drawing modes of DRAWING_TOOL
Definition: drawing_tool.h:68
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddItem()
int GetToolId() const
Definition: draw_frame.h:488
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type...
TOOL_MENU m_menu
Menu model displayed by the tool.
static TOOL_ACTION findMove
Find an item and start moving.
Definition: pcb_actions.h:399
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

31 {
32  return m_toolMgr->IsToolActive( m_toolId );
33 }
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns true if a tool with given id is active (executing) ...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
int PCB_EDITOR_CONTROL::LockSelected ( const TOOL_EVENT aEvent)

Locks selected items.

Definition at line 524 of file pcb_editor_control.cpp.

References modifyLockSelected(), and ON.

Referenced by setTransitions().

525 {
526  return modifyLockSelected( ON );
527 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::modifyLockSelected ( MODIFY_MODE  aMode)
private

Definition at line 536 of file pcb_editor_control.cpp.

References SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), i, BOARD_ITEM::IsLocked(), m_frame, TOOL_BASE::m_toolMgr, OFF, ON, PCB_EDIT_FRAME::OnModify(), TOOL_MANAGER::RunAction(), PCB_TOOL::selection(), PCB_ACTIONS::selectionCursor, and TOGGLE.

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

537 {
539  const SELECTION& selection = selTool->GetSelection();
540 
541  if( selection.Empty() )
543 
544  bool modified = false;
545 
546  for( auto i : selection )
547  {
548  auto item = static_cast<BOARD_ITEM*>( i );
549  bool prevState = item->IsLocked();
550 
551  switch( aMode )
552  {
553  case ON:
554  item->SetLocked( true );
555  break;
556 
557  case OFF:
558  item->SetLocked( false );
559  break;
560 
561  case TOGGLE:
562  item->SetLocked( !prevState );
563  break;
564  }
565 
566  // Check if we really modified an item
567  if( !modified && prevState != item->IsLocked() )
568  modified = true;
569  }
570 
571  if( modified )
572  m_frame->OnModify();
573 
574  return 0;
575 }
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION & GetSelection()
Function GetSelection()
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
virtual bool IsLocked() const
Function IsLocked.
size_t i
Definition: json11.cpp:597
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:50
int PCB_EDITOR_CONTROL::PlaceModule ( const TOOL_EVENT aEvent)

Function PlaceModule() Displays a dialog to select a module to be added and allows the user to set its position.

Definition at line 416 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), COMMIT::Added(), PCB_BASE_FRAME::AddModuleToBoard(), BUT_LEFT, BUT_RIGHT, PCB_TOOL::controls(), SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), ID_PCB_MODULE_BUTT, TOOL_EVT_UTILS::IsCancelInteractive(), PCB_BASE_FRAME::LoadModuleFromLibrary(), m_frame, m_menu, TOOL_BASE::m_toolMgr, PCB_TOOL::module(), TOOL_EVENT::Parameter(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), BOARD_COMMIT::Revert(), TOOL_MANAGER::RunAction(), PCB_TOOL::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, EDA_DRAW_FRAME::SetNoToolSelected(), MODULE::SetPosition(), PCB_BASE_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

417 {
418  MODULE* module = aEvent.Parameter<MODULE*>();
421  SELECTION& selection = selTool->GetSelection();
422  BOARD_COMMIT commit( m_frame );
423 
425  controls->ShowCursor( true );
426  controls->SetSnapping( true );
427 
428  Activate();
429  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_PENCIL, _( "Add footprint" ) );
430 
431  // Add all the drawable parts to preview
432  VECTOR2I cursorPos = controls->GetCursorPosition();
433 
434  if( module )
435  {
436  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
437  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
438  }
439 
440  bool reselect = false;
441 
442  // Main loop: keep receiving events
443  while( OPT_TOOL_EVENT evt = Wait() )
444  {
445  cursorPos = controls->GetCursorPosition();
446 
447  if( reselect && module )
448  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
449 
450  if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
451  {
452  if( module )
453  {
455  commit.Revert();
456  module = NULL;
457  }
458  else // let's have another chance placing a module
459  break;
460 
461  if( evt->IsActivate() ) // now finish unconditionally
462  break;
463  }
464 
465  else if( evt->IsClick( BUT_LEFT ) )
466  {
467  if( !module )
468  {
469  // Pick the module to be placed
470  module = m_frame->LoadModuleFromLibrary( wxEmptyString );
471 
472  if( module == NULL )
473  continue;
474 
475  m_frame->AddModuleToBoard( module );
476  commit.Added( module );
477  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
478  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
479  controls->SetCursorPosition( cursorPos, false );
480  }
481  else
482  {
484  commit.Push( _( "Place a module" ) );
485  module = NULL; // to indicate that there is no module that we currently modify
486  }
487  }
488 
489  else if( evt->IsClick( BUT_RIGHT ) )
490  {
491  m_menu.ShowContextMenu( selTool->GetSelection() );
492  }
493 
494  else if( module && evt->IsMotion() )
495  {
496  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
497  selection.SetReferencePoint( cursorPos );
498  getView()->Update( &selection );
499  }
500 
501  else if( module && evt->IsAction( &PCB_ACTIONS::properties ) )
502  {
503  // Calling 'Properties' action clears the selection, so we need to restore it
504  reselect = true;
505  }
506 
507  // Enable autopanning and cursor capture only when there is a module to be placed
508  controls->SetAutoPan( !!module );
509  controls->CaptureCursor( !!module );
510  }
511 
513 
514  return 0;
515 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
MODULE * LoadModuleFromLibrary(const wxString &aLibrary, bool aUseFootprintViewer=true)
Function LoadModuleFromLibrary opens a dialog to select a footprint.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:108
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:134
SELECTION & GetSelection()
Function GetSelection()
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
MODULE * module() const
Definition: pcb_tool.h:137
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
void SetPosition(const wxPoint &aPos) override
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1499
void AddModuleToBoard(MODULE *module, wxDC *aDC=nullptr)
Adds the given module to the board.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:616
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
void Activate()
Function Activate() Runs the tool.
TOOL_MENU m_menu
Menu model displayed by the tool.
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
int PCB_EDITOR_CONTROL::PlaceTarget ( const TOOL_EVENT aEvent)

Function PlaceTarget() Allows user to place a layer alignment target.

Definition at line 578 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), PCB_TOOL::board(), BUT_LEFT, BUT_RIGHT, PCB_TOOL::controls(), PCB_ACTIONS::decWidth, Edge_Cuts, KIGFX::VIEW_CONTROLS::GetCursorPosition(), BOARD::GetDesignSettings(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), ID_PCB_TARGET_BUTT, PCB_ACTIONS::incWidth, TOOL_EVT_UTILS::IsCancelInteractive(), BOARD_DESIGN_SETTINGS::m_EdgeSegmentWidth, m_frame, m_menu, TOOL_BASE::m_toolMgr, KIGFX::VIEW_GROUP::Remove(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, EDA_DRAW_FRAME::SetNoToolSelected(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), WIDTH_STEP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

579 {
580  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
581  KIGFX::VIEW* view = getView();
583  BOARD* board = getModel<BOARD>();
584  PCB_TARGET* target = new PCB_TARGET( board );
585 
586  // Init the new item attributes
587  target->SetLayer( Edge_Cuts );
588  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
589  target->SetSize( Millimeter2iu( 5 ) );
590  VECTOR2I cursorPos = controls->GetCursorPosition();
591  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
592 
593  // Add a VIEW_GROUP that serves as a preview for the new item
594  KIGFX::VIEW_GROUP preview( view );
595  preview.Add( target );
596  view->Add( &preview );
597 
599  controls->SetSnapping( true );
600 
601  Activate();
602  m_frame->SetToolID( ID_PCB_TARGET_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
603 
604  // Main loop: keep receiving events
605  while( OPT_TOOL_EVENT evt = Wait() )
606  {
607  cursorPos = controls->GetCursorPosition();
608 
609  if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
610  break;
611 
612  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
613  {
614  target->SetWidth( target->GetWidth() + WIDTH_STEP );
615  view->Update( &preview );
616  }
617 
618  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
619  {
620  int width = target->GetWidth();
621 
622  if( width > WIDTH_STEP )
623  {
624  target->SetWidth( width - WIDTH_STEP );
625  view->Update( &preview );
626  }
627  }
628 
629  else if( evt->IsClick( BUT_LEFT ) )
630  {
631  assert( target->GetSize() > 0 );
632  assert( target->GetWidth() > 0 );
633 
634  BOARD_COMMIT commit( m_frame );
635  commit.Add( target );
636  commit.Push( _( "Place a layer alignment target" ) );
637 
638  preview.Remove( target );
639 
640  // Create next PCB_TARGET
641  target = new PCB_TARGET( *target );
642  preview.Add( target );
643  }
644 
645  else if( evt->IsClick( BUT_RIGHT ) )
646  {
647  m_menu.ShowContextMenu( selTool->GetSelection() );
648  }
649 
650  else if( evt->IsMotion() )
651  {
652  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
653  view->Update( &preview );
654  }
655  }
656 
657  delete target;
658 
659  controls->SetSnapping( false );
660  view->Remove( &preview );
661 
663 
664  return 0;
665 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:184
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:187
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:134
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:616
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:133
static const int WIDTH_STEP
void Activate()
Function Activate() Runs the tool.
TOOL_MENU m_menu
Menu model displayed by the tool.
Class VIEW.
Definition: view.h:58
int m_EdgeSegmentWidth
current graphic line width (EDGE layer only)
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
BOARD * board() const
Definition: pcb_tool.h:136
void PCB_EDITOR_CONTROL::ratsnestTimer ( wxTimerEvent &  aEvent)
private

Event handler to recalculate dynamic ratsnest

Definition at line 1160 of file pcb_editor_control.cpp.

References calculateSelectionRatsnest(), EDA_DRAW_FRAME::GetGalCanvas(), m_frame, m_ratsnestTimer, and EDA_DRAW_PANEL_GAL::Refresh().

Referenced by Init().

1161 {
1162  m_ratsnestTimer.Stop();
1164  static_cast<PCB_DRAW_PANEL_GAL*>( m_frame->GetGalCanvas() )->RedrawRatsnest();
1166 }
wxTimer m_ratsnestTimer
Timer that start ratsnest calculation when it is slow to compute.
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:895
void calculateSelectionRatsnest()
Recalculates dynamic ratsnest for the current selection
void PCB_EDITOR_CONTROL::Reset ( RESET_REASON  aReason)
overridevirtual

Function Reset() Brings the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PCB_TOOL.

Definition at line 248 of file pcb_editor_control.cpp.

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

249 {
250  m_frame = getEditFrame<PCB_EDIT_FRAME>();
251 
252  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
253  {
254  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
255  getView()->Remove( m_placeOrigin.get() );
256  getView()->Add( m_placeOrigin.get() );
257  }
258 }
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
Model changes (required full reload)
Definition: tool_base.h:83
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:364
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:334
Rendering engine changes.
Definition: tool_base.h:84
void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 85 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
const SELECTION & PCB_TOOL::selection ( ) const
protectedinherited

Definition at line 219 of file pcb_tool.cpp.

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

Referenced by PAD_TOOL::applyPadSettings(), calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), CrossProbePcbToSch(), deleteItem(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), highlightNet(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::placeBoardItems(), PlaceModule(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), EDIT_TOOL::Rotate(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), SELECTION_TOOL::selectNet(), selectPRitem(), showLocalRatsnest(), UpdateSelectionRatsnest(), ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

220 {
221  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
222  const auto& selection = selTool->GetSelection();
223  return selection;
224 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
SELECTION & PCB_TOOL::selection ( )
protectedinherited

Definition at line 226 of file pcb_tool.cpp.

References TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, and PCB_TOOL::selection().

227 {
228  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
229  auto& selection = selTool->GetSelection();
230  return selection;
231 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

Assigns a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 74 of file tool_interactive.cpp.

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

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

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool&#39;s context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
bool PCB_EDITOR_CONTROL::SetDrillOrigin ( KIGFX::VIEW aView,
PCB_BASE_FRAME aFrame,
BOARD_ITEM aItem,
const VECTOR2D aPoint 
)
static

UI-level access (including undo) to setting the drill origin

Definition at line 891 of file pcb_editor_control.cpp.

References DoSetDrillOrigin(), PCB_BASE_FRAME::SaveCopyInUndoList(), and UR_DRILLORIGIN.

Referenced by DrillOrigin(), and PCB_EDIT_FRAME::OnLeftClick().

893 {
894  aFrame->SaveCopyInUndoList( originViewItem, UR_DRILLORIGIN );
895  return DoSetDrillOrigin( aView, aFrame, originViewItem, aPosition );
896 }
static bool DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *aItem, const VECTOR2D &aPoint)
Low-level access (below undo) to setting the drill origin
virtual void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))=0
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
void PCB_TOOL::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

Toggles edit module mode. When enabled, one may select parts of modules individually (graphics, pads, etc.), so they can be modified.

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 93 of file pcb_tool.h.

94  {
95  m_editModules = aEnabled;
96  }
bool m_editModules
Definition: pcb_tool.h:143
void PCB_EDITOR_CONTROL::setTransitions ( )
overrideprivatevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL.

Definition at line 1185 of file pcb_editor_control.cpp.

References SELECTION_TOOL::ClearedEvent, CrossProbePcbToSch(), CrossProbeSchToPcb(), PCB_ACTIONS::crossProbeSchToPcb, DrillOrigin(), PCB_ACTIONS::drillOrigin, TOOL_INTERACTIVE::Go(), HideSelectionRatsnest(), HighlightNet(), PCB_ACTIONS::highlightNet, HighlightNetCursor(), PCB_ACTIONS::highlightNetCursor, PCB_ACTIONS::highlightNetSelection, PCB_ACTIONS::lock, LockSelected(), PlaceModule(), PCB_ACTIONS::placeModule, PlaceTarget(), PCB_ACTIONS::placeTarget, SELECTION_TOOL::SelectedEvent, PCB_ACTIONS::selectionModified, ShowLocalRatsnest(), PCB_ACTIONS::showLocalRatsnest, PCB_ACTIONS::toggleLock, ToggleLockSelected(), TrackWidthDec(), PCB_ACTIONS::trackWidthDec, TrackWidthInc(), PCB_ACTIONS::trackWidthInc, PCB_ACTIONS::unlock, UnlockSelected(), UpdateSelectionRatsnest(), ViaSizeDec(), PCB_ACTIONS::viaSizeDec, ViaSizeInc(), PCB_ACTIONS::viaSizeInc, WIDTH_STEP, ZoneDuplicate(), PCB_ACTIONS::zoneDuplicate, ZoneMerge(), and PCB_ACTIONS::zoneMerge.

1186 {
1187  // Track & via size control
1192 
1193  // Zone actions
1196 
1197  // Placing tools
1200 
1201  // Other
1214 }
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:373
static TOOL_ACTION placeModule
Activation of the drawing tool (placing a MODULE)
Definition: pcb_actions.h:175
int ZoneMerge(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:375
int PlaceModule(const TOOL_EVENT &aEvent)
Function PlaceModule() Displays a dialog to select a module to be added and allows the user to set it...
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:388
static TOOL_ACTION lock
Definition: pcb_actions.h:374
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:288
int TrackWidthDec(const TOOL_EVENT &aEvent)
int HideSelectionRatsnest(const TOOL_EVENT &aEvent)
Hides ratsnest for selected items. Called when there are no items selected.
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:287
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
static TOOL_ACTION highlightNetCursor
Definition: pcb_actions.h:386
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION showLocalRatsnest
Definition: pcb_actions.h:392
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:111
static TOOL_ACTION crossProbeSchToPcb
Definition: pcb_actions.h:389
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:286
int ShowLocalRatsnest(const TOOL_EVENT &aEvent)
Shows local ratsnest of a component
int ViaSizeDec(const TOOL_EVENT &aEvent)
int TrackWidthInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:298
int DrillOrigin(const TOOL_EVENT &aEvent)
Runs the drill origin tool for setting the origin for drill and pick-and-place files.
int ViaSizeInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeTarget
Activation of the drawing tool (placing a TARGET)
Definition: pcb_actions.h:172
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
int UnlockSelected(const TOOL_EVENT &aEvent)
Unlocks selected items.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launches a tool to pick the item whose net is going to be highlighted.
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:301
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Updates ratsnest for selected items.
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:385
static TOOL_ACTION highlightNetSelection
Definition: pcb_actions.h:387
int PlaceTarget(const TOOL_EVENT &aEvent)
Function PlaceTarget() Allows user to place a layer alignment target.
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Notifies eeschema about the selected item.
int CrossProbeSchToPcb(const TOOL_EVENT &aEvent)
Reacts to selection change in eeschema.
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Toggles &#39;lock&#39; property for selected items.
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:289
int PCB_EDITOR_CONTROL::ShowLocalRatsnest ( const TOOL_EVENT aEvent)

Shows local ratsnest of a component

Definition at line 1099 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), TOOL_MANAGER::GetTool(), ID_PCB_SHOW_1_RATSNEST_BUTT, m_frame, TOOL_BASE::m_toolMgr, PCB_BASE_FRAME::SetToolID(), showLocalRatsnest(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

1100 {
1101  Activate();
1102 
1103  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
1104  assert( picker );
1105 
1106  m_frame->SetToolID( ID_PCB_SHOW_1_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) );
1107  picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, _1 ) );
1108  picker->SetSnapping( false );
1109  picker->Activate();
1110  Wait();
1111 
1112  return 0;
1113 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Generic tool for picking a point.
Definition: picker_tool.h:34
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
static bool showLocalRatsnest(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
void Activate()
Function Activate() Runs the tool.
int PCB_EDITOR_CONTROL::ToggleLockSelected ( const TOOL_EVENT aEvent)

Toggles 'lock' property for selected items.

Definition at line 518 of file pcb_editor_control.cpp.

References modifyLockSelected(), and TOGGLE.

Referenced by setTransitions().

519 {
520  return modifyLockSelected( TOGGLE );
521 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::TrackWidthDec ( const TOOL_EVENT aEvent)

Definition at line 365 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetTrackWidthIndex(), TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), BOARD_DESIGN_SETTINGS::SetTrackWidthIndex(), PCB_ACTIONS::trackViaSizeChanged, and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

366 {
367  BOARD* board = getModel<BOARD>();
368  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
369 
370  if( widthIndex < 0 )
371  widthIndex = 0;
372 
373  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
374  board->GetDesignSettings().UseCustomTrackViaSize( false );
375 
377 
378  return 0;
379 }
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:291
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD * board() const
Definition: pcb_tool.h:136
int PCB_EDITOR_CONTROL::TrackWidthInc ( const TOOL_EVENT aEvent)

Definition at line 348 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetTrackWidthIndex(), TOOL_BASE::m_toolMgr, BOARD_DESIGN_SETTINGS::m_TrackWidthList, TOOL_MANAGER::RunAction(), BOARD_DESIGN_SETTINGS::SetTrackWidthIndex(), PCB_ACTIONS::trackViaSizeChanged, and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

349 {
350  BOARD* board = getModel<BOARD>();
351  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
352 
353  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
354  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
355 
356  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
357  board->GetDesignSettings().UseCustomTrackViaSize( false );
358 
360 
361  return 0;
362 }
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
std::vector< int > m_TrackWidthList
Track width list.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:291
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD * board() const
Definition: pcb_tool.h:136
int PCB_EDITOR_CONTROL::UnlockSelected ( const TOOL_EVENT aEvent)

Unlocks selected items.

Definition at line 530 of file pcb_editor_control.cpp.

References modifyLockSelected(), and OFF.

Referenced by setTransitions().

531 {
532  return modifyLockSelected( OFF );
533 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest ( const TOOL_EVENT aEvent)

Updates ratsnest for selected items.

Definition at line 1116 of file pcb_editor_control.cpp.

References calculateSelectionRatsnest(), TOOL_MANAGER::GetTool(), m_ratsnestTimer, m_slowRatsnest, TOOL_BASE::m_toolMgr, PROF_COUNTER::msecs(), PCB_TOOL::selection(), and PROF_COUNTER::Stop().

Referenced by setTransitions().

1117 {
1118  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1119  auto& selection = selectionTool->GetSelection();
1120  auto connectivity = getModel<BOARD>()->GetConnectivity();
1121 
1122  if( selection.Empty() )
1123  {
1124  connectivity->ClearDynamicRatsnest();
1125  }
1126  else if( m_slowRatsnest )
1127  {
1128  // Compute ratsnest only when user stops dragging for a moment
1129  connectivity->HideDynamicRatsnest();
1130  m_ratsnestTimer.Start( 20 );
1131  }
1132  else
1133  {
1134  // Check how much time doest it take to calculate ratsnest
1135  PROF_COUNTER counter;
1137  counter.Stop();
1138 
1139  // If it is too slow, then switch to 'slow ratsnest' mode when
1140  // ratsnest is calculated when user stops dragging items for a moment
1141  if( counter.msecs() > 25 )
1142  {
1143  m_slowRatsnest = true;
1144  connectivity->HideDynamicRatsnest();
1145  }
1146  }
1147 
1148  return 0;
1149 }
void Stop()
save the time when this function was called, and set the counter stane to stop
Definition: profile.h:82
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:45
wxTimer m_ratsnestTimer
Timer that start ratsnest calculation when it is slow to compute.
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
double msecs() const
Definition: profile.h:124
bool m_slowRatsnest
Flag to indicate whether the current selection ratsnest is slow to calculate.
void calculateSelectionRatsnest()
Recalculates dynamic ratsnest for the current selection
int PCB_EDITOR_CONTROL::ViaSizeDec ( const TOOL_EVENT aEvent)

Definition at line 399 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetViaSizeIndex(), TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), BOARD_DESIGN_SETTINGS::SetViaSizeIndex(), PCB_ACTIONS::trackViaSizeChanged, and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

400 {
401  BOARD* board = getModel<BOARD>();
402  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
403 
404  if( sizeIndex < 0 )
405  sizeIndex = 0;
406 
407  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
408  board->GetDesignSettings().UseCustomTrackViaSize( false );
409 
411 
412  return 0;
413 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:291
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD * board() const
Definition: pcb_tool.h:136
int PCB_EDITOR_CONTROL::ViaSizeInc ( const TOOL_EVENT aEvent)

Definition at line 382 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetViaSizeIndex(), TOOL_BASE::m_toolMgr, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, TOOL_MANAGER::RunAction(), BOARD_DESIGN_SETTINGS::SetViaSizeIndex(), PCB_ACTIONS::trackViaSizeChanged, and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

383 {
384  BOARD* board = getModel<BOARD>();
385  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
386 
387  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
388  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
389 
390  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
391  board->GetDesignSettings().UseCustomTrackViaSize( false );
392 
394 
395  return 0;
396 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:291
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Vias size and drill list.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD * board() const
Definition: pcb_tool.h:136
OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

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

Definition at line 55 of file tool_interactive.cpp.

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

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

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

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

Definition at line 768 of file pcb_editor_control.cpp.

References COMMIT::Add(), EDA_ITEM::ClearSelected(), DisplayError(), dyn_cast(), ZONE_SETTINGS::ExportSetting(), TOOL_MANAGER::GetTool(), InvokeCopperZonesEditor(), InvokeKeepoutAreaEditor(), InvokeNonCopperZonesEditor(), ZONE_SETTINGS::m_CurrentZone_Layer, m_frame, ZONE_SETTINGS::m_Layers, TOOL_BASE::m_toolMgr, BOARD_COMMIT::Push(), and PCB_TOOL::selection().

Referenced by setTransitions().

769 {
770  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
771  const auto& selection = selTool->GetSelection();
772 
773  // because this pops up the zone editor, it would be confusing
774  // to handle multiple zones, so just handle single selections
775  // containing exactly one zone
776  if( selection.Size() != 1 )
777  return 0;
778 
779  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
780 
781  if( !oldZone )
782  return 0;
783 
784  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
785  newZone->ClearSelected();
786  newZone->UnFill();
787  ZONE_SETTINGS zoneSettings;
788  zoneSettings << *oldZone;
789 
790  bool success = false;
791 
792  if( oldZone->GetIsKeepout() )
793  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
794  else if( oldZone->IsOnCopperLayer() )
795  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
796  else
797  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
798 
799  // If the new zone is on the same layer as the the initial zone,
800  // do nothing
801  if( success )
802  {
803  if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
804  {
805  DisplayError(
806  m_frame, _( "The duplicated keepout zone cannot be on the same layers as the original zone." ) );
807  success = false;
808  }
809  else if( !oldZone->GetIsKeepout() && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
810  {
811  DisplayError(
812  m_frame, _( "The duplicated zone cannot be on the same layer as the original zone." ) );
813  success = false;
814  }
815  }
816 
817  // duplicate the zone
818  if( success )
819  {
820  BOARD_COMMIT commit( m_frame );
821  zoneSettings.ExportSetting( *newZone );
822 
823  commit.Add( newZone.release() );
824  commit.Push( _( "Duplicate zone" ) );
825  }
826 
827  return 0;
828 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
void ClearSelected()
Definition: base_struct.h:242
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
void ExportSetting(ZONE_CONTAINER &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
ZONE_EDIT_T InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_CONTAINER *aZone, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing...
Class ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:49
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
ZONE_EDIT_T InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing...
ZONE_EDIT_T InvokeKeepoutAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeKeepoutAreaEditor invokes up a modal dialog window for copper zone editing...
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
Definition: zone_settings.h:69
int PCB_EDITOR_CONTROL::ZoneMerge ( const TOOL_EVENT aEvent)

Definition at line 703 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), ZONE_CONTAINER::GetIsKeepout(), ZONE_CONTAINER::GetLayer(), BOARD_CONNECTED_ITEM::GetNetCode(), ZONE_CONTAINER::GetPriority(), TOOL_MANAGER::GetTool(), m_frame, TOOL_BASE::m_toolMgr, mergeZones(), TOOL_MANAGER::RunAction(), PCB_TOOL::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, SELECTION::Size(), and BOARD::TestAreaIntersection().

Referenced by setTransitions().

704 {
705  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
706  BOARD* board = getModel<BOARD>();
707  BOARD_COMMIT commit( m_frame );
708 
709  if( selection.Size() < 2 )
710  return 0;
711 
712  int netcode = -1;
713 
714  ZONE_CONTAINER* firstZone = nullptr;
715  std::vector<ZONE_CONTAINER*> toMerge, merged;
716 
717  for( auto item : selection )
718  {
719  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
720 
721  if( !curr_area )
722  continue;
723 
724  if( !firstZone )
725  firstZone = curr_area;
726 
727  netcode = curr_area->GetNetCode();
728 
729  if( firstZone )
730  {
731  if( firstZone->GetNetCode() != netcode )
732  continue;
733 
734  if( curr_area->GetPriority() != firstZone->GetPriority() )
735  continue;
736 
737  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
738  continue;
739 
740  if( curr_area->GetLayer() != firstZone->GetLayer() )
741  continue;
742 
743  if( !board->TestAreaIntersection( curr_area, firstZone ) )
744  continue;
745 
746  toMerge.push_back( curr_area );
747  }
748  else
749  {
750  toMerge.push_back( curr_area );
751  }
752  }
753 
755 
756  if( mergeZones( commit, toMerge, merged ) )
757  {
758  commit.Push( _( "Merge zones" ) );
759 
760  for( auto item : merged )
762  }
763 
764  return 0;
765 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:175
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
bool TestAreaIntersection(ZONE_CONTAINER *area_ref, ZONE_CONTAINER *area_to_test)
Function TestAreaIntersection Test for intersection of 2 copper areas area_to_test must be after area...
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:602
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
int GetNetCode() const
Function GetNetCode.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:101
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE_CONTAINER * > &aOriginZones, std::vector< ZONE_CONTAINER * > &aMergedZones)
BOARD * board() const
Definition: pcb_tool.h:136

Member Data Documentation

PCB_EDIT_FRAME* PCB_EDITOR_CONTROL::m_frame
private
TOOL_MENU PCB_EDITOR_CONTROL::m_menu
private

Menu model displayed by the tool.

Definition at line 133 of file pcb_editor_control.h.

Referenced by Init(), PlaceModule(), and PlaceTarget().

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

Place & drill origin marker.

Definition at line 136 of file pcb_editor_control.h.

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

bool PCB_EDITOR_CONTROL::m_probingSchToPcb
private

Flag to ignore a single crossprobe message from eeschema.

Definition at line 139 of file pcb_editor_control.h.

Referenced by CrossProbePcbToSch(), CrossProbeSchToPcb(), and PCB_EDITOR_CONTROL().

wxTimer PCB_EDITOR_CONTROL::m_ratsnestTimer
private

Timer that start ratsnest calculation when it is slow to compute.

Definition at line 145 of file pcb_editor_control.h.

Referenced by Init(), ratsnestTimer(), and UpdateSelectionRatsnest().

bool PCB_EDITOR_CONTROL::m_slowRatsnest
private

Flag to indicate whether the current selection ratsnest is slow to calculate.

Definition at line 142 of file pcb_editor_control.h.

Referenced by HideSelectionRatsnest(), PCB_EDITOR_CONTROL(), and UpdateSelectionRatsnest().

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 210 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), CrossProbePcbToSch(), CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), HighlightNet(), HighlightNetCursor(), PICKER_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceDXF(), PlaceModule(), PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), GERBVIEW_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), TrackWidthDec(), TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), UpdateSelectionRatsnest(), ViaSizeDec(), ViaSizeInc(), TOOL_INTERACTIVE::Wait(), ZoneDuplicate(), and ZoneMerge().

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName

(eg. pcbnew.InteractiveSelection).

Definition at line 214 of file tool_base.h.

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_BASE::attachManager().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

const int PCB_EDITOR_CONTROL::WIDTH_STEP = 100000
staticprivate

Definition at line 153 of file pcb_editor_control.h.

Referenced by PlaceTarget(), and setTransitions().


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