KiCad PCB EDA Suite
footprint_editor_tools.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) 2014-2019 CERN
5  * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include "footprint_editor_tools.h"
27 #include "kicad_clipboard.h"
28 #include "selection_tool.h"
29 #include "pcb_actions.h"
30 #include <core/optional.h>
31 #include <tool/tool_manager.h>
32 #include <class_draw_panel_gal.h>
33 #include <view/view_controls.h>
34 #include <view/view_group.h>
35 #include <pcb_painter.h>
36 #include <origin_viewitem.h>
37 #include <status_popup.h>
38 #include <footprint_edit_frame.h>
39 #include <kicad_plugin.h>
40 #include <pcbnew_id.h>
41 #include <collectors.h>
42 #include <confirm.h>
43 #include <bitmaps.h>
44 #include <pcb_edit_frame.h>
45 #include <class_board.h>
46 #include <class_module.h>
47 #include <class_edge_mod.h>
48 #include <board_commit.h>
49 #include <project.h>
50 #include <tools/tool_event_utils.h>
51 #include <fp_lib_table.h>
52 #include <functional>
53 using namespace std::placeholders;
54 #include <wx/defs.h>
55 
56 
58  PCB_TOOL_BASE( "pcbnew.ModuleEditor" ),
59  m_frame( nullptr )
60 {
61 }
62 
63 
65 {
66 }
67 
68 
70 {
71  m_frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
72 }
73 
74 
76 {
77  // Build a context menu for the footprint tree
78  //
79  CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
80 
81  auto libSelectedCondition = [ this ] ( const SELECTION& aSel ) {
82  LIB_ID sel = m_frame->GetTreeFPID();
83  return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty();
84  };
85  auto pinnedLibSelectedCondition = [ this ] ( const SELECTION& aSel ) {
87  return current && current->m_Type == LIB_TREE_NODE::LIB && current->m_Pinned;
88  };
89  auto unpinnedLibSelectedCondition = [ this ] (const SELECTION& aSel ) {
91  return current && current->m_Type == LIB_TREE_NODE::LIB && !current->m_Pinned;
92  };
93  auto fpSelectedCondition = [ this ] ( const SELECTION& aSel ) {
94  LIB_ID sel = m_frame->GetTreeFPID();
95  return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
96  };
97 
98  ctxMenu.AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition );
99  ctxMenu.AddItem( ACTIONS::unpinLibrary, pinnedLibSelectedCondition );
100  ctxMenu.AddSeparator();
101 
104  ctxMenu.AddItem( ACTIONS::save, libSelectedCondition );
105  ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition );
106  ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition );
107 
108  ctxMenu.AddSeparator();
110 #ifdef KICAD_SCRIPTING
112 #endif
113  ctxMenu.AddItem( PCB_ACTIONS::editFootprint, fpSelectedCondition );
114 
115  ctxMenu.AddSeparator();
116  ctxMenu.AddItem( ACTIONS::save, fpSelectedCondition );
117  ctxMenu.AddItem( ACTIONS::saveCopyAs, fpSelectedCondition );
118  ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition );
119  ctxMenu.AddItem( ACTIONS::revert, fpSelectedCondition );
120 
121  ctxMenu.AddSeparator();
122  ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition );
123  ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition );
125 
126  ctxMenu.AddSeparator();
128  ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpSelectedCondition );
129 
130  return true;
131 }
132 
133 
135 {
136  wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_NEW_MODULE );
137  getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
138  return 0;
139 }
140 
141 
143 {
144  wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_NEW_MODULE_FROM_WIZARD );
145  getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
146  return 0;
147 }
148 
149 
151 {
152  wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE );
153  getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
154  return 0;
155 }
156 
157 
159 {
160  wxCommandEvent evt( wxEVT_NULL, ID_MODEDIT_SAVE_AS );
161  getEditFrame<FOOTPRINT_EDIT_FRAME>()->Process_Special_Functions( evt );
162  return 0;
163 }
164 
165 
167 {
168  getEditFrame<FOOTPRINT_EDIT_FRAME>()->RevertFootprint();
169  return 0;
170 }
171 
172 
174 {
175  LIB_ID fpID = m_frame->GetTreeFPID();
176 
177  if( fpID == m_frame->GetLoadedFPID() )
178  m_copiedModule.reset( new MODULE( *m_frame->GetBoard()->GetFirstModule() ) );
179  else
180  m_copiedModule.reset( m_frame->LoadFootprint( fpID ) );
181 
182  if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
183  DeleteFootprint(aEvent );
184 
185  return 0;
186 }
187 
188 
190 {
192  {
193  wxString newLib = m_frame->GetTreeFPID().GetLibNickname();
194  MODULE* newModule( m_copiedModule.get() );
195  wxString newName = newModule->GetFPID().GetLibItemName();
196 
197  while( m_frame->Prj().PcbFootprintLibs()->FootprintExists( newLib, newName ) )
198  newName += _( "_copy" );
199 
200  newModule->SetFPID( LIB_ID( newLib, newName ) );
201  m_frame->SaveFootprintInLibrary( newModule, newLib );
202 
203  m_frame->SyncLibraryTree( true );
204  m_frame->FocusOnLibID( newModule->GetFPID() );
205  }
206 
207  return 0;
208 }
209 
210 
212 {
213  FOOTPRINT_EDIT_FRAME* frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
214 
215  if( frame->DeleteModuleFromLibrary( frame->GetTargetFPID(), true ) )
216  {
217  if( frame->GetTargetFPID() == frame->GetLoadedFPID() )
218  frame->Clear_Pcb( false );
219 
220  frame->SyncLibraryTree( true );
221  }
222 
223  return 0;
224 }
225 
226 
228 {
229  if( !m_frame->Clear_Pcb( true ) )
230  return -1; // this command is aborted
231 
234 
235  if( m_frame->GetBoard()->GetFirstModule() )
237 
238  // Clear undo and redo lists because we don't have handling to in
239  // FP editor to undo across imports (the module _is_ the board with the stack)
240  // todo: Abstract undo/redo stack to a higher element or keep consistent board item in fpeditor
242 
244  m_frame->OnModify();
245  return 0;
246 }
247 
248 
250 {
251  LIB_ID fpID = m_frame->GetTreeFPID();
252  MODULE* fp;
253 
254  if( !fpID.IsValid() )
255  fp = m_frame->GetBoard()->GetFirstModule();
256  else
257  fp = m_frame->LoadFootprint( fpID );
258 
259  m_frame->Export_Module( fp );
260  return 0;
261 }
262 
263 
265 {
267  return 0;
268 }
269 
270 
272 {
273  LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
274 
275  if( currentNode && !currentNode->m_Pinned )
276  {
277  currentNode->m_Pinned = true;
279  }
280 
281  return 0;
282 }
283 
284 
286 {
287  LIB_TREE_NODE* currentNode = m_frame->GetCurrentTreeNode();
288 
289  if( currentNode && currentNode->m_Pinned )
290  {
291  currentNode->m_Pinned = false;
293  }
294 
295  return 0;
296 }
297 
298 
300 {
302  return 0;
303 }
304 
305 
307 {
308  MODULE* footprint = m_frame->GetBoard()->GetFirstModule();
309 
310  if( footprint )
311  {
312  getEditFrame<FOOTPRINT_EDIT_FRAME>()->OnEditItemRequest( footprint );
313  m_frame->GetCanvas()->Refresh();
314  }
315  return 0;
316 }
317 
318 
320 {
321  getEditFrame<FOOTPRINT_EDIT_FRAME>()->InstallPadOptionsFrame( nullptr );
322  return 0;
323 }
324 
325 
327 {
328  if( !m_frame->GetBoard()->GetFirstModule() )
329  return 0;
330 
331  struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
332  {
333  virtual ~PAD_PLACER()
334  {
335  }
336 
337  std::unique_ptr<BOARD_ITEM> CreateItem() override
338  {
339  D_PAD* pad = new D_PAD( m_board->GetFirstModule() );
341  pad->IncrementPadName( true, true );
342  return std::unique_ptr<BOARD_ITEM>( pad );
343  }
344 
345  bool PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit ) override
346  {
347  D_PAD* pad = dynamic_cast<D_PAD*>( aItem );
348 
349  if( pad )
350  {
352  pad->SetLocalCoord();
353  aCommit.Add( aItem );
354  return true;
355  }
356 
357  return false;
358  }
359  };
360 
361  PAD_PLACER placer;
362 
363  doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place pad" ),
365 
366  return 0;
367 }
368 
369 
371 {
373  BOARD_COMMIT commit( m_frame );
374 
375  if( selection.Size() != 1 )
376  return 0;
377 
378  if( selection[0]->Type() != PCB_PAD_T )
379  return 0;
380 
381  auto pad = static_cast<D_PAD*>( selection[0] );
382 
383  if( pad->GetShape() != PAD_SHAPE_CUSTOM )
384  return 0;
385 
386  commit.Modify( pad );
387 
388  wxPoint anchor = pad->GetPosition();
389 
390  for( auto prim : pad->GetPrimitives() )
391  {
392  auto ds = new EDGE_MODULE( board()->GetFirstModule() );
393 
394  prim.ExportTo( ds ); // ExportTo exports to a DRAWSEGMENT
395  // Fix an arbitray draw layer for this EDGE_MODULE
396  ds->SetLayer( Dwgs_User ); //pad->GetLayer() );
397  ds->Move( anchor );
398  ds->Rotate( anchor, pad->GetOrientation() );
399 
400  commit.Add( ds );
401  }
402 
403  pad->SetShape( pad->GetAnchorPadShape() );
404  // Cleanup the pad primitives data, because the initial pad was a custom
405  // shaped pad, and it contains primitives, that does not exist in non custom pads,
406  // and can create issues later:
407  if( pad->GetShape() != PAD_SHAPE_CUSTOM ) // should be always the case
408  {
409  pad->DeletePrimitivesList();
410  }
411 
412  commit.Push( _("Explode pad to shapes") );
413 
415 
416  return 0;
417 }
418 
419 
421 {
423 
424  std::unique_ptr<D_PAD> pad( new D_PAD( board()->GetFirstModule() ) );
425  D_PAD *refPad = nullptr;
426  bool multipleRefPadsFound = false;
427  bool illegalItemsFound = false;
428 
429  std::vector<PAD_CS_PRIMITIVE> shapes;
430 
431  BOARD_COMMIT commit( m_frame );
432 
433  for( auto item : selection )
434  {
435  switch( item->Type() )
436  {
437  case PCB_PAD_T:
438  {
439  if( refPad )
440  multipleRefPadsFound = true;
441 
442  refPad = static_cast<D_PAD*>( item );
443  break;
444  }
445 
446  case PCB_MODULE_EDGE_T:
447  {
448  auto em = static_cast<EDGE_MODULE*> ( item );
449 
450  PAD_CS_PRIMITIVE shape( em->GetShape() );
451  shape.m_Start = em->GetStart();
452  shape.m_End = em->GetEnd();
453  shape.m_Radius = em->GetRadius();
454  shape.m_Thickness = em->GetWidth();
455  shape.m_ArcAngle = em->GetAngle();
456  shape.m_Ctrl1 = em->GetBezControl1();
457  shape.m_Ctrl2 = em->GetBezControl2();
458  shape.m_Poly = em->BuildPolyPointsList();
459 
460  shapes.push_back(shape);
461 
462  break;
463  }
464 
465  default:
466  {
467  illegalItemsFound = true;
468  break;
469  }
470  }
471  }
472 
473  if( refPad && selection.Size() == 1 )
474  {
475  // don't convert a pad into itself...
476  return 0;
477  }
478 
479  if( multipleRefPadsFound )
480  {
481  DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n"
482  "selection contains more than one reference pad." ) );
483  return 0;
484  }
485 
486  if( illegalItemsFound )
487  {
488  DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n"
489  "selection contains unsupported items.\n"
490  "Only graphical lines, circles, arcs and polygons "
491  "are allowed." ) );
492  return 0;
493  }
494 
495  double refOrientation = 0.0;
496 
497  if( refPad )
498  {
499  pad.reset( static_cast<D_PAD*>( refPad->Clone() ) );
500 
501  if( refPad->GetShape() == PAD_SHAPE_RECT )
502  pad->SetAnchorPadShape( PAD_SHAPE_RECT );
503 
504  // ignore the pad offset for the moment. Makes more trouble than it's worth.
505  pad->SetOffset( wxPoint( 0, 0 ) );
506  refOrientation = pad->GetOrientation();
507  pad->SetOrientation( 0.0 );
508  }
509  else
510  {
511  // Create a default pad anchor:
512  pad->SetAnchorPadShape( PAD_SHAPE_CIRCLE );
513  pad->SetAttribute( PAD_ATTRIB_SMD );
514  pad->SetLayerSet( D_PAD::SMDMask() );
515  int radius = Millimeter2iu( 0.2 );
516  pad->SetSize ( wxSize( radius, radius ) );
517  pad->IncrementPadName( true, true );
518  pad->SetOrientation( 0 );
519  }
520 
521  pad->SetShape ( PAD_SHAPE_CUSTOM );
522 
523  OPT<VECTOR2I> anchor;
524  VECTOR2I tmp;
525 
526  if( refPad )
527  {
528  anchor = VECTOR2I( pad->GetPosition() );
529  }
530  else if( pad->GetBestAnchorPosition( tmp ) )
531  {
532  anchor = tmp;
533  }
534 
535  if( !anchor )
536  {
537  DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n"
538  "unable to determine the anchor point position.\n"
539  "Consider adding a small anchor pad to the selection "
540  "and try again.") );
541  return 0;
542  }
543 
544 
545  // relocate the shapes, they are relative to the anchor pad position
546  for( auto& shape : shapes )
547  {
548  shape.Move( wxPoint( -anchor->x, -anchor->y ) );
549  shape.Rotate( wxPoint( 0, 0 ), -refOrientation );
550  }
551 
552  pad->SetPosition( wxPoint( anchor->x, anchor->y ) );
553  pad->AddPrimitives( shapes );
554  pad->ClearFlags();
555 
556  bool result = pad->MergePrimitivesAsPolygon();
557  pad->Rotate( wxPoint( anchor->x, anchor->y ), refOrientation );
558 
559  if( !result )
560  {
561  DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n"
562  "selected items do not form a single solid shape.") );
563  return 0;
564  }
565 
566  auto padPtr = pad.release();
567 
568  commit.Add( padPtr );
569  for ( auto item : selection )
570  {
571  commit.Remove( item );
572  }
573 
575  commit.Push(_("Create Pad from Selected Shapes") );
576  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, padPtr );
577 
578  return 0;
579 }
580 
582 {
585  Go( &MODULE_EDITOR_TOOLS::Save, ACTIONS::save.MakeEvent() );
592 
597 
600 
606 
610 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
static bool ShowAlways(const SELECTION &aSelection)
Function ShowAlways The default condition function (always returns true).
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:585
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
static TOOL_ACTION pinLibrary
Definition: actions.h:104
static TOOL_ACTION saveToBoard
Definition: pcb_actions.h:344
int DefaultPadProperties(const TOOL_EVENT &aEvent)
Edit the properties used for new pad creation.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_pad.cpp:1315
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
static TOOL_ACTION footprintProperties
Definition: pcb_actions.h:355
int Properties(const TOOL_EVENT &aEvent)
int DeleteFootprint(const TOOL_EVENT &aEvent)
BOARD * board() const
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
This file is part of the common library.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: class_pad.cpp:111
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
int CutCopyFootprint(const TOOL_EVENT &aEvent)
int EditFootprint(const TOOL_EVENT &aEvent)
VIEW_CONTROLS class definition.
SELECTION_TOOL.
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
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:98
static TOOL_ACTION explodePadToShapes
Definition: pcb_actions.h:362
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
FOOTPRINT_EDIT_FRAME * m_frame
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:62
void LoadModuleFromLibrary(LIB_ID aFPID)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:359
static TOOL_ACTION unpinLibrary
Definition: actions.h:105
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
const LIB_ID & GetFPID() const
Definition: class_module.h:219
int CreatePadFromShapes(const TOOL_EVENT &aEvent)
Function CreatePadFromShapes()
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
bool IsValid() const
Definition: lib_id.h:171
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
int UnpinLibrary(const TOOL_EVENT &aEvent)
void SetLocalCoord()
Set relative coordinates.
Definition: class_pad.cpp:408
static TOOL_ACTION createFootprint
Definition: pcb_actions.h:340
static TOOL_ACTION saveCopyAs
Definition: actions.h:56
static TOOL_ACTION cutFootprint
Definition: pcb_actions.h:349
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
static TOOL_ACTION copyFootprint
Definition: pcb_actions.h:350
int ImportFootprint(const TOOL_EVENT &aEvent)
PCB_BASE_EDIT_FRAME * frame() const
int ExplodePadToShapes(const TOOL_EVENT &aEvent)
Function ExplodePadToShapes()
int Revert(const TOOL_EVENT &aEvent)
void SyncLibraryTree(bool aProgress)
Synchronize the footprint library tree to the current state of the footprint library table.
void RegenerateLibraryTree()
Filter, sort, and redisplay the library tree.
int SaveAs(const TOOL_EVENT &aEvent)
bool Clear_Pcb(bool aQuery)
Delete all and reinitialize the current board.
Definition: initpcb.cpp:98
static TOOL_ACTION toggleFootprintTree
Definition: pcb_actions.h:333
const PCBNEW_SELECTION & selection() const
int PlacePad(const TOOL_EVENT &aEvent)
Function PlacePad() Places a pad in module editor.
int Save(const TOOL_EVENT &aEvent)
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
void OnModify() override
Must be called after a footprint change in order to set the "modify" flag of the current screen and p...
static TOOL_ACTION exportFootprint
Definition: pcb_actions.h:353
void FocusOnLibID(const LIB_ID &aLibID)
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static TOOL_ACTION editFootprint
Definition: pcb_actions.h:347
static TOOL_ACTION save
Definition: actions.h:54
TOOL_EVENT.
Definition: tool_event.h:171
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:89
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
int NewFootprint(const TOOL_EVENT &aEvent)
int ExportFootprint(const TOOL_EVENT &aEvent)
int PinLibrary(const TOOL_EVENT &aEvent)
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:283
int PasteFootprint(const TOOL_EVENT &aEvent)
void setTransitions() override
Sets up handlers for various events.
static TOOL_ACTION addLibrary
Definition: actions.h:52
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves the graphic crosshair cursor to the requested position expressed in world coordinates.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
static TOOL_ACTION newLibrary
Definition: actions.h:51
LIB_TREE_NODE * GetCurrentTreeNode() const
static TOOL_ACTION importFootprint
Definition: pcb_actions.h:352
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void Export_Module(MODULE *aModule)
Create a file containing only one footprint.
void AddSeparator(int aOrder=ANY_ORDER)
Function AddSeparator()
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:427
bool SaveFootprintInLibrary(MODULE *aModule, const wxString &aLibraryName)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static TOOL_ACTION saveToLibrary
Definition: pcb_actions.h:345
static TOOL_ACTION createPadFromShapes
Definition: pcb_actions.h:361
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
static TOOL_ACTION defaultPadProperties
Definition: pcb_actions.h:356
MODULE * LoadFootprint(const LIB_ID &aFootprintId)
Function LoadFootprint attempts to load aFootprintId from the footprint library table.
static TOOL_ACTION saveAs
Definition: actions.h:55
LIB_ID GetLoadedFPID() const
Return the LIB_ID of the part being edited.
#define _(s)
Definition: 3d_actions.cpp:33
void ImportSettingsFrom(const D_PAD &aMasterPad)
Imports the pad settings from aMasterPad.
Definition: class_pad.cpp:1488
enum TYPE m_Type
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:76
D_PAD m_Pad_Master
A dummy pad to store all default parameters.
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
int CreateFootprint(const TOOL_EVENT &aEvent)
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:78
boost::optional< T > OPT
Definition: optional.h:7
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
static TOOL_ACTION pasteFootprint
Definition: pcb_actions.h:351
std::unique_ptr< MODULE > m_copiedModule
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:237
Module description (excepted pads)
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...
BOARD * GetBoard() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
EDGE_MODULE class definition.
MODULE * Import_Module(const wxString &aName=wxT(""))
Read a file containing only one footprint.
int ToggleFootprintTree(const TOOL_EVENT &aEvent)
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION deleteFootprint
Definition: pcb_actions.h:348
bool FootprintExists(const wxString &aNickname, const wxString &aFootprintName)
Function FootprintExists.
LIB_ID GetTreeFPID() const
Return the LIB_ID of the part or library selected in the footprint tree.
static TOOL_ACTION revert
Definition: actions.h:58
static TOOL_ACTION newFootprint
Definition: pcb_actions.h:337
bool empty() const
Definition: utf8.h:108