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-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 #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_pcb_target.h>
35 #include <class_zone.h>
36 #include <collectors.h>
37 #include <cstdint>
40 #include <functional>
41 #include <gestfich.h>
42 #include <memory>
44 #include <origin_viewitem.h>
45 #include <painter.h>
46 #include <pcb_edit_frame.h>
47 #include <pcbnew_id.h>
48 #include <project.h>
49 #include <tool/tool_manager.h>
50 #include <tools/tool_event_utils.h>
51 #include <view/view_controls.h>
52 #include <view/view_group.h>
54 #include <ws_proxy_undo_item.h>
55 
56 using namespace std::placeholders;
57 
58 
60 {
61 public:
63  ACTION_MENU( true )
64  {
65  SetIcon( add_zone_xpm );
66  SetTitle( _( "Zones" ) );
67 
68  Add( PCB_ACTIONS::zoneFill );
72 
73  AppendSeparator();
74 
79  }
80 
81 
82 protected:
83  ACTION_MENU* create() const override
84  {
85  return new ZONE_CONTEXT_MENU();
86  }
87 
88 private:
89  void update() override
90  {
91  SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
92 
93  // enable zone actions that act on a single zone
94  bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 ) &&
96  )( selTool->GetSelection() );
97 
98  Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
99  Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
100  Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
101 
102  // enable zone actions that ably to a specific set of zones (as opposed to all of them)
103  bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
104 
105  Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
106  Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
107 
108  // lines like this make me really think about a better name for SELECTION_CONDITIONS class
109  bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
110  /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
113 
114  Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
115  }
116 };
117 
118 
120 {
121 public:
123  ACTION_MENU( true )
124  {
125  SetIcon( locked_xpm );
126  SetTitle( _( "Locking" ) );
127 
128  Add( PCB_ACTIONS::lock );
129  Add( PCB_ACTIONS::unlock );
131  }
132 
133  ACTION_MENU* create() const override
134  {
135  return new LOCK_CONTEXT_MENU();
136  }
137 };
138 
139 
141  PCB_TOOL_BASE( "pcbnew.EditorControl" ),
142  m_frame( nullptr )
143 {
144  m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
146 }
147 
148 
150 {
151 }
152 
153 
155 {
156  m_frame = getEditFrame<PCB_EDIT_FRAME>();
157 
158  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
159  {
160  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
161  getView()->Remove( m_placeOrigin.get() );
162  getView()->Add( m_placeOrigin.get() );
163  }
164 }
165 
166 
168 {
169  auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
170  return ( !m_frame->ToolStackIsEmpty() );
171  };
172 
173  auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
174  return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
175  };
176 
177  auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
178  return ( m_frame->IsCurrentTool( PCB_ACTIONS::placeModule ) && aSel.GetSize() == 0 );
179  };
180 
181  auto& ctxMenu = m_menu.GetMenu();
182 
183  // "Cancel" goes at the top of the context menu when a tool is active
184  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
185  ctxMenu.AddSeparator( 1 );
186 
187  // "Get and Place Footprint" should be available for Place Footprint tool
188  ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
189  ctxMenu.AddSeparator( 1000 );
190 
191  // Finally, add the standard zoom & grid items
192  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
193 
194  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
195  zoneMenu->SetTool( this );
196 
197  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
198  lockMenu->SetTool( this );
199 
200  // Add the PCB control menus to relevant other tools
201 
203 
204  if( selTool )
205  {
206  auto& toolMenu = selTool->GetToolMenu();
207  auto& menu = toolMenu.GetMenu();
208 
209  // Add "Get and Place Footprint" when Selection tool is in an inactive state
210  menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
211  menu.AddSeparator();
212 
213  toolMenu.AddSubMenu( zoneMenu );
214  toolMenu.AddSubMenu( lockMenu );
215 
216  menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ), 200 );
217  menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
218  }
219 
220  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
221 
222  if( drawingTool )
223  {
224  auto& toolMenu = drawingTool->GetToolMenu();
225  auto& menu = toolMenu.GetMenu();
226 
227  toolMenu.AddSubMenu( zoneMenu );
228 
229  // Functor to say if the PCB_EDIT_FRAME is in a given mode
230  // Capture the tool pointer and tool mode by value
231  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
232  {
233  return [=]( const SELECTION& sel )
234  {
235  return drawingTool->GetDrawingMode() == aMode;
236  };
237  };
238 
239  menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
240  }
241 
242  return true;
243 }
244 
245 
247 {
249  return 0;
250 }
251 
252 
254 {
256  return 0;
257 }
258 
259 
261 {
263  return 0;
264 }
265 
266 
268 {
270  return 0;
271 }
272 
273 
275 {
277  return 0;
278 }
279 
280 
282 {
283  PICKED_ITEMS_LIST undoCmd;
284  WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
285  ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
286 
287  undoCmd.PushItem( wrapper );
289 
293 
294  if( dlg.ShowModal() != wxID_OK )
296 
297  return 0;
298 }
299 
300 
302 {
304  return 0;
305 }
306 
307 
309 {
310  getEditFrame<PCB_EDIT_FRAME>()->DoShowBoardSetupDialog();
311  return 0;
312 }
313 
314 
316 {
317  getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
318  return 0;
319 }
320 
321 
323 {
324  wxString fullFileName = frame()->GetBoard()->GetFileName();
325  wxString path;
326  wxString name;
327  wxString ext;
328 
329  wxFileName::SplitPath( fullFileName, &path, &name, &ext );
330  name += wxT( ".ses" );
331 
332  fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), path, name,
333  wxT( ".ses" ), wxT( "*.ses" ), frame(), wxFD_OPEN, false );
334 
335  if( !fullFileName.IsEmpty() )
336  getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
337 
338  return 0;
339 }
340 
341 
343 {
344  wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
345  wxFileName fn;
346 
347  if( fullFileName.IsEmpty() )
348  {
349  fn = m_frame->GetBoard()->GetFileName();
350  fn.SetExt( SpecctraDsnFileExtension );
351  }
352  else
353  fn = fullFileName;
354 
355  fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
357  frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
358 
359  if( !fullFileName.IsEmpty() )
360  {
361  m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
362  getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
363  }
364 
365  return 0;
366 }
367 
368 
370 {
371  wxCommandEvent dummy;
372 
373  if( aEvent.IsAction( &PCB_ACTIONS::generateGerbers ) )
375  else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
377  else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
379  else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
381  else
382  wxFAIL_MSG( "GenerateFabFiles(): unexpected request" );
383 
384  return 0;
385 }
386 
387 
389 {
390  NETLIST netlist;
391 
393  {
394  DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
395  updateDialog.ShowModal();
396  }
397 
398  return 0;
399 }
400 
401 
403 {
404  m_frame->RunEeschema();
405  return 0;
406 }
407 
408 
410 {
411  getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
412  return 0;
413 }
414 
415 
417 {
418  getEditFrame<PCB_EDIT_FRAME>()->ToggleMicrowaveToolbar();
419  return 0;
420 }
421 
422 
424 {
425 #if defined( KICAD_SCRIPTING_WXPYTHON )
426  m_frame->ScriptingConsoleEnableDisable();
427 #endif
428  return 0;
429 }
430 
431 
432 // Track & via size control
434 {
435  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
436  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
438 
440  {
441  BOARD_COMMIT commit( this );
442 
443  for( EDA_ITEM* item : selection )
444  {
445  if( item->Type() == PCB_TRACE_T )
446  {
447  TRACK* track = (TRACK*) item;
448 
449  for( int candidate : designSettings.m_TrackWidthList )
450  {
451  if( candidate > track->GetWidth() )
452  {
453  commit.Modify( track );
454  track->SetWidth( candidate );
455  break;
456  }
457  }
458  }
459  }
460 
461  commit.Push( "Increase Track Width" );
462  }
463  else
464  {
465  int widthIndex = designSettings.GetTrackWidthIndex() + 1;
466 
467  if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
468  widthIndex = designSettings.m_TrackWidthList.size() - 1;
469 
470  designSettings.SetTrackWidthIndex( widthIndex );
471  designSettings.UseCustomTrackViaSize( false );
472 
474  }
475 
476  return 0;
477 }
478 
479 
481 {
482  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
483  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
485 
487  {
488  BOARD_COMMIT commit( this );
489 
490  for( EDA_ITEM* item : selection )
491  {
492  if( item->Type() == PCB_TRACE_T )
493  {
494  TRACK* track = (TRACK*) item;
495 
496  for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 0; --i )
497  {
498  int candidate = designSettings.m_TrackWidthList[ i ];
499 
500  if( candidate < track->GetWidth() )
501  {
502  commit.Modify( track );
503  track->SetWidth( candidate );
504  break;
505  }
506  }
507  }
508  }
509 
510  commit.Push( "Decrease Track Width" );
511  }
512  else
513  {
514  int widthIndex = designSettings.GetTrackWidthIndex() - 1;
515 
516  if( widthIndex < 0 )
517  widthIndex = 0;
518 
519  designSettings.SetTrackWidthIndex( widthIndex );
520  designSettings.UseCustomTrackViaSize( false );
521 
523  }
524 
525  return 0;
526 }
527 
528 
530 {
531  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
532  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
534 
536  {
537  BOARD_COMMIT commit( this );
538 
539  for( EDA_ITEM* item : selection )
540  {
541  if( item->Type() == PCB_VIA_T )
542  {
543  VIA* via = (VIA*) item;
544 
545  for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
546  {
547  if( candidate.m_Diameter > via->GetWidth() )
548  {
549  commit.Modify( via );
550  via->SetWidth( candidate.m_Diameter );
551  via->SetDrill( candidate.m_Drill );
552  break;
553  }
554  }
555  }
556  }
557 
558  commit.Push( "Increase Via Size" );
559  }
560  else
561  {
562  int sizeIndex = designSettings.GetViaSizeIndex() + 1;
563 
564  if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
565  sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
566 
567  designSettings.SetViaSizeIndex( sizeIndex );
568  designSettings.UseCustomTrackViaSize( false );
569 
571  }
572 
573  return 0;
574 }
575 
576 
578 {
579  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
580  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
582 
584  {
585  BOARD_COMMIT commit( this );
586 
587  for( EDA_ITEM* item : selection )
588  {
589  if( item->Type() == PCB_VIA_T )
590  {
591  VIA* via = (VIA*) item;
592 
593  for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
594  {
595  VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
596 
597  if( candidate.m_Diameter < via->GetWidth() )
598  {
599  commit.Modify( via );
600  via->SetWidth( candidate.m_Diameter );
601  via->SetDrill( candidate.m_Drill );
602  break;
603  }
604  }
605  }
606  }
607 
608  commit.Push( "Decrease Via Size" );
609  }
610  else
611  {
612  int sizeIndex = designSettings.GetViaSizeIndex() - 1;
613 
614  if( sizeIndex < 0 )
615  sizeIndex = 0;
616 
617  designSettings.SetViaSizeIndex( sizeIndex );
618  designSettings.UseCustomTrackViaSize( false );
619 
621  }
622 
623  return 0;
624 }
625 
626 
628 {
629  MODULE* module = aEvent.Parameter<MODULE*>();
631  BOARD_COMMIT commit( m_frame );
632  BOARD* board = getModel<BOARD>();
633 
635  controls->ShowCursor( true );
636  controls->SetSnapping( true );
637 
638  std::string tool = aEvent.GetCommandStr().get();
639  m_frame->PushTool( tool );
640  Activate();
641 
642  VECTOR2I cursorPos = controls->GetCursorPosition();
643  bool reselect = false;
644 
645  // Prime the pump
646  if( module )
647  {
648  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
651  }
652  else if( aEvent.HasPosition() )
654 
655  // Main loop: keep receiving events
656  while( TOOL_EVENT* evt = Wait() )
657  {
658  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
659  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
660 
661  if( reselect && module )
663 
664  auto cleanup = [&] ()
665  {
667  commit.Revert();
668  module = NULL;
669  };
670 
671  if( evt->IsCancelInteractive() )
672  {
673  if( module )
674  cleanup();
675  else
676  {
677  m_frame->PopTool( tool );
678  break;
679  }
680  }
681 
682  else if( evt->IsActivate() )
683  {
684  if( module )
685  cleanup();
686 
687  if( evt->IsMoveTool() )
688  {
689  // leave ourselves on the stack so we come back after the move
690  break;
691  }
692  else
693  {
694  frame()->PopTool( tool );
695  break;
696  }
697  }
698 
699  else if( evt->IsClick( BUT_LEFT ) )
700  {
701  if( !module )
702  {
703  // Pick the module to be placed
705 
706  if( module == NULL )
707  continue;
708 
709  module->SetLink( 0 );
710 
711  module->SetFlags( IS_NEW ); // whatever
713 
714  // Set parent so that clearance can be loaded
715  module->SetParent( board );
716 
717  // Put it on FRONT layer,
718  // (Can be stored flipped if the lib is an archive built from a board)
719  if( module->IsFlipped() )
721 
722  module->SetOrientation( 0 );
723  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
724 
725  commit.Add( module );
727  controls->SetCursorPosition( cursorPos, false );
728  }
729  else
730  {
732  commit.Push( _( "Place a module" ) );
733  module = NULL; // to indicate that there is no module that we currently modify
734  }
735  }
736 
737  else if( evt->IsClick( BUT_RIGHT ) )
738  {
740  }
741 
742  else if( module && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
743  {
744  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
745  selection().SetReferencePoint( cursorPos );
746  getView()->Update( & selection() );
747  }
748 
749  else if( module && evt->IsAction( &PCB_ACTIONS::properties ) )
750  {
751  // Calling 'Properties' action clears the selection, so we need to restore it
752  reselect = true;
753  }
754 
755  else
756  evt->SetPassEvent();
757 
758  // Enable autopanning and cursor capture only when there is a module to be placed
759  controls->SetAutoPan( !!module );
761  }
762 
763  return 0;
764 }
765 
766 
768 {
769  return modifyLockSelected( TOGGLE );
770 }
771 
772 
774 {
775  return modifyLockSelected( ON );
776 }
777 
778 
780 {
781  return modifyLockSelected( OFF );
782 }
783 
784 
786 {
788  const PCBNEW_SELECTION& selection = selTool->GetSelection();
789  BOARD_COMMIT commit( m_frame );
790 
791  if( selection.Empty() )
793 
794  bool modified = false;
795 
796  for( EDA_ITEM* item : selection )
797  {
798  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
799  bool prevState = board_item->IsLocked();
800 
801  commit.Modify( board_item );
802 
803  switch( aMode )
804  {
805  case ON: board_item->SetLocked( true ); break;
806  case OFF: board_item->SetLocked( false ); break;
807  case TOGGLE: board_item->SetLocked( !prevState ); break;
808  }
809 
810  // Check if we really modified an item
811  if( !modified && prevState != board_item->IsLocked() )
812  modified = true;
813  }
814 
815  if( modified )
816  {
817  switch( aMode )
818  {
819  case ON: commit.Push( _( "Lock" ) ); break;
820  case OFF: commit.Push( _( "Unlock" ) ); break;
821  case TOGGLE: commit.Push( _( "Toggle Locking" ) ); break;
822  }
823 
825  m_frame->OnModify();
826  }
827 
828  return 0;
829 }
830 
831 
833 {
834  KIGFX::VIEW* view = getView();
836  BOARD* board = getModel<BOARD>();
837  PCB_TARGET* target = new PCB_TARGET( board );
838 
839  // Init the new item attributes
840  target->SetLayer( Edge_Cuts );
842  target->SetSize( Millimeter2iu( 5 ) );
843  VECTOR2I cursorPos = controls->GetCursorPosition();
844  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
845 
846  // Add a VIEW_GROUP that serves as a preview for the new item
847  KIGFX::VIEW_GROUP preview( view );
848  preview.Add( target );
849  view->Add( &preview );
850 
852  controls->SetSnapping( true );
853 
854  std::string tool = aEvent.GetCommandStr().get();
855  m_frame->PushTool( tool );
856  Activate();
857 
858  // Main loop: keep receiving events
859  while( TOOL_EVENT* evt = Wait() )
860  {
861  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
862  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
863 
864  if( evt->IsCancelInteractive() )
865  {
866  frame()->PopTool( tool );
867  break;
868  }
869 
870  else if( evt->IsActivate() )
871  {
872  if( evt->IsMoveTool() )
873  {
874  // leave ourselves on the stack so we come back after the move
875  break;
876  }
877  else
878  {
879  frame()->PopTool( tool );
880  break;
881  }
882  }
883 
884  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
885  {
886  target->SetWidth( target->GetWidth() + WIDTH_STEP );
887  view->Update( &preview );
888  }
889 
890  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
891  {
892  int width = target->GetWidth();
893 
894  if( width > WIDTH_STEP )
895  {
896  target->SetWidth( width - WIDTH_STEP );
897  view->Update( &preview );
898  }
899  }
900 
901  else if( evt->IsClick( BUT_LEFT ) )
902  {
903  assert( target->GetSize() > 0 );
904  assert( target->GetWidth() > 0 );
905 
906  BOARD_COMMIT commit( m_frame );
907  commit.Add( target );
908  commit.Push( _( "Place a layer alignment target" ) );
909 
910  preview.Remove( target );
911 
912  // Create next PCB_TARGET
913  target = new PCB_TARGET( *target );
914  preview.Add( target );
915  }
916 
917  else if( evt->IsClick( BUT_RIGHT ) )
918  {
920  }
921 
922  else if( evt->IsMotion() )
923  {
924  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
925  view->Update( &preview );
926  }
927 
928  else
929  evt->SetPassEvent();
930  }
931 
932  preview.Clear();
933  delete target;
934  view->Remove( &preview );
935  controls->SetSnapping( false );
936  return 0;
937 }
938 
939 
940 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
941  std::vector<ZONE_CONTAINER *>& aMergedZones )
942 {
943  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
944  {
945  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
947  }
948 
949  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
950 
951  // We should have one polygon with hole
952  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
953  // and therefore cannot be merged (they are dectected as intersecting)
954  // but we should never have more than 2 polys
955  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
956  {
957  wxLogMessage( "BOARD::CombineAreas error: more than 2 polys after merging" );
958  return false;
959  }
960 
961  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
962  {
963  aCommit.Remove( aOriginZones[i] );
964  }
965 
966  aCommit.Modify( aOriginZones[0] );
967  aMergedZones.push_back( aOriginZones[0] );
968 
969  aOriginZones[0]->SetLocalFlags( 1 );
970  aOriginZones[0]->Hatch();
971  aOriginZones[0]->CacheTriangulation();
972 
973  return true;
974 }
975 
976 
978 {
979  const PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
980  BOARD* board = getModel<BOARD>();
981  BOARD_COMMIT commit( m_frame );
982 
983  if( selection.Size() < 2 )
984  return 0;
985 
986  int netcode = -1;
987 
988  ZONE_CONTAINER* firstZone = nullptr;
989  std::vector<ZONE_CONTAINER*> toMerge, merged;
990 
991  for( auto item : selection )
992  {
993  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
994 
995  if( !curr_area )
996  continue;
997 
998  if( !firstZone )
999  firstZone = curr_area;
1000 
1001  netcode = curr_area->GetNetCode();
1002 
1003  if( firstZone->GetNetCode() != netcode )
1004  continue;
1005 
1006  if( curr_area->GetPriority() != firstZone->GetPriority() )
1007  continue;
1008 
1009  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
1010  continue;
1011 
1012  if( curr_area->GetLayer() != firstZone->GetLayer() )
1013  continue;
1014 
1015  if( !board->TestAreaIntersection( curr_area, firstZone ) )
1016  continue;
1017 
1018  toMerge.push_back( curr_area );
1019  }
1020 
1022 
1023  if( mergeZones( commit, toMerge, merged ) )
1024  {
1025  commit.Push( _( "Merge zones" ) );
1026 
1027  for( auto item : merged )
1029  }
1030 
1031  return 0;
1032 }
1033 
1034 
1036 {
1037  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1038  const auto& selection = selTool->GetSelection();
1039 
1040  // because this pops up the zone editor, it would be confusing to handle multiple zones,
1041  // so just handle single selections containing exactly one zone
1042  if( selection.Size() != 1 )
1043  return 0;
1044 
1045  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1046 
1047  if( !oldZone )
1048  return 0;
1049 
1050  ZONE_SETTINGS zoneSettings;
1051  zoneSettings << *oldZone;
1052  int dialogResult;
1053 
1054  if( oldZone->GetIsKeepout() )
1055  dialogResult = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
1056  else if( oldZone->IsOnCopperLayer() )
1057  dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1058  else
1059  dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1060 
1061  if( dialogResult != wxID_OK )
1062  return 0;
1063 
1064  // duplicate the zone
1065  BOARD_COMMIT commit( m_frame );
1066 
1067  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
1068  newZone->ClearSelected();
1069  newZone->UnFill();
1070  zoneSettings.ExportSetting( *newZone );
1071 
1072  // If the new zone is on the same layer(s) as the the initial zone,
1073  // offset it a bit so it can more easily be picked.
1074  if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
1075  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1076  else if( !oldZone->GetIsKeepout() && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
1077  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1078 
1079  commit.Add( newZone.release() );
1080  commit.Push( _( "Duplicate zone" ) );
1081 
1082  return 0;
1083 }
1084 
1085 
1087  BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
1088 {
1089  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
1090  originViewItem->SetPosition( wxPoint( aPosition.x, aPosition.y ) );
1091  aView->MarkDirty();
1092  aFrame->OnModify();
1093 }
1094 
1095 
1097 {
1098  std::string tool = aEvent.GetCommandStr().get();
1100 
1101  // Deactivate other tools; particularly important if another PICKER is currently running
1102  Activate();
1103 
1104  picker->SetClickHandler(
1105  [this] ( const VECTOR2D& pt ) -> bool
1106  {
1108  DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
1109  return false; // drill origin is a one-shot; don't continue with tool
1110  } );
1111 
1112  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1113 
1114  return 0;
1115 }
1116 
1117 
1119 {
1120  view()->SetMirror( !view()->IsMirroredX(), false );
1121  view()->RecacheAllItems();
1122  frame()->Refresh();
1123  return 0;
1124 }
1125 
1126 
1128 {
1129  Go( &PCB_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1130  Go( &PCB_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1131  Go( &PCB_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1135  Go( &PCB_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1136 
1147 
1148  // Track & via size control
1153 
1154  // Zone actions
1157 
1158  // Placing tools
1162 
1163  // Other
1167 
1174 }
1175 
1176 
1177 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:397
void RollbackFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
Definition: undo_redo.cpp:606
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
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:399
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:314
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
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:82
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:158
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:412
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:398
ACTION_MENU.
Definition: action_menu.h:43
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:289
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:282
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.
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: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:101
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:204
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:281
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:109
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:426
MODULE * SelectFootprintFromLibTree(LIB_ID aPreselect=LIB_ID())
Function SelectFootprintFromLibTree opens a dialog to select a footprint.
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:285
static TOOL_ACTION showPythonConsole
Definition: pcb_actions.h:327
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
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:325
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:153
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:215
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:317
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:288
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:201
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:318
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:102
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:145
#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.
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:280
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
timestamp_t GetNewTimeStamp()
Definition: common.cpp:215
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...
Generic tool for picking a point.
const PCBNEW_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
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:217
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:309
#define NULL
#define MAX_PAGE_SIZE_PCBNEW_MILS
Definition: page_info.h:40
void SetLink(timestamp_t aLink)
Definition: class_module.h:550
DRAWING_TOOL.
Definition: drawing_tool.h:49
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
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.
PCB_GENERAL_SETTINGS & Settings()
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.
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:52
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:292
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:414
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:316
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:291
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:298
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:631
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:290
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:311
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:295
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:319
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:312
static TOOL_ACTION showMicrowaveToolbar
Definition: pcb_actions.h:326
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:100
KIGFX::VIEW_CONTROLS * controls() const
int GetWidth() const
Definition: class_track.h:103
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:160
static const int WIDTH_STEP
Place & drill origin marker
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:31
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:351
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:163
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
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:96
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:277
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:237
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Toggles 'lock' property for selected items.
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)
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:283
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:87
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:115
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:315
static SELECTION_CONDITION SameNet(bool aAllowUnconnected=false)
Function SameNet Creates a functor that tests if selection contains items belonging to the same net o...
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:212
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:39