KiCad PCB EDA Suite
pad_tool.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
25 #include "pad_tool.h"
26 #include <class_draw_panel_gal.h>
27 #include <view/view_controls.h>
28 #include <view/view.h>
29 #include <tool/tool_manager.h>
30 #include <bitmaps.h>
31 #include <class_board_item.h>
32 #include <class_module.h>
33 #include <class_edge_mod.h>
34 #include <board_commit.h>
36 #include <tools/pcb_actions.h>
37 #include <tools/selection_tool.h>
39 #include <tools/edit_tool.h>
41 #include <pad_naming.h>
42 #include <widgets/infobar.h>
43 
45  PCB_TOOL_BASE( "pcbnew.PadTool" ),
46  m_padCopied( false ),
47  m_wasHighContrast( false ),
48  m_editPad( niluuid )
49 {}
50 
51 
53 {}
54 
55 
57 {
58  if( aReason == MODEL_RELOAD )
59  m_lastPadName = wxT( "1" );
60 
61  m_padCopied = false;
63 }
64 
65 
67 {
69 
70  if( selTool )
71  {
72  // Add context menu entries that are displayed when selection tool is active
73  CONDITIONAL_MENU& menu = selTool->GetToolMenu().GetMenu();
74 
78 
79  auto explodeCondition = [&]( const SELECTION& aSel )
80  {
81  return m_editPad == niluuid
82  && aSel.Size() == 1 && aSel[0]->Type() == PCB_PAD_T;
83  };
84 
85  auto recombineCondition = [&]( const SELECTION& aSel )
86  {
87  return m_editPad != niluuid;
88  };
89 
90  menu.AddSeparator( 400 );
91 
92  if( m_editModules )
93  {
95  menu.AddItem( PCB_ACTIONS::recombinePad, recombineCondition, 400 );
96  menu.AddItem( PCB_ACTIONS::explodePad, explodeCondition, 400 );
97  }
98 
99  menu.AddItem( PCB_ACTIONS::copyPadSettings, singlePadSel, 400 );
100  menu.AddItem( PCB_ACTIONS::applyPadSettings, padSel, 400 );
101  menu.AddItem( PCB_ACTIONS::pushPadSettings, singlePadSel, 400 );
102  }
103 
104  return true;
105 }
106 
107 
109 {
110  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
111  const auto& selection = selTool.GetSelection();
112  const D_PAD& masterPad = frame()->GetDesignSettings().m_Pad_Master;
113 
114  BOARD_COMMIT commit( frame() );
115 
116  // for every selected pad, paste global settings
117  for( auto item : selection )
118  {
119  if( item->Type() == PCB_PAD_T )
120  {
121  commit.Modify( item );
122  static_cast<D_PAD&>( *item ).ImportSettingsFrom( masterPad );
123  }
124  }
125 
126  commit.Push( _( "Paste Pad Properties" ) );
127 
129  frame()->Refresh();
130 
131  return 0;
132 }
133 
134 
136 {
137  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
138  const auto& selection = selTool.GetSelection();
139 
140  D_PAD& masterPad = frame()->GetDesignSettings().m_Pad_Master;
141 
142  // can only copy from a single pad
143  if( selection.Size() == 1 )
144  {
145  auto item = selection[0];
146 
147  if( item->Type() == PCB_PAD_T )
148  {
149  const auto& selPad = static_cast<const D_PAD&>( *item );
150  masterPad.ImportSettingsFrom( selPad );
151  m_padCopied = true;
152  }
153  }
154 
155  return 0;
156 }
157 
158 
159 static void doPushPadProperties( BOARD& board, const D_PAD& aSrcPad, BOARD_COMMIT& commit,
160  bool aSameFootprints,
161  bool aPadShapeFilter,
162  bool aPadOrientFilter,
163  bool aPadLayerFilter,
164  bool aPadTypeFilter )
165 {
166  const MODULE* moduleRef = aSrcPad.GetParent();
167 
168  double pad_orient = aSrcPad.GetOrientation() - moduleRef->GetOrientation();
169 
170  for( auto module : board.Modules() )
171  {
172  if( !aSameFootprints && ( module != moduleRef ) )
173  continue;
174 
175  if( module->GetFPID() != moduleRef->GetFPID() )
176  continue;
177 
178  for( auto pad : module->Pads() )
179  {
180  if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
181  continue;
182 
183  double currpad_orient = pad->GetOrientation() - module->GetOrientation();
184 
185  if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
186  continue;
187 
188  if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
189  continue;
190 
191  if( aPadTypeFilter && ( pad->GetAttribute() != aSrcPad.GetAttribute() ) )
192  continue;
193 
194  // Special-case for aperture pads
195  if( aPadTypeFilter && pad->GetAttribute() == PAD_ATTRIB_CONN )
196  {
197  if( pad->IsAperturePad() != aSrcPad.IsAperturePad() )
198  continue;
199  }
200 
201  commit.Modify( pad );
202 
203  // Apply source pad settings to this pad
204  pad->ImportSettingsFrom( aSrcPad );
205  }
206  }
207 }
208 
209 
211 {
212  auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
213  const auto& selection = selTool.GetSelection();
214  D_PAD* srcPad;
215 
216  if( selection.Size() == 1 && selection[0]->Type() == PCB_PAD_T )
217  srcPad = static_cast<D_PAD*>( selection[0] );
218  else
219  return 0;
220 
221  MODULE* module = srcPad->GetParent();
222 
223  if( !module )
224  return 0;
225 
226  frame()->SetMsgPanel( module );
227 
229  int dialogRet = dlg.ShowModal();
230 
231  if( dialogRet == wxID_CANCEL )
232  return 0;
233 
234  const bool edit_Same_Modules = (dialogRet == 1);
235 
236  BOARD_COMMIT commit( frame() );
237 
238  doPushPadProperties( *getModel<BOARD>(), *srcPad, commit, edit_Same_Modules,
243 
244  commit.Push( _( "Push Pad Settings" ) );
245 
247  frame()->Refresh();
248 
249  return 0;
250 }
251 
252 
254 {
255  if( !board()->GetFirstModule() || board()->GetFirstModule()->Pads().empty() )
256  return 0;
257 
258  DIALOG_ENUM_PADS settingsDlg( frame() );
259 
260  if( settingsDlg.ShowModal() != wxID_OK )
261  return 0;
262 
263  std::string tool = aEvent.GetCommandStr().get();
264  frame()->PushTool( tool );
265  Activate();
266 
267  GENERAL_COLLECTOR collector;
268  const KICAD_T types[] = { PCB_PAD_T, EOT };
269 
271  guide.SetIgnoreMTextsMarkedNoShow( true );
272  guide.SetIgnoreMTextsOnBack( true );
273  guide.SetIgnoreMTextsOnFront( true );
274  guide.SetIgnoreModulesVals( true );
275  guide.SetIgnoreModulesRefs( true );
276 
277  int seqPadNum = settingsDlg.GetStartNumber();
278  wxString padPrefix = settingsDlg.GetPrefix();
279  std::deque<int> storedPadNumbers;
280 
282  getViewControls()->ShowCursor( true );
283 
285  VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
286  std::list<D_PAD*> selectedPads;
287  BOARD_COMMIT commit( frame() );
288  std::map<wxString, std::pair<int, wxString>> oldNames;
289  bool isFirstPoint = true; // used to be sure oldCursorPos will be initialized at least once.
290 
291  STATUS_TEXT_POPUP statusPopup( frame() );
292  wxString msg = _( "Click on pad %s%d\nPress <esc> to cancel or double-click to commit" );
293  statusPopup.SetText( wxString::Format( msg, padPrefix, seqPadNum ) );
294  statusPopup.Popup();
295  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
296 
297  while( TOOL_EVENT* evt = Wait() )
298  {
299  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
300 
301  if( evt->IsCancelInteractive() )
302  {
304  commit.Revert();
305 
306  frame()->PopTool( tool );
307  break;
308  }
309 
310  else if( evt->IsActivate() )
311  {
312  commit.Push( _( "Renumber pads" ) );
313 
314  frame()->PopTool( tool );
315  break;
316  }
317 
318  else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
319  {
320  selectedPads.clear();
321  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
322 
323  // Be sure the old cursor mouse position was initialized:
324  if( isFirstPoint )
325  {
326  oldCursorPos = cursorPos;
327  isFirstPoint = false;
328  }
329 
330  // wxWidgets deliver mouse move events not frequently enough, resulting in skipping
331  // pads if the user moves cursor too fast. To solve it, create a line that approximates
332  // the mouse move and search pads that are on the line.
333  int distance = ( cursorPos - oldCursorPos ).EuclideanNorm();
334  // Search will be made every 0.1 mm:
335  int segments = distance / int( 0.1*IU_PER_MM ) + 1;
336  const wxPoint line_step( ( cursorPos - oldCursorPos ) / segments );
337 
338  collector.Empty();
339 
340  for( int j = 0; j < segments; ++j )
341  {
342  wxPoint testpoint( cursorPos.x - j * line_step.x, cursorPos.y - j * line_step.y );
343  collector.Collect( board(), types, testpoint, guide );
344 
345  for( int i = 0; i < collector.GetCount(); ++i )
346  selectedPads.push_back( static_cast<D_PAD*>( collector[i] ) );
347  }
348 
349  selectedPads.unique();
350 
351  for( D_PAD* pad : selectedPads )
352  {
353  // If pad was not selected, then enumerate it
354  if( !pad->IsSelected() )
355  {
356  commit.Modify( pad );
357 
358  // Rename pad and store the old name
359  int newval;
360 
361  if( storedPadNumbers.size() > 0 )
362  {
363  newval = storedPadNumbers.front();
364  storedPadNumbers.pop_front();
365  }
366  else
367  newval = seqPadNum++;
368 
369  wxString newName = wxString::Format( wxT( "%s%d" ), padPrefix, newval );
370  oldNames[newName] = { newval, pad->GetName() };
371  pad->SetName( newName );
372  SetLastPadName( newName );
373  pad->SetSelected();
374  getView()->Update( pad );
375 
376  // Ensure the popup text shows the correct next value
377  if( storedPadNumbers.size() > 0 )
378  newval = storedPadNumbers.front();
379  else
380  newval = seqPadNum;
381 
382  statusPopup.SetText( wxString::Format( msg, padPrefix, newval ) );
383  }
384 
385  // ... or restore the old name if it was enumerated and clicked again
386  else if( pad->IsSelected() && evt->IsClick( BUT_LEFT ) )
387  {
388  auto it = oldNames.find( pad->GetName() );
389  wxASSERT( it != oldNames.end() );
390 
391  if( it != oldNames.end() )
392  {
393  storedPadNumbers.push_back( it->second.first );
394  pad->SetName( it->second.second );
395  SetLastPadName( it->second.second );
396  oldNames.erase( it );
397 
398  int newval = storedPadNumbers.front();
399 
400  statusPopup.SetText( wxString::Format( msg, padPrefix, newval ) );
401  }
402 
403  pad->ClearSelected();
404  getView()->Update( pad );
405  }
406  }
407  }
408 
409  else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) ||
410  evt->IsDblClick( BUT_LEFT ) )
411  {
412  commit.Push( _( "Renumber pads" ) );
413  frame()->PopTool( tool );
414  break;
415  }
416 
417  else if( evt->IsClick( BUT_RIGHT ) )
418  {
420  }
421 
422  else
423  evt->SetPassEvent();
424 
425  // Prepare the next loop by updating the old cursor mouse position
426  // to this last mouse cursor position
427  oldCursorPos = getViewControls()->GetCursorPosition();
428  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
429  }
430 
431  for( auto p : board()->GetFirstModule()->Pads() )
432  {
433  p->ClearSelected();
434  view->Update( p );
435  }
436 
437  statusPopup.Hide();
438  return 0;
439 }
440 
441 
442 int PAD_TOOL::PlacePad( const TOOL_EVENT& aEvent )
443 {
444  if( !board()->GetFirstModule() )
445  return 0;
446 
447  struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
448  {
449  PAD_PLACER( PAD_TOOL* aPadTool )
450  {
451  m_padTool = aPadTool;
452  }
453 
454  virtual ~PAD_PLACER()
455  {
456  }
457 
458  std::unique_ptr<BOARD_ITEM> CreateItem() override
459  {
460  D_PAD* pad = new D_PAD( m_board->GetFirstModule() );
461 
462  pad->ImportSettingsFrom( m_frame->GetDesignSettings().m_Pad_Master );
463 
464  if( PAD_NAMING::PadCanHaveName( *pad ) )
465  {
466  wxString padName = m_padTool->GetLastPadName();
467  padName = m_board->GetFirstModule()->GetNextPadName( padName );
468  pad->SetName( padName );
469  m_padTool->SetLastPadName( padName );
470  }
471 
472  return std::unique_ptr<BOARD_ITEM>( pad );
473  }
474 
475  bool PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit ) override
476  {
477  D_PAD* pad = dynamic_cast<D_PAD*>( aItem );
478 
479  if( pad )
480  {
481  m_frame->GetDesignSettings().m_Pad_Master.ImportSettingsFrom( *pad );
482  pad->SetLocalCoord();
483  aCommit.Add( aItem );
484  return true;
485  }
486 
487  return false;
488  }
489 
490  PAD_TOOL* m_padTool;
491  };
492 
493  PAD_PLACER placer( this );
494 
495  doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place pad" ),
497 
498  return 0;
499 }
500 
501 
502 int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
503 {
505  WX_INFOBAR* infoBar = frame()->GetInfoBar();
507  wxString msg;
508 
509  if( m_editPad != niluuid )
510  {
511  D_PAD* pad = dynamic_cast<D_PAD*>( frame()->GetItem( m_editPad ) );
512 
513  if( pad )
514  recombinePad( pad );
515 
516  m_editPad = niluuid;
517  }
518  else if( selection.Size() == 1 && selection[0]->Type() == PCB_PAD_T )
519  {
520  D_PAD* pad = static_cast<D_PAD*>( selection[0] );
521  PCB_LAYER_ID layer = explodePad( pad );
522 
525  frame()->SetActiveLayer( layer );
526 
527  if( !m_wasHighContrast )
529 
530  if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
531  msg.Printf( _( "Pad Edit Mode. Press %s again to exit." ),
533  else
534  msg.Printf( _( "Pad Edit Mode. Press %s to exit." ),
536 
537  infoBar->RemoveAllButtons();
538  infoBar->ShowMessage( msg, wxICON_INFORMATION );
539 
540  m_editPad = pad->m_Uuid;
541  }
542 
543  if( m_editPad == niluuid )
544  {
545  bool highContrast = ( opts.m_ContrastModeDisplay !=
547 
548  if( m_wasHighContrast != highContrast )
550 
551  infoBar->Dismiss();
552  }
553 
554  return 0;
555 }
556 
557 
559 {
560  PCB_LAYER_ID layer;
561  BOARD_COMMIT commit( frame() );
562 
563  if( aPad->IsOnLayer( F_Cu ) )
564  layer = F_Cu;
565  else if( aPad->IsOnLayer( B_Cu ) )
566  layer = B_Cu;
567  else
568  layer = *aPad->GetLayerSet().UIOrder();
569 
570  if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
571  {
572  commit.Modify( aPad );
573 
574  for( const std::shared_ptr<DRAWSEGMENT>& primitive : aPad->GetPrimitives() )
575  {
576  EDGE_MODULE* ds = new EDGE_MODULE( board()->GetFirstModule() );
577 
578  ds->SetShape( primitive->GetShape() );
579  ds->SetWidth( primitive->GetWidth() );
580  ds->SetStart( primitive->GetStart() );
581  ds->SetEnd( primitive->GetEnd() );
582  ds->SetBezControl1( primitive->GetBezControl1() );
583  ds->SetBezControl2( primitive->GetBezControl2() );
584  ds->SetAngle( primitive->GetAngle() );
585  ds->SetPolyShape( primitive->GetPolyShape() );
586  ds->SetLocalCoord();
587  ds->Move( aPad->GetPosition() );
588  ds->Rotate( aPad->GetPosition(), aPad->GetOrientation() );
589  ds->SetLayer( layer );
590 
591  commit.Add( ds );
592  }
593 
594  aPad->SetShape( aPad->GetAnchorPadShape() );
595  aPad->DeletePrimitivesList();
596  m_editPad = aPad->m_Uuid;
597  }
598 
599  commit.Push( _("Edit pad shapes") );
601  return layer;
602 }
603 
604 
606 {
607  auto findNext = [&]( PCB_LAYER_ID aLayer ) -> EDGE_MODULE*
608  {
609  SHAPE_POLY_SET padPoly;
610  aPad->TransformShapeWithClearanceToPolygon( padPoly, aLayer, 0 );
611 
612  for( BOARD_ITEM* item : board()->GetFirstModule()->GraphicalItems() )
613  {
614  DRAWSEGMENT* draw = dynamic_cast<DRAWSEGMENT*>( item );
615 
616  if( !draw || ( draw->GetEditFlags() & STRUCT_DELETED ) )
617  continue;
618 
619  if( draw->GetLayer() != aLayer )
620  continue;
621 
622  SHAPE_POLY_SET drawPoly;
623  draw->TransformShapeWithClearanceToPolygon( drawPoly, aLayer, 0 );
624  drawPoly.BooleanIntersection( padPoly, SHAPE_POLY_SET::PM_FAST );
625 
626  if( !drawPoly.IsEmpty() )
627  return (EDGE_MODULE*) item;
628  }
629 
630  return nullptr;
631  };
632 
633  BOARD_COMMIT commit( frame() );
634  PCB_LAYER_ID layer;
635 
636  if( aPad->IsOnLayer( F_Cu ) )
637  layer = F_Cu;
638  else if( aPad->IsOnLayer( B_Cu ) )
639  layer = B_Cu;
640  else
641  layer = *aPad->GetLayerSet().UIOrder();
642 
643  while( EDGE_MODULE* edge = findNext( layer ) )
644  {
645  commit.Modify( aPad );
646 
647  // We've found an intersecting item. First convert the pad to a custom-shape
648  // pad (if it isn't already)
649  //
650  if( aPad->GetShape() == PAD_SHAPE_RECT || aPad->GetShape() == PAD_SHAPE_CIRCLE )
651  {
652  aPad->SetAnchorPadShape( aPad->GetShape() );
653  }
654  else if( aPad->GetShape() != PAD_SHAPE_CUSTOM )
655  {
656  // Create a new minimally-sized circular anchor and convert existing pad
657  // to a polygon primitive
658  SHAPE_POLY_SET existingOutline;
659  int maxError = board()->GetDesignSettings().m_MaxError;
660  aPad->TransformShapeWithClearanceToPolygon( existingOutline, layer, 0, maxError );
661 
663  wxSize minAnnulus( Millimeter2iu( 0.2 ), Millimeter2iu( 0.2 ) );
664  aPad->SetSize( aPad->GetDrillSize() + minAnnulus );
665  aPad->SetOffset( wxPoint( 0, 0 ) );
666 
667  DRAWSEGMENT* shape = new DRAWSEGMENT;
668  shape->SetShape( S_POLYGON );
669  shape->SetPolyShape( existingOutline );
670  shape->Move( - aPad->GetPosition() );
671  shape->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation() );
672 
673  aPad->AddPrimitive( shape );
674  }
675 
676  aPad->SetShape( PAD_SHAPE_CUSTOM );
677 
678  // Now add the new shape to the primitives list
679  //
680  DRAWSEGMENT* ds = new DRAWSEGMENT;
681 
682  ds->SetShape( edge->GetShape() );
683  ds->SetWidth( edge->GetWidth() );
684  ds->SetStart( edge->GetStart() );
685  ds->SetEnd( edge->GetEnd() );
686  ds->SetBezControl1( edge->GetBezControl1() );
687  ds->SetBezControl2( edge->GetBezControl2() );
688  ds->SetAngle( edge->GetAngle() );
689  ds->SetPolyShape( edge->GetPolyShape() );
690 
691  ds->Move( - aPad->GetPosition() );
692  ds->Rotate( wxPoint( 0, 0 ), - aPad->GetOrientation() );
693  aPad->AddPrimitive( ds );
694 
695  edge->SetFlags( STRUCT_DELETED );
696  commit.Remove( edge );
697  }
698 
699  commit.Push(_("Recombine pads") );
700 }
701 
702 
704 {
708 
711 
714 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:133
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:110
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Definition: infobar.cpp:119
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
double GetOrientation() const
Definition: class_module.h:224
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
void recombinePad(D_PAD *aPad)
Definition: pad_tool.cpp:605
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
static TOOL_ACTION explodePad
Definition: pcb_actions.h:363
void SetShape(STROKE_T aShape)
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
void SetPolyShape(const SHAPE_POLY_SET &aShape)
virtual void Move(const wxPoint &aMoveVector) override
Function Move move this object.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
KIID m_editPad
Definition: pad_tool.h:100
Model changes (required full reload)
Definition: tool_base.h:82
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
PAD_SHAPE_T GetAnchorPadShape() const
Function GetAnchorPadShape.
Definition: class_pad.h:171
wxPoint GetPosition() const override
Definition: class_pad.h:165
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
static constexpr double IU_PER_MM
Mock up a conversion function.
VIEW_CONTROLS class definition.
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
Definition: collectors.cpp:580
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
void SetIgnoreModulesVals(bool ignore)
Definition: collectors.h:594
SELECTION_TOOL.
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
virtual void Revert() override
Revertes the commit by restoring the modifed items state.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
PAD_TOOL()
Definition: pad_tool.cpp:44
polygon (not yet used for tracks, but could be in microwave apps)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
static TOOL_ACTION enumeratePads
Tool for quick pad enumeration.
Definition: pcb_actions.h:367
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool PadCanHaveName(const D_PAD &aPad)
Check if a pad should be named.
Definition: pad_naming.cpp:26
PAD_TOOL.
Definition: pad_tool.h:37
TOOL_MENU & GetToolMenu()
void SetIgnoreModulesRefs(bool ignore)
Definition: collectors.h:600
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
static SELECTION_CONDITION HasType(KICAD_T aType)
Creates a functor that tests if among the selected items there is at least one of a given type.
bool m_padCopied
Definition: pad_tool.h:97
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:537
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:361
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
const LIB_ID & GetFPID() const
Definition: class_module.h:228
static SELECTION_CONDITION Count(int aNumber)
Creates a functor that tests if the number of selected items is equal to the value given as parameter...
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
void Reset(RESET_REASON aReason) override
React to model/view changes
Definition: pad_tool.cpp:56
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
void SetBezControl2(const wxPoint &aPoint)
Implementing DIALOG_ENUM_PADS_BASE.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:211
void SetLocalCoord()
Set relative coordinates.
Definition: class_pad.cpp:485
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:335
void AddPrimitive(DRAWSEGMENT *aPrimitive)
Add item to the custom shape primitives list.
PCB_BASE_EDIT_FRAME * frame() const
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
static TOOL_ACTION pushPadSettings
Copy the current pad's settings to other pads in the module or on the board.
Definition: pcb_actions.h:387
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
void SetAnchorPadShape(PAD_SHAPE_T aShape)
Function SetAnchorPadShape Set the shape of the anchor pad for custm shped pads.
Definition: class_pad.h:198
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:139
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
const PCBNEW_SELECTION & selection() const
bool m_wasHighContrast
Definition: pad_tool.h:99
void SetLastPadName(const wxString &aPadName)
Definition: pad_tool.h:74
int pushPadSettings(const TOOL_EVENT &aEvent)
Push pad settings from a pad to other pads on board or module
Definition: pad_tool.cpp:210
void SetIgnoreMTextsOnBack(bool ignore)
Definition: collectors.h:552
static TOOL_ACTION copyPadSettings
Copy the selected pad's settings to the board design settings.
Definition: pcb_actions.h:381
MODULES & Modules()
Definition: class_board.h:249
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
Definition: class_pad.h:131
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:237
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SHAPE_POLY_SET.
virtual void PopTool(const std::string &actionName)
void SetIgnoreMTextsOnFront(bool ignore)
Definition: collectors.h:558
TOOL_EVENT.
Definition: tool_event.h:171
KIID niluuid(0)
LSET GetLayerSet() const override
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
Definition: class_pad.h:332
wxString GetPrefix() const
Returns common prefix for all enumerated pads.
static TOOL_ACTION applyPadSettings
Copy the default pad settings to the selected pad.
Definition: pcb_actions.h:384
int pastePadProperties(const TOOL_EVENT &aEvent)
Apply pad settings from board design settings to a pad
Definition: pad_tool.cpp:108
void SetAngle(double aAngle) override
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
static TOOL_ACTION recombinePad
Definition: pcb_actions.h:364
KIGFX::PCB_VIEW * view() const
void SetSize(const wxSize &aSize)
Definition: class_pad.h:223
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
virtual void Popup(wxWindow *aFocus=nullptr)
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
virtual void Move(const wxPoint &aWhere)
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:546
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1531
int EnumeratePads(const TOOL_EVENT &aEvent)
Function EnumeratePads() Tool for quick pad enumeration.
Definition: pad_tool.cpp:253
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset intersection For aFastMode meaning, see function booleanOp
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
Subclass of DIALOG_ENUM_PADS_BASE, which is generated by wxFormBuilder.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:212
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
void SetStart(const wxPoint &aStart)
void AddSeparator(int aOrder=ANY_ORDER)
Adds a separator to the menu.
const KIID m_Uuid
Definition: base_struct.h:162
MODULE * GetParent() const
Definition: class_pad.h:111
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
PCB_LAYER_ID explodePad(D_PAD *aPad)
Definition: pad_tool.cpp:558
void SetLocalCoord()
Set relative coordinates from draw coordinates.
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
Handle the rotate action in the loop by calling the item's rotate method.
static void doPushPadProperties(BOARD &board, const D_PAD &aSrcPad, BOARD_COMMIT &commit, bool aSameFootprints, bool aPadShapeFilter, bool aPadOrientFilter, bool aPadLayerFilter, bool aPadTypeFilter)
Definition: pad_tool.cpp:159
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in a variety of units (the basic call r...
Definition: class_pad.h:321
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
void ImportSettingsFrom(const D_PAD &aMasterPad)
Imports the pad settings from aMasterPad.
Definition: class_pad.cpp:1241
~PAD_TOOL()
Definition: pad_tool.cpp:52
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
wxString m_lastPadName
Definition: pad_tool.h:96
const wxSize & GetDrillSize() const
Definition: class_pad.h:230
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Creates a functor that tests if the selected items are only of given type.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
static bool empty(const wxTextEntryBase *aCtrl)
bool IsAperturePad() const
Definition: class_pad.h:342
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
void SetShape(PAD_SHAPE_T aShape)
Set the new shape of this pad.
Definition: class_pad.h:148
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
void SetEnd(const wxPoint &aEnd)
virtual void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
void Activate()
Function Activate() Runs the tool.
WX_INFOBAR * GetInfoBar()
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Function KeyNameFromKeyCode return the key name from the key code Only some wxWidgets key values are ...
int GetStartNumber() const
Returns the starting number that is going to be used for the first enumerated pad.
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:157
void doInteractiveItemPlacement(const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
Helper function for performing a common interactive idiom: wait for a left click, place an item there...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VIEW.
Definition: view.h:61
const std::vector< std::shared_ptr< DRAWSEGMENT > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: class_pad.h:273
int EditPad(const TOOL_EVENT &aEvent)
Enters/exits WYSIWYG pad shape editing.
Definition: pad_tool.cpp:502
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:390
bool Init() override
Basic initalization
Definition: pad_tool.cpp:66
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_pad.h:528
int PlacePad(const TOOL_EVENT &aEvent)
Function PlacePad() Places a pad in module editor.
Definition: pad_tool.cpp:442
EDGE_MODULE class definition.
LSEQ UIOrder() const
Definition: lset.cpp:846
void SetOffset(const wxPoint &aOffset)
Definition: class_pad.h:232
static constexpr int Millimeter2iu(double mm)
static TOOL_ACTION highContrastMode
Definition: actions.h:101
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Adds a menu entry to run a TOOL_ACTION on selected items.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void setTransitions() override
Bind handlers to corresponding TOOL_ACTIONs
Definition: pad_tool.cpp:703
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
void DeletePrimitivesList()
clear the basic shapes list
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...
void SetText(const wxString &aText)
Display a text.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
int copyPadSettings(const TOOL_EVENT &aEvent)
Copy pad settings from a pad to the board design settings
Definition: pad_tool.cpp:135
void SetBezControl1(const wxPoint &aPoint)
void SetWidth(int aWidth)