KiCad PCB EDA Suite
board_editor_control.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 CERN
5  * Copyright (C) 2014-2021 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 #include "board_editor_control.h"
26 #include "drawing_tool.h"
27 #include "pcb_actions.h"
28 #include "pcb_picker_tool.h"
29 #include "pcb_selection_tool.h"
30 #include "edit_tool.h"
31 #include "tool/tool_event.h"
32 #include <bitmaps.h>
33 #include <board_commit.h>
34 #include <board.h>
35 #include <pcb_group.h>
36 #include <footprint.h>
37 #include <pcb_target.h>
38 #include <track.h>
39 #include <zone.h>
40 #include <pcb_marker.h>
41 #include <collectors.h>
42 #include <confirm.h>
43 #include <cstdint>
46 #include <functional>
47 #include <gestfich.h>
48 #include <kiface_i.h>
49 #include <kiway.h>
50 #include <memory>
52 #include <origin_viewitem.h>
53 #include <painter.h>
54 #include <pcb_edit_frame.h>
55 #include <pcbnew_id.h>
56 #include <pcbnew_settings.h>
57 #include <project.h>
58 #include <project/project_file.h> // LAST_PATH_TYPE
59 #include <tool/tool_manager.h>
60 #include <tools/tool_event_utils.h>
61 #include <router/router_tool.h>
62 #include <view/view_controls.h>
63 #include <view/view_group.h>
66 #include <footprint_edit_frame.h>
67 
68 using namespace std::placeholders;
69 
70 
72 {
73 public:
75  ACTION_MENU( true )
76  {
77  SetIcon( add_zone_xpm );
78  SetTitle( _( "Zones" ) );
79 
80  Add( PCB_ACTIONS::zoneFill );
84 
85  AppendSeparator();
86 
91  }
92 
93 
94 protected:
95  ACTION_MENU* create() const override
96  {
97  return new ZONE_CONTEXT_MENU();
98  }
99 };
100 
101 
103 {
104 public:
106  ACTION_MENU( true )
107  {
108  SetIcon( locked_xpm );
109  SetTitle( _( "Locking" ) );
110 
111  Add( PCB_ACTIONS::lock );
112  Add( PCB_ACTIONS::unlock );
114  }
115 
116  ACTION_MENU* create() const override
117  {
118  return new LOCK_CONTEXT_MENU();
119  }
120 };
121 
122 
124  PCB_TOOL_BASE( "pcbnew.EditorControl" ),
125  m_frame( nullptr )
126 {
127  m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
129 }
130 
131 
133 {
134 }
135 
136 
138 {
139  m_frame = getEditFrame<PCB_EDIT_FRAME>();
140 
141  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
142  {
143  m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin );
144  getView()->Remove( m_placeOrigin.get() );
145  getView()->Add( m_placeOrigin.get() );
146  }
147 }
148 
149 
151 {
152  auto activeToolCondition =
153  [ this ] ( const SELECTION& aSel )
154  {
155  return ( !m_frame->ToolStackIsEmpty() );
156  };
157 
158  auto inactiveStateCondition =
159  [ this ] ( const SELECTION& aSel )
160  {
161  return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
162  };
163 
164  auto placeModuleCondition =
165  [ this ] ( const SELECTION& aSel )
166  {
167  return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
168  };
169 
170  auto& ctxMenu = m_menu.GetMenu();
171 
172  // "Cancel" goes at the top of the context menu when a tool is active
173  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
174  ctxMenu.AddSeparator( 1 );
175 
176  // "Get and Place Footprint" should be available for Place Footprint tool
177  ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
178  ctxMenu.AddSeparator( 1000 );
179 
180  // Finally, add the standard zoom & grid items
181  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
182 
183  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
184  zoneMenu->SetTool( this );
185 
186  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
187  lockMenu->SetTool( this );
188 
189  // Add the PCB control menus to relevant other tools
190 
192 
193  if( selTool )
194  {
195  auto& toolMenu = selTool->GetToolMenu();
196  auto& menu = toolMenu.GetMenu();
197 
198  // Add "Get and Place Footprint" when Selection tool is in an inactive state
199  menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
200  menu.AddSeparator();
201 
202  toolMenu.AddSubMenu( zoneMenu );
203  toolMenu.AddSubMenu( lockMenu );
204 
205  menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 );
206 
207  menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_T ), 200 );
208  }
209 
210  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
211 
212  if( drawingTool )
213  {
214  auto& toolMenu = drawingTool->GetToolMenu();
215  auto& menu = toolMenu.GetMenu();
216 
217  toolMenu.AddSubMenu( zoneMenu );
218 
219  // Functor to say if the PCB_EDIT_FRAME is in a given mode
220  // Capture the tool pointer and tool mode by value
221  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
222  {
223  return [=]( const SELECTION& sel )
224  {
225  return drawingTool->GetDrawingMode() == aMode;
226  };
227  };
228 
229  menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
230  }
231 
232  return true;
233 }
234 
235 
237 {
239  return 0;
240 }
241 
242 
244 {
246  return 0;
247 }
248 
249 
251 {
253  return 0;
254 }
255 
256 
258 {
260  return 0;
261 }
262 
263 
265 {
267  return 0;
268 }
269 
270 
272 {
273  PICKED_ITEMS_LIST undoCmd;
274  DS_PROXY_UNDO_ITEM* undoItem = new DS_PROXY_UNDO_ITEM( m_frame );
275  ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
276 
277  undoCmd.PushItem( wrapper );
279 
283 
284  if( dlg.ShowModal() != wxID_OK )
286 
287  return 0;
288 }
289 
290 
292 {
294  return 0;
295 }
296 
297 
299 {
300  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
301  return 0;
302 }
303 
304 
306 {
307  getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
308  return 0;
309 }
310 
311 
313 {
314  wxString fullFileName = frame()->GetBoard()->GetFileName();
315  wxString path;
316  wxString name;
317  wxString ext;
318 
319  wxFileName::SplitPath( fullFileName, &path, &name, &ext );
320  name += wxT( ".ses" );
321 
322  fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), path, name,
323  wxT( ".ses" ), wxT( "*.ses" ), frame(), wxFD_OPEN, false );
324 
325  if( !fullFileName.IsEmpty() )
326  getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
327 
328  return 0;
329 }
330 
331 
333 {
334  wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
335  wxFileName fn;
336 
337  if( fullFileName.IsEmpty() )
338  {
339  fn = m_frame->GetBoard()->GetFileName();
340  fn.SetExt( SpecctraDsnFileExtension );
341  }
342  else
343  fn = fullFileName;
344 
345  fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
347  frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
348 
349  if( !fullFileName.IsEmpty() )
350  {
351  m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
352  getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
353  }
354 
355  return 0;
356 }
357 
358 
360 {
361  wxCommandEvent dummy;
362 
363  if( aEvent.IsAction( &PCB_ACTIONS::generateGerbers ) )
365  else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
367  else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
369  else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
371  else
372  wxFAIL_MSG( "GenerateFabFiles(): unexpected request" );
373 
374  return 0;
375 }
376 
377 
379 {
380  int errors = 0;
381  wxString details;
382 
383  /*******************************
384  * Repair duplicate IDs and missing nets
385  */
386 
387  std::set<KIID> ids;
388  int duplicates = 0;
389 
390  auto processItem =
391  [&]( EDA_ITEM* aItem )
392  {
393  if( ids.count( aItem->m_Uuid ) )
394  {
395  duplicates++;
396  const_cast<KIID&>( aItem->m_Uuid ) = KIID();
397  }
398 
399  ids.insert( aItem->m_Uuid );
400 
401  BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
402 
403  if( cItem && cItem->GetNetCode() )
404  {
405  NETINFO_ITEM* netinfo = cItem->GetNet();
406 
407  if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
408  {
409  board()->Add( netinfo );
410 
411  details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
412  netinfo->GetNetname() );
413  errors++;
414  }
415  }
416  };
417 
418  // Footprint IDs are the most important, so give them the first crack at "claiming" a
419  // particular KIID.
420 
421  for( FOOTPRINT* footprint : board()->Footprints() )
422  processItem( footprint );
423 
424  // After that the principal use is for DRC marker pointers, which are most likely to pads
425  // or tracks.
426 
427  for( FOOTPRINT* footprint : board()->Footprints() )
428  {
429  for( PAD* pad : footprint->Pads() )
430  processItem( pad );
431  }
432 
433  for( TRACK* track : board()->Tracks() )
434  processItem( track );
435 
436  // From here out I don't think order matters much.
437 
438  for( FOOTPRINT* footprint : board()->Footprints() )
439  {
440  processItem( &footprint->Reference() );
441  processItem( &footprint->Value() );
442 
443  for( BOARD_ITEM* item : footprint->GraphicalItems() )
444  processItem( item );
445 
446  for( ZONE* zone : footprint->Zones() )
447  processItem( zone );
448 
449  for( PCB_GROUP* group : footprint->Groups() )
450  processItem( group );
451  }
452 
453  for( BOARD_ITEM* drawing : board()->Drawings() )
454  processItem( drawing );
455 
456  for( ZONE* zone : board()->Zones() )
457  processItem( zone );
458 
459  for( PCB_MARKER* marker : board()->Markers() )
460  processItem( marker );
461 
462  for( PCB_GROUP* group : board()->Groups() )
463  processItem( group );
464 
465  if( duplicates )
466  {
467  errors += duplicates;
468  details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
469  }
470 
471  /*******************************
472  * Your test here
473  */
474 
475  /*******************************
476  * Inform the user
477  */
478 
479  if( errors )
480  {
481  m_frame->OnModify();
482 
483  wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
484  DisplayInfoMessage( m_frame, msg, details );
485  }
486  else
487  {
488  DisplayInfoMessage( m_frame, _( "No board problems found." ) );
489  }
490 
491  return 0;
492 }
493 
494 
496 {
497  NETLIST netlist;
498 
499  if( m_frame->FetchNetlistFromSchematic( netlist, _( "Updating PCB requires a fully annotated "
500  "schematic." ) ) )
501  {
502  DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
503  updateDialog.ShowModal();
504  }
505 
506  return 0;
507 }
508 
510 {
511  if( Kiface().IsSingle() )
512  {
514  m_frame, _( "Cannot update schematic because Pcbnew is opened in stand-alone "
515  "mode. In order to create or update PCBs from schematics, you "
516  "must launch the KiCad project manager and create a project." ) );
517  return 0;
518  }
519 
520  m_frame->RunEeschema();
522 
523  if( frame )
524  {
525  std::string payload;
527  }
528  return 0;
529 }
530 
531 
533 {
534  m_frame->RunEeschema();
535  return 0;
536 }
537 
538 
540 {
541  getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
542  return 0;
543 }
544 
545 
547 {
548 #if defined( KICAD_SCRIPTING_WXPYTHON )
549  m_frame->ScriptingConsoleEnableDisable();
550 #endif
551  return 0;
552 }
553 
554 
555 // Track & via size control
557 {
558  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
559  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
561 
563  {
564  BOARD_COMMIT commit( this );
565 
566  for( EDA_ITEM* item : selection )
567  {
568  if( item->Type() == PCB_TRACE_T )
569  {
570  TRACK* track = (TRACK*) item;
571 
572  for( int candidate : designSettings.m_TrackWidthList )
573  {
574  if( candidate > track->GetWidth() )
575  {
576  commit.Modify( track );
577  track->SetWidth( candidate );
578  break;
579  }
580  }
581  }
582  }
583 
584  commit.Push( "Increase Track Width" );
585  return 0;
586  }
587 
588  ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
589 
590  if( routerTool && routerTool->IsToolActive()
591  && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
592  {
593  int widthIndex = designSettings.GetDiffPairIndex() + 1;
594 
595  // If we go past the last track width entry in the list, start over at the beginning
596  if( widthIndex >= (int) designSettings.m_DiffPairDimensionsList.size() )
597  widthIndex = 0;
598 
599  designSettings.SetDiffPairIndex( widthIndex );
600  designSettings.UseCustomDiffPairDimensions( false );
601 
603  }
604  else
605  {
606  int widthIndex = designSettings.GetTrackWidthIndex() + 1;
607 
608  // If we go past the last track width entry in the list, start over at the beginning
609  if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
610  widthIndex = 0;
611 
612  designSettings.SetTrackWidthIndex( widthIndex );
613  designSettings.UseCustomTrackViaSize( false );
614 
616  }
617 
618  return 0;
619 }
620 
621 
623 {
624  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
625  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
627 
629  {
630  BOARD_COMMIT commit( this );
631 
632  for( EDA_ITEM* item : selection )
633  {
634  if( item->Type() == PCB_TRACE_T )
635  {
636  TRACK* track = (TRACK*) item;
637 
638  for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 0; --i )
639  {
640  int candidate = designSettings.m_TrackWidthList[ i ];
641 
642  if( candidate < track->GetWidth() )
643  {
644  commit.Modify( track );
645  track->SetWidth( candidate );
646  break;
647  }
648  }
649  }
650  }
651 
652  commit.Push( "Decrease Track Width" );
653  return 0;
654  }
655 
656  ROUTER_TOOL* routerTool = m_toolMgr->GetTool<ROUTER_TOOL>();
657 
658  if( routerTool && routerTool->IsToolActive()
659  && routerTool->Router()->Mode() == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
660  {
661  int widthIndex = designSettings.GetDiffPairIndex() - 1;
662 
663  // If we get to the lowest entry start over at the highest
664  if( widthIndex < 0 )
665  widthIndex = designSettings.m_DiffPairDimensionsList.size() - 1;
666 
667  designSettings.SetDiffPairIndex( widthIndex );
668  designSettings.UseCustomDiffPairDimensions( false );
669 
671  }
672  else
673  {
674  int widthIndex = designSettings.GetTrackWidthIndex() - 1;
675 
676  // If we get to the lowest entry start over at the highest
677  if( widthIndex < 0 )
678  widthIndex = designSettings.m_TrackWidthList.size() - 1;
679 
680  designSettings.SetTrackWidthIndex( widthIndex );
681  designSettings.UseCustomTrackViaSize( false );
682 
684  }
685 
686  return 0;
687 }
688 
689 
691 {
692  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
693  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
695 
697  {
698  BOARD_COMMIT commit( this );
699 
700  for( EDA_ITEM* item : selection )
701  {
702  if( item->Type() == PCB_VIA_T )
703  {
704  VIA* via = (VIA*) item;
705 
706  for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
707  {
708  if( candidate.m_Diameter > via->GetWidth() )
709  {
710  commit.Modify( via );
711  via->SetWidth( candidate.m_Diameter );
712  via->SetDrill( candidate.m_Drill );
713  break;
714  }
715  }
716  }
717  }
718 
719  commit.Push( "Increase Via Size" );
720  }
721  else
722  {
723  int sizeIndex = designSettings.GetViaSizeIndex() + 1;
724 
725  // If we go past the last via entry in the list, start over at the beginning
726  if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
727  sizeIndex = 0;
728 
729  designSettings.SetViaSizeIndex( sizeIndex );
730  designSettings.UseCustomTrackViaSize( false );
731 
733  }
734 
735  return 0;
736 }
737 
738 
740 {
741  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
742  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
744 
746  {
747  BOARD_COMMIT commit( this );
748 
749  for( EDA_ITEM* item : selection )
750  {
751  if( item->Type() == PCB_VIA_T )
752  {
753  VIA* via = (VIA*) item;
754 
755  for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
756  {
757  VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
758 
759  if( candidate.m_Diameter < via->GetWidth() )
760  {
761  commit.Modify( via );
762  via->SetWidth( candidate.m_Diameter );
763  via->SetDrill( candidate.m_Drill );
764  break;
765  }
766  }
767  }
768  }
769 
770  commit.Push( "Decrease Via Size" );
771  }
772  else
773  {
774  int sizeIndex = 0; // Assume we only have a single via size entry
775 
776  // If there are more, cycle through them backwards
777  if( designSettings.m_ViasDimensionsList.size() > 0 )
778  {
779  sizeIndex = designSettings.GetViaSizeIndex() - 1;
780 
781  // If we get to the lowest entry start over at the highest
782  if( sizeIndex < 0 )
783  sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
784  }
785 
786  designSettings.SetViaSizeIndex( sizeIndex );
787  designSettings.UseCustomTrackViaSize( false );
788 
790  }
791 
792  return 0;
793 }
794 
795 
797 {
798  FOOTPRINT* fp = aEvent.Parameter<FOOTPRINT*>();
800  BOARD_COMMIT commit( m_frame );
801  BOARD* board = getModel<BOARD>();
802 
804  controls->ShowCursor( true );
805 
806  std::string tool = aEvent.GetCommandStr().get();
807  m_frame->PushTool( tool );
808  Activate();
809 
810  VECTOR2I cursorPos = controls->GetCursorPosition();
811  bool reselect = false;
812  bool fromOtherCommand = fp != nullptr;
813 
814  // Prime the pump
815  if( fp )
816  {
817  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
820  }
821  else if( !aEvent.IsReactivate() )
823 
824  auto setCursor =
825  [&]()
826  {
828  };
829 
830  // Set initial cursor
831  setCursor();
832 
833  // Main loop: keep receiving events
834  while( TOOL_EVENT* evt = Wait() )
835  {
836  setCursor();
837  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
838 
839  if( reselect && fp )
841 
842  auto cleanup =
843  [&] ()
844  {
846  commit.Revert();
847 
848  if( fromOtherCommand )
849  {
851 
852  if( undo )
853  {
855  undo->ClearListAndDeleteItems();
856  delete undo;
857  }
858  }
859 
860  fp = NULL;
861  };
862 
863  if( evt->IsCancelInteractive() )
864  {
865  if( fp )
866  cleanup();
867  else
868  {
869  m_frame->PopTool( tool );
870  break;
871  }
872  }
873  else if( evt->IsActivate() )
874  {
875  if( fp )
876  cleanup();
877 
878  if( evt->IsMoveTool() )
879  {
880  // leave ourselves on the stack so we come back after the move
881  break;
882  }
883  else
884  {
885  frame()->PopTool( tool );
886  break;
887  }
888  }
889  else if( evt->IsClick( BUT_LEFT ) )
890  {
891  if( !fp )
892  {
893  // Pick the footprint to be placed
895 
896  if( fp == NULL )
897  continue;
898 
899  fp->SetLink( niluuid );
900 
901  fp->SetFlags(IS_NEW ); // whatever
902 
903  // Set parent so that clearance can be loaded
904  fp->SetParent( board );
905 
906  for( PAD* pad : fp->Pads() )
907  {
908  pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest );
909  pad->SetLocked( !m_frame->Settings().m_AddUnlockedPads );
910 
911  // Pads in the library all have orphaned nets. Replace with Default.
912  pad->SetNetCode( 0 );
913  }
914 
915  // Put it on FRONT layer,
916  // (Can be stored flipped if the lib is an archive built from a board)
917  if( fp->IsFlipped() )
919 
920  fp->SetOrientation( 0 );
921  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
922 
923  commit.Add( fp );
925  controls->SetCursorPosition( cursorPos, false );
926  }
927  else
928  {
930  commit.Push( _( "Place a footprint" ) );
931  fp = NULL; // to indicate that there is no footprint that we currently modify
932  }
933  }
934  else if( evt->IsClick( BUT_RIGHT ) )
935  {
937  }
938  else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
939  {
940  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
941  selection().SetReferencePoint( cursorPos );
942  getView()->Update( &selection() );
943  getView()->Update( fp );
944  }
945  else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
946  {
947  // Calling 'Properties' action clears the selection, so we need to restore it
948  reselect = true;
949  }
950  else
951  {
952  evt->SetPassEvent();
953  }
954 
955  // Enable autopanning and cursor capture only when there is a footprint to be placed
956  controls->SetAutoPan( !!fp );
957  controls->CaptureCursor( !!fp );
958  }
959 
961  return 0;
962 }
963 
964 
966 {
967  return modifyLockSelected( TOGGLE );
968 }
969 
970 
972 {
973  return modifyLockSelected( ON );
974 }
975 
976 
978 {
979  return modifyLockSelected( OFF );
980 }
981 
982 
984 {
986  const PCB_SELECTION& selection = selTool->GetSelection();
987  BOARD_COMMIT commit( m_frame );
988 
989  if( selection.Empty() )
991 
992  // Resolve TOGGLE mode
993  if( aMode == TOGGLE )
994  {
995  aMode = ON;
996 
997  for( EDA_ITEM* item : selection )
998  {
999  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1000 
1001  if( board_item->IsLocked() )
1002  {
1003  aMode = OFF;
1004  break;
1005  }
1006  }
1007  }
1008 
1009  bool modified = false;
1010 
1011  for( EDA_ITEM* item : selection )
1012  {
1013  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
1014 
1015  commit.Modify( board_item );
1016 
1017  if( aMode == ON )
1018  {
1019  modified |= !board_item->IsLocked();
1020  board_item->SetLocked( true );
1021  }
1022  else
1023  {
1024  modified |= board_item->IsLocked();
1025  board_item->SetLocked( false );
1026  }
1027  }
1028 
1029  if( modified )
1030  {
1031  commit.Push( aMode == ON ? _( "Lock" ) : _( "Unlock" ) );
1033  m_frame->OnModify();
1034  }
1035 
1036  return 0;
1037 }
1038 
1039 
1041 {
1042  KIGFX::VIEW* view = getView();
1044  BOARD* board = getModel<BOARD>();
1045  PCB_TARGET* target = new PCB_TARGET( board );
1046 
1047  // Init the new item attributes
1048  target->SetLayer( Edge_Cuts );
1050  target->SetSize( Millimeter2iu( 5 ) );
1051  VECTOR2I cursorPos = controls->GetCursorPosition();
1052  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1053 
1054  // Add a VIEW_GROUP that serves as a preview for the new item
1055  KIGFX::VIEW_GROUP preview( view );
1056  preview.Add( target );
1057  view->Add( &preview );
1058 
1060 
1061  std::string tool = aEvent.GetCommandStr().get();
1062  m_frame->PushTool( tool );
1063  Activate();
1064 
1065  auto setCursor =
1066  [&]()
1067  {
1069  };
1070 
1071  // Set initial cursor
1072  setCursor();
1073 
1074  // Main loop: keep receiving events
1075  while( TOOL_EVENT* evt = Wait() )
1076  {
1077  setCursor();
1078  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
1079 
1080  if( evt->IsCancelInteractive() )
1081  {
1082  frame()->PopTool( tool );
1083  break;
1084  }
1085  else if( evt->IsActivate() )
1086  {
1087  if( evt->IsMoveTool() )
1088  {
1089  // leave ourselves on the stack so we come back after the move
1090  break;
1091  }
1092  else
1093  {
1094  frame()->PopTool( tool );
1095  break;
1096  }
1097  }
1098  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1099  {
1100  target->SetWidth( target->GetWidth() + WIDTH_STEP );
1101  view->Update( &preview );
1102  }
1103  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
1104  {
1105  int width = target->GetWidth();
1106 
1107  if( width > WIDTH_STEP )
1108  {
1109  target->SetWidth( width - WIDTH_STEP );
1110  view->Update( &preview );
1111  }
1112  }
1113  else if( evt->IsClick( BUT_LEFT ) )
1114  {
1115  assert( target->GetSize() > 0 );
1116  assert( target->GetWidth() > 0 );
1117 
1118  BOARD_COMMIT commit( m_frame );
1119  commit.Add( target );
1120  commit.Push( "Place a layer alignment target" );
1121 
1122  preview.Remove( target );
1123 
1124  // Create next PCB_TARGET
1125  target = new PCB_TARGET( *target );
1126  preview.Add( target );
1127  }
1128  else if( evt->IsClick( BUT_RIGHT ) )
1129  {
1131  }
1132  else if( evt->IsMotion() )
1133  {
1134  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1135  view->Update( &preview );
1136  }
1137  else
1138  {
1139  evt->SetPassEvent();
1140  }
1141  }
1142 
1143  preview.Clear();
1144  delete target;
1145  view->Remove( &preview );
1146 
1148  return 0;
1149 }
1150 
1151 
1152 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE*>& aOriginZones,
1153  std::vector<ZONE*>& aMergedZones )
1154 {
1155  aCommit.Modify( aOriginZones[0] );
1156 
1157  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1158  {
1159  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
1161  }
1162 
1163  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
1164 
1165  // We should have one polygon with hole
1166  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
1167  // and therefore cannot be merged (they are dectected as intersecting)
1168  // but we should never have more than 2 polys
1169  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
1170  {
1171  wxLogMessage( "BOARD::mergeZones error: more than 2 polys after merging" );
1172  return false;
1173  }
1174 
1175  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1176  {
1177  aCommit.Remove( aOriginZones[i] );
1178  }
1179 
1180  aMergedZones.push_back( aOriginZones[0] );
1181 
1182  aOriginZones[0]->SetLocalFlags( 1 );
1183  aOriginZones[0]->HatchBorder();
1184  aOriginZones[0]->CacheTriangulation();
1185 
1186  return true;
1187 }
1188 
1189 
1191 {
1192  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1193  BOARD* board = getModel<BOARD>();
1194  BOARD_COMMIT commit( m_frame );
1195 
1196  if( selection.Size() < 2 )
1197  return 0;
1198 
1199  int netcode = -1;
1200 
1201  ZONE* firstZone = nullptr;
1202  std::vector<ZONE*> toMerge, merged;
1203 
1204  for( auto item : selection )
1205  {
1206  ZONE* curr_area = dynamic_cast<ZONE*>( item );
1207 
1208  if( !curr_area )
1209  continue;
1210 
1211  if( !firstZone )
1212  firstZone = curr_area;
1213 
1214  netcode = curr_area->GetNetCode();
1215 
1216  if( firstZone->GetNetCode() != netcode )
1217  continue;
1218 
1219  if( curr_area->GetPriority() != firstZone->GetPriority() )
1220  continue;
1221 
1222  if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1223  continue;
1224 
1225  if( curr_area->GetLayer() != firstZone->GetLayer() )
1226  continue;
1227 
1228  if( !board->TestZoneIntersection( curr_area, firstZone ) )
1229  continue;
1230 
1231  toMerge.push_back( curr_area );
1232  }
1233 
1235 
1236  if( mergeZones( commit, toMerge, merged ) )
1237  {
1238  commit.Push( "Merge zones" );
1239 
1240  for( auto item : merged )
1242  }
1243 
1244  return 0;
1245 }
1246 
1247 
1249 {
1251  const PCB_SELECTION& selection = selTool->GetSelection();
1252 
1253  // because this pops up the zone editor, it would be confusing to handle multiple zones,
1254  // so just handle single selections containing exactly one zone
1255  if( selection.Size() != 1 )
1256  return 0;
1257 
1258  ZONE* oldZone = dyn_cast<ZONE*>( selection[0] );
1259 
1260  if( !oldZone )
1261  return 0;
1262 
1263  ZONE_SETTINGS zoneSettings;
1264  zoneSettings << *oldZone;
1265  int dialogResult;
1266 
1267  if( oldZone->GetIsRuleArea() )
1268  dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings );
1269  else if( oldZone->IsOnCopperLayer() )
1270  dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1271  else
1272  dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1273 
1274  if( dialogResult != wxID_OK )
1275  return 0;
1276 
1277  // duplicate the zone
1278  BOARD_COMMIT commit( m_frame );
1279 
1280  std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( *oldZone );
1281  newZone->ClearSelected();
1282  newZone->UnFill();
1283  zoneSettings.ExportSetting( *newZone );
1284 
1285  // If the new zone is on the same layer(s) as the the initial zone,
1286  // offset it a bit so it can more easily be picked.
1287  if( oldZone->GetIsRuleArea() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
1288  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1289  else if( !oldZone->GetIsRuleArea() && zoneSettings.m_Layers.test( oldZone->GetLayer() ) )
1290  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1291 
1292  commit.Add( newZone.release() );
1293  commit.Push( _( "Duplicate zone" ) );
1294 
1295  return 0;
1296 }
1297 
1298 
1300 {
1303 
1304  if( selection.Empty() )
1305  return 0;
1306 
1308 
1309  if( !fp )
1310  return 0;
1311 
1312  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1313 
1314  auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1315 
1316  editor->LoadFootprintFromBoard( fp );
1317 
1318  editor->Show( true );
1319  editor->Raise(); // Iconize( false );
1320 
1321  if( selection.IsHover() )
1323 
1324  return 0;
1325 }
1326 
1327 
1329  EDA_ITEM* originViewItem, const VECTOR2D& aPosition )
1330 {
1331  aFrame->GetDesignSettings().m_AuxOrigin = (wxPoint) aPosition;
1332  originViewItem->SetPosition( (wxPoint) aPosition );
1333  aView->MarkDirty();
1334  aFrame->OnModify();
1335 }
1336 
1337 
1339 {
1340  std::string tool = aEvent.GetCommandStr().get();
1342 
1343  // Deactivate other tools; particularly important if another PICKER is currently running
1344  Activate();
1345 
1346  picker->SetClickHandler(
1347  [this] ( const VECTOR2D& pt ) -> bool
1348  {
1350  DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
1351  return false; // drill origin is a one-shot; don't continue with tool
1352  } );
1353 
1354  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1355 
1356  return 0;
1357 }
1358 
1359 
1361 {
1362  Go( &BOARD_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1363  Go( &BOARD_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1364  Go( &BOARD_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1368  Go( &BOARD_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1369 
1380 
1381  // Track & via size control
1386 
1387  // Zone actions
1390 
1391  // Placing tools
1395 
1397 
1398  // Other
1402 
1409 }
1410 
1411 
1412 const int BOARD_EDITOR_CONTROL::WIDTH_STEP = 100000;
int Open(const TOOL_EVENT &aEvent)
int LockSelected(const TOOL_EVENT &aEvent)
Unlock selected items.
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:418
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:577
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
void OnModify() override
Must be called after a board change to set the modified flag.
bool IsCurrentTool(const TOOL_ACTION &aAction) const
Definition: track.h:343
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
int New(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:420
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
KIID niluuid(0)
bool IsHover() const
Definition: selection.h:72
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:177
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:334
ZONES & Zones()
Definition: board.h:302
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
BOARD * board() const
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:344
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:266
This file is part of the common library TODO brief description.
static TOOL_ACTION pageSettings
Definition: actions.h:59
int TrackWidthInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:172
Model changes (required full reload)
Definition: tool_base.h:81
unsigned GetPriority() const
Function GetPriority.
Definition: zone.h:124
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:160
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:755
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:433
bool Init() override
Init() is called once upon a registration of the tool.
FOOTPRINT * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Open a dialog to select a footprint.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:194
static TOOL_ACTION lock
Definition: pcb_actions.h:419
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:45
This file is part of the common library.
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:302
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:307
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:300
std::vector< int > m_TrackWidthList
void ToPlotter(int aID)
Open a dialog frame to create plot and drill files relative to the current board.
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
void SetSize(int aSize)
Definition: pcb_target.h:66
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
static constexpr double IU_PER_MM
Mock up a conversion function.
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:316
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
int GetSize() const
Definition: pcb_target.h:67
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
int Plot(const TOOL_EVENT &aEvent)
virtual void Revert() override
MARKERS & Markers()
Definition: board.h:305
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void UseCustomDiffPairDimensions(bool aEnabled)
Enables/disables custom differential pair dimensions.
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:351
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:121
void SetWksFileName(const wxString &aFilename)
int GeneratePosFile(const TOOL_EVENT &aEvent)
void RecreateBOMFileFromBoard(wxCommandEvent &aEvent)
Create a BOM file from the current loaded board.
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:299
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
TOOL_MENU & GetToolMenu()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:463
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:303
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:346
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:584
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:345
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:439
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:345
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:166
virtual void Clear()
Remove all the stored items from the group.
Definition: view_group.cpp:75
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
Definition: board_item.h:257
int ImportNetlist(const TOOL_EVENT &aEvent)
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
Definition: undo_redo.cpp:373
const wxString & GetFileName() const
Definition: board.h:291
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
static TOOL_ACTION generateReportFile
Definition: pcb_actions.h:337
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:306
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
wxString GetLastPath(LAST_PATH_TYPE aType)
Get the last path for a particular type.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
int PageSettings(const TOOL_EVENT &aEvent)
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:165
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:338
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PADS & Pads()
Definition: footprint.h:164
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:175
static TOOL_ACTION saveCopyAs
Definition: actions.h:56
void SetWidth(int aWidth)
Definition: track.h:109
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:70
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:459
int modifyLockSelected(MODIFY_MODE aMode)
Set up handlers for various events.
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
static TOOL_ACTION pickerTool
Definition: actions.h:158
FP_TEXT & Reference()
Definition: footprint.h:460
PCB_BASE_EDIT_FRAME * frame() const
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:89
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
FP_ZONES & Zones()
Definition: footprint.h:170
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:298
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:563
Definition: kiid.h:44
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:264
int GetWidth() const
Definition: pcb_target.h:70
int DrillOrigin(const TOOL_EVENT &aEvent)
Low-level access (below undo) to setting the drill origin.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
void GenFootprintsReport(wxCommandEvent &event)
Call DoGenFootprintsReport to create a footprint report file.
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:167
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
int EditFpInFpEditor(const TOOL_EVENT &aEvent)
const PCB_SELECTION & selection() const
int ViaSizeInc(const TOOL_EVENT &aEvent)
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:202
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:207
int UpdatePCBFromSchematic(const TOOL_EVENT &aEvent)
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:329
#define NULL
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition: page_info.h:40
int UnlockSelected(const TOOL_EVENT &aEvent)
Run the drill origin tool for setting the origin for drill and pick-and-place files.
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
Definition: drawing_tool.h:50
unsigned GetViaSizeIndex() const
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: zone.cpp:215
static TOOL_ACTION open
Definition: actions.h:53
static const int WIDTH_STEP
How does line width change after one -/+ key press.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1543
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION doNew
Definition: actions.h:47
FOOTPRINTS & Footprints()
Definition: board.h:296
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void SetPosition(const wxPoint &aPos) override
Definition: pcb_target.h:60
Generic, UI-independent tool event.
Definition: tool_event.h:173
int BoardSetup(const TOOL_EVENT &aEvent)
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1366
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
Definition: gestfich.cpp:52
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:310
FOOTPRINT * footprint() const
unsigned GetTrackWidthIndex() const
KIGFX::PCB_VIEW * view() const
Definition of file extensions used in Kicad.
bool ToolStackIsEmpty()
Definition: tools_holder.h:117
const wxString & GetNetname() const
Definition: netinfo.h:119
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:46
An interface for classes handling user events controlling the view behavior such as zooming,...
int SaveAs(const TOOL_EVENT &aEvent)
virtual void Remove(VIEW_ITEM *aItem)
Remove an item from the group.
Definition: view_group.cpp:62
DRAWINGS & GraphicalItems()
Definition: footprint.h:167
int Save(const TOOL_EVENT &aEvent)
static TOOL_ACTION plot
Definition: actions.h:61
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:105
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
Definition: commit.h:90
int RepairBoard(const TOOL_EVENT &aEvent)
void SetDiffPairIndex(unsigned aIndex)
A holder to handle information on schematic or board items.
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:436
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
static TOOL_ACTION generatePosFile
Definition: pcb_actions.h:336
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:159
MODIFY_MODE
< How to modify a property for selected items.
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:161
int ShowEeschema(const TOOL_EVENT &aEvent)
const std::string SpecctraDsnFileExtension
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:309
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:316
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
Generic tool for picking an item.
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:308
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:69
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:331
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:313
bool IsFlipped() const
Definition: footprint.h:263
FP_GROUPS & Groups()
Definition: footprint.h:173
int ImportSpecctraSession(const TOOL_EVENT &aEvent)
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:339
void SetLink(const KIID &aLink)
Definition: footprint.h:529
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
Handle the data for a net.
Definition: netinfo.h:64
virtual bool IsLocked() const
Definition: board_item.h:249
int ZoneMerge(const TOOL_EVENT &aEvent)
Duplicate a zone onto a layer (prompts for new layer)
static TOOL_ACTION placeFootprint
Definition: pcb_actions.h:162
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:332
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
KIGFX::VIEW_CONTROLS * controls() const
int GetWidth() const
Definition: track.h:110
const char * name
Definition: DXF_plotter.cpp:59
Common, abstract interface for edit frames.
static TOOL_ACTION saveAs
Definition: actions.h:55
const BITMAP_OPAQUE locked_xpm[1]
Definition: locked.cpp:30
void GenD356File(wxCommandEvent &event)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:189
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION repairBoard
Definition: pcb_actions.h:439
bool IsToolActive() const
Definition: tool_base.cpp:31
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:66
int PlaceFootprint(const TOOL_EVENT &aEvent)
Display a dialog to select a footprint to be added and allows the user to set its position.
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Lock selected items.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: track.h:474
PCBNEW_SETTINGS & Settings()
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
The selection tool: currently supports:
#define IU_PER_MILS
Definition: plotter.cpp:137
int TogglePythonConsole(const TOOL_EVENT &aEvent)
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE * > &aOriginZones, std::vector< ZONE * > &aMergedZones)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
wxPoint GetPosition() const override
Definition: footprint.h:182
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
std::vector< VIA_DIMENSION > m_ViasDimensionsList
T * FirstOfKind() const
Definition: selection.h:214
bool IsReactivate() const
Definition: tool_event.h:273
void SetWidth(int aWidth)
Definition: pcb_target.h:69
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
bool Files_io_from_id(int aId)
Read and write board files according to aId.
void Activate()
Run the tool.
Definition: id.h:97
const BITMAP_OPAQUE add_zone_xpm[1]
Definition: add_zone.cpp:25
wxString SpecctraDsnFileWildcard()
ACTION_MENU * create() const override
< Return an instance of this class. It has to be overridden in inheriting classes.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
unsigned GetDiffPairIndex() const
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
int GenerateDrillFiles(const TOOL_EVENT &aEvent)
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:321
int ToggleLayersManager(const TOOL_EVENT &aEvent)
ACTION_MENU * create() const override
< Return an instance of this class. It has to be overridden in inheriting classes.
int ViaSizeDec(const TOOL_EVENT &aEvent)
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
A selection filter which prunes the selection to contain only items of type #PCB_MODULE_T.
Definition: edit_tool.cpp:2164
BOARD * GetBoard() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
ROUTER * Router() const
Definition: pad.h:60
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1437
MODE GetDrawingMode() const
Return the current drawing mode of the DRAWING_TOOL or #MODE::NONE if not currently in any drawing mo...
int GenerateFabFiles(const TOOL_EVENT &aEvent)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:281
ROUTER_MODE Mode() const
Definition: pns_router.h:136
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
int TrackWidthDec(const TOOL_EVENT &aEvent)
static constexpr int Millimeter2iu(double mm)
Rendering engine changes.
Definition: tool_base.h:82
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:301
DRAWINGS & Drawings()
Definition: board.h:299
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
wxPoint m_AuxOrigin
origin for plot exports
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
TRACKS & Tracks()
Definition: board.h:293
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:60
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:598
int PlaceTarget(const TOOL_EVENT &aEvent)
Allow user to place a layer alignment target.
Definition: track.h:83
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
static TOOL_ACTION refreshPreview
Definition: actions.h:109
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:126
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1508
void SetLastPath(LAST_PATH_TYPE aType, const wxString &aLastPath)
Set the path of the last file successfully read.
static TOOL_ACTION generateDrillFiles
Definition: pcb_actions.h:335
int SaveCopyAs(const TOOL_EVENT &aEvent)
Container for design settings for a BOARD object.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98