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...
 
int UpdateSelectionRatsnest (const TOOL_EVENT &aEvent)
 

Updates ratsnest for selected items.

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

Shows local ratsnest of a component

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

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::VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () 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 Enumeration Documentation

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

Definition at line 98 of file pcb_tool.h.

How to modify a property for selected items.

Enumerator
ON 
OFF 
TOGGLE 

Definition at line 125 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 235 of file pcb_editor_control.cpp.

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

235  :
236  PCB_TOOL( "pcbnew.EditorControl" ),
237  m_frame( nullptr )
238 {
239  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
241  m_probingSchToPcb = false;
242 }
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:65
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 245 of file pcb_editor_control.cpp.

246 {
247 }

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 MODULE_EDITOR_TOOLS::CopyItems(), 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(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), 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:220
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
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 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
KIGFX::VIEW_CONTROLS* PCB_TOOL::controls ( ) const
inlineprotectedinherited
int PCB_EDITOR_CONTROL::CrossProbePcbToSch ( const TOOL_EVENT aEvent)

Notifies eeschema about the selected item.

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

931 {
932  if( m_probingSchToPcb )
933  {
934  m_probingSchToPcb = false;
935  return 0;
936  }
937 
939  const SELECTION& selection = selTool->GetSelection();
940 
941  if( selection.Size() == 1 )
942  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
943 
944  return 0;
945 }
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 948 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().

949 {
950  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
951 
952  if( item )
953  {
954  m_probingSchToPcb = true;
955  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
957 
958  // If it is a pad and the net highlighting tool is enabled, highlight the net
959  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
960  {
961  int net = static_cast<D_PAD*>( item )->GetNetCode();
963  }
964  else
965  // Otherwise simply select the corresponding item
966  {
968  }
969  }
970 
971  return 0;
972 }
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:564
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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:356
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int GetToolId() const
Definition: draw_frame.h:419
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 ( 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 38 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::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_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), 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(), DRAWING_TOOL::DrawVia(), and MODULE_EDITOR_TOOLS::PlacePad().

41 {
42  using namespace std::placeholders;
43  std::unique_ptr<BOARD_ITEM> newItem;
44 
45  Activate();
46 
47  BOARD_COMMIT commit( frame() );
48 
50 
51  // do not capture or auto-pan until we start placing an item
52  controls()->ShowCursor( true );
53  controls()->SetSnapping( true );
54 
55  // Add a VIEW_GROUP that serves as a preview for the new item
56  SELECTION preview;
57  view()->Add( &preview );
58 
59  aPlacer->m_board = board();
60  aPlacer->m_frame = frame();
61 
62  if( aOptions & IPO_SINGLE_CLICK )
63  {
64  VECTOR2I cursorPos = controls()->GetCursorPosition();
65 
66  newItem = aPlacer->CreateItem();
67  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
68 
69  preview.Add( newItem.get() );
70  }
71 
72  // Main loop: keep receiving events
73  while( OPT_TOOL_EVENT evt = Wait() )
74  {
75  VECTOR2I cursorPos = controls()->GetCursorPosition();
76 
78  {
79  if( newItem )
80  {
81  // Delete the old item and have another try
82  newItem = nullptr;
83 
84  preview.Clear();
85 
86  if( aOptions & IPO_SINGLE_CLICK )
87  break;
88 
89  controls()->SetAutoPan( false );
90  controls()->CaptureCursor( false );
91  controls()->ShowCursor( true );
92  }
93  else
94  {
95  break;
96  }
97 
98  if( evt->IsActivate() ) // now finish unconditionally
99  break;
100  }
101 
102  else if( evt->IsClick( BUT_LEFT ) )
103  {
104  if( !newItem )
105  {
106  // create the item if possible
107  newItem = aPlacer->CreateItem();
108 
109  // no item created, so wait for another click
110  if( !newItem )
111  continue;
112 
113  controls()->CaptureCursor( true );
114  controls()->SetAutoPan( true );
115 
116  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
117 
118  preview.Add( newItem.get() );
119 
120  if( newItem->Type() == PCB_MODULE_T )
121  {
122  auto module = dyn_cast<MODULE*>( newItem.get() );
123 
124  // modules have more drawable parts
125  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
126  }
127  }
128  else
129  {
130  newItem->ClearFlags();
131  preview.Remove( newItem.get() );
132 
133  aPlacer->PlaceItem( newItem.get() );
134 
135  if( newItem->Type() == PCB_MODULE_T )
136  {
137  auto module = dyn_cast<MODULE*>( newItem.get() );
138  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
139  }
140 
141  commit.Add( newItem.release() );
142  commit.Push( aCommitMessage );
143 
144  controls()->CaptureCursor( false );
145  controls()->SetAutoPan( false );
146  controls()->ShowCursor( true );
147 
148  if( !( aOptions & IPO_REPEAT ) )
149  break;
150 
151  if( aOptions & IPO_SINGLE_CLICK )
152  {
154 
155  newItem = aPlacer->CreateItem();
156  newItem->SetPosition( wxPoint( pos.x, pos.y ) );
157 
158  preview.Add( newItem.get() );
159  }
160  }
161  }
162 
163  else if( newItem && evt->Category() == TC_COMMAND )
164  {
165  /*
166  * Handle any events that can affect the item as we move
167  * it around, eg rotate and flip
168  */
169 
170  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
171  {
172  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
173  *frame(), *evt );
174  newItem->Rotate( newItem->GetPosition(), rotationAngle );
175  view()->Update( &preview );
176  }
177  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
178  {
179  newItem->Flip( newItem->GetPosition() );
180  view()->Update( &preview );
181  }
182  }
183 
184  else if( newItem && evt->IsMotion() )
185  {
186  // track the cursor
187  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
188 
189  // Show a preview of the item
190  view()->Update( &preview );
191  }
192  }
193 
194  view()->Remove( &preview );
195 }
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:123
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
virtual bool PlaceItem(BOARD_ITEM *aItem)
Definition: pcb_tool.h:51
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:341
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:53
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
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:124
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:125
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, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
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:96
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:311
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
BOARD * board() const
Definition: pcb_tool.h:126
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 986 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().

987 {
988  Activate();
989 
991  assert( picker );
992 
993  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) );
994  picker->SetClickHandler( std::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
995  picker->Activate();
996  Wait();
997 
998  return 0;
999 }
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 91 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

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

92  {
93  return m_editModules;
94  }
bool m_editModules
Definition: pcb_tool.h:128
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(), TOOL_SETTINGS::getConfigBase(), and ZONE_CREATE_HELPER::performZoneCutout().

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(), and CONTEXT_MENU::onMenuEvent().

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(), MICROWAVE_TOOL::drawMicrowaveInductor(), DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), PCBNEW_CONTROL::HighContrastMode(), PNS::TOOL_BASE::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(), 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(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), 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(), ALIGN_DISTRIBUTE_TOOL::SetTransitions(), PCBNEW_CONTROL::SetTransitions(), POSITION_RELATIVE_TOOL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), PICKER_TOOL::SetTransitions(), SetTransitions(), EDIT_TOOL::SetTransitions(), SELECTION_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 1055 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().

1056 {
1057  int netcode = aEvent.Parameter<intptr_t>();
1058 
1059  if( netcode > 0 )
1060  {
1062  render->SetHighlight( true, netcode );
1064  }
1065  else
1066  {
1067  // No net code specified, pick the net code belonging to the item under the cursor
1068  highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
1069  }
1070 
1071  return 0;
1072 }
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
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:674
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 1075 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().

1076 {
1077  Activate();
1078 
1079  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1080  assert( picker );
1081 
1082  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
1083  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1 ) );
1084  picker->SetSnapping( false );
1085  picker->Activate();
1086  Wait();
1087 
1088  return 0;
1089 }
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 263 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.

264 {
265  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
266  zoneMenu->SetTool( this );
267 
268  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
269  lockMenu->SetTool( this );
270 
271  // Add the PCB control menus to relevant other tools
272 
274 
275  if( selTool )
276  {
277  auto& toolMenu = selTool->GetToolMenu();
278  auto& menu = toolMenu.GetMenu();
279 
280  toolMenu.AddSubMenu( zoneMenu );
281  toolMenu.AddSubMenu( lockMenu );
282 
283  menu.AddMenu( zoneMenu.get(), false,
285 
286  menu.AddMenu( lockMenu.get(), false,
288  }
289 
290  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
291 
292  if( drawingTool )
293  {
294  auto& toolMenu = drawingTool->GetToolMenu();
295  auto& menu = toolMenu.GetMenu();
296 
297  toolMenu.AddSubMenu( zoneMenu );
298 
299  // Functor to say if the PCB_EDIT_FRAME is in a given mode
300  // Capture the tool pointer and tool mode by value
301  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
302  {
303  return [=]( const SELECTION& sel )
304  {
305  return drawingTool->GetDrawingMode() == aMode;
306  };
307  };
308 
309  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
310  }
311 
312  return true;
313 }
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 506 of file pcb_editor_control.cpp.

References modifyLockSelected(), and ON.

Referenced by SetTransitions().

507 {
508  return modifyLockSelected( ON );
509 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::modifyLockSelected ( MODIFY_MODE  aMode)
private

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

519 {
521  const SELECTION& selection = selTool->GetSelection();
522 
523  if( selection.Empty() )
525 
526  bool modified = false;
527 
528  for( auto i : selection )
529  {
530  auto item = static_cast<BOARD_ITEM*>( i );
531  bool prevState = item->IsLocked();
532 
533  switch( aMode )
534  {
535  case ON:
536  item->SetLocked( true );
537  break;
538 
539  case OFF:
540  item->SetLocked( false );
541  break;
542 
543  case TOGGLE:
544  item->SetLocked( !prevState );
545  break;
546  }
547 
548  // Check if we really modified an item
549  if( !modified && prevState != item->IsLocked() )
550  modified = true;
551  }
552 
553  if( modified )
554  m_frame->OnModify();
555 
556  return 0;
557 }
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:993
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 385 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_TOOL::controls(), PCB_ACTIONS::flip, MODULE::Flip(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), MODULE::GetPosition(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), ID_PCB_MODULE_BUTT, TOOL_EVT_UTILS::IsRotateToolEvt(), PCB_BASE_FRAME::LoadModuleFromLibrary(), m_frame, TOOL_BASE::m_toolMgr, PROJECT::PcbFootprintLibs(), 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(), EDA_DRAW_FRAME::SetNoToolSelected(), 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().

386 {
387  MODULE* module = NULL;
388  KIGFX::VIEW* view = getView();
390  BOARD* board = getModel<BOARD>();
391 
392  // Add a VIEW_GROUP that serves as a preview for the new item
393  KIGFX::VIEW_GROUP preview( view );
394  view->Add( &preview );
395 
397  controls->ShowCursor( true );
398  controls->SetSnapping( true );
399 
400  Activate();
401  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_PENCIL, _( "Add footprint" ) );
402 
403  // Main loop: keep receiving events
404  while( OPT_TOOL_EVENT evt = Wait() )
405  {
406  VECTOR2I cursorPos = controls->GetCursorPosition();
407 
408  if( evt->IsCancel() || evt->IsActivate() )
409  {
410  if( module )
411  {
412  delete module;
413  module = NULL;
414 
415  preview.Clear();
416  controls->ShowCursor( true );
417  }
418  else
419  break;
420 
421  if( evt->IsActivate() ) // now finish unconditionally
422  break;
423  }
424 
425  else if( module && evt->Category() == TC_COMMAND )
426  {
427  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
428  {
429  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
430  *m_frame, *evt );
431  module->Rotate( module->GetPosition(), rotationAngle );
432  view->Update( &preview );
433  }
434  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
435  {
436  module->Flip( module->GetPosition() );
437  view->Update( &preview );
438  }
439  }
440 
441  else if( evt->IsClick( BUT_LEFT ) )
442  {
443  if( !module )
444  {
445  // Pick the module to be placed
446  module = m_frame->LoadModuleFromLibrary( wxEmptyString,
448  true, NULL );
449 
450  if( module == NULL )
451  continue;
452 
453  // Module has been added in LoadModuleFromLibrary(),
454  // so we have to remove it before committing the change @todo LEGACY
455  board->Remove( module );
456  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
457 
458  // Add all the drawable parts to preview
459  preview.Add( module );
460  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
461  }
462  else
463  {
464  BOARD_COMMIT commit( m_frame );
465  commit.Add( module );
466  commit.Push( _( "Place a module" ) );
467 
468  // Remove from preview
469  preview.Remove( module );
470  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
471  module = NULL; // to indicate that there is no module that we currently modify
472  }
473 
474  bool placing = ( module != NULL );
475 
476  controls->SetAutoPan( placing );
477  controls->CaptureCursor( placing );
478  controls->ShowCursor( !placing );
479  }
480 
481  else if( module && evt->IsMotion() )
482  {
483  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
484  view->Update( &preview );
485  }
486  }
487 
488  controls->ShowCursor( false );
489  controls->SetSnapping( false );
490  controls->SetAutoPan( false );
491  controls->CaptureCursor( false );
492 
493  view->Remove( &preview );
495 
496  return 0;
497 }
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:123
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:155
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:341
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:163
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.
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:124
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, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
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
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:96
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:560
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
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:311
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
Removes an item from the container.
BOARD * board() const
Definition: pcb_tool.h:126
int PCB_EDITOR_CONTROL::PlaceTarget ( const TOOL_EVENT aEvent)

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

Definition at line 560 of file pcb_editor_control.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), KIGFX::VIEW::Add(), PCB_TOOL::board(), BUT_LEFT, PCB_TOOL::controls(), PCB_ACTIONS::decWidth, Edge_Cuts, KIGFX::VIEW_CONTROLS::GetCursorPosition(), BOARD::GetDesignSettings(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), 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, EDA_DRAW_FRAME::SetNoToolSelected(), 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().

561 {
562  KIGFX::VIEW* view = getView();
564  BOARD* board = getModel<BOARD>();
565  PCB_TARGET* target = new PCB_TARGET( board );
566 
567  // Init the new item attributes
568  target->SetLayer( Edge_Cuts );
569  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
570  target->SetSize( Millimeter2iu( 5 ) );
571  VECTOR2I cursorPos = controls->GetCursorPosition();
572  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
573 
574  // Add a VIEW_GROUP that serves as a preview for the new item
575  KIGFX::VIEW_GROUP preview( view );
576  preview.Add( target );
577  view->Add( &preview );
578 
580  controls->SetSnapping( true );
581 
582  Activate();
583  m_frame->SetToolID( ID_PCB_MIRE_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
584 
585  // Main loop: keep receiving events
586  while( OPT_TOOL_EVENT evt = Wait() )
587  {
588  cursorPos = controls->GetCursorPosition();
589 
590  if( evt->IsCancel() || evt->IsActivate() )
591  break;
592 
593  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
594  {
595  target->SetWidth( target->GetWidth() + WIDTH_STEP );
596  view->Update( &preview );
597  }
598 
599  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
600  {
601  int width = target->GetWidth();
602 
603  if( width > WIDTH_STEP )
604  {
605  target->SetWidth( width - WIDTH_STEP );
606  view->Update( &preview );
607  }
608  }
609 
610  else if( evt->IsClick( BUT_LEFT ) )
611  {
612  assert( target->GetSize() > 0 );
613  assert( target->GetWidth() > 0 );
614 
615  BOARD_COMMIT commit( m_frame );
616  commit.Add( target );
617  commit.Push( _( "Place a layer alignment target" ) );
618 
619  preview.Remove( target );
620 
621  // Create next PCB_TARGET
622  target = new PCB_TARGET( *target );
623  preview.Add( target );
624  }
625 
626  else if( evt->IsMotion() )
627  {
628  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
629  view->Update( &preview );
630  }
631  }
632 
633  delete target;
634 
635  controls->SetSnapping( false );
636  view->Remove( &preview );
637 
639 
640  return 0;
641 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
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:167
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:341
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:170
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:124
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:533
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, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:560
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 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:311
Class VIEW.
Definition: view.h:58
int m_EdgeSegmentWidth
current graphic line width (EDGE layer only)
BOARD * board() const
Definition: pcb_tool.h:126
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 250 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().

251 {
252  m_frame = getEditFrame<PCB_EDIT_FRAME>();
253 
254  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
255  {
256  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
257  getView()->Remove( m_placeOrigin.get() );
258  getView()->Add( m_placeOrigin.get() );
259  }
260 }
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:341
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:311
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 86 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

87  {
88  m_editModules = aEnabled;
89  }
bool m_editModules
Definition: pcb_tool.h:128
void PCB_EDITOR_CONTROL::SetTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from TOOL_BASE.

Definition at line 1142 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::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, 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.

1143 {
1144  // Track & via size control
1149 
1150  // Zone actions
1157 
1158  // Placing tools
1161 
1162  // Other
1173 }
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:343
static TOOL_ACTION placeModule
Activation of the drawing tool (placing a MODULE)
Definition: pcb_actions.h:158
int ZoneMerge(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:345
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:358
static TOOL_ACTION lock
Definition: pcb_actions.h:344
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:271
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:264
int TrackWidthDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:263
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
static TOOL_ACTION highlightNetCursor
Definition: pcb_actions.h:357
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:362
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:270
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:105
static TOOL_ACTION crossProbeSchToPcb
Definition: pcb_actions.h:359
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:262
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:274
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:155
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:273
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:272
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:277
int ZoneFill(const TOOL_EVENT &aEvent)
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Updates ratsnest for selected items.
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:356
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:265
int PCB_EDITOR_CONTROL::ShowLocalRatsnest ( const TOOL_EVENT aEvent)

Shows local ratsnest of a component

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

1120 {
1121  Activate();
1122 
1123  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
1124  assert( picker );
1125 
1126  m_frame->SetToolID( ID_PCB_SHOW_1_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) );
1127  picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, _1 ) );
1128  picker->SetSnapping( false );
1129  picker->Activate();
1130  Wait();
1131 
1132  return 0;
1133 }
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: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 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 500 of file pcb_editor_control.cpp.

References modifyLockSelected(), and TOGGLE.

Referenced by SetTransitions().

501 {
502  return modifyLockSelected( TOGGLE );
503 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::TrackWidthDec ( const TOOL_EVENT aEvent)

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

335 {
336  BOARD* board = getModel<BOARD>();
337  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
338 
339  if( widthIndex < 0 )
340  widthIndex = 0;
341 
342  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
343  board->GetDesignSettings().UseCustomTrackViaSize( false );
344 
346 
347  return 0;
348 }
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:267
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:533
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:126
int PCB_EDITOR_CONTROL::TrackWidthInc ( const TOOL_EVENT aEvent)

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

318 {
319  BOARD* board = getModel<BOARD>();
320  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
321 
322  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
323  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
324 
325  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
326  board->GetDesignSettings().UseCustomTrackViaSize( false );
327 
329 
330  return 0;
331 }
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:267
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:533
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:126
int PCB_EDITOR_CONTROL::UnlockSelected ( const TOOL_EVENT aEvent)

Unlocks selected items.

Definition at line 512 of file pcb_editor_control.cpp.

References modifyLockSelected(), and OFF.

Referenced by SetTransitions().

513 {
514  return modifyLockSelected( OFF );
515 }
int modifyLockSelected(MODIFY_MODE aMode)
int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest ( const TOOL_EVENT aEvent)

Updates ratsnest for selected items.

Definition at line 1136 of file pcb_editor_control.cpp.

Referenced by SetTransitions().

1137 {
1138  return 0;
1139 }
int PCB_EDITOR_CONTROL::ViaSizeDec ( const TOOL_EVENT aEvent)

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

369 {
370  BOARD* board = getModel<BOARD>();
371  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
372 
373  if( sizeIndex < 0 )
374  sizeIndex = 0;
375 
376  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
377  board->GetDesignSettings().UseCustomTrackViaSize( false );
378 
380 
381  return 0;
382 }
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:267
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:533
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:126
int PCB_EDITOR_CONTROL::ViaSizeInc ( const TOOL_EVENT aEvent)

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

352 {
353  BOARD* board = getModel<BOARD>();
354  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
355 
356  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
357  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
358 
359  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
360  board->GetDesignSettings().UseCustomTrackViaSize( false );
361 
363 
364  return 0;
365 }
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:267
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:533
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:126
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(), PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), SELECTION_TOOL::selectMultiple(), 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: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 876 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().

877 {
878  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
879  const auto& selection = selTool->GetSelection();
880 
881  // because this pops up the zone editor, it would be confusing
882  // to handle multiple zones, so just handle single selections
883  // containing exactly one zone
884  if( selection.Size() != 1 )
885  return 0;
886 
887  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
888 
889  if( !oldZone )
890  return 0;
891 
892  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
893  newZone->ClearSelected();
894  newZone->UnFill();
895  ZONE_SETTINGS zoneSettings;
896  zoneSettings << *oldZone;
897 
898  bool success = false;
899 
900  if( oldZone->GetIsKeepout() )
901  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
902  else if( oldZone->IsOnCopperLayer() )
903  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
904  else
905  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
906 
907  // If the new zone is on the same layer as the the initial zone,
908  // do nothing
909  if( success && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
910  {
912  _( "The duplicated zone cannot be on the same layer as the original zone." ) );
913  success = false;
914  }
915 
916  // duplicate the zone
917  if( success )
918  {
919  BOARD_COMMIT commit( m_frame );
920  zoneSettings.ExportSetting( *newZone );
921 
922  commit.Add( newZone.release() );
923  commit.Push( _( "Duplicate zone" ) );
924  }
925 
926  return 0;
927 }
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.
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
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
int PCB_EDITOR_CONTROL::ZoneFill ( const TOOL_EVENT aEvent)

Definition at line 645 of file pcb_editor_control.cpp.

References PCB_EDIT_FRAME::Fill_Zone(), SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), m_frame, TOOL_BASE::m_toolMgr, COMMIT::Modify(), PCB_ZONE_AREA_T, and BOARD_COMMIT::Push().

Referenced by SetTransitions().

646 {
647  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
648  const auto& selection = selTool->GetSelection();
649  auto connectivity = getModel<BOARD>()->GetConnectivity();
650 
651  BOARD_COMMIT commit( this );
652 
653  for( auto item : selection )
654  {
655  assert( item->Type() == PCB_ZONE_AREA_T );
656 
657  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( item );
658 
659  commit.Modify( zone );
660 
661  m_frame->Fill_Zone( zone );
662  zone->SetIsFilled( true );
663  }
664 
665  commit.Push( _( "Fill Zone" ) );
666 
667  connectivity->RecalculateRatsnest();
668 
669  return 0;
670 }
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
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
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...
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int PCB_EDITOR_CONTROL::ZoneFillAll ( const TOOL_EVENT aEvent)

Definition at line 673 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), PCB_EDIT_FRAME::Fill_Zone(), PCB_TOOL::frame(), BOARD::GetArea(), BOARD::GetAreaCount(), GetChars(), BOARD_CONNECTED_ITEM::GetNetname(), m_frame, COMMIT::Modify(), BOARD_COMMIT::Push(), BOARD_COMMIT::Revert(), and ZONE_CONTAINER::SetIsFilled().

Referenced by SetTransitions().

674 {
675  BOARD* board = getModel<BOARD>();
676  auto connectivity = getModel<BOARD>()->GetConnectivity();
677  int areaCount = board->GetAreaCount();
678  const wxString fmt = _( "Filling zone %d out of %d (net %s)..." );
679  wxString msg;
680  bool aborted = false;
681 
682  // Create a message with a long net name, and build a wxProgressDialog
683  // with a correct size to show this long net name
684  msg.Printf( fmt, 000, areaCount, wxT("XXXXXXXXXXXXXXXXX" ) );
685 
686  auto progressDialog = new wxProgressDialog( _( "Fill All Zones" ), msg,
687  areaCount, frame(),
688  wxPD_AUTO_HIDE | wxPD_CAN_ABORT |
689  wxPD_APP_MODAL | wxPD_ELAPSED_TIME );
690 
691  BOARD_COMMIT commit( this );
692 
693  for( int i = 0; i < areaCount; ++i )
694  {
695  ZONE_CONTAINER* zone = board->GetArea( i );
696 
697  msg.Printf( fmt, i, areaCount, GetChars( zone->GetNetname() ) );
698 
699  commit.Modify( zone );
700 
701  if( !progressDialog->Update( i, msg ) )
702  {
703  aborted = true;
704  break; // Aborted by user
705  }
706 
707  m_frame->Fill_Zone( zone );
708  zone->SetIsFilled( true );
709  }
710 
711  if( aborted )
712  commit.Revert();
713  else
714  commit.Push( _( "Fill All Zones" ) );
715 
716  connectivity->RecalculateRatsnest();
717  progressDialog->Destroy();
718 
719  return 0;
720 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
void SetIsFilled(bool isFilled)
Definition: class_zone.h:201
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1025
int Fill_Zone(ZONE_CONTAINER *aZone)
Function Fill_Zone Calculate the zone filling for the outline zone_container The zone outline is a fr...
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
const wxString & GetNetname() const
Function GetNetname.
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:996
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
BOARD * board() const
Definition: pcb_tool.h:126
int PCB_EDITOR_CONTROL::ZoneMerge ( const TOOL_EVENT aEvent)

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

812 {
813  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
814  BOARD* board = getModel<BOARD>();
815  BOARD_COMMIT commit( m_frame );
816 
817  if( selection.Size() < 2 )
818  return 0;
819 
820  int netcode = -1;
821 
822  ZONE_CONTAINER* firstZone = nullptr;
823  std::vector<ZONE_CONTAINER*> toMerge, merged;
824 
825  for( auto item : selection )
826  {
827  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
828 
829  if( !curr_area )
830  continue;
831 
832  if( !firstZone )
833  firstZone = curr_area;
834 
835  netcode = curr_area->GetNetCode();
836 
837  if( firstZone )
838  {
839  if( firstZone->GetNetCode() != netcode )
840  continue;
841 
842  if( curr_area->GetPriority() != firstZone->GetPriority() )
843  continue;
844 
845  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
846  continue;
847 
848  if( curr_area->GetLayer() != firstZone->GetLayer() )
849  continue;
850 
851  if( !board->TestAreaIntersection( curr_area, firstZone ) )
852  continue;
853 
854  toMerge.push_back( curr_area );
855  }
856  else
857  {
858  toMerge.push_back( curr_area );
859  }
860  }
861 
863 
864  if( mergeZones( commit, toMerge, merged ) )
865  {
866  commit.Push( _( "Merge zones" ) );
867 
868  for( auto item : merged )
870  }
871 
872  return 0;
873 }
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
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:654
int GetNetCode() const
Function GetNetCode.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:112
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:119
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE_CONTAINER * > &aOriginZones, std::vector< ZONE_CONTAINER * > &aMergedZones)
BOARD * board() const
Definition: pcb_tool.h:126
int PCB_EDITOR_CONTROL::ZoneUnfill ( const TOOL_EVENT aEvent)

Definition at line 723 of file pcb_editor_control.cpp.

References SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, COMMIT::Modify(), PCB_ZONE_AREA_T, and BOARD_COMMIT::Push().

Referenced by SetTransitions().

724 {
725  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
726  const auto& selection = selTool->GetSelection();
727  auto connectivity = getModel<BOARD>()->GetConnectivity();
728 
729  BOARD_COMMIT commit( this );
730 
731  for( auto item : selection )
732  {
733  assert( item->Type() == PCB_ZONE_AREA_T );
734 
735  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
736 
737  commit.Modify( zone );
738 
739  zone->SetIsFilled( false );
740  zone->ClearFilledPolysList();
741  }
742 
743  commit.Push( _( "Unfill Zone" ) );
744 
745  connectivity->RecalculateRatsnest();
746 
747  return 0;
748 }
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
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
void SetIsFilled(bool isFilled)
Definition: class_zone.h:201
SELECTION & GetSelection()
Function GetSelection()
int PCB_EDITOR_CONTROL::ZoneUnfillAll ( const TOOL_EVENT aEvent)

Definition at line 751 of file pcb_editor_control.cpp.

References PCB_TOOL::board(), ZONE_CONTAINER::ClearFilledPolysList(), BOARD::GetArea(), BOARD::GetAreaCount(), COMMIT::Modify(), BOARD_COMMIT::Push(), and ZONE_CONTAINER::SetIsFilled().

Referenced by SetTransitions().

752 {
753  BOARD* board = getModel<BOARD>();
754  auto connectivity = getModel<BOARD>()->GetConnectivity();
755 
756  BOARD_COMMIT commit( this );
757 
758  for( int i = 0; i < board->GetAreaCount(); ++i )
759  {
760  ZONE_CONTAINER* zone = board->GetArea( i );
761 
762  commit.Modify( zone );
763 
764  zone->SetIsFilled( false );
765  zone->ClearFilledPolysList();
766  }
767 
768  commit.Push( _( "Unfill All Zones" ) );
769 
770  connectivity->RecalculateRatsnest();
771 
772  return 0;
773 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
void SetIsFilled(bool isFilled)
Definition: class_zone.h:201
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1025
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:996
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: class_zone.h:572
BOARD * board() const
Definition: pcb_tool.h:126

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 119 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 122 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(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), Init(), EDIT_TOOL::Init(), POSITION_RELATIVE_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(), PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), 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::SelectItems(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), ShowLocalRatsnest(), SELECTION_TOOL::toggleSelection(), TrackWidthDec(), TrackWidthInc(), SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItems(), 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 130 of file pcb_editor_control.h.

Referenced by PlaceTarget().


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