KiCad PCB EDA Suite
PLACEMENT_TOOL Class Reference

#include <placement_tool.h>

Inheritance diagram for PLACEMENT_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

 PLACEMENT_TOOL ()
 
virtual ~PLACEMENT_TOOL ()
 
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 AlignTop (const TOOL_EVENT &aEvent)
 Function AlignTop() Sets Y coordinate of the selected items to the value of the top-most selected item Y coordinate. More...
 
int AlignBottom (const TOOL_EVENT &aEvent)
 Function AlignBottom() Sets Y coordinate of the selected items to the value of the bottom-most selected item Y coordinate. More...
 
int AlignLeft (const TOOL_EVENT &aEvent)
 Function AlignLeft() Sets X coordinate of the selected items to the value of the left-most selected item X coordinate. More...
 
int AlignRight (const TOOL_EVENT &aEvent)
 Function AlignRight() Sets X coordinate of the selected items to the value of the right-most selected item X coordinate. More...
 
int DistributeHorizontally (const TOOL_EVENT &aEvent)
 Function DistributeHorizontally() Distributes the selected items along the X axis. More...
 
int DistributeVertically (const TOOL_EVENT &aEvent)
 Function DistributeVertically() Distributes the selected items along the Y axis. More...
 
void SetTransitions () override
 

Sets up handlers for various events.

More...
 
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 Member Functions

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

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 Attributes

SELECTION_TOOLm_selectionTool
 
CONTEXT_MENUm_placementMenu
 

Detailed Description

Definition at line 32 of file placement_tool.h.

Member Enumeration Documentation

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

PLACEMENT_TOOL::PLACEMENT_TOOL ( )

Definition at line 71 of file placement_tool.cpp.

71  :
72  TOOL_INTERACTIVE( "pcbnew.Placement" ), m_selectionTool( NULL ), m_placementMenu( NULL )
73 {
74 }
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Constructor.
SELECTION_TOOL * m_selectionTool
CONTEXT_MENU * m_placementMenu
PLACEMENT_TOOL::~PLACEMENT_TOOL ( )
virtual

Definition at line 76 of file placement_tool.cpp.

References m_placementMenu.

77 {
78  delete m_placementMenu;
79 }
CONTEXT_MENU * m_placementMenu

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(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::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(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), and ROUTER_TOOL::SettingsDialog().

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...
int PLACEMENT_TOOL::AlignBottom ( const TOOL_EVENT aEvent)

Function AlignBottom() Sets Y coordinate of the selected items to the value of the bottom-most selected item Y coordinate.

Definition at line 151 of file placement_tool.cpp.

References CHT_MODIFY, SELECTION::Front(), EDA_RECT::GetBottom(), EDA_ITEM::GetBoundingBox(), SELECTION_TOOL::GetSelection(), m_selectionTool, BOARD_COMMIT::Push(), SELECTION::Size(), and COMMIT::StageItems().

Referenced by SetTransitions().

152 {
153  const SELECTION& selection = m_selectionTool->GetSelection();
154 
155  if( selection.Size() <= 1 )
156  return 0;
157 
158  BOARD_COMMIT commit( getEditFrame<PCB_BASE_FRAME>() );
159  commit.StageItems( selection, CHT_MODIFY );
160 
161  // Compute the lowest point of selection - it will be the edge of alignment
162  int bottom = selection.Front()->GetBoundingBox().GetBottom();
163 
164  for( int i = 1; i < selection.Size(); ++i )
165  {
166  int currentBottom = selection[i]->GetBoundingBox().GetBottom();
167 
168  if( bottom < currentBottom ) // Y increases when going down
169  bottom = currentBottom;
170  }
171 
172  // Move the selected items
173  for( auto i : selection )
174  {
175  auto item = static_cast<BOARD_ITEM*>( i );
176 
177  int difference = bottom - item->GetBoundingBox().GetBottom();
178 
179  item->Move( wxPoint( 0, difference ) );
180  }
181 
182  commit.Push( _( "Align to bottom" ) );
183 
184  return 0;
185 }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
EDA_ITEM * Front() const
Definition: selection.h:137
SELECTION_TOOL * m_selectionTool
SELECTION & GetSelection()
Function GetSelection()
int GetBottom() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
int PLACEMENT_TOOL::AlignLeft ( const TOOL_EVENT aEvent)

Function AlignLeft() Sets X coordinate of the selected items to the value of the left-most selected item X coordinate.

Definition at line 188 of file placement_tool.cpp.

References CHT_MODIFY, SELECTION::Front(), EDA_ITEM::GetBoundingBox(), SELECTION_TOOL::GetSelection(), EDA_RECT::GetX(), m_selectionTool, BOARD_COMMIT::Push(), SELECTION::Size(), and COMMIT::StageItems().

Referenced by SetTransitions().

189 {
190  const SELECTION& selection = m_selectionTool->GetSelection();
191 
192  if( selection.Size() <= 1 )
193  return 0;
194 
195  BOARD_COMMIT commit( getEditFrame<PCB_BASE_FRAME>() );
196  commit.StageItems( selection, CHT_MODIFY );
197 
198  // Compute the leftmost point of selection - it will be the edge of alignment
199  int left = selection.Front()->GetBoundingBox().GetX();
200 
201  for( int i = 1; i < selection.Size(); ++i )
202  {
203  int currentLeft = selection[i]->GetBoundingBox().GetX();
204 
205  if( left > currentLeft ) // X decreases when going left
206  left = currentLeft;
207  }
208 
209  // Move the selected items
210  for( auto i : selection )
211  {
212  auto item = static_cast<BOARD_ITEM*>( i );
213 
214  int difference = left - item->GetBoundingBox().GetX();
215 
216  item->Move( wxPoint( difference, 0 ) );
217  }
218 
219  commit.Push( _( "Align to left" ) );
220 
221  return 0;
222 }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
EDA_ITEM * Front() const
Definition: selection.h:137
SELECTION_TOOL * m_selectionTool
SELECTION & GetSelection()
Function GetSelection()
int GetX() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
int PLACEMENT_TOOL::AlignRight ( const TOOL_EVENT aEvent)

Function AlignRight() Sets X coordinate of the selected items to the value of the right-most selected item X coordinate.

Definition at line 225 of file placement_tool.cpp.

References CHT_MODIFY, SELECTION::Front(), EDA_ITEM::GetBoundingBox(), EDA_RECT::GetRight(), SELECTION_TOOL::GetSelection(), m_selectionTool, BOARD_COMMIT::Push(), SELECTION::Size(), and COMMIT::StageItems().

Referenced by SetTransitions().

226 {
227  const SELECTION& selection = m_selectionTool->GetSelection();
228 
229  if( selection.Size() <= 1 )
230  return 0;
231 
232  BOARD_COMMIT commit( getEditFrame<PCB_BASE_FRAME>() );
233  commit.StageItems( selection, CHT_MODIFY );
234 
235  // Compute the rightmost point of selection - it will be the edge of alignment
236  int right = selection.Front()->GetBoundingBox().GetRight();
237 
238  for( int i = 1; i < selection.Size(); ++i )
239  {
240  int currentRight = selection[i]->GetBoundingBox().GetRight();
241 
242  if( right < currentRight ) // X increases when going right
243  right = currentRight;
244  }
245 
246  // Move the selected items
247  for( auto i : selection )
248  {
249  auto item = static_cast<BOARD_ITEM*>( i );
250 
251  int difference = right - item->GetBoundingBox().GetRight();
252 
253  item->Move( wxPoint( difference, 0 ) );
254  }
255 
256  commit.Push( _( "Align to right" ) );
257 
258  return 0;
259 }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
EDA_ITEM * Front() const
Definition: selection.h:137
SELECTION_TOOL * m_selectionTool
SELECTION & GetSelection()
Function GetSelection()
int GetRight() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
int PLACEMENT_TOOL::AlignTop ( const TOOL_EVENT aEvent)

Function AlignTop() Sets Y coordinate of the selected items to the value of the top-most selected item Y coordinate.

Definition at line 114 of file placement_tool.cpp.

References CHT_MODIFY, SELECTION::Front(), EDA_ITEM::GetBoundingBox(), SELECTION_TOOL::GetSelection(), EDA_RECT::GetY(), m_selectionTool, BOARD_COMMIT::Push(), SELECTION::Size(), and COMMIT::StageItems().

Referenced by SetTransitions().

115 {
116  const SELECTION& selection = m_selectionTool->GetSelection();
117 
118  if( selection.Size() <= 1 )
119  return 0;
120 
121  BOARD_COMMIT commit( getEditFrame<PCB_BASE_FRAME>() );
122  commit.StageItems( selection, CHT_MODIFY );
123 
124  // Compute the highest point of selection - it will be the edge of alignment
125  int top = selection.Front()->GetBoundingBox().GetY();
126 
127  for( int i = 1; i < selection.Size(); ++i )
128  {
129  int currentTop = selection[i]->GetBoundingBox().GetY();
130 
131  if( top > currentTop ) // Y decreases when going up
132  top = currentTop;
133  }
134 
135  // Move the selected items
136  for( auto i : selection )
137  {
138  auto item = static_cast<BOARD_ITEM*>( i );
139 
140  int difference = top - item->GetBoundingBox().GetY();
141 
142  item->Move( wxPoint( 0, difference ) );
143  }
144 
145  commit.Push( _( "Align to top" ) );
146 
147  return 0;
148 }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
EDA_ITEM * Front() const
Definition: selection.h:137
SELECTION_TOOL * m_selectionTool
SELECTION & GetSelection()
Function GetSelection()
int GetY() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
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 PLACEMENT_TOOL::DistributeHorizontally ( const TOOL_EVENT aEvent)

Function DistributeHorizontally() Distributes the selected items along the X axis.

Definition at line 274 of file placement_tool.cpp.

References CHT_MODIFY, compareX(), SELECTION_TOOL::GetSelection(), m_selectionTool, BOARD_COMMIT::Push(), SELECTION::Size(), and COMMIT::StageItems().

Referenced by SetTransitions().

275 {
276  const SELECTION& selection = m_selectionTool->GetSelection();
277 
278  if( selection.Size() <= 1 )
279  return 0;
280 
281  BOARD_COMMIT commit( getEditFrame<PCB_BASE_FRAME>() );
282  commit.StageItems( selection, CHT_MODIFY );
283 
284  // Prepare a list, so the items can be sorted by their X coordinate
285  std::vector<BOARD_ITEM*> itemsList;
286 
287  for( auto item : selection )
288  itemsList.push_back( static_cast<BOARD_ITEM*>( item ) );
289 
290  // Sort items by X coordinate
291  std::sort(itemsList.begin(), itemsList.end(), compareX );
292 
293  // Expected X coordinate for the next item (=minX)
294  int position = itemsList.front()->GetBoundingBox().Centre().x;
295 
296  // X coordinate for the last item
297  const int maxX = itemsList.back()->GetBoundingBox().Centre().x;
298 
299  // Distance between items
300  const int distance = ( maxX - position ) / ( itemsList.size() - 1 );
301 
302  for( auto item : itemsList )
303  {
304  int difference = position - item->GetBoundingBox().Centre().x;
305 
306  item->Move( wxPoint( difference, 0 ) );
307 
308  position += distance;
309  }
310 
311  commit.Push( _( "Distribute horizontally" ) );
312 
313  return 0;
314 }
SELECTION_TOOL * m_selectionTool
static bool compareX(const BOARD_ITEM *aA, const BOARD_ITEM *aB)
SELECTION & GetSelection()
Function GetSelection()
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
int PLACEMENT_TOOL::DistributeVertically ( const TOOL_EVENT aEvent)

Function DistributeVertically() Distributes the selected items along the Y axis.

Definition at line 317 of file placement_tool.cpp.

References CHT_MODIFY, compareY(), SELECTION_TOOL::GetSelection(), m_selectionTool, BOARD_COMMIT::Push(), SELECTION::Size(), and COMMIT::StageItems().

Referenced by SetTransitions().

318 {
319  const SELECTION& selection = m_selectionTool->GetSelection();
320 
321  if( selection.Size() <= 1 )
322  return 0;
323 
324  BOARD_COMMIT commit( getEditFrame<PCB_BASE_FRAME>() );
325  commit.StageItems( selection, CHT_MODIFY );
326 
327  // Prepare a list, so the items can be sorted by their Y coordinate
328  std::vector<BOARD_ITEM*> itemsList;
329 
330  for( auto item : selection )
331  itemsList.push_back( static_cast<BOARD_ITEM*>( item ) );
332 
333  // Sort items by Y coordinate
334  std::sort( itemsList.begin(), itemsList.end(), compareY );
335 
336  // Expected Y coordinate for the next item (=minY)
337  int position = (*itemsList.begin())->GetBoundingBox().Centre().y;
338 
339  // Y coordinate for the last item
340  const int maxY = (*itemsList.rbegin())->GetBoundingBox().Centre().y;
341 
342  // Distance between items
343  const int distance = ( maxY - position ) / ( itemsList.size() - 1 );
344 
345  for( auto item : itemsList )
346  {
347  int difference = position - item->GetBoundingBox().Centre().y;
348 
349  item->Move( wxPoint( 0, difference ) );
350 
351  position += distance;
352  }
353 
354  commit.Push( _( "Distribute vertically" ) );
355 
356  return 0;
357 }
SELECTION_TOOL * m_selectionTool
SELECTION & GetSelection()
Function GetSelection()
static bool compareY(const BOARD_ITEM *aA, const BOARD_ITEM *aB)
int Size() const
Returns the number of selected parts.
Definition: selection.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 PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), PCBNEW_CONTROL::HighContrastMode(), PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::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(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::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(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneUnfill(), PCB_EDITOR_CONTROL::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(), SetTransitions(), PCBNEW_CONTROL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), PICKER_TOOL::SetTransitions(), PCB_EDITOR_CONTROL::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)
bool PLACEMENT_TOOL::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 82 of file placement_tool.cpp.

References CONTEXT_MENU::Add(), CONDITIONAL_MENU::AddMenu(), PCB_ACTIONS::alignBottom, PCB_ACTIONS::alignLeft, PCB_ACTIONS::alignRight, PCB_ACTIONS::alignTop, DisplayError(), PCB_ACTIONS::distributeHorizontally, PCB_ACTIONS::distributeVertically, TOOL_MANAGER::FindTool(), TOOL_MENU::GetMenu(), SELECTION_TOOL::GetToolMenu(), m_placementMenu, m_selectionTool, TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::MoreThan(), CONTEXT_MENU::SetIcon(), and CONTEXT_MENU::SetTitle().

83 {
84  // Find the selection tool, so they can cooperate
85  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
86 
87  if( !m_selectionTool )
88  {
89  DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
90  return false;
91  }
92 
93  // Create a context menu and make it available through selection tool
95  m_placementMenu->SetIcon( align_items_xpm );
96  m_placementMenu->SetTitle( _( "Align/distribute" ) );
97 
98  // Add all align/distribute commands
103  m_placementMenu->AppendSeparator();
106 
109 
110  return true;
111 }
static TOOL_ACTION alignRight
Align items to the right edge of selection bounding box.
Definition: pcb_actions.h:209
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
static SELECTION_CONDITION MoreThan(int aNumber)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
Class CONTEXT_MENU.
Definition: context_menu.h:44
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
SELECTION_TOOL * m_selectionTool
static TOOL_ACTION distributeVertically
Distributes items evenly along the vertical axis.
Definition: pcb_actions.h:215
static TOOL_ACTION alignBottom
Align items to the bottom edge of selection bounding box.
Definition: pcb_actions.h:203
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon=NULL)
Function Add() Adds an entry to the menu.
static TOOL_ACTION distributeHorizontally
Distributes items evenly along the horizontal axis.
Definition: pcb_actions.h:212
static TOOL_ACTION alignLeft
Align items to the left edge of selection bounding box.
Definition: pcb_actions.h:206
CONTEXT_MENU * m_placementMenu
static TOOL_ACTION alignTop
Align items to the top edge of selection bounding box.
Definition: pcb_actions.h:200
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
Definition: context_menu.h:74
void AddMenu(CONTEXT_MENU *aMenu, bool aExpand=false, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the context menu.
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
void PLACEMENT_TOOL::Reset ( RESET_REASON  aReason)
inlineoverridevirtual

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 39 of file placement_tool.h.

39 {}
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 PLACEMENT_TOOL::SetTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from TOOL_BASE.

Definition at line 360 of file placement_tool.cpp.

References AlignBottom(), PCB_ACTIONS::alignBottom, AlignLeft(), PCB_ACTIONS::alignLeft, AlignRight(), PCB_ACTIONS::alignRight, AlignTop(), PCB_ACTIONS::alignTop, DistributeHorizontally(), PCB_ACTIONS::distributeHorizontally, DistributeVertically(), PCB_ACTIONS::distributeVertically, and TOOL_INTERACTIVE::Go().

361 {
366 
369 }
static TOOL_ACTION alignRight
Align items to the right edge of selection bounding box.
Definition: pcb_actions.h:209
static TOOL_ACTION distributeVertically
Distributes items evenly along the vertical axis.
Definition: pcb_actions.h:215
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION alignBottom
Align items to the bottom edge of selection bounding box.
Definition: pcb_actions.h:203
static TOOL_ACTION distributeHorizontally
Distributes items evenly along the horizontal axis.
Definition: pcb_actions.h:212
int AlignRight(const TOOL_EVENT &aEvent)
Function AlignRight() Sets X coordinate of the selected items to the value of the right-most selected...
static TOOL_ACTION alignLeft
Align items to the left edge of selection bounding box.
Definition: pcb_actions.h:206
int DistributeVertically(const TOOL_EVENT &aEvent)
Function DistributeVertically() Distributes the selected items along the Y axis.
static TOOL_ACTION alignTop
Align items to the top edge of selection bounding box.
Definition: pcb_actions.h:200
int AlignLeft(const TOOL_EVENT &aEvent)
Function AlignLeft() Sets X coordinate of the selected items to the value of the left-most selected i...
int AlignBottom(const TOOL_EVENT &aEvent)
Function AlignBottom() Sets Y coordinate of the selected items to the value of the bottom-most select...
int DistributeHorizontally(const TOOL_EVENT &aEvent)
Function DistributeHorizontally() Distributes the selected items along the X axis.
int AlignTop(const TOOL_EVENT &aEvent)
Function AlignTop() Sets Y coordinate of the selected items to the value of the top-most selected ite...
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(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::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(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::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.

Member Data Documentation

CONTEXT_MENU* PLACEMENT_TOOL::m_placementMenu
private

Definition at line 86 of file placement_tool.h.

Referenced by Init(), and ~PLACEMENT_TOOL().

SELECTION_TOOL* PLACEMENT_TOOL::m_selectionTool
private
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(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::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(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::Init(), Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::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(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::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(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SELECTION_TOOL::UnselectItem(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::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().


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