KiCad PCB EDA Suite
pcb_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-2020 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 "pcb_editor_control.h"
26 #include "drawing_tool.h"
27 #include "pcb_actions.h"
28 #include "pcbnew_picker_tool.h"
29 #include "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 <class_board.h>
35 #include <class_pcb_group.h>
36 #include <class_module.h>
37 #include <class_pcb_target.h>
38 #include <class_track.h>
39 #include <class_zone.h>
40 #include <class_marker_pcb.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 <view/view_controls.h>
62 #include <view/view_group.h>
65 #include <footprint_edit_frame.h>
66 
67 using namespace std::placeholders;
68 
69 
71 {
72 public:
74  ACTION_MENU( true )
75  {
76  SetIcon( add_zone_xpm );
77  SetTitle( _( "Zones" ) );
78 
79  Add( PCB_ACTIONS::zoneFill );
83 
84  AppendSeparator();
85 
90  }
91 
92 
93 protected:
94  ACTION_MENU* create() const override
95  {
96  return new ZONE_CONTEXT_MENU();
97  }
98 };
99 
100 
102 {
103 public:
105  ACTION_MENU( true )
106  {
107  SetIcon( locked_xpm );
108  SetTitle( _( "Locking" ) );
109 
110  Add( PCB_ACTIONS::lock );
111  Add( PCB_ACTIONS::unlock );
113  }
114 
115  ACTION_MENU* create() const override
116  {
117  return new LOCK_CONTEXT_MENU();
118  }
119 };
120 
121 
123  PCB_TOOL_BASE( "pcbnew.EditorControl" ),
124  m_frame( nullptr )
125 {
126  m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
128 }
129 
130 
132 {
133 }
134 
135 
137 {
138  m_frame = getEditFrame<PCB_EDIT_FRAME>();
139 
140  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
141  {
142  m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin );
143  getView()->Remove( m_placeOrigin.get() );
144  getView()->Add( m_placeOrigin.get() );
145  }
146 }
147 
148 
150 {
151  auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
152  return ( !m_frame->ToolStackIsEmpty() );
153  };
154 
155  auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
156  return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
157  };
158 
159  auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
160  return ( m_frame->IsCurrentTool( PCB_ACTIONS::placeModule ) && aSel.GetSize() == 0 );
161  };
162 
163  auto& ctxMenu = m_menu.GetMenu();
164 
165  // "Cancel" goes at the top of the context menu when a tool is active
166  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
167  ctxMenu.AddSeparator( 1 );
168 
169  // "Get and Place Footprint" should be available for Place Footprint tool
170  ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
171  ctxMenu.AddSeparator( 1000 );
172 
173  // Finally, add the standard zoom & grid items
174  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
175 
176  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
177  zoneMenu->SetTool( this );
178 
179  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
180  lockMenu->SetTool( this );
181 
182  // Add the PCB control menus to relevant other tools
183 
185 
186  if( selTool )
187  {
188  auto& toolMenu = selTool->GetToolMenu();
189  auto& menu = toolMenu.GetMenu();
190 
191  // Add "Get and Place Footprint" when Selection tool is in an inactive state
192  menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
193  menu.AddSeparator();
194 
195  toolMenu.AddSubMenu( zoneMenu );
196  toolMenu.AddSubMenu( lockMenu );
197 
198  menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 100 );
199 
200  menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ), 200 );
201  }
202 
203  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
204 
205  if( drawingTool )
206  {
207  auto& toolMenu = drawingTool->GetToolMenu();
208  auto& menu = toolMenu.GetMenu();
209 
210  toolMenu.AddSubMenu( zoneMenu );
211 
212  // Functor to say if the PCB_EDIT_FRAME is in a given mode
213  // Capture the tool pointer and tool mode by value
214  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
215  {
216  return [=]( const SELECTION& sel )
217  {
218  return drawingTool->GetDrawingMode() == aMode;
219  };
220  };
221 
222  menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
223  }
224 
225  return true;
226 }
227 
228 
230 {
232  return 0;
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 {
266  PICKED_ITEMS_LIST undoCmd;
267  WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
268  ITEM_PICKER wrapper( nullptr, undoItem, UNDO_REDO::PAGESETTINGS );
269 
270  undoCmd.PushItem( wrapper );
272 
276 
277  if( dlg.ShowModal() != wxID_OK )
279 
280  return 0;
281 }
282 
283 
285 {
287  return 0;
288 }
289 
290 
292 {
293  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
294  return 0;
295 }
296 
297 
299 {
300  getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
301  return 0;
302 }
303 
304 
306 {
307  wxString fullFileName = frame()->GetBoard()->GetFileName();
308  wxString path;
309  wxString name;
310  wxString ext;
311 
312  wxFileName::SplitPath( fullFileName, &path, &name, &ext );
313  name += wxT( ".ses" );
314 
315  fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), path, name,
316  wxT( ".ses" ), wxT( "*.ses" ), frame(), wxFD_OPEN, false );
317 
318  if( !fullFileName.IsEmpty() )
319  getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
320 
321  return 0;
322 }
323 
324 
326 {
327  wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
328  wxFileName fn;
329 
330  if( fullFileName.IsEmpty() )
331  {
332  fn = m_frame->GetBoard()->GetFileName();
333  fn.SetExt( SpecctraDsnFileExtension );
334  }
335  else
336  fn = fullFileName;
337 
338  fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
340  frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
341 
342  if( !fullFileName.IsEmpty() )
343  {
344  m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
345  getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
346  }
347 
348  return 0;
349 }
350 
351 
353 {
354  wxCommandEvent dummy;
355 
356  if( aEvent.IsAction( &PCB_ACTIONS::generateGerbers ) )
358  else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
360  else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
362  else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
364  else
365  wxFAIL_MSG( "GenerateFabFiles(): unexpected request" );
366 
367  return 0;
368 }
369 
370 
372 {
373  int errors = 0;
374  wxString details;
375 
376  /*******************************
377  * Repair duplicate IDs and missing nets
378  */
379 
380  std::set<KIID> ids;
381  int duplicates = 0;
382 
383  auto processItem =
384  [&]( EDA_ITEM* aItem )
385  {
386  if( ids.count( aItem->m_Uuid ) )
387  {
388  duplicates++;
389  const_cast<KIID&>( aItem->m_Uuid ) = KIID();
390  }
391 
392  ids.insert( aItem->m_Uuid );
393 
394  BOARD_CONNECTED_ITEM* cItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem );
395 
396  if( cItem && cItem->GetNetCode() )
397  {
398  NETINFO_ITEM* netinfo = cItem->GetNet();
399 
400  if( netinfo && !board()->FindNet( netinfo->GetNetname() ) )
401  {
402  board()->Add( netinfo );
403 
404  details += wxString::Format( _( "Orphaned net %s re-parented.\n" ),
405  netinfo->GetNetname() );
406  errors++;
407  }
408  }
409  };
410 
411  // Footprint IDs are the most important, so give them the first crack at "claiming" a
412  // particular KIID.
413 
414  for( MODULE* footprint : board()->Modules() )
415  processItem( footprint );
416 
417  // After that the principal use is for DRC marker pointers, which are most likely to pads
418  // or tracks.
419 
420  for( MODULE* footprint : board()->Modules() )
421  {
422  for( D_PAD* pad : footprint->Pads() )
423  processItem( pad );
424  }
425 
426  for( TRACK* track : board()->Tracks() )
427  processItem( track );
428 
429  // From here out I don't think order matters much.
430 
431  for( MODULE* footprint : board()->Modules() )
432  {
433  processItem( &footprint->Reference() );
434  processItem( &footprint->Value() );
435 
436  for( BOARD_ITEM* item : footprint->GraphicalItems() )
437  processItem( item );
438 
439  for( ZONE_CONTAINER* zone : footprint->Zones() )
440  processItem( zone );
441 
442  for( PCB_GROUP* group : footprint->Groups() )
443  processItem( group );
444  }
445 
446  for( BOARD_ITEM* drawing : board()->Drawings() )
447  processItem( drawing );
448 
449  for( ZONE_CONTAINER* zone : board()->Zones() )
450  processItem( zone );
451 
452  for( MARKER_PCB* marker : board()->Markers() )
453  processItem( marker );
454 
455  for( PCB_GROUP* group : board()->Groups() )
456  processItem( group );
457 
458  if( duplicates )
459  {
460  errors += duplicates;
461  details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
462  }
463 
464  /*******************************
465  * Your test here
466  */
467 
468  /*******************************
469  * Inform the user
470  */
471 
472  if( errors )
473  {
474  m_frame->OnModify();
475 
476  wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
477  DisplayInfoMessage( m_frame, msg, details );
478  }
479  else
480  {
481  DisplayInfoMessage( m_frame, _( "No board problems found." ) );
482  }
483 
484  return 0;
485 }
486 
487 
489 {
490  NETLIST netlist;
491 
493  {
494  DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
495  updateDialog.ShowModal();
496  }
497 
498  return 0;
499 }
500 
502 {
503  if( Kiface().IsSingle() )
504  {
506  m_frame, _( "Cannot update schematic because Pcbnew is opened in stand-alone "
507  "mode. In order to create or update PCBs from schematics, you "
508  "must launch the KiCad project manager and create a project." ) );
509  return 0;
510  }
511 
512  m_frame->RunEeschema();
514 
515  if( frame )
516  {
517  std::string payload;
519  }
520  return 0;
521 }
522 
523 
525 {
526  m_frame->RunEeschema();
527  return 0;
528 }
529 
530 
532 {
533  getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
534  return 0;
535 }
536 
537 
539 {
540 #if defined( KICAD_SCRIPTING_WXPYTHON )
541  m_frame->ScriptingConsoleEnableDisable();
542 #endif
543  return 0;
544 }
545 
546 
547 // Track & via size control
549 {
550  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
551  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
553 
555  {
556  BOARD_COMMIT commit( this );
557 
558  for( EDA_ITEM* item : selection )
559  {
560  if( item->Type() == PCB_TRACE_T )
561  {
562  TRACK* track = (TRACK*) item;
563 
564  for( int candidate : designSettings.m_TrackWidthList )
565  {
566  if( candidate > track->GetWidth() )
567  {
568  commit.Modify( track );
569  track->SetWidth( candidate );
570  break;
571  }
572  }
573  }
574  }
575 
576  commit.Push( "Increase Track Width" );
577  }
578  else
579  {
580  int widthIndex = designSettings.GetTrackWidthIndex() + 1;
581 
582  // If we go past the last track width entry in the list, start over at the beginning
583  if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
584  {
585  widthIndex = 0;
586  }
587 
588  designSettings.SetTrackWidthIndex( widthIndex );
589  designSettings.UseCustomTrackViaSize( false );
590 
592  }
593 
594  return 0;
595 }
596 
597 
599 {
600  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
601  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
603 
605  {
606  BOARD_COMMIT commit( this );
607 
608  for( EDA_ITEM* item : selection )
609  {
610  if( item->Type() == PCB_TRACE_T )
611  {
612  TRACK* track = (TRACK*) item;
613 
614  for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 0; --i )
615  {
616  int candidate = designSettings.m_TrackWidthList[ i ];
617 
618  if( candidate < track->GetWidth() )
619  {
620  commit.Modify( track );
621  track->SetWidth( candidate );
622  break;
623  }
624  }
625  }
626  }
627 
628  commit.Push( "Decrease Track Width" );
629  }
630  else
631  {
632  int widthIndex = 0; // Assume we only have a single track width entry
633 
634  // If there are more, cycle through them backwards
635  if( designSettings.m_TrackWidthList.size() > 0 )
636  {
637  widthIndex = designSettings.GetTrackWidthIndex() - 1;
638  // If we get to the lowest entry start over at the highest
639  if( widthIndex < 0 )
640  widthIndex = designSettings.m_TrackWidthList.size() - 1;
641  }
642 
643  designSettings.SetTrackWidthIndex( widthIndex );
644  designSettings.UseCustomTrackViaSize( false );
645 
647  }
648 
649  return 0;
650 }
651 
652 
654 {
655  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
656  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
658 
660  {
661  BOARD_COMMIT commit( this );
662 
663  for( EDA_ITEM* item : selection )
664  {
665  if( item->Type() == PCB_VIA_T )
666  {
667  VIA* via = (VIA*) item;
668 
669  for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
670  {
671  if( candidate.m_Diameter > via->GetWidth() )
672  {
673  commit.Modify( via );
674  via->SetWidth( candidate.m_Diameter );
675  via->SetDrill( candidate.m_Drill );
676  break;
677  }
678  }
679  }
680  }
681 
682  commit.Push( "Increase Via Size" );
683  }
684  else
685  {
686  int sizeIndex = designSettings.GetViaSizeIndex() + 1;
687 
688  // If we go past the last via entry in the list, start over at the beginning
689  if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
690  sizeIndex = 0;
691 
692  designSettings.SetViaSizeIndex( sizeIndex );
693  designSettings.UseCustomTrackViaSize( false );
694 
696  }
697 
698  return 0;
699 }
700 
701 
703 {
704  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
705  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
707 
709  {
710  BOARD_COMMIT commit( this );
711 
712  for( EDA_ITEM* item : selection )
713  {
714  if( item->Type() == PCB_VIA_T )
715  {
716  VIA* via = (VIA*) item;
717 
718  for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
719  {
720  VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
721 
722  if( candidate.m_Diameter < via->GetWidth() )
723  {
724  commit.Modify( via );
725  via->SetWidth( candidate.m_Diameter );
726  via->SetDrill( candidate.m_Drill );
727  break;
728  }
729  }
730  }
731  }
732 
733  commit.Push( "Decrease Via Size" );
734  }
735  else
736  {
737  int sizeIndex = 0; // Assume we only have a single via size entry
738 
739  // If there are more, cycle through them backwards
740  if( designSettings.m_ViasDimensionsList.size() > 0 )
741  {
742  sizeIndex = designSettings.GetViaSizeIndex() - 1;
743 
744  // If we get to the lowest entry start over at the highest
745  if( sizeIndex < 0 )
746  sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
747  }
748 
749  designSettings.SetViaSizeIndex( sizeIndex );
750  designSettings.UseCustomTrackViaSize( false );
751 
753  }
754 
755  return 0;
756 }
757 
758 
760 {
761  MODULE* fp = aEvent.Parameter<MODULE*>();
763  BOARD_COMMIT commit( m_frame );
764  BOARD* board = getModel<BOARD>();
765 
767  controls->ShowCursor( true );
768 
769  std::string tool = aEvent.GetCommandStr().get();
770  m_frame->PushTool( tool );
771  Activate();
772 
773  VECTOR2I cursorPos = controls->GetCursorPosition();
774  bool reselect = false;
775  bool fromOtherCommand = fp != nullptr;
776 
777  // Prime the pump
778  if( fp )
779  {
780  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
783  }
784  else if( aEvent.HasPosition() )
786 
787  auto setCursor =
788  [&]()
789  {
791  };
792 
793  // Set initial cursor
794  setCursor();
795 
796  // Main loop: keep receiving events
797  while( TOOL_EVENT* evt = Wait() )
798  {
799  setCursor();
800  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
801 
802  if( reselect && fp )
804 
805  auto cleanup = [&] ()
806  {
808  commit.Revert();
809 
810  if( fromOtherCommand )
811  {
813 
814  if( undo )
815  {
816  m_frame->PutDataInPreviousState( undo, false );
817  undo->ClearListAndDeleteItems();
818  delete undo;
819  }
820  }
821 
822  fp = NULL;
823  };
824 
825  if( evt->IsCancelInteractive() )
826  {
827  if( fp )
828  cleanup();
829  else
830  {
831  m_frame->PopTool( tool );
832  break;
833  }
834  }
835 
836  else if( evt->IsActivate() )
837  {
838  if( fp )
839  cleanup();
840 
841  if( evt->IsMoveTool() )
842  {
843  // leave ourselves on the stack so we come back after the move
844  break;
845  }
846  else
847  {
848  frame()->PopTool( tool );
849  break;
850  }
851  }
852 
853  else if( evt->IsClick( BUT_LEFT ) )
854  {
855  if( !fp )
856  {
857  // Pick the footprint to be placed
859 
860  if( fp == NULL )
861  continue;
862 
863  fp->SetLink( niluuid );
864 
865  fp->SetFlags(IS_NEW ); // whatever
866 
867  // Set parent so that clearance can be loaded
868  fp->SetParent( board );
869 
870  // Pads in the library all have orphaned nets. Replace with Default.
871  for( D_PAD* pad : fp->Pads() )
872  pad->SetNetCode( 0 );
873 
874  // Put it on FRONT layer,
875  // (Can be stored flipped if the lib is an archive built from a board)
876  if( fp->IsFlipped() )
878 
879  fp->SetOrientation( 0 );
880  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
881 
882  commit.Add( fp );
884  controls->SetCursorPosition( cursorPos, false );
885  }
886  else
887  {
889  commit.Push( _( "Place a footprint" ) );
890  fp = NULL; // to indicate that there is no footprint that we currently modify
891  }
892  }
893 
894  else if( evt->IsClick( BUT_RIGHT ) )
895  {
897  }
898 
899  else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
900  {
901  fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
902  selection().SetReferencePoint( cursorPos );
903  getView()->Update( & selection() );
904  }
905 
906  else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
907  {
908  // Calling 'Properties' action clears the selection, so we need to restore it
909  reselect = true;
910  }
911 
912  else
913  evt->SetPassEvent();
914 
915  // Enable autopanning and cursor capture only when there is a footprint to be placed
916  controls->SetAutoPan( !!fp );
917  controls->CaptureCursor( !!fp );
918  }
919 
920  return 0;
921 }
922 
923 
925 {
926  return modifyLockSelected( TOGGLE );
927 }
928 
929 
931 {
932  return modifyLockSelected( ON );
933 }
934 
935 
937 {
938  return modifyLockSelected( OFF );
939 }
940 
941 
943 {
945  const PCBNEW_SELECTION& selection = selTool->GetSelection();
946  BOARD_COMMIT commit( m_frame );
947 
948  if( selection.Empty() )
950 
951  bool modified = false;
952 
953  for( EDA_ITEM* item : selection )
954  {
955  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
956  bool prevState = board_item->IsLocked();
957 
958  commit.Modify( board_item );
959 
960  switch( aMode )
961  {
962  case ON: board_item->SetLocked( true ); break;
963  case OFF: board_item->SetLocked( false ); break;
964  case TOGGLE: board_item->SetLocked( !prevState ); break;
965  }
966 
967  // Check if we really modified an item
968  if( !modified && prevState != board_item->IsLocked() )
969  modified = true;
970  }
971 
972  if( modified )
973  {
974  switch( aMode )
975  {
976  case ON: commit.Push( _( "Lock" ) ); break;
977  case OFF: commit.Push( _( "Unlock" ) ); break;
978  case TOGGLE: commit.Push( _( "Toggle Locking" ) ); break;
979  }
980 
982  m_frame->OnModify();
983  }
984 
985  return 0;
986 }
987 
988 
990 {
991  KIGFX::VIEW* view = getView();
993  BOARD* board = getModel<BOARD>();
994  PCB_TARGET* target = new PCB_TARGET( board );
995 
996  // Init the new item attributes
997  target->SetLayer( Edge_Cuts );
999  target->SetSize( Millimeter2iu( 5 ) );
1000  VECTOR2I cursorPos = controls->GetCursorPosition();
1001  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1002 
1003  // Add a VIEW_GROUP that serves as a preview for the new item
1004  KIGFX::VIEW_GROUP preview( view );
1005  preview.Add( target );
1006  view->Add( &preview );
1007 
1009 
1010  std::string tool = aEvent.GetCommandStr().get();
1011  m_frame->PushTool( tool );
1012  Activate();
1013 
1014  auto setCursor =
1015  [&]()
1016  {
1018  };
1019 
1020  // Set initial cursor
1021  setCursor();
1022 
1023  // Main loop: keep receiving events
1024  while( TOOL_EVENT* evt = Wait() )
1025  {
1026  setCursor();
1027  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
1028 
1029  if( evt->IsCancelInteractive() )
1030  {
1031  frame()->PopTool( tool );
1032  break;
1033  }
1034 
1035  else if( evt->IsActivate() )
1036  {
1037  if( evt->IsMoveTool() )
1038  {
1039  // leave ourselves on the stack so we come back after the move
1040  break;
1041  }
1042  else
1043  {
1044  frame()->PopTool( tool );
1045  break;
1046  }
1047  }
1048 
1049  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1050  {
1051  target->SetWidth( target->GetWidth() + WIDTH_STEP );
1052  view->Update( &preview );
1053  }
1054 
1055  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
1056  {
1057  int width = target->GetWidth();
1058 
1059  if( width > WIDTH_STEP )
1060  {
1061  target->SetWidth( width - WIDTH_STEP );
1062  view->Update( &preview );
1063  }
1064  }
1065 
1066  else if( evt->IsClick( BUT_LEFT ) )
1067  {
1068  assert( target->GetSize() > 0 );
1069  assert( target->GetWidth() > 0 );
1070 
1071  BOARD_COMMIT commit( m_frame );
1072  commit.Add( target );
1073  commit.Push( "Place a layer alignment target" );
1074 
1075  preview.Remove( target );
1076 
1077  // Create next PCB_TARGET
1078  target = new PCB_TARGET( *target );
1079  preview.Add( target );
1080  }
1081 
1082  else if( evt->IsClick( BUT_RIGHT ) )
1083  {
1085  }
1086 
1087  else if( evt->IsMotion() )
1088  {
1089  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
1090  view->Update( &preview );
1091  }
1092 
1093  else
1094  evt->SetPassEvent();
1095  }
1096 
1097  preview.Clear();
1098  delete target;
1099  view->Remove( &preview );
1100  return 0;
1101 }
1102 
1103 
1104 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
1105  std::vector<ZONE_CONTAINER *>& aMergedZones )
1106 {
1107  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1108  {
1109  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
1111  }
1112 
1113  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
1114 
1115  // We should have one polygon with hole
1116  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
1117  // and therefore cannot be merged (they are dectected as intersecting)
1118  // but we should never have more than 2 polys
1119  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
1120  {
1121  wxLogMessage( "BOARD::CombineAreas error: more than 2 polys after merging" );
1122  return false;
1123  }
1124 
1125  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1126  {
1127  aCommit.Remove( aOriginZones[i] );
1128  }
1129 
1130  aCommit.Modify( aOriginZones[0] );
1131  aMergedZones.push_back( aOriginZones[0] );
1132 
1133  aOriginZones[0]->SetLocalFlags( 1 );
1134  aOriginZones[0]->HatchBorder();
1135  aOriginZones[0]->CacheTriangulation();
1136 
1137  return true;
1138 }
1139 
1140 
1142 {
1143  const PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1144  BOARD* board = getModel<BOARD>();
1145  BOARD_COMMIT commit( m_frame );
1146 
1147  if( selection.Size() < 2 )
1148  return 0;
1149 
1150  int netcode = -1;
1151 
1152  ZONE_CONTAINER* firstZone = nullptr;
1153  std::vector<ZONE_CONTAINER*> toMerge, merged;
1154 
1155  for( auto item : selection )
1156  {
1157  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
1158 
1159  if( !curr_area )
1160  continue;
1161 
1162  if( !firstZone )
1163  firstZone = curr_area;
1164 
1165  netcode = curr_area->GetNetCode();
1166 
1167  if( firstZone->GetNetCode() != netcode )
1168  continue;
1169 
1170  if( curr_area->GetPriority() != firstZone->GetPriority() )
1171  continue;
1172 
1173  if( curr_area->GetIsRuleArea() != firstZone->GetIsRuleArea() )
1174  continue;
1175 
1176  if( curr_area->GetLayer() != firstZone->GetLayer() )
1177  continue;
1178 
1179  if( !board->TestAreaIntersection( curr_area, firstZone ) )
1180  continue;
1181 
1182  toMerge.push_back( curr_area );
1183  }
1184 
1186 
1187  if( mergeZones( commit, toMerge, merged ) )
1188  {
1189  commit.Push( "Merge zones" );
1190 
1191  for( auto item : merged )
1193  }
1194 
1195  return 0;
1196 }
1197 
1198 
1200 {
1202  const SELECTION& selection = selTool->GetSelection();
1203 
1204  // because this pops up the zone editor, it would be confusing to handle multiple zones,
1205  // so just handle single selections containing exactly one zone
1206  if( selection.Size() != 1 )
1207  return 0;
1208 
1209  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1210 
1211  if( !oldZone )
1212  return 0;
1213 
1214  ZONE_SETTINGS zoneSettings;
1215  zoneSettings << *oldZone;
1216  int dialogResult;
1217 
1218  if( oldZone->GetIsRuleArea() )
1219  dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings );
1220  else if( oldZone->IsOnCopperLayer() )
1221  dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1222  else
1223  dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1224 
1225  if( dialogResult != wxID_OK )
1226  return 0;
1227 
1228  // duplicate the zone
1229  BOARD_COMMIT commit( m_frame );
1230 
1231  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
1232  newZone->ClearSelected();
1233  newZone->UnFill();
1234  zoneSettings.ExportSetting( *newZone );
1235 
1236  // If the new zone is on the same layer(s) as the the initial zone,
1237  // offset it a bit so it can more easily be picked.
1238  if( oldZone->GetIsRuleArea() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
1239  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1240  else if( !oldZone->GetIsRuleArea() && zoneSettings.m_Layers.test( oldZone->GetLayer() ) )
1241  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1242 
1243  commit.Add( newZone.release() );
1244  commit.Push( _( "Duplicate zone" ) );
1245 
1246  return 0;
1247 }
1248 
1249 
1251 {
1254 
1255  if( selection.Empty() )
1256  return 0;
1257 
1259 
1260  if( !fp )
1261  return 0;
1262 
1263  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1264 
1265  auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1266 
1267  editor->Load_Module_From_BOARD( fp );
1268 
1269  editor->Show( true );
1270  editor->Raise(); // Iconize( false );
1271 
1272  if( selection.IsHover() )
1274 
1275  return 0;
1276 }
1277 
1278 
1280  EDA_ITEM* originViewItem, const VECTOR2D& aPosition )
1281 {
1282  aFrame->GetDesignSettings().m_AuxOrigin = (wxPoint) aPosition;
1283  originViewItem->SetPosition( (wxPoint) aPosition );
1284  aView->MarkDirty();
1285  aFrame->OnModify();
1286 }
1287 
1288 
1290 {
1291  std::string tool = aEvent.GetCommandStr().get();
1293 
1294  // Deactivate other tools; particularly important if another PICKER is currently running
1295  Activate();
1296 
1297  picker->SetClickHandler(
1298  [this] ( const VECTOR2D& pt ) -> bool
1299  {
1301  DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
1302  return false; // drill origin is a one-shot; don't continue with tool
1303  } );
1304 
1305  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1306 
1307  return 0;
1308 }
1309 
1310 
1312 {
1313  view()->SetMirror( !view()->IsMirroredX(), false );
1314  view()->RecacheAllItems();
1315  frame()->GetCanvas()->ForceRefresh();
1317  return 0;
1318 }
1319 
1320 
1322 {
1323  Go( &PCB_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1324  Go( &PCB_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1325  Go( &PCB_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1329  Go( &PCB_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1330 
1341 
1342  // Track & via size control
1347 
1348  // Zone actions
1351 
1352  // Placing tools
1356 
1358 
1359  // Other
1363 
1371 }
1372 
1373 
1374 const int PCB_EDITOR_CONTROL::WIDTH_STEP = 100000;
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 TOOL_ACTION toggleLock
Definition: pcb_actions.h:412
void RollbackFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
Definition: undo_redo.cpp:627
void SetLink(const KIID &aLink)
Definition: class_module.h:552
Struct VIA_DIMENSION is a small helper container to handle a stock of specific vias each with unique ...
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
static TOOL_ACTION placeModule
Definition: pcb_actions.h:161
bool IsCurrentTool(const TOOL_ACTION &aAction) const
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:61
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
int ZoneMerge(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:414
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
int GetNetCode() const
Function GetNetCode.
int PlaceModule(const TOOL_EVENT &aEvent)
Function PlaceModule() Displays a dialog to select a module to be added and allows the user to set it...
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
KIID niluuid(0)
bool IsHover() const
Definition: selection.h:71
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Pointer to the currently used edit frame.
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:330
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
BOARD * board() const
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:340
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:253
This file is part of the common library TODO brief description.
static TOOL_ACTION pageSettings
Definition: actions.h:59
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:168
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:284
Model changes (required full reload)
Definition: tool_base.h:82
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:159
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:427
virtual void OnDisplayOptionsChanged()
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
int Open(const TOOL_EVENT &aEvent)
static TOOL_ACTION lock
Definition: pcb_actions.h:413
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:43
This file is part of the common library.
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:327
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:303
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:296
std::vector< int > m_TrackWidthList
void ToPlotter(int aID)
Function ToPlotter Open a dialog frame to create plot and drill files relative to the current board.
void SetSize(int aSize)
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
static constexpr double IU_PER_MM
Mock up a conversion function.
VIEW_CONTROLS class definition.
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: class_board.h:303
PCB_GROUP is a set of BOARD_ITEMs (i.e., without duplicates)
int TrackWidthDec(const TOOL_EVENT &aEvent)
int GetSize() const
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Creates a functor that tests if the selected items are only of given types.
SELECTION_TOOL.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
virtual void Revert() override
Revertes the commit by restoring the modifed items state.
int UpdateSchematicFromPCB(const TOOL_EVENT &aEvent)
MARKERS & Markers()
Definition: class_board.h:293
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
int GenerateDrillFiles(const TOOL_EVENT &aEvent)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1377
int ShowEeschema(const TOOL_EVENT &aEvent)
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.
int BoardSetup(const TOOL_EVENT &aEvent)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:106
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:357
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:214
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:120
void SetWksFileName(const wxString &aFilename)
int ImportSpecctraSession(const TOOL_EVENT &aEvent)
PADS & Pads()
Definition: class_module.h:182
void RecreateBOMFileFromBoard(wxCommandEvent &aEvent)
Function RecreateBOMFileFromBoard Creates a BOM file from the current loaded board.
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:295
TOOL_MENU & GetToolMenu()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:457
MODULE * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Function SelectFootprintFromLibTree opens a dialog to select a footprint.
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:342
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:558
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
static TOOL_ACTION showLayersManager
Definition: pcb_actions.h:341
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:161
virtual void Clear()
Function Clear() Removes all the stored items from the group.
Definition: view_group.cpp:74
virtual void SetLocked(bool aLocked)
Function SetLocked modifies 'lock' status for of the item.
void SetMirror(bool aMirrorX, bool aMirrorY)
Function SetMirror() Controls the mirroring of the VIEW.
Definition: view.cpp:546
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
bool TestAreaIntersection(ZONE_CONTAINER *area_ref, ZONE_CONTAINER *area_to_test)
Test for intersection of 2 copper areas.
const wxString & GetFileName() const
Definition: class_board.h:279
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION generateReportFile
Definition: pcb_actions.h:333
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:302
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor 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
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:76
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:213
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:185
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:334
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:171
static TOOL_ACTION saveCopyAs
Definition: actions.h:56
void SetWidth(int aWidth)
Definition: class_track.h:109
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
int Save(const TOOL_EVENT &aEvent)
MODIFY_MODE
How to modify a property for selected items.
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
static TOOL_ACTION pickerTool
Definition: actions.h:153
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:84
int GetLineThickness(PCB_LAYER_ID aLayer) const
Function GetLineThickness Returns the default graphic segment thickness from the layer class for the ...
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:294
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: kiid.h:44
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
Markers used to show a drc problem on boards.
int GetWidth() const
void GenFootprintsReport(wxCommandEvent &event)
Function GenFootprintsReport Calls DoGenFootprintsReport to create a footprint reprot file See DoGenF...
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:162
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
Generic tool for picking a point.
const PCBNEW_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:221
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList, bool aRedoCommand, bool aRebuildRatsnet=true)
Function PutDataInPreviousState Used in undo or redo command.
Definition: undo_redo.cpp:383
int ViaSizeDec(const TOOL_EVENT &aEvent)
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:194
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:325
#define NULL
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition: page_info.h:40
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:343
MODULES & Modules()
Definition: class_board.h:284
DRAWING_TOOL.
Definition: drawing_tool.h:50
int TrackWidthInc(const TOOL_EVENT &aEvent)
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, SELECTION_TOOL *sTool)
Function FootprintFilter() A selection filter which prunes the selection to contain only items of typ...
Definition: edit_tool.cpp:1693
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
static TOOL_ACTION open
Definition: actions.h:53
int Plot(const TOOL_EVENT &aEvent)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION doNew
Definition: actions.h:47
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void SetPosition(const wxPoint &aPos) override
TOOL_EVENT.
Definition: tool_event.h:171
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)
Function EDA_FILE_SELECTOR.
Definition: gestfich.cpp:51
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:306
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
int SaveAs(const TOOL_EVENT &aEvent)
KIGFX::PCB_VIEW * view() const
Definition of file extensions used in Kicad.
bool ToolStackIsEmpty()
Definition: tools_holder.h:136
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
Low-level access (below undo) to setting the drill origin
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:231
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
PopCommandFromUndoList return the last command to undo and remove it from list nothing is deleted.
int DrillOrigin(const TOOL_EVENT &aEvent)
Runs the drill origin tool for setting the origin for drill and pick-and-place files.
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
static TOOL_ACTION plot
Definition: actions.h:61
int GeneratePosFile(const TOOL_EVENT &aEvent)
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
void SetPosition(const wxPoint &aPos) override
PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
int ViaSizeInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION showEeschema
Definition: pcb_actions.h:430
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
void ExportSetting(ZONE_CONTAINER &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
static TOOL_ACTION generatePosFile
Definition: pcb_actions.h:332
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:158
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:160
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
const std::string SpecctraDsnFileExtension
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:305
int UnlockSelected(const TOOL_EVENT &aEvent)
Unlocks selected items.
KIGFX::VIEW * getView() const
Function getView()
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)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
static TOOL_ACTION boardSetup
Definition: pcb_actions.h:312
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: class_zone.h:728
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
void SetOrientation(double aNewAngle)
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:304
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
int New(const TOOL_EVENT &aEvent)
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:327
int SaveCopyAs(const TOOL_EVENT &aEvent)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:309
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:437
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:335
static const KICAD_T LockableItems[]
A scan list for TRACKS, VIAS, MODULES.
Definition: collectors.h:318
MODE
The possible drawing modes of DRAWING_TOOL
Definition: drawing_tool.h:63
int TogglePythonConsole(const TOOL_EVENT &aEvent)
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
int GenerateFabFiles(const TOOL_EVENT &aEvent)
virtual bool IsLocked() const
Function IsLocked.
ZONE_CONTAINERS & Zones()
Definition: class_board.h:290
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:328
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:106
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
KIGFX::VIEW_CONTROLS * controls() const
int GetWidth() const
Definition: class_track.h:110
int FlipPcbView(const TOOL_EVENT &aEvent)
const char * name
Definition: DXF_plotter.cpp:59
Common, abstract interface for edit frames.
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
PCB_EDIT_FRAME * m_frame
static TOOL_ACTION saveAs
Definition: actions.h:55
int PlaceTarget(const TOOL_EVENT &aEvent)
Function PlaceTarget() Allows user to place a layer alignment target.
const BITMAP_OPAQUE locked_xpm[1]
Definition: locked.cpp:42
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void GenD356File(wxCommandEvent &event)
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:186
static const int WIDTH_STEP
Place & drill origin marker
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION repairBoard
Definition: pcb_actions.h:433
int modifyLockSelected(MODIFY_MODE aMode)
int ImportNetlist(const TOOL_EVENT &aEvent)
int ToggleLayersManager(const TOOL_EVENT &aEvent)
int UpdatePCBFromSchematic(const TOOL_EVENT &aEvent)
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
Function SaveCopyInUndoList Creates a new entry in undo list of commands.
Definition: undo_redo.cpp:179
int EditFpInFpEditor(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Creates a functor that tests if the selected items are only of given type.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:486
PCBNEW_SETTINGS & Settings()
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: eda_item.h:148
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
std::vector< VIA_DIMENSION > m_ViasDimensionsList
T * FirstOfKind() const
Definition: selection.h:195
void SetWidth(int aWidth)
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)
Function Files_io_from_id Read and write board files.
void Activate()
Function Activate() Runs the tool.
Definition: id.h:97
const BITMAP_OPAQUE add_zone_xpm[1]
Definition: add_zone.cpp:59
PCB_TARGET class definition.
wxString SpecctraDsnFileWildcard()
ACTION_MENU * create() const override
Returns 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:97
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:59
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:327
wxPoint GetPosition() const override
Definition: class_module.h:201
ACTION_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes.
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:291
BOARD * GetBoard() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VIEW.
Definition: view.h:63
int PageSettings(const TOOL_EVENT &aEvent)
MODE GetDrawingMode() const
Function GetDrawingMode.
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE_CONTAINER * > &aOriginZones, std::vector< ZONE_CONTAINER * > &aMergedZones)
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:268
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:274
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Toggles 'lock' property for selected items.
static constexpr int Millimeter2iu(double mm)
Rendering engine changes.
Definition: tool_base.h:83
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
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.
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:297
DRAWINGS & Drawings()
Definition: class_board.h:287
void setTransitions() override
Sets up handlers for various events.
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
int RepairBoard(const TOOL_EVENT &aEvent)
wxPoint m_AuxOrigin
origin for plot exports
bool FetchNetlistFromSchematic(NETLIST &aNetlist, FETCH_NETLIST_MODE aMode)
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
TRACKS & Tracks()
Definition: class_board.h:281
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:59
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:596
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...
static TOOL_ACTION refreshPreview
Definition: actions.h:104
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:121
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1513
Class to handle a set of BOARD_ITEMs.
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
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:331
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100