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 <bitmaps.h>
31 #include <board_commit.h>
32 #include <class_board.h>
33 #include <class_module.h>
34 #include <class_track.h>
35 #include <class_pcb_target.h>
36 #include <class_zone.h>
37 #include <collectors.h>
38 #include <confirm.h>
39 #include <cstdint>
42 #include <functional>
43 #include <gestfich.h>
44 #include <kiface_i.h>
45 #include <kiway.h>
46 #include <memory>
48 #include <origin_viewitem.h>
49 #include <painter.h>
50 #include <pcb_edit_frame.h>
51 #include <pcbnew_id.h>
52 #include <pcbnew_settings.h>
53 #include <project.h>
54 #include <tool/tool_manager.h>
55 #include <tools/tool_event_utils.h>
56 #include <view/view_controls.h>
57 #include <view/view_group.h>
59 #include <ws_proxy_undo_item.h>
60 
61 using namespace std::placeholders;
62 
63 
65 {
66 public:
68  ACTION_MENU( true )
69  {
70  SetIcon( add_zone_xpm );
71  SetTitle( _( "Zones" ) );
72 
73  Add( PCB_ACTIONS::zoneFill );
77 
78  AppendSeparator();
79 
84  }
85 
86 
87 protected:
88  ACTION_MENU* create() const override
89  {
90  return new ZONE_CONTEXT_MENU();
91  }
92 
93 private:
94  void update() override
95  {
96  SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
97 
98  // enable zone actions that act on a single zone
99  bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 ) &&
101  )( selTool->GetSelection() );
102 
103  Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
104  Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
105  Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
106 
107  // enable zone actions that ably to a specific set of zones (as opposed to all of them)
108  bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
109 
110  Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
111  Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
112 
113  // lines like this make me really think about a better name for SELECTION_CONDITIONS class
114  bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
115  /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
118 
119  Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
120  }
121 };
122 
123 
125 {
126 public:
128  ACTION_MENU( true )
129  {
130  SetIcon( locked_xpm );
131  SetTitle( _( "Locking" ) );
132 
133  Add( PCB_ACTIONS::lock );
134  Add( PCB_ACTIONS::unlock );
136  }
137 
138  ACTION_MENU* create() const override
139  {
140  return new LOCK_CONTEXT_MENU();
141  }
142 };
143 
144 
146  PCB_TOOL_BASE( "pcbnew.EditorControl" ),
147  m_frame( nullptr )
148 {
149  m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
151 }
152 
153 
155 {
156 }
157 
158 
160 {
161  m_frame = getEditFrame<PCB_EDIT_FRAME>();
162 
163  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
164  {
165  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
166  getView()->Remove( m_placeOrigin.get() );
167  getView()->Add( m_placeOrigin.get() );
168  }
169 }
170 
171 
173 {
174  auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
175  return ( !m_frame->ToolStackIsEmpty() );
176  };
177 
178  auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
179  return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
180  };
181 
182  auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
183  return ( m_frame->IsCurrentTool( PCB_ACTIONS::placeModule ) && aSel.GetSize() == 0 );
184  };
185 
186  auto& ctxMenu = m_menu.GetMenu();
187 
188  // "Cancel" goes at the top of the context menu when a tool is active
189  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
190  ctxMenu.AddSeparator( 1 );
191 
192  // "Get and Place Footprint" should be available for Place Footprint tool
193  ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
194  ctxMenu.AddSeparator( 1000 );
195 
196  // Finally, add the standard zoom & grid items
197  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
198 
199  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
200  zoneMenu->SetTool( this );
201 
202  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
203  lockMenu->SetTool( this );
204 
205  // Add the PCB control menus to relevant other tools
206 
208 
209  if( selTool )
210  {
211  auto& toolMenu = selTool->GetToolMenu();
212  auto& menu = toolMenu.GetMenu();
213 
214  // Add "Get and Place Footprint" when Selection tool is in an inactive state
215  menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
216  menu.AddSeparator();
217 
218  toolMenu.AddSubMenu( zoneMenu );
219  toolMenu.AddSubMenu( lockMenu );
220 
221  menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ), 200 );
222  menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
223  }
224 
225  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
226 
227  if( drawingTool )
228  {
229  auto& toolMenu = drawingTool->GetToolMenu();
230  auto& menu = toolMenu.GetMenu();
231 
232  toolMenu.AddSubMenu( zoneMenu );
233 
234  // Functor to say if the PCB_EDIT_FRAME is in a given mode
235  // Capture the tool pointer and tool mode by value
236  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
237  {
238  return [=]( const SELECTION& sel )
239  {
240  return drawingTool->GetDrawingMode() == aMode;
241  };
242  };
243 
244  menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
245  }
246 
247  return true;
248 }
249 
250 
252 {
254  return 0;
255 }
256 
257 
259 {
261  return 0;
262 }
263 
264 
266 {
268  return 0;
269 }
270 
271 
273 {
275  return 0;
276 }
277 
278 
280 {
282  return 0;
283 }
284 
285 
287 {
288  PICKED_ITEMS_LIST undoCmd;
289  WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
290  ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
291 
292  undoCmd.PushItem( wrapper );
294 
298 
299  if( dlg.ShowModal() != wxID_OK )
301 
302  return 0;
303 }
304 
305 
307 {
309  return 0;
310 }
311 
312 
314 {
315  getEditFrame<PCB_EDIT_FRAME>()->DoShowBoardSetupDialog();
316  return 0;
317 }
318 
319 
321 {
322  getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
323  return 0;
324 }
325 
326 
328 {
329  wxString fullFileName = frame()->GetBoard()->GetFileName();
330  wxString path;
331  wxString name;
332  wxString ext;
333 
334  wxFileName::SplitPath( fullFileName, &path, &name, &ext );
335  name += wxT( ".ses" );
336 
337  fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), path, name,
338  wxT( ".ses" ), wxT( "*.ses" ), frame(), wxFD_OPEN, false );
339 
340  if( !fullFileName.IsEmpty() )
341  getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
342 
343  return 0;
344 }
345 
346 
348 {
349  wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
350  wxFileName fn;
351 
352  if( fullFileName.IsEmpty() )
353  {
354  fn = m_frame->GetBoard()->GetFileName();
355  fn.SetExt( SpecctraDsnFileExtension );
356  }
357  else
358  fn = fullFileName;
359 
360  fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
362  frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
363 
364  if( !fullFileName.IsEmpty() )
365  {
366  m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
367  getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
368  }
369 
370  return 0;
371 }
372 
373 
375 {
376  wxCommandEvent dummy;
377 
378  if( aEvent.IsAction( &PCB_ACTIONS::generateGerbers ) )
380  else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
382  else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
384  else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
386  else
387  wxFAIL_MSG( "GenerateFabFiles(): unexpected request" );
388 
389  return 0;
390 }
391 
392 
394 {
395  NETLIST netlist;
396 
398  {
399  DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
400  updateDialog.ShowModal();
401  }
402 
403  return 0;
404 }
405 
407 {
408  if( Kiface().IsSingle() )
409  {
411  m_frame, _( "Cannot update schematic because Pcbnew is opened in stand-alone "
412  "mode. In order to create or update PCBs from schematics, you "
413  "must launch the KiCad project manager and create a project." ) );
414  return 0;
415  }
416 
417  m_frame->RunEeschema();
419 
420  if( frame )
421  {
422  std::string payload;
424  }
425  return 0;
426 }
427 
428 
430 {
431  m_frame->RunEeschema();
432  return 0;
433 }
434 
435 
437 {
438  getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
439  return 0;
440 }
441 
442 
444 {
445  getEditFrame<PCB_EDIT_FRAME>()->ToggleMicrowaveToolbar();
446  return 0;
447 }
448 
449 
451 {
452 #if defined( KICAD_SCRIPTING_WXPYTHON )
453  m_frame->ScriptingConsoleEnableDisable();
454 #endif
455  return 0;
456 }
457 
458 
459 // Track & via size control
461 {
462  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
463  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
465 
467  {
468  BOARD_COMMIT commit( this );
469 
470  for( EDA_ITEM* item : selection )
471  {
472  if( item->Type() == PCB_TRACE_T )
473  {
474  TRACK* track = (TRACK*) item;
475 
476  for( int candidate : designSettings.m_TrackWidthList )
477  {
478  if( candidate > track->GetWidth() )
479  {
480  commit.Modify( track );
481  track->SetWidth( candidate );
482  break;
483  }
484  }
485  }
486  }
487 
488  commit.Push( "Increase Track Width" );
489  }
490  else
491  {
492  int widthIndex = designSettings.GetTrackWidthIndex() + 1;
493 
494  if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
495  widthIndex = designSettings.m_TrackWidthList.size() - 1;
496 
497  designSettings.SetTrackWidthIndex( widthIndex );
498  designSettings.UseCustomTrackViaSize( false );
499 
501  }
502 
503  return 0;
504 }
505 
506 
508 {
509  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
510  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
512 
514  {
515  BOARD_COMMIT commit( this );
516 
517  for( EDA_ITEM* item : selection )
518  {
519  if( item->Type() == PCB_TRACE_T )
520  {
521  TRACK* track = (TRACK*) item;
522 
523  for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 0; --i )
524  {
525  int candidate = designSettings.m_TrackWidthList[ i ];
526 
527  if( candidate < track->GetWidth() )
528  {
529  commit.Modify( track );
530  track->SetWidth( candidate );
531  break;
532  }
533  }
534  }
535  }
536 
537  commit.Push( "Decrease Track Width" );
538  }
539  else
540  {
541  int widthIndex = designSettings.GetTrackWidthIndex() - 1;
542 
543  if( widthIndex < 0 )
544  widthIndex = 0;
545 
546  designSettings.SetTrackWidthIndex( widthIndex );
547  designSettings.UseCustomTrackViaSize( false );
548 
550  }
551 
552  return 0;
553 }
554 
555 
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_VIA_T )
569  {
570  VIA* via = (VIA*) item;
571 
572  for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
573  {
574  if( candidate.m_Diameter > via->GetWidth() )
575  {
576  commit.Modify( via );
577  via->SetWidth( candidate.m_Diameter );
578  via->SetDrill( candidate.m_Drill );
579  break;
580  }
581  }
582  }
583  }
584 
585  commit.Push( "Increase Via Size" );
586  }
587  else
588  {
589  int sizeIndex = designSettings.GetViaSizeIndex() + 1;
590 
591  if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
592  sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
593 
594  designSettings.SetViaSizeIndex( sizeIndex );
595  designSettings.UseCustomTrackViaSize( false );
596 
598  }
599 
600  return 0;
601 }
602 
603 
605 {
606  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
607  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
609 
611  {
612  BOARD_COMMIT commit( this );
613 
614  for( EDA_ITEM* item : selection )
615  {
616  if( item->Type() == PCB_VIA_T )
617  {
618  VIA* via = (VIA*) item;
619 
620  for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
621  {
622  VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
623 
624  if( candidate.m_Diameter < via->GetWidth() )
625  {
626  commit.Modify( via );
627  via->SetWidth( candidate.m_Diameter );
628  via->SetDrill( candidate.m_Drill );
629  break;
630  }
631  }
632  }
633  }
634 
635  commit.Push( "Decrease Via Size" );
636  }
637  else
638  {
639  int sizeIndex = designSettings.GetViaSizeIndex() - 1;
640 
641  if( sizeIndex < 0 )
642  sizeIndex = 0;
643 
644  designSettings.SetViaSizeIndex( sizeIndex );
645  designSettings.UseCustomTrackViaSize( false );
646 
648  }
649 
650  return 0;
651 }
652 
653 
655 {
656  MODULE* module = aEvent.Parameter<MODULE*>();
658  BOARD_COMMIT commit( m_frame );
659  BOARD* board = getModel<BOARD>();
660 
662  controls->ShowCursor( true );
663  controls->SetSnapping( true );
664 
665  std::string tool = aEvent.GetCommandStr().get();
666  m_frame->PushTool( tool );
667  Activate();
668 
669  VECTOR2I cursorPos = controls->GetCursorPosition();
670  bool reselect = false;
671 
672  // Prime the pump
673  if( module )
674  {
675  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
678  }
679  else if( aEvent.HasPosition() )
681 
682  // Main loop: keep receiving events
683  while( TOOL_EVENT* evt = Wait() )
684  {
685  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
686  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
687 
688  if( reselect && module )
690 
691  auto cleanup = [&] ()
692  {
694  commit.Revert();
695  module = NULL;
696  };
697 
698  if( evt->IsCancelInteractive() )
699  {
700  if( module )
701  cleanup();
702  else
703  {
704  m_frame->PopTool( tool );
705  break;
706  }
707  }
708 
709  else if( evt->IsActivate() )
710  {
711  if( module )
712  cleanup();
713 
714  if( evt->IsMoveTool() )
715  {
716  // leave ourselves on the stack so we come back after the move
717  break;
718  }
719  else
720  {
721  frame()->PopTool( tool );
722  break;
723  }
724  }
725 
726  else if( evt->IsClick( BUT_LEFT ) )
727  {
728  if( !module )
729  {
730  // Pick the module to be placed
732 
733  if( module == NULL )
734  continue;
735 
736  module->SetLink( niluuid );
737 
738  module->SetFlags( IS_NEW ); // whatever
739 
740  // Set parent so that clearance can be loaded
741  module->SetParent( board );
742 
743  // Put it on FRONT layer,
744  // (Can be stored flipped if the lib is an archive built from a board)
745  if( module->IsFlipped() )
747 
748  module->SetOrientation( 0 );
749  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
750 
751  commit.Add( module );
753  controls->SetCursorPosition( cursorPos, false );
754  }
755  else
756  {
758  commit.Push( _( "Place a module" ) );
759  module = NULL; // to indicate that there is no module that we currently modify
760  }
761  }
762 
763  else if( evt->IsClick( BUT_RIGHT ) )
764  {
766  }
767 
768  else if( module && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
769  {
770  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
771  selection().SetReferencePoint( cursorPos );
772  getView()->Update( & selection() );
773  }
774 
775  else if( module && evt->IsAction( &PCB_ACTIONS::properties ) )
776  {
777  // Calling 'Properties' action clears the selection, so we need to restore it
778  reselect = true;
779  }
780 
781  else
782  evt->SetPassEvent();
783 
784  // Enable autopanning and cursor capture only when there is a module to be placed
785  controls->SetAutoPan( !!module );
787  }
788 
789  return 0;
790 }
791 
792 
794 {
795  return modifyLockSelected( TOGGLE );
796 }
797 
798 
800 {
801  return modifyLockSelected( ON );
802 }
803 
804 
806 {
807  return modifyLockSelected( OFF );
808 }
809 
810 
812 {
814  const PCBNEW_SELECTION& selection = selTool->GetSelection();
815  BOARD_COMMIT commit( m_frame );
816 
817  if( selection.Empty() )
819 
820  bool modified = false;
821 
822  for( EDA_ITEM* item : selection )
823  {
824  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
825  bool prevState = board_item->IsLocked();
826 
827  commit.Modify( board_item );
828 
829  switch( aMode )
830  {
831  case ON: board_item->SetLocked( true ); break;
832  case OFF: board_item->SetLocked( false ); break;
833  case TOGGLE: board_item->SetLocked( !prevState ); break;
834  }
835 
836  // Check if we really modified an item
837  if( !modified && prevState != board_item->IsLocked() )
838  modified = true;
839  }
840 
841  if( modified )
842  {
843  switch( aMode )
844  {
845  case ON: commit.Push( _( "Lock" ) ); break;
846  case OFF: commit.Push( _( "Unlock" ) ); break;
847  case TOGGLE: commit.Push( _( "Toggle Locking" ) ); break;
848  }
849 
851  m_frame->OnModify();
852  }
853 
854  return 0;
855 }
856 
857 
859 {
860  KIGFX::VIEW* view = getView();
862  BOARD* board = getModel<BOARD>();
863  PCB_TARGET* target = new PCB_TARGET( board );
864 
865  // Init the new item attributes
866  target->SetLayer( Edge_Cuts );
868  target->SetSize( Millimeter2iu( 5 ) );
869  VECTOR2I cursorPos = controls->GetCursorPosition();
870  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
871 
872  // Add a VIEW_GROUP that serves as a preview for the new item
873  KIGFX::VIEW_GROUP preview( view );
874  preview.Add( target );
875  view->Add( &preview );
876 
878  controls->SetSnapping( true );
879 
880  std::string tool = aEvent.GetCommandStr().get();
881  m_frame->PushTool( tool );
882  Activate();
883 
884  // Main loop: keep receiving events
885  while( TOOL_EVENT* evt = Wait() )
886  {
887  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
888  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
889 
890  if( evt->IsCancelInteractive() )
891  {
892  frame()->PopTool( tool );
893  break;
894  }
895 
896  else if( evt->IsActivate() )
897  {
898  if( evt->IsMoveTool() )
899  {
900  // leave ourselves on the stack so we come back after the move
901  break;
902  }
903  else
904  {
905  frame()->PopTool( tool );
906  break;
907  }
908  }
909 
910  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
911  {
912  target->SetWidth( target->GetWidth() + WIDTH_STEP );
913  view->Update( &preview );
914  }
915 
916  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
917  {
918  int width = target->GetWidth();
919 
920  if( width > WIDTH_STEP )
921  {
922  target->SetWidth( width - WIDTH_STEP );
923  view->Update( &preview );
924  }
925  }
926 
927  else if( evt->IsClick( BUT_LEFT ) )
928  {
929  assert( target->GetSize() > 0 );
930  assert( target->GetWidth() > 0 );
931 
932  BOARD_COMMIT commit( m_frame );
933  commit.Add( target );
934  commit.Push( _( "Place a layer alignment target" ) );
935 
936  preview.Remove( target );
937 
938  // Create next PCB_TARGET
939  target = new PCB_TARGET( *target );
940  preview.Add( target );
941  }
942 
943  else if( evt->IsClick( BUT_RIGHT ) )
944  {
946  }
947 
948  else if( evt->IsMotion() )
949  {
950  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
951  view->Update( &preview );
952  }
953 
954  else
955  evt->SetPassEvent();
956  }
957 
958  preview.Clear();
959  delete target;
960  view->Remove( &preview );
961  controls->SetSnapping( false );
962  return 0;
963 }
964 
965 
966 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
967  std::vector<ZONE_CONTAINER *>& aMergedZones )
968 {
969  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
970  {
971  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
973  }
974 
975  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
976 
977  // We should have one polygon with hole
978  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
979  // and therefore cannot be merged (they are dectected as intersecting)
980  // but we should never have more than 2 polys
981  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
982  {
983  wxLogMessage( "BOARD::CombineAreas error: more than 2 polys after merging" );
984  return false;
985  }
986 
987  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
988  {
989  aCommit.Remove( aOriginZones[i] );
990  }
991 
992  aCommit.Modify( aOriginZones[0] );
993  aMergedZones.push_back( aOriginZones[0] );
994 
995  aOriginZones[0]->SetLocalFlags( 1 );
996  aOriginZones[0]->Hatch();
997  aOriginZones[0]->CacheTriangulation();
998 
999  return true;
1000 }
1001 
1002 
1004 {
1005  const PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1006  BOARD* board = getModel<BOARD>();
1007  BOARD_COMMIT commit( m_frame );
1008 
1009  if( selection.Size() < 2 )
1010  return 0;
1011 
1012  int netcode = -1;
1013 
1014  ZONE_CONTAINER* firstZone = nullptr;
1015  std::vector<ZONE_CONTAINER*> toMerge, merged;
1016 
1017  for( auto item : selection )
1018  {
1019  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
1020 
1021  if( !curr_area )
1022  continue;
1023 
1024  if( !firstZone )
1025  firstZone = curr_area;
1026 
1027  netcode = curr_area->GetNetCode();
1028 
1029  if( firstZone->GetNetCode() != netcode )
1030  continue;
1031 
1032  if( curr_area->GetPriority() != firstZone->GetPriority() )
1033  continue;
1034 
1035  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
1036  continue;
1037 
1038  if( curr_area->GetLayer() != firstZone->GetLayer() )
1039  continue;
1040 
1041  if( !board->TestAreaIntersection( curr_area, firstZone ) )
1042  continue;
1043 
1044  toMerge.push_back( curr_area );
1045  }
1046 
1048 
1049  if( mergeZones( commit, toMerge, merged ) )
1050  {
1051  commit.Push( _( "Merge zones" ) );
1052 
1053  for( auto item : merged )
1055  }
1056 
1057  return 0;
1058 }
1059 
1060 
1062 {
1063  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1064  const auto& selection = selTool->GetSelection();
1065 
1066  // because this pops up the zone editor, it would be confusing to handle multiple zones,
1067  // so just handle single selections containing exactly one zone
1068  if( selection.Size() != 1 )
1069  return 0;
1070 
1071  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1072 
1073  if( !oldZone )
1074  return 0;
1075 
1076  ZONE_SETTINGS zoneSettings;
1077  zoneSettings << *oldZone;
1078  int dialogResult;
1079 
1080  if( oldZone->GetIsKeepout() )
1081  dialogResult = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
1082  else if( oldZone->IsOnCopperLayer() )
1083  dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1084  else
1085  dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1086 
1087  if( dialogResult != wxID_OK )
1088  return 0;
1089 
1090  // duplicate the zone
1091  BOARD_COMMIT commit( m_frame );
1092 
1093  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
1094  newZone->ClearSelected();
1095  newZone->UnFill();
1096  zoneSettings.ExportSetting( *newZone );
1097 
1098  // If the new zone is on the same layer(s) as the the initial zone,
1099  // offset it a bit so it can more easily be picked.
1100  if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
1101  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1102  else if( !oldZone->GetIsKeepout() && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
1103  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1104 
1105  commit.Add( newZone.release() );
1106  commit.Push( _( "Duplicate zone" ) );
1107 
1108  return 0;
1109 }
1110 
1111 
1113  BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
1114 {
1115  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
1116  originViewItem->SetPosition( wxPoint( aPosition.x, aPosition.y ) );
1117  aView->MarkDirty();
1118  aFrame->OnModify();
1119 }
1120 
1121 
1123 {
1124  std::string tool = aEvent.GetCommandStr().get();
1126 
1127  // Deactivate other tools; particularly important if another PICKER is currently running
1128  Activate();
1129 
1130  picker->SetClickHandler(
1131  [this] ( const VECTOR2D& pt ) -> bool
1132  {
1134  DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
1135  return false; // drill origin is a one-shot; don't continue with tool
1136  } );
1137 
1138  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1139 
1140  return 0;
1141 }
1142 
1143 
1145 {
1146  view()->SetMirror( !view()->IsMirroredX(), false );
1147  view()->RecacheAllItems();
1148  frame()->Refresh();
1149  return 0;
1150 }
1151 
1152 
1154 {
1155  Go( &PCB_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1156  Go( &PCB_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1157  Go( &PCB_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1161  Go( &PCB_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1162 
1173 
1174  // Track & via size control
1179 
1180  // Zone actions
1183 
1184  // Placing tools
1188 
1189  // Other
1193 
1201 }
1202 
1203 
1204 const int PCB_EDITOR_CONTROL::WIDTH_STEP = 100000;
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:399
void RollbackFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
Definition: undo_redo.cpp:607
void SetLink(const KIID &aLink)
Definition: class_module.h:550
Struct VIA_DIMENSION is a small helper container to handle a stock of specific vias each with unique ...
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
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:60
static TOOL_ACTION placeModule
Definition: pcb_actions.h:160
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:59
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:401
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
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...
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Pointer to the currently used edit frame.
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:316
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
int InvokeKeepoutAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeKeepoutAreaEditor invokes up a modal dialog window for copper zone editing.
BOARD * board() const
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
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:167
virtual void SetPosition(const wxPoint &aPos)=0
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:292
Model changes (required full reload)
Definition: tool_base.h:81
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:158
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:414
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
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:400
ACTION_MENU.
Definition: action_menu.h:43
This file is part of the common library.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:291
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:284
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)
static SELECTION_CONDITION MoreThan(int aNumber)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
VIEW_CONTROLS class definition.
int TrackWidthDec(const TOOL_EVENT &aEvent)
int GetSize() const
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Function OnlyTypes 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)
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:218
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
int ShowEeschema(const TOOL_EVENT &aEvent)
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
int BoardSetup(const TOOL_EVENT &aEvent)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:213
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)
void RecreateBOMFileFromBoard(wxCommandEvent &aEvent)
Function RecreateBOMFileFromBoard Creates a BOM file from the current loaded board.
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:283
TOOL_MENU & GetToolMenu()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:428
MODULE * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Function SelectFootprintFromLibTree opens a dialog to select a footprint.
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:287
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:329
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:512
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:327
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:156
int ToggleMicrowaveToolbar(const TOOL_EVENT &aEvent)
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:565
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
bool TestAreaIntersection(ZONE_CONTAINER *area_ref, ZONE_CONTAINER *area_to_test)
Function TestAreaIntersection Test for intersection of 2 copper areas area_to_test must be after area...
const wxString & GetFileName() const
Definition: class_board.h:218
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:319
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:290
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:74
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:205
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:320
Definitions for tracks, vias and zones.
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:170
static TOOL_ACTION saveCopyAs
Definition: actions.h:56
void SetWidth(int aWidth)
Definition: class_track.h:104
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:148
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
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:109
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.
PCB->SCH forward update.
Definition: mail_type.h:44
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:282
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
int GetWidth() const
void GenFootprintsReport(wxCommandEvent &event)
Function GenFootprintsReport Calls DoGenFootprintsReport to create a footprint reprot file See DoGenF...
static SELECTION_CONDITION SameLayer()
Function SameLayer Creates a functor that tests if selection contains items that belong exclusively t...
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:157
Generic tool for picking a point.
const PCBNEW_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
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:212
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:311
#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:341
DRAWING_TOOL.
Definition: drawing_tool.h:49
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:218
int TrackWidthInc(const TOOL_EVENT &aEvent)
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
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
KIID niluuid(0)
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:52
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:294
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
int SaveAs(const TOOL_EVENT &aEvent)
KIGFX::PCB_VIEW * view() const
Definition of file extensions used in Kicad.
static const KICAD_T Zones[]
A scan list for zones outlines only.
Definition: collectors.h:277
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:416
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
Function SaveCopyInUndoList Creates a new entry in undo list of commands.
Definition: undo_redo.cpp:182
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:318
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:157
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:159
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
const std::string SpecctraDsnFileExtension
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:293
int UnlockSelected(const TOOL_EVENT &aEvent)
Unlocks selected items.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
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:300
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:649
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:292
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *aItem, const VECTOR2D &aPoint)
Low-level access (below undo) to setting the drill origin
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:58
int New(const TOOL_EVENT &aEvent)
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:313
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:297
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:427
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:321
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:62
int TogglePythonConsole(const TOOL_EVENT &aEvent)
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
int GenerateFabFiles(const TOOL_EVENT &aEvent)
virtual bool IsLocked() const
Function IsLocked.
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:314
static TOOL_ACTION showMicrowaveToolbar
Definition: pcb_actions.h:328
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:100
KIGFX::VIEW_CONTROLS * controls() const
int GetWidth() const
Definition: class_track.h:105
int FlipPcbView(const TOOL_EVENT &aEvent)
bool ToolStackIsEmpty()
const char * name
Definition: DXF_plotter.cpp:60
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)
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
static const int WIDTH_STEP
Place & drill origin marker
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
void SetOrientation(double newangle)
int modifyLockSelected(MODIFY_MODE aMode)
int ImportNetlist(const TOOL_EVENT &aEvent)
int ToggleLayersManager(const TOOL_EVENT &aEvent)
int UpdatePCBFromSchematic(const TOOL_EVENT &aEvent)
void update() override
Update menu state stub.
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:76
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType 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:431
PCBNEW_SETTINGS & Settings()
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
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:78
std::vector< VIA_DIMENSION > m_ViasDimensionsList
void SetWidth(int aWidth)
virtual void PopTool(const std::string &actionName)
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:74
PCB_TARGET class definition.
wxString SpecctraDsnFileWildcard()
void SetAuxOrigin(const wxPoint &aPoint) override
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:58
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:346
ACTION_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes.
Module description (excepted pads)
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:279
BOARD * GetBoard() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VIEW.
Definition: view.h:61
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 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:267
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Toggles 'lock' property for selected items.
Rendering engine changes.
Definition: tool_base.h:82
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)
Function AddItem()
bool IsCurrentTool(const TOOL_ACTION &aAction) const
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
const wxPoint GetPosition() const override
Definition: class_module.h:210
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:285
void setTransitions() override
Sets up handlers for various events.
bool FetchNetlistFromSchematic(NETLIST &aNetlist, FETCH_NETLIST_MODE aMode)
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
Definition: zone_settings.h:88
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:70
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:610
static TOOL_ACTION refreshPreview
Definition: actions.h:101
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:118
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:317
static SELECTION_CONDITION SameNet(bool aAllowUnconnected=false)
Function SameNet Creates a functor that tests if selection contains items belonging to the same net o...
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:40