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 ZoneFill (const TOOL_EVENT &aEvent)
 
int ZoneFillAll (const TOOL_EVENT &aEvent)
 
int ZoneUnfill (const TOOL_EVENT &aEvent)
 
int ZoneUnfillAll (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)
 

Places the origin point 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...
 
void SetTransitions () override
 

Sets up handlers for various events.

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

Protected Types

using ITEM_CREATOR = std::function< std::unique_ptr< BOARD_ITEM >(const TOOL_EVENT &aEvt) >
 Callable that returns a new board item. More...
 

Protected Member Functions

void doInteractiveItemPlacement (ITEM_CREATOR aItemCreator, const wxString &aCommitMessage)
 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::VIEWview () const
 
PCB_EDIT_FRAMEframe () const
 
BOARDboard () const
 
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

int modifyLockSelected (MODIFY_MODE aMode)
 

Private Attributes

PCB_EDIT_FRAMEm_frame
 

Pointer to the currently used edit frame.

More...
 
std::unique_ptr< KIGFX::ORIGIN_VIEWITEMm_placeOrigin
 

Place & drill origin marker.

More...
 
bool m_probingSchToPcb
 

Flag to ignore a single crossprobe message from eeschema.

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 41 of file pcb_editor_control.h.

Member Typedef Documentation

using PCB_TOOL::ITEM_CREATOR = std::function< std::unique_ptr< BOARD_ITEM >( const TOOL_EVENT& aEvt ) >
protectedinherited

Callable that returns a new board item.

The event that triggered it is provided, so you can check modifier keys, position, etc, if required

Definition at line 91 of file pcb_tool.h.

Member Enumeration Documentation

How to modify a property for selected items.

Enumerator
ON 
OFF 
TOGGLE 

Definition at line 119 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, and m_probingSchToPcb.

231  :
232  PCB_TOOL( "pcbnew.EditorControl" ),
233  m_frame( nullptr )
234 {
235  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
237  m_probingSchToPcb = false;
238 }
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:52
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
bool m_probingSchToPcb
Flag to ignore a single crossprobe message from eeschema.
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 241 of file pcb_editor_control.cpp.

242 {
243 }

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited
void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

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

Definition at line 54 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

55 {
56  m_toolMgr = aManager;
57  m_toolSettings = TOOL_SETTINGS( this );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
friend class TOOL_SETTINGS
Definition: tool_base.h:160
int PCB_EDITOR_CONTROL::CrossProbePcbToSch ( const TOOL_EVENT aEvent)

Notifies eeschema about the selected item.

Definition at line 901 of file pcb_editor_control.cpp.

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

Referenced by SetTransitions().

902 {
903  if( m_probingSchToPcb )
904  {
905  m_probingSchToPcb = false;
906  return 0;
907  }
908 
910  const SELECTION& selection = selTool->GetSelection();
911 
912  if( selection.Size() == 1 )
913  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
914 
915  return 0;
916 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
SELECTION & GetSelection()
Function GetSelection()
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 919 of file pcb_editor_control.cpp.

References 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, TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW::SetCenter(), and EDA_ITEM::Type().

Referenced by SetTransitions().

920 {
921  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
922 
923  if( item )
924  {
925  m_probingSchToPcb = true;
926  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
928 
929  // If it is a pad and the net highlighting tool is enabled, highlight the net
930  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
931  {
932  int net = static_cast<D_PAD*>( item )->GetNetCode();
934  }
935  else
936  // Otherwise simply select the corresponding item
937  {
939  }
940  }
941 
942  return 0;
943 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
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:220
virtual const wxPoint & GetPosition() const =0
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:102
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:563
VECTOR2< double > VECTOR2D
Definition: vector2d.h:579
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:342
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int GetToolId() const
Definition: draw_frame.h:406
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.
void PCB_TOOL::doInteractiveItemPlacement ( ITEM_CREATOR  aItemCreator,
const wxString &  aCommitMessage 
)
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::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), PCB_MODULE_T, BOARD_COMMIT::Push(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint().

41 {
42  using namespace std::placeholders;
43 
44  KIGFX::VIEW& view = *getView();
46  auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
47 
48  std::unique_ptr<BOARD_ITEM> newItem;
49 
50  Activate();
51 
52  BOARD_COMMIT commit( &frame );
53 
55 
56  // do not capture or auto-pan until we start placing an item
57  controls.ShowCursor( true );
58  controls.SetSnapping( true );
59 
60  // Add a VIEW_GROUP that serves as a preview for the new item
61  SELECTION preview;
62  view.Add( &preview );
63 
64  // Main loop: keep receiving events
65  while( OPT_TOOL_EVENT evt = Wait() )
66  {
67  VECTOR2I cursorPos = controls.GetCursorPosition();
68 
70  {
71  if( newItem )
72  {
73  // Delete the old item and have another try
74  newItem = nullptr;
75 
76  preview.Clear();
77 
78  controls.SetAutoPan( false );
79  controls.CaptureCursor( false );
80  controls.ShowCursor( true );
81  }
82  else
83  {
84  break;
85  }
86 
87  if( evt->IsActivate() ) // now finish unconditionally
88  break;
89  }
90 
91  else if( evt->IsClick( BUT_LEFT ) )
92  {
93  if( !newItem )
94  {
95  // create the item if possible
96  newItem = aItemCreator( *evt );
97 
98  // no item created, so wait for another click
99  if( !newItem )
100  continue;
101 
102  controls.CaptureCursor( true );
103  controls.SetAutoPan( true );
104 
105  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
106 
107  preview.Add( newItem.get() );
108 
109  if( newItem->Type() == PCB_MODULE_T )
110  {
111  auto module = dyn_cast<MODULE*>( newItem.get() );
112 
113  // modules have more drawable parts
114  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
115  }
116  }
117  else
118  {
119  newItem->ClearFlags();
120  preview.Remove( newItem.get() );
121 
122  if( newItem->Type() == PCB_MODULE_T )
123  {
124  auto module = dyn_cast<MODULE*>( newItem.get() );
125  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
126  }
127 
128  commit.Add( newItem.release() );
129  commit.Push( aCommitMessage );
130 
131  controls.CaptureCursor( false );
132  controls.SetAutoPan( false );
133  controls.ShowCursor( true );
134  }
135  }
136 
137  else if( newItem && evt->Category() == TC_COMMAND )
138  {
139  /*
140  * Handle any events that can affect the item as we move
141  * it around, eg rotate and flip
142  */
143 
144  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
145  {
146  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
147  frame, *evt );
148  newItem->Rotate( newItem->GetPosition(), rotationAngle );
149  view.Update( &preview );
150  }
151  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
152  {
153  newItem->Flip( newItem->GetPosition() );
154  view.Update( &preview );
155  }
156  }
157 
158  else if( newItem && evt->IsMotion() )
159  {
160  // track the cursor
161  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
162 
163  // Show a preview of the item
164  view.Update( &preview );
165  }
166  }
167 
168  view.Remove( &preview );
169 }
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.
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
void RunOnChildren(std::function< void(BOARD_ITEM *)> aFunction)
Function RunOnChildren.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
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
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
class MODULE, a footprint
Definition: typeinfo.h:101
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:109
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
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
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:90
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.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
Class VIEW.
Definition: view.h:58
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
int PCB_EDITOR_CONTROL::DrillOrigin ( const TOOL_EVENT aEvent)

Places the origin point for drill and pick-and-place files.

Definition at line 957 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().

958 {
959  Activate();
960 
962  assert( picker );
963 
964  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust zero" ) );
965  picker->SetClickHandler( std::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
966  picker->Activate();
967  Wait();
968 
969  return 0;
970 }
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:95
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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:35
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
static bool setDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, KIGFX::ORIGIN_VIEWITEM *aItem, const VECTOR2D &aPosition)
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
void Activate()
Function Activate() Runs the tool.
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 78 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

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

79  {
80  return m_editModules;
81  }
bool m_editModules
Definition: pcb_tool.h:112
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

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

Function getEditFrame()

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

Definition at line 193 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

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

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

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

References TOOL_BASE::m_toolId.

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

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

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

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

Definition at line 144 of file tool_base.h.

References TOOL_BASE::m_toolMgr.

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

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 204 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

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

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

References TOOL_BASE::m_toolName.

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

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

Definition at line 72 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

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

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

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

References TOOL_BASE::m_type.

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

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 30 of file tool_base.cpp.

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

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

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

Function Go()

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

Definition at line 122 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

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

124 {
125  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
126 
127  goInternal( sptr, aConditions );
128 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
int PCB_EDITOR_CONTROL::HighlightNet ( const TOOL_EVENT aEvent)

Highlights net belonging to the item under the cursor.

Definition at line 1026 of file pcb_editor_control.cpp.

References KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), 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().

1027 {
1028  int netcode = aEvent.Parameter<intptr_t>();
1029 
1030  if( netcode > 0 )
1031  {
1033  render->SetHighlight( true, netcode );
1035  }
1036  else
1037  {
1038  // No net code specified, pick the net code belonging to the item under the cursor
1039  highlightNet( m_toolMgr, getView()->ToWorld( getViewControls()->GetMousePosition() ) );
1040  }
1041 
1042  return 0;
1043 }
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:220
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:36
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
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:243
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:673
void SetHighlight(bool aEnabled, int aNetcode=-1)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
Definition: painter.h:139
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 1046 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), TOOL_MANAGER::GetTool(), highlightNet(), ID_PCB_HIGHLIGHT_BUTT, m_frame, TOOL_BASE::m_toolMgr, PICKER_TOOL::SetClickHandler(), PICKER_TOOL::SetSnapping(), PCB_BASE_FRAME::SetToolID(), and TOOL_INTERACTIVE::Wait().

Referenced by SetTransitions().

1047 {
1048  Activate();
1049 
1050  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1051  assert( picker );
1052 
1053  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_PENCIL, _( "Highlight net" ) );
1054  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1 ) );
1055  picker->SetSnapping( false );
1056  picker->Activate();
1057  Wait();
1058 
1059  return 0;
1060 }
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:54
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:95
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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:35
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
Function highlightNet() Looks for a BOARD_CONNECTED_ITEM in a given spot, and if one is found - it en...
void Activate()
Function Activate() Runs the tool.
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 259 of file pcb_editor_control.cpp.

References CONDITIONAL_MENU::AddMenu(), DRAWING_TOOL::GetDrawingMode(), TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), DRAWING_TOOL::GetToolMenu(), SELECTION_TOOL::GetToolMenu(), TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::OnlyType(), SELECTION_CONDITIONS::OnlyTypes(), PCB_ZONE_AREA_T, GENERAL_COLLECTOR::Tracks, and DRAWING_TOOL::ZONE.

260 {
261  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
262  zoneMenu->SetTool( this );
263 
264  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
265  lockMenu->SetTool( this );
266 
267  // Add the PCB control menus to relevant other tools
268 
270 
271  if( selTool )
272  {
273  auto& toolMenu = selTool->GetToolMenu();
274  auto& menu = toolMenu.GetMenu();
275 
276  toolMenu.AddSubMenu( zoneMenu );
277  toolMenu.AddSubMenu( lockMenu );
278 
279  menu.AddMenu( zoneMenu.get(), false,
281 
282  menu.AddMenu( lockMenu.get(), false,
284  }
285 
286  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
287 
288  if( drawingTool )
289  {
290  auto& toolMenu = drawingTool->GetToolMenu();
291  auto& menu = toolMenu.GetMenu();
292 
293  toolMenu.AddSubMenu( zoneMenu );
294 
295  // Functor to say if the PCB_EDIT_FRAME is in a given mode
296  // Capture the tool pointer and tool mode by value
297  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
298  {
299  return [=]( const SELECTION& sel )
300  {
301  return drawingTool->GetDrawingMode() == aMode;
302  };
303  };
304 
305  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
306  }
307 
308  return true;
309 }
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:294
MODE GetDrawingMode() const
Function GetDrawingMode.
Class SELECTION_TOOL.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
TOOL_MENU & GetToolMenu()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
TOOL_MENU & GetToolMenu()
Get the DRAWING_TOOL top-level context menu
Definition: drawing_tool.h:62
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...
MODE
The possible drawing modes of DRAWING_TOOL
Definition: drawing_tool.h:68
void AddMenu(CONTEXT_MENU *aMenu, bool aExpand=false, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type...
int PCB_EDITOR_CONTROL::LockSelected ( const TOOL_EVENT aEvent)

Locks selected items.

Definition at line 497 of file pcb_editor_control.cpp.

References modifyLockSelected(), and ON.

Referenced by SetTransitions().

498 {
499  return modifyLockSelected( ON );
500 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::modifyLockSelected ( MODIFY_MODE  aMode)
private

Definition at line 509 of file pcb_editor_control.cpp.

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

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

510 {
512  const SELECTION& selection = selTool->GetSelection();
513 
514  if( selection.Empty() )
516 
517  bool modified = false;
518 
519  for( auto i : selection )
520  {
521  auto item = static_cast<BOARD_ITEM*>( i );
522  bool prevState = item->IsLocked();
523 
524  switch( aMode )
525  {
526  case ON:
527  item->SetLocked( true );
528  break;
529 
530  case OFF:
531  item->SetLocked( false );
532  break;
533 
534  case TOGGLE:
535  item->SetLocked( !prevState );
536  break;
537  }
538 
539  // Check if we really modified an item
540  if( !modified && prevState != item->IsLocked() )
541  modified = true;
542  }
543 
544  if( modified )
545  m_frame->OnModify();
546 
547  return 0;
548 }
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:1004
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:220
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()
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
virtual bool IsLocked() const
Function IsLocked.
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 381 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), PCB_TOOL::board(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), PCB_ACTIONS::flip, MODULE::Flip(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), MODULE::GetPosition(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), ID_NO_TOOL_SELECTED, ID_PCB_MODULE_BUTT, TOOL_EVT_UTILS::IsRotateToolEvt(), PCB_BASE_FRAME::LoadModuleFromLibrary(), m_frame, TOOL_BASE::m_toolMgr, KIWAY_HOLDER::Prj(), BOARD_COMMIT::Push(), KIGFX::VIEW_GROUP::Remove(), KIGFX::VIEW::Remove(), BOARD::Remove(), MODULE::Rotate(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), MODULE::SetPosition(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::SetToolID(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SetTransitions().

382 {
383  MODULE* module = NULL;
384  KIGFX::VIEW* view = getView();
386  BOARD* board = getModel<BOARD>();
387 
388  // Add a VIEW_GROUP that serves as a preview for the new item
389  KIGFX::VIEW_GROUP preview( view );
390  view->Add( &preview );
391 
393  controls->ShowCursor( true );
394  controls->SetSnapping( true );
395 
396  Activate();
397  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_HAND, _( "Add footprint" ) );
398 
399  // Main loop: keep receiving events
400  while( OPT_TOOL_EVENT evt = Wait() )
401  {
402  VECTOR2I cursorPos = controls->GetCursorPosition();
403 
404  if( evt->IsCancel() || evt->IsActivate() )
405  {
406  if( module )
407  {
408  delete module;
409  module = NULL;
410 
411  preview.Clear();
412  controls->ShowCursor( true );
413  }
414  else
415  break;
416 
417  if( evt->IsActivate() ) // now finish unconditionally
418  break;
419  }
420 
421  else if( module && evt->Category() == TC_COMMAND )
422  {
423  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
424  {
425  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
426  *m_frame, *evt );
427  module->Rotate( module->GetPosition(), rotationAngle );
428  view->Update( &preview );
429  }
430  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
431  {
432  module->Flip( module->GetPosition() );
433  view->Update( &preview );
434  }
435  }
436 
437  else if( evt->IsClick( BUT_LEFT ) )
438  {
439  if( !module )
440  {
441  // Pick the module to be placed
442  module = m_frame->LoadModuleFromLibrary( wxEmptyString,
443  m_frame->Prj().PcbFootprintLibs(),
444  true, NULL );
445 
446  if( module == NULL )
447  continue;
448 
449  // Module has been added in LoadModuleFromLibrary(),
450  // so we have to remove it before committing the change @todo LEGACY
451  board->Remove( module );
452  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
453 
454  // Add all the drawable parts to preview
455  preview.Add( module );
456  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
457  }
458  else
459  {
460  BOARD_COMMIT commit( m_frame );
461  commit.Add( module );
462  commit.Push( _( "Place a module" ) );
463 
464  // Remove from preview
465  preview.Remove( module );
466  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
467  module = NULL; // to indicate that there is no module that we currently modify
468  }
469 
470  bool placing = ( module != NULL );
471 
472  controls->SetAutoPan( placing );
473  controls->CaptureCursor( placing );
474  controls->ShowCursor( !placing );
475  }
476 
477  else if( module && evt->IsMotion() )
478  {
479  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
480  view->Update( &preview );
481  }
482  }
483 
484  view->Remove( &preview );
485  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
486 
487  return 0;
488 }
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.
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
void RunOnChildren(std::function< void(BOARD_ITEM *)> aFunction)
Function RunOnChildren.
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 Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
const wxPoint & GetPosition() const override
Definition: class_module.h:143
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
MODULE * LoadModuleFromLibrary(const wxString &aLibrary, FP_LIB_TABLE *aTable, bool aUseFootprintViewer=true, wxDC *aDC=NULL)
Function LoadModuleFromLibrary opens a dialog to select a footprint, and loads it into current board...
Definition: loadcmp.cpp:160
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
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
void SetPosition(const wxPoint &aPos) override
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:90
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:166
void Activate()
Function Activate() Runs the tool.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
Class VIEW.
Definition: view.h:58
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void Remove(BOARD_ITEM *aBoardItem) override
>
BOARD * board() const
Definition: pcb_tool.h:110
int PCB_EDITOR_CONTROL::PlaceTarget ( const TOOL_EVENT aEvent)

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

Definition at line 551 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), KIGFX::VIEW::Add(), PCB_TOOL::board(), BUT_LEFT, PCB_ACTIONS::decWidth, Edge_Cuts, KIGFX::VIEW_CONTROLS::GetCursorPosition(), BOARD::GetDesignSettings(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), ID_NO_TOOL_SELECTED, ID_PCB_MIRE_BUTT, PCB_ACTIONS::incWidth, BOARD_DESIGN_SETTINGS::m_EdgeSegmentWidth, m_frame, TOOL_BASE::m_toolMgr, KIGFX::VIEW_GROUP::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::SetToolID(), KIGFX::VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), WIDTH_STEP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SetTransitions().

552 {
553  KIGFX::VIEW* view = getView();
555  BOARD* board = getModel<BOARD>();
556  PCB_TARGET* target = new PCB_TARGET( board );
557 
558  // Init the new item attributes
559  target->SetLayer( Edge_Cuts );
560  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
561  target->SetSize( Millimeter2iu( 5 ) );
562  VECTOR2I cursorPos = controls->GetCursorPosition();
563  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
564 
565  // Add a VIEW_GROUP that serves as a preview for the new item
566  KIGFX::VIEW_GROUP preview( view );
567  preview.Add( target );
568  view->Add( &preview );
569 
571  controls->SetSnapping( true );
572 
573  Activate();
574  m_frame->SetToolID( ID_PCB_MIRE_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
575 
576  // Main loop: keep receiving events
577  while( OPT_TOOL_EVENT evt = Wait() )
578  {
579  cursorPos = controls->GetCursorPosition();
580 
581  if( evt->IsCancel() || evt->IsActivate() )
582  break;
583 
584  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
585  {
586  target->SetWidth( target->GetWidth() + WIDTH_STEP );
587  view->Update( &preview );
588  }
589 
590  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
591  {
592  int width = target->GetWidth();
593 
594  if( width > WIDTH_STEP )
595  {
596  target->SetWidth( width - WIDTH_STEP );
597  view->Update( &preview );
598  }
599  }
600 
601  else if( evt->IsClick( BUT_LEFT ) )
602  {
603  assert( target->GetSize() > 0 );
604  assert( target->GetWidth() > 0 );
605 
606  BOARD_COMMIT commit( m_frame );
607  commit.Add( target );
608  commit.Push( _( "Place a layer alignment target" ) );
609 
610  preview.Remove( target );
611 
612  // Create next PCB_TARGET
613  target = new PCB_TARGET( *target );
614  preview.Add( target );
615  }
616 
617  else if( evt->IsMotion() )
618  {
619  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
620  view->Update( &preview );
621  }
622  }
623 
624  delete target;
625 
626  controls->SetSnapping( false );
627  view->Remove( &preview );
628 
629  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
630 
631  return 0;
632 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
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:158
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
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:161
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
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:166
static const int WIDTH_STEP
void Activate()
Function Activate() Runs the tool.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
Class VIEW.
Definition: view.h:58
int m_EdgeSegmentWidth
current graphic line width (EDGE layer only)
BOARD * board() const
Definition: pcb_tool.h:110
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.

Implements TOOL_BASE.

Definition at line 246 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().

247 {
248  m_frame = getEditFrame<PCB_EDIT_FRAME>();
249 
250  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
251  {
252  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
253  getView()->Remove( m_placeOrigin.get() );
254  getView()->Add( m_placeOrigin.get() );
255  }
256 }
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
Model changes (required full reload)
Definition: tool_base.h:83
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
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 78 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

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

Function SetContextMenu()

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

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

Definition at line 67 of file tool_interactive.cpp.

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

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

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

References PCB_TOOL::m_editModules.

74  {
75  m_editModules = aEnabled;
76  }
bool m_editModules
Definition: pcb_tool.h:112
void PCB_EDITOR_CONTROL::SetTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from TOOL_BASE.

Definition at line 1063 of file pcb_editor_control.cpp.

References CrossProbePcbToSch(), CrossProbeSchToPcb(), PCB_ACTIONS::crossProbeSchToPcb, DrillOrigin(), PCB_ACTIONS::drillOrigin, TOOL_INTERACTIVE::Go(), HighlightNet(), PCB_ACTIONS::highlightNet, HighlightNetCursor(), PCB_ACTIONS::highlightNetCursor, PCB_ACTIONS::lock, LockSelected(), PlaceModule(), PCB_ACTIONS::placeModule, PlaceTarget(), PCB_ACTIONS::placeTarget, SELECTION_TOOL::SelectedEvent, PCB_ACTIONS::toggleLock, ToggleLockSelected(), TrackWidthDec(), PCB_ACTIONS::trackWidthDec, TrackWidthInc(), PCB_ACTIONS::trackWidthInc, PCB_ACTIONS::unlock, UnlockSelected(), ViaSizeDec(), PCB_ACTIONS::viaSizeDec, ViaSizeInc(), PCB_ACTIONS::viaSizeInc, ZoneDuplicate(), PCB_ACTIONS::zoneDuplicate, ZoneFill(), PCB_ACTIONS::zoneFill, ZoneFillAll(), PCB_ACTIONS::zoneFillAll, ZoneMerge(), PCB_ACTIONS::zoneMerge, ZoneUnfill(), PCB_ACTIONS::zoneUnfill, ZoneUnfillAll(), and PCB_ACTIONS::zoneUnfillAll.

1064 {
1065  // Track & via size control
1070 
1071  // Zone actions
1078 
1079  // Placing tools
1082 
1083  // Other
1092 }
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:329
static TOOL_ACTION placeModule
Activation of the drawing tool (placing a MODULE)
Definition: pcb_actions.h:149
int ZoneMerge(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:331
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:344
static TOOL_ACTION lock
Definition: pcb_actions.h:330
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:257
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:250
int TrackWidthDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:249
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
static TOOL_ACTION highlightNetCursor
Definition: pcb_actions.h:343
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:256
static TOOL_ACTION crossProbeSchToPcb
Definition: pcb_actions.h:345
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:248
int ViaSizeDec(const TOOL_EVENT &aEvent)
int TrackWidthInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:260
int DrillOrigin(const TOOL_EVENT &aEvent)
Places the origin point for drill and pick-and-place files.
int ZoneUnfill(const TOOL_EVENT &aEvent)
int ViaSizeInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION placeTarget
Activation of the drawing tool (placing a TARGET)
Definition: pcb_actions.h:146
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:259
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 zoneUnfill
Definition: pcb_actions.h:258
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:263
int ZoneFill(const TOOL_EVENT &aEvent)
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:342
int PlaceTarget(const TOOL_EVENT &aEvent)
Function PlaceTarget() Allows user to place a layer alignment target.
int ZoneFillAll(const TOOL_EVENT &aEvent)
int ZoneUnfillAll(const TOOL_EVENT &aEvent)
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 'lock' property for selected items.
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:251
int PCB_EDITOR_CONTROL::ToggleLockSelected ( const TOOL_EVENT aEvent)

Toggles 'lock' property for selected items.

Definition at line 491 of file pcb_editor_control.cpp.

References modifyLockSelected(), and TOGGLE.

Referenced by SetTransitions().

492 {
493  return modifyLockSelected( TOGGLE );
494 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::TrackWidthDec ( const TOOL_EVENT aEvent)

Definition at line 330 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().

331 {
332  BOARD* board = getModel<BOARD>();
333  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
334 
335  if( widthIndex < 0 )
336  widthIndex = 0;
337 
338  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
339  board->GetDesignSettings().UseCustomTrackViaSize( false );
340 
342 
343  return 0;
344 }
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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:253
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
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:110
int PCB_EDITOR_CONTROL::TrackWidthInc ( const TOOL_EVENT aEvent)

Definition at line 313 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().

314 {
315  BOARD* board = getModel<BOARD>();
316  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
317 
318  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
319  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
320 
321  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
322  board->GetDesignSettings().UseCustomTrackViaSize( false );
323 
325 
326  return 0;
327 }
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:220
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:253
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
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:110
int PCB_EDITOR_CONTROL::UnlockSelected ( const TOOL_EVENT aEvent)

Unlocks selected items.

Definition at line 503 of file pcb_editor_control.cpp.

References modifyLockSelected(), and OFF.

Referenced by SetTransitions().

504 {
505  return modifyLockSelected( OFF );
506 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::ViaSizeDec ( const TOOL_EVENT aEvent)

Definition at line 364 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().

365 {
366  BOARD* board = getModel<BOARD>();
367  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
368 
369  if( sizeIndex < 0 )
370  sizeIndex = 0;
371 
372  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
373  board->GetDesignSettings().UseCustomTrackViaSize( false );
374 
376 
377  return 0;
378 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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:253
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:530
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD * board() const
Definition: pcb_tool.h:110
int PCB_EDITOR_CONTROL::ViaSizeInc ( const TOOL_EVENT aEvent)

Definition at line 347 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().

348 {
349  BOARD* board = getModel<BOARD>();
350  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
351 
352  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
353  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
354 
355  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
356  board->GetDesignSettings().UseCustomTrackViaSize( false );
357 
359 
360  return 0;
361 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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:253
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:530
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
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:110
OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

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

Definition at line 55 of file tool_interactive.cpp.

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

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

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

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

Definition at line 847 of file pcb_editor_control.cpp.

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

Referenced by SetTransitions().

848 {
849  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
850  const auto& selection = selTool->GetSelection();
851 
852  // because this pops up the zone editor, it would be confusing
853  // to handle multiple zones, so just handle single selections
854  // containing exactly one zone
855  if( selection.Size() != 1 )
856  return 0;
857 
858  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
859 
860  if( !oldZone )
861  return 0;
862 
863  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
864  newZone->ClearSelected();
865  newZone->UnFill();
866  ZONE_SETTINGS zoneSettings;
867  zoneSettings << *oldZone;
868 
869  bool success = false;
870 
871  if( oldZone->GetIsKeepout() )
872  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
873  else if( oldZone->IsOnCopperLayer() )
874  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
875  else
876  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
877 
878  // If the new zone is on the same layer as the the initial zone,
879  // do nothing
880  if( success && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
881  {
883  _( "The duplicated zone cannot be on the same layer as the original zone." ) );
884  success = false;
885  }
886 
887  // duplicate the zone
888  if( success )
889  {
890  BOARD_COMMIT commit( m_frame );
891  zoneSettings.ExportSetting( *newZone );
892 
893  commit.Add( newZone.release() );
894  commit.Push( _( "Duplicate zone" ) );
895  }
896 
897  return 0;
898 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
void ClearSelected()
Definition: base_struct.h:231
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
void ExportSetting(ZONE_CONTAINER &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
SELECTION & GetSelection()
Function GetSelection()
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.
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
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:69
int PCB_EDITOR_CONTROL::ZoneFill ( const TOOL_EVENT aEvent)

Definition at line 636 of file pcb_editor_control.cpp.

References PCB_EDIT_FRAME::Fill_Zone(), SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), m_frame, TOOL_BASE::m_toolMgr, COMMIT::Modify(), PCB_ZONE_AREA_T, BOARD_COMMIT::Push(), RN_DATA::Recalculate(), KIGFX::VIEW::Update(), and RN_DATA::Update().

Referenced by SetTransitions().

637 {
638  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
639  const auto& selection = selTool->GetSelection();
640  RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
641 
642  BOARD_COMMIT commit( this );
643 
644  for( auto item : selection )
645  {
646  assert( item->Type() == PCB_ZONE_AREA_T );
647 
648  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( item );
649 
650  commit.Modify( zone );
651 
652  m_frame->Fill_Zone( zone );
653  zone->SetIsFilled( true );
654  ratsnest->Update( zone );
655  getView()->Update( zone );
656  }
657 
658  commit.Push( _( "Fill Zone" ) );
659 
660  ratsnest->Recalculate();
661 
662  return 0;
663 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
Class RN_DATA.
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
bool Update(const BOARD_ITEM *aItem)
Function Update() Updates the ratsnest data for an item.
SELECTION & GetSelection()
Function GetSelection()
int Fill_Zone(ZONE_CONTAINER *aZone)
Function Fill_Zone Calculate the zone filling for the outline zone_container The zone outline is a fr...
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
void Recalculate(int aNet=-1)
Function Recalculate() Recomputes ratsnest for selected net number or all nets that need updating...
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int PCB_EDITOR_CONTROL::ZoneFillAll ( const TOOL_EVENT aEvent)

Definition at line 666 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), PCB_EDIT_FRAME::Fill_Zone(), BOARD::GetArea(), BOARD::GetAreaCount(), BOARD::GetRatsnest(), TOOL_BASE::getView(), m_frame, COMMIT::Modify(), BOARD_COMMIT::Push(), ZONE_CONTAINER::SetIsFilled(), and KIGFX::VIEW::Update().

Referenced by SetTransitions().

667 {
668  BOARD* board = getModel<BOARD>();
669  RN_DATA* ratsnest = board->GetRatsnest();
670 
671  BOARD_COMMIT commit( this );
672 
673  for( int i = 0; i < board->GetAreaCount(); ++i )
674  {
675  ZONE_CONTAINER* zone = board->GetArea( i );
676 
677  commit.Modify( zone );
678 
679  m_frame->Fill_Zone( zone );
680  zone->SetIsFilled( true );
681  ratsnest->Update( zone );
682  getView()->Update( zone );
683  }
684 
685  commit.Push( _( "Fill All Zones" ) );
686 
687  ratsnest->Recalculate();
688 
689  return 0;
690 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
Class RN_DATA.
void SetIsFilled(bool isFilled)
Definition: class_zone.h:188
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1051
int Fill_Zone(ZONE_CONTAINER *aZone)
Function Fill_Zone Calculate the zone filling for the outline zone_container The zone outline is a fr...
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
RN_DATA * GetRatsnest() const
Function GetRatsnest() returns list of missing connections between components/tracks.
Definition: class_board.h:287
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:1022
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:166
BOARD * board() const
Definition: pcb_tool.h:110
int PCB_EDITOR_CONTROL::ZoneMerge ( const TOOL_EVENT aEvent)

Definition at line 789 of file pcb_editor_control.cpp.

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

Referenced by SetTransitions().

790 {
791  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
792  BOARD* board = getModel<BOARD>();
793  BOARD_COMMIT commit( m_frame );
794 
795  if( selection.Size() < 2 )
796  return 0;
797 
798  int netcode = -1;
799 
800  ZONE_CONTAINER* firstZone = nullptr;
801  std::vector<ZONE_CONTAINER*> toMerge, merged;
802 
803  for( auto item : selection )
804  {
805  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
806 
807  if( !curr_area )
808  continue;
809 
810  if( !firstZone )
811  firstZone = curr_area;
812 
813  netcode = curr_area->GetNetCode();
814 
815  if( firstZone->GetNetCode() != netcode )
816  continue;
817 
818  if( curr_area->GetPriority() != firstZone->GetPriority() )
819  continue;
820 
821  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
822  continue;
823 
824  if( curr_area->GetLayer() != firstZone->GetLayer() )
825  continue;
826 
827  if( !board->TestAreaIntersection( curr_area, firstZone ) )
828  continue;
829 
830  toMerge.push_back( curr_area );
831  }
832 
834 
835  if( mergeZones( commit, toMerge, merged ) )
836  {
837  commit.Push( _( "Merge zones" ) );
838 
839  for( auto item : merged )
841  }
842 
843  return 0;
844 }
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:78
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:527
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:166
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:112
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:106
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE_CONTAINER * > &aOriginZones, std::vector< ZONE_CONTAINER * > &aMergedZones)
BOARD * board() const
Definition: pcb_tool.h:110
int PCB_EDITOR_CONTROL::ZoneUnfill ( const TOOL_EVENT aEvent)

Definition at line 693 of file pcb_editor_control.cpp.

References SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), TOOL_BASE::m_toolMgr, COMMIT::Modify(), PCB_ZONE_AREA_T, BOARD_COMMIT::Push(), RN_DATA::Recalculate(), KIGFX::VIEW::Update(), and RN_DATA::Update().

Referenced by SetTransitions().

694 {
695  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
696  const auto& selection = selTool->GetSelection();
697  RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
698 
699  BOARD_COMMIT commit( this );
700 
701  for( auto item : selection )
702  {
703  assert( item->Type() == PCB_ZONE_AREA_T );
704 
705  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
706 
707  commit.Modify( zone );
708 
709  zone->SetIsFilled( false );
710  zone->ClearFilledPolysList();
711  ratsnest->Update( zone );
712  getView()->Update( zone );
713  }
714 
715  commit.Push( _( "Unfill Zone" ) );
716 
717  ratsnest->Recalculate();
718 
719  return 0;
720 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
Class RN_DATA.
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
bool Update(const BOARD_ITEM *aItem)
Function Update() Updates the ratsnest data for an item.
void SetIsFilled(bool isFilled)
Definition: class_zone.h:188
SELECTION & GetSelection()
Function GetSelection()
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
void Recalculate(int aNet=-1)
Function Recalculate() Recomputes ratsnest for selected net number or all nets that need updating...
int PCB_EDITOR_CONTROL::ZoneUnfillAll ( const TOOL_EVENT aEvent)

Definition at line 723 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), ZONE_CONTAINER::ClearFilledPolysList(), BOARD::GetArea(), BOARD::GetAreaCount(), BOARD::GetRatsnest(), TOOL_BASE::getView(), COMMIT::Modify(), BOARD_COMMIT::Push(), ZONE_CONTAINER::SetIsFilled(), and KIGFX::VIEW::Update().

Referenced by SetTransitions().

724 {
725  BOARD* board = getModel<BOARD>();
726  RN_DATA* ratsnest = board->GetRatsnest();
727 
728  BOARD_COMMIT commit( this );
729 
730  for( int i = 0; i < board->GetAreaCount(); ++i )
731  {
732  ZONE_CONTAINER* zone = board->GetArea( i );
733 
734  commit.Modify( zone );
735 
736  zone->SetIsFilled( false );
737  zone->ClearFilledPolysList();
738  ratsnest->Update( zone );
739  getView()->Update( zone );
740  }
741 
742  commit.Push( _( "Unfill All Zones" ) );
743 
744  ratsnest->Recalculate();
745 
746  return 0;
747 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
Class RN_DATA.
void SetIsFilled(bool isFilled)
Definition: class_zone.h:188
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1051
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
RN_DATA * GetRatsnest() const
Function GetRatsnest() returns list of missing connections between components/tracks.
Definition: class_board.h:287
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:1022
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: class_zone.h:460
BOARD * board() const
Definition: pcb_tool.h:110

Member Data Documentation

PCB_EDIT_FRAME* PCB_EDITOR_CONTROL::m_frame
private
std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> PCB_EDITOR_CONTROL::m_placeOrigin
private

Place & drill origin marker.

Definition at line 113 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 116 of file pcb_editor_control.h.

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

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 215 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PCBNEW_CONTROL::AppendBoard(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), SELECTION_TOOL::clearSelection(), MODULE_EDITOR_TOOLS::CopyItems(), PAD_TOOL::copyPadSettings(), 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::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), EDIT_TOOL::getModificationPoint(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), HighlightNet(), HighlightNetCursor(), ROUTER_TOOL::Init(), PLACEMENT_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), 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(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), SELECTION_TOOL::SelectItem(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), SELECTION_TOOL::toggleSelection(), TrackWidthDec(), TrackWidthInc(), SELECTION_TOOL::UnselectItem(), ViaSizeDec(), ViaSizeInc(), TOOL_INTERACTIVE::Wait(), ZoneDuplicate(), ZoneFill(), ZoneMerge(), and ZoneUnfill().

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName

(eg. pcbnew.InteractiveSelection).

Definition at line 219 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 221 of file tool_base.h.

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

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 212 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

const int PCB_EDITOR_CONTROL::WIDTH_STEP = 100000
staticprivate

Definition at line 124 of file pcb_editor_control.h.

Referenced by PlaceTarget().


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