KiCad PCB EDA Suite
pcb_editor_control.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014 CERN
5  * Copyright (C) 2014-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 #include "pcb_editor_control.h"
26 #include "drawing_tool.h"
27 #include "pcb_actions.h"
28 #include "pcbnew_picker_tool.h"
29 #include "selection_tool.h"
30 #include "edit_tool.h"
31 #include <bitmaps.h>
32 #include <board_commit.h>
33 #include <class_board.h>
34 #include <class_module.h>
35 #include <class_pcb_target.h>
36 #include <class_track.h>
37 #include <class_zone.h>
38 #include <collectors.h>
39 #include <confirm.h>
40 #include <cstdint>
43 #include <functional>
44 #include <gestfich.h>
45 #include <kiface_i.h>
46 #include <kiway.h>
47 #include <memory>
49 #include <origin_viewitem.h>
50 #include <painter.h>
51 #include <pcb_edit_frame.h>
52 #include <pcbnew_id.h>
53 #include <pcbnew_settings.h>
54 #include <project.h>
55 #include <project/project_file.h> // LAST_PATH_TYPE
56 #include <tool/tool_manager.h>
57 #include <tools/tool_event_utils.h>
58 #include <view/view_controls.h>
59 #include <view/view_group.h>
61 #include <ws_proxy_undo_item.h>
62 #include <footprint_edit_frame.h>
63 
64 using namespace std::placeholders;
65 
66 
68 {
69 public:
71  ACTION_MENU( true )
72  {
73  SetIcon( add_zone_xpm );
74  SetTitle( _( "Zones" ) );
75 
76  Add( PCB_ACTIONS::zoneFill );
80 
81  AppendSeparator();
82 
87  }
88 
89 
90 protected:
91  ACTION_MENU* create() const override
92  {
93  return new ZONE_CONTEXT_MENU();
94  }
95 
96 private:
97  void update() override
98  {
99  SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
100 
101  // enable zone actions that act on a single zone
102  bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 ) &&
104  )( selTool->GetSelection() );
105 
106  Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
107  Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
108  Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
109 
110  // enable zone actions that ably to a specific set of zones (as opposed to all of them)
111  bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
112 
113  Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
114  Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
115 
116  // lines like this make me really think about a better name for SELECTION_CONDITIONS class
117  bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
118  /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
121 
122  Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
123  }
124 };
125 
126 
128 {
129 public:
131  ACTION_MENU( true )
132  {
133  SetIcon( locked_xpm );
134  SetTitle( _( "Locking" ) );
135 
136  Add( PCB_ACTIONS::lock );
137  Add( PCB_ACTIONS::unlock );
139  }
140 
141  ACTION_MENU* create() const override
142  {
143  return new LOCK_CONTEXT_MENU();
144  }
145 };
146 
147 
149  PCB_TOOL_BASE( "pcbnew.EditorControl" ),
150  m_frame( nullptr )
151 {
152  m_placeOrigin = std::make_unique<KIGFX::ORIGIN_VIEWITEM>( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
154 }
155 
156 
158 {
159 }
160 
161 
163 {
164  m_frame = getEditFrame<PCB_EDIT_FRAME>();
165 
166  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
167  {
168  m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin );
169  getView()->Remove( m_placeOrigin.get() );
170  getView()->Add( m_placeOrigin.get() );
171  }
172 }
173 
174 
176 {
177  auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
178  return ( !m_frame->ToolStackIsEmpty() );
179  };
180 
181  auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
182  return ( m_frame->ToolStackIsEmpty() && aSel.Size() == 0 );
183  };
184 
185  auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
186  return ( m_frame->IsCurrentTool( PCB_ACTIONS::placeModule ) && aSel.GetSize() == 0 );
187  };
188 
189  auto& ctxMenu = m_menu.GetMenu();
190 
191  // "Cancel" goes at the top of the context menu when a tool is active
192  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
193  ctxMenu.AddSeparator( 1 );
194 
195  // "Get and Place Footprint" should be available for Place Footprint tool
196  ctxMenu.AddItem( PCB_ACTIONS::getAndPlace, placeModuleCondition, 1000 );
197  ctxMenu.AddSeparator( 1000 );
198 
199  // Finally, add the standard zoom & grid items
200  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
201 
202  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
203  zoneMenu->SetTool( this );
204 
205  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
206  lockMenu->SetTool( this );
207 
208  // Add the PCB control menus to relevant other tools
209 
211 
212  if( selTool )
213  {
214  auto& toolMenu = selTool->GetToolMenu();
215  auto& menu = toolMenu.GetMenu();
216 
217  // Add "Get and Place Footprint" when Selection tool is in an inactive state
218  menu.AddItem( PCB_ACTIONS::getAndPlace, inactiveStateCondition );
219  menu.AddSeparator();
220 
221  toolMenu.AddSubMenu( zoneMenu );
222  toolMenu.AddSubMenu( lockMenu );
223 
224  menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ), 200 );
225  menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
226  }
227 
228  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
229 
230  if( drawingTool )
231  {
232  auto& toolMenu = drawingTool->GetToolMenu();
233  auto& menu = toolMenu.GetMenu();
234 
235  toolMenu.AddSubMenu( zoneMenu );
236 
237  // Functor to say if the PCB_EDIT_FRAME is in a given mode
238  // Capture the tool pointer and tool mode by value
239  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
240  {
241  return [=]( const SELECTION& sel )
242  {
243  return drawingTool->GetDrawingMode() == aMode;
244  };
245  };
246 
247  menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
248  }
249 
250  return true;
251 }
252 
253 
255 {
257  return 0;
258 }
259 
260 
262 {
264  return 0;
265 }
266 
267 
269 {
271  return 0;
272 }
273 
274 
276 {
278  return 0;
279 }
280 
281 
283 {
285  return 0;
286 }
287 
288 
290 {
291  PICKED_ITEMS_LIST undoCmd;
292  WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
293  ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
294 
295  undoCmd.PushItem( wrapper );
297 
301 
302  if( dlg.ShowModal() != wxID_OK )
304 
305  return 0;
306 }
307 
308 
310 {
312  return 0;
313 }
314 
315 
317 {
318  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog();
319  return 0;
320 }
321 
322 
324 {
325  getEditFrame<PCB_EDIT_FRAME>()->InstallNetlistFrame();
326  return 0;
327 }
328 
329 
331 {
332  wxString fullFileName = frame()->GetBoard()->GetFileName();
333  wxString path;
334  wxString name;
335  wxString ext;
336 
337  wxFileName::SplitPath( fullFileName, &path, &name, &ext );
338  name += wxT( ".ses" );
339 
340  fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), path, name,
341  wxT( ".ses" ), wxT( "*.ses" ), frame(), wxFD_OPEN, false );
342 
343  if( !fullFileName.IsEmpty() )
344  getEditFrame<PCB_EDIT_FRAME>()->ImportSpecctraSession( fullFileName );
345 
346  return 0;
347 }
348 
349 
351 {
352  wxString fullFileName = m_frame->GetLastPath( LAST_PATH_SPECCTRADSN );
353  wxFileName fn;
354 
355  if( fullFileName.IsEmpty() )
356  {
357  fn = m_frame->GetBoard()->GetFileName();
358  fn.SetExt( SpecctraDsnFileExtension );
359  }
360  else
361  fn = fullFileName;
362 
363  fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN File" ), fn.GetPath(), fn.GetFullName(),
365  frame(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, false );
366 
367  if( !fullFileName.IsEmpty() )
368  {
369  m_frame->SetLastPath( LAST_PATH_SPECCTRADSN, fullFileName );
370  getEditFrame<PCB_EDIT_FRAME>()->ExportSpecctraFile( fullFileName );
371  }
372 
373  return 0;
374 }
375 
376 
378 {
379  wxCommandEvent dummy;
380 
381  if( aEvent.IsAction( &PCB_ACTIONS::generateGerbers ) )
383  else if( aEvent.IsAction( &PCB_ACTIONS::generateReportFile ) )
385  else if( aEvent.IsAction( &PCB_ACTIONS::generateD356File ) )
387  else if( aEvent.IsAction( &PCB_ACTIONS::generateBOM ) )
389  else
390  wxFAIL_MSG( "GenerateFabFiles(): unexpected request" );
391 
392  return 0;
393 }
394 
395 
397 {
398  NETLIST netlist;
399 
401  {
402  DIALOG_UPDATE_PCB updateDialog( m_frame, &netlist );
403  updateDialog.ShowModal();
404  }
405 
406  return 0;
407 }
408 
410 {
411  if( Kiface().IsSingle() )
412  {
414  m_frame, _( "Cannot update schematic because Pcbnew is opened in stand-alone "
415  "mode. In order to create or update PCBs from schematics, you "
416  "must launch the KiCad project manager and create a project." ) );
417  return 0;
418  }
419 
420  m_frame->RunEeschema();
422 
423  if( frame )
424  {
425  std::string payload;
427  }
428  return 0;
429 }
430 
431 
433 {
434  m_frame->RunEeschema();
435  return 0;
436 }
437 
438 
440 {
441  getEditFrame<PCB_EDIT_FRAME>()->ToggleLayersManager();
442  return 0;
443 }
444 
445 
447 {
448  getEditFrame<PCB_EDIT_FRAME>()->ToggleMicrowaveToolbar();
449  return 0;
450 }
451 
452 
454 {
455 #if defined( KICAD_SCRIPTING_WXPYTHON )
456  m_frame->ScriptingConsoleEnableDisable();
457 #endif
458  return 0;
459 }
460 
461 
462 // Track & via size control
464 {
465  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
466  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
468 
470  {
471  BOARD_COMMIT commit( this );
472 
473  for( EDA_ITEM* item : selection )
474  {
475  if( item->Type() == PCB_TRACE_T )
476  {
477  TRACK* track = (TRACK*) item;
478 
479  for( int candidate : designSettings.m_TrackWidthList )
480  {
481  if( candidate > track->GetWidth() )
482  {
483  commit.Modify( track );
484  track->SetWidth( candidate );
485  break;
486  }
487  }
488  }
489  }
490 
491  commit.Push( "Increase Track Width" );
492  }
493  else
494  {
495  int widthIndex = designSettings.GetTrackWidthIndex() + 1;
496 
497  // If we go past the last track width entry in the list, start over at the beginning
498  if( widthIndex >= (int) designSettings.m_TrackWidthList.size() )
499  {
500  widthIndex = 0;
501  }
502 
503  designSettings.SetTrackWidthIndex( widthIndex );
504  designSettings.UseCustomTrackViaSize( false );
505 
507  }
508 
509  return 0;
510 }
511 
512 
514 {
515  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
516  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
518 
520  {
521  BOARD_COMMIT commit( this );
522 
523  for( EDA_ITEM* item : selection )
524  {
525  if( item->Type() == PCB_TRACE_T )
526  {
527  TRACK* track = (TRACK*) item;
528 
529  for( int i = designSettings.m_TrackWidthList.size() - 1; i >= 0; --i )
530  {
531  int candidate = designSettings.m_TrackWidthList[ i ];
532 
533  if( candidate < track->GetWidth() )
534  {
535  commit.Modify( track );
536  track->SetWidth( candidate );
537  break;
538  }
539  }
540  }
541  }
542 
543  commit.Push( "Decrease Track Width" );
544  }
545  else
546  {
547  int widthIndex = 0; // Assume we only have a single track width entry
548 
549  // If there are more, cycle through them backwards
550  if( designSettings.m_TrackWidthList.size() > 0 )
551  {
552  widthIndex = designSettings.GetTrackWidthIndex() - 1;
553  // If we get to the lowest entry start over at the highest
554  if( widthIndex < 0 )
555  widthIndex = designSettings.m_TrackWidthList.size() - 1;
556  }
557 
558  designSettings.SetTrackWidthIndex( widthIndex );
559  designSettings.UseCustomTrackViaSize( false );
560 
562  }
563 
564  return 0;
565 }
566 
567 
569 {
570  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
571  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
573 
575  {
576  BOARD_COMMIT commit( this );
577 
578  for( EDA_ITEM* item : selection )
579  {
580  if( item->Type() == PCB_VIA_T )
581  {
582  VIA* via = (VIA*) item;
583 
584  for( VIA_DIMENSION candidate : designSettings.m_ViasDimensionsList )
585  {
586  if( candidate.m_Diameter > via->GetWidth() )
587  {
588  commit.Modify( via );
589  via->SetWidth( candidate.m_Diameter );
590  via->SetDrill( candidate.m_Drill );
591  break;
592  }
593  }
594  }
595  }
596 
597  commit.Push( "Increase Via Size" );
598  }
599  else
600  {
601  int sizeIndex = designSettings.GetViaSizeIndex() + 1;
602 
603  // If we go past the last via entry in the list, start over at the beginning
604  if( sizeIndex >= (int) designSettings.m_ViasDimensionsList.size() )
605  sizeIndex = 0;
606 
607  designSettings.SetViaSizeIndex( sizeIndex );
608  designSettings.UseCustomTrackViaSize( false );
609 
611  }
612 
613  return 0;
614 }
615 
616 
618 {
619  BOARD_DESIGN_SETTINGS& designSettings = getModel<BOARD>()->GetDesignSettings();
620  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
622 
624  {
625  BOARD_COMMIT commit( this );
626 
627  for( EDA_ITEM* item : selection )
628  {
629  if( item->Type() == PCB_VIA_T )
630  {
631  VIA* via = (VIA*) item;
632 
633  for( int i = designSettings.m_ViasDimensionsList.size() - 1; i >= 0; --i )
634  {
635  VIA_DIMENSION candidate = designSettings.m_ViasDimensionsList[ i ];
636 
637  if( candidate.m_Diameter < via->GetWidth() )
638  {
639  commit.Modify( via );
640  via->SetWidth( candidate.m_Diameter );
641  via->SetDrill( candidate.m_Drill );
642  break;
643  }
644  }
645  }
646  }
647 
648  commit.Push( "Decrease Via Size" );
649  }
650  else
651  {
652  int sizeIndex = 0; // Assume we only have a single via size entry
653 
654  // If there are more, cycle through them backwards
655  if( designSettings.m_ViasDimensionsList.size() > 0 )
656  {
657  sizeIndex = designSettings.GetViaSizeIndex() - 1;
658 
659  // If we get to the lowest entry start over at the highest
660  if( sizeIndex < 0 )
661  sizeIndex = designSettings.m_ViasDimensionsList.size() - 1;
662  }
663 
664  designSettings.SetViaSizeIndex( sizeIndex );
665  designSettings.UseCustomTrackViaSize( false );
666 
668  }
669 
670  return 0;
671 }
672 
673 
675 {
676  MODULE* module = aEvent.Parameter<MODULE*>();
678  BOARD_COMMIT commit( m_frame );
679  BOARD* board = getModel<BOARD>();
680 
682  controls->ShowCursor( true );
683  controls->SetSnapping( true );
684 
685  std::string tool = aEvent.GetCommandStr().get();
686  m_frame->PushTool( tool );
687  Activate();
688 
689  VECTOR2I cursorPos = controls->GetCursorPosition();
690  bool reselect = false;
691 
692  // Prime the pump
693  if( module )
694  {
695  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
698  }
699  else if( aEvent.HasPosition() )
701 
702  // Main loop: keep receiving events
703  while( TOOL_EVENT* evt = Wait() )
704  {
705  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
706  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
707 
708  if( reselect && module )
710 
711  auto cleanup = [&] ()
712  {
714  commit.Revert();
715  module = NULL;
716  };
717 
718  if( evt->IsCancelInteractive() )
719  {
720  if( module )
721  cleanup();
722  else
723  {
724  m_frame->PopTool( tool );
725  break;
726  }
727  }
728 
729  else if( evt->IsActivate() )
730  {
731  if( module )
732  cleanup();
733 
734  if( evt->IsMoveTool() )
735  {
736  // leave ourselves on the stack so we come back after the move
737  break;
738  }
739  else
740  {
741  frame()->PopTool( tool );
742  break;
743  }
744  }
745 
746  else if( evt->IsClick( BUT_LEFT ) )
747  {
748  if( !module )
749  {
750  // Pick the module to be placed
752 
753  if( module == NULL )
754  continue;
755 
756  module->SetLink( niluuid );
757 
758  module->SetFlags( IS_NEW ); // whatever
759 
760  // Set parent so that clearance can be loaded
761  module->SetParent( board );
762 
763  // Put it on FRONT layer,
764  // (Can be stored flipped if the lib is an archive built from a board)
765  if( module->IsFlipped() )
767 
768  module->SetOrientation( 0 );
769  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
770 
771  commit.Add( module );
773  controls->SetCursorPosition( cursorPos, false );
774  }
775  else
776  {
778  commit.Push( _( "Place a module" ) );
779  module = NULL; // to indicate that there is no module that we currently modify
780  }
781  }
782 
783  else if( evt->IsClick( BUT_RIGHT ) )
784  {
786  }
787 
788  else if( module && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
789  {
790  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
791  selection().SetReferencePoint( cursorPos );
792  getView()->Update( & selection() );
793  }
794 
795  else if( module && evt->IsAction( &PCB_ACTIONS::properties ) )
796  {
797  // Calling 'Properties' action clears the selection, so we need to restore it
798  reselect = true;
799  }
800 
801  else
802  evt->SetPassEvent();
803 
804  // Enable autopanning and cursor capture only when there is a module to be placed
805  controls->SetAutoPan( !!module );
807  }
808 
809  return 0;
810 }
811 
812 
814 {
815  return modifyLockSelected( TOGGLE );
816 }
817 
818 
820 {
821  return modifyLockSelected( ON );
822 }
823 
824 
826 {
827  return modifyLockSelected( OFF );
828 }
829 
830 
832 {
834  const PCBNEW_SELECTION& selection = selTool->GetSelection();
835  BOARD_COMMIT commit( m_frame );
836 
837  if( selection.Empty() )
839 
840  bool modified = false;
841 
842  for( EDA_ITEM* item : selection )
843  {
844  BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
845  bool prevState = board_item->IsLocked();
846 
847  commit.Modify( board_item );
848 
849  switch( aMode )
850  {
851  case ON: board_item->SetLocked( true ); break;
852  case OFF: board_item->SetLocked( false ); break;
853  case TOGGLE: board_item->SetLocked( !prevState ); break;
854  }
855 
856  // Check if we really modified an item
857  if( !modified && prevState != board_item->IsLocked() )
858  modified = true;
859  }
860 
861  if( modified )
862  {
863  switch( aMode )
864  {
865  case ON: commit.Push( _( "Lock" ) ); break;
866  case OFF: commit.Push( _( "Unlock" ) ); break;
867  case TOGGLE: commit.Push( _( "Toggle Locking" ) ); break;
868  }
869 
871  m_frame->OnModify();
872  }
873 
874  return 0;
875 }
876 
877 
879 {
880  KIGFX::VIEW* view = getView();
882  BOARD* board = getModel<BOARD>();
883  PCB_TARGET* target = new PCB_TARGET( board );
884 
885  // Init the new item attributes
886  target->SetLayer( Edge_Cuts );
888  target->SetSize( Millimeter2iu( 5 ) );
889  VECTOR2I cursorPos = controls->GetCursorPosition();
890  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
891 
892  // Add a VIEW_GROUP that serves as a preview for the new item
893  KIGFX::VIEW_GROUP preview( view );
894  preview.Add( target );
895  view->Add( &preview );
896 
898  controls->SetSnapping( true );
899 
900  std::string tool = aEvent.GetCommandStr().get();
901  m_frame->PushTool( tool );
902  Activate();
903 
904  // Main loop: keep receiving events
905  while( TOOL_EVENT* evt = Wait() )
906  {
907  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
908  cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
909 
910  if( evt->IsCancelInteractive() )
911  {
912  frame()->PopTool( tool );
913  break;
914  }
915 
916  else if( evt->IsActivate() )
917  {
918  if( evt->IsMoveTool() )
919  {
920  // leave ourselves on the stack so we come back after the move
921  break;
922  }
923  else
924  {
925  frame()->PopTool( tool );
926  break;
927  }
928  }
929 
930  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
931  {
932  target->SetWidth( target->GetWidth() + WIDTH_STEP );
933  view->Update( &preview );
934  }
935 
936  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
937  {
938  int width = target->GetWidth();
939 
940  if( width > WIDTH_STEP )
941  {
942  target->SetWidth( width - WIDTH_STEP );
943  view->Update( &preview );
944  }
945  }
946 
947  else if( evt->IsClick( BUT_LEFT ) )
948  {
949  assert( target->GetSize() > 0 );
950  assert( target->GetWidth() > 0 );
951 
952  BOARD_COMMIT commit( m_frame );
953  commit.Add( target );
954  commit.Push( _( "Place a layer alignment target" ) );
955 
956  preview.Remove( target );
957 
958  // Create next PCB_TARGET
959  target = new PCB_TARGET( *target );
960  preview.Add( target );
961  }
962 
963  else if( evt->IsClick( BUT_RIGHT ) )
964  {
966  }
967 
968  else if( evt->IsMotion() )
969  {
970  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
971  view->Update( &preview );
972  }
973 
974  else
975  evt->SetPassEvent();
976  }
977 
978  preview.Clear();
979  delete target;
980  view->Remove( &preview );
981  controls->SetSnapping( false );
982  return 0;
983 }
984 
985 
986 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
987  std::vector<ZONE_CONTAINER *>& aMergedZones )
988 {
989  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
990  {
991  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
993  }
994 
995  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
996 
997  // We should have one polygon with hole
998  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
999  // and therefore cannot be merged (they are dectected as intersecting)
1000  // but we should never have more than 2 polys
1001  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
1002  {
1003  wxLogMessage( "BOARD::CombineAreas error: more than 2 polys after merging" );
1004  return false;
1005  }
1006 
1007  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1008  {
1009  aCommit.Remove( aOriginZones[i] );
1010  }
1011 
1012  aCommit.Modify( aOriginZones[0] );
1013  aMergedZones.push_back( aOriginZones[0] );
1014 
1015  aOriginZones[0]->SetLocalFlags( 1 );
1016  aOriginZones[0]->Hatch();
1017  aOriginZones[0]->CacheTriangulation();
1018 
1019  return true;
1020 }
1021 
1022 
1024 {
1025  const PCBNEW_SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1026  BOARD* board = getModel<BOARD>();
1027  BOARD_COMMIT commit( m_frame );
1028 
1029  if( selection.Size() < 2 )
1030  return 0;
1031 
1032  int netcode = -1;
1033 
1034  ZONE_CONTAINER* firstZone = nullptr;
1035  std::vector<ZONE_CONTAINER*> toMerge, merged;
1036 
1037  for( auto item : selection )
1038  {
1039  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
1040 
1041  if( !curr_area )
1042  continue;
1043 
1044  if( !firstZone )
1045  firstZone = curr_area;
1046 
1047  netcode = curr_area->GetNetCode();
1048 
1049  if( firstZone->GetNetCode() != netcode )
1050  continue;
1051 
1052  if( curr_area->GetPriority() != firstZone->GetPriority() )
1053  continue;
1054 
1055  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
1056  continue;
1057 
1058  if( curr_area->GetLayer() != firstZone->GetLayer() )
1059  continue;
1060 
1061  if( !board->TestAreaIntersection( curr_area, firstZone ) )
1062  continue;
1063 
1064  toMerge.push_back( curr_area );
1065  }
1066 
1068 
1069  if( mergeZones( commit, toMerge, merged ) )
1070  {
1071  commit.Push( _( "Merge zones" ) );
1072 
1073  for( auto item : merged )
1075  }
1076 
1077  return 0;
1078 }
1079 
1080 
1082 {
1084  const SELECTION& selection = selTool->GetSelection();
1085 
1086  // because this pops up the zone editor, it would be confusing to handle multiple zones,
1087  // so just handle single selections containing exactly one zone
1088  if( selection.Size() != 1 )
1089  return 0;
1090 
1091  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1092 
1093  if( !oldZone )
1094  return 0;
1095 
1096  ZONE_SETTINGS zoneSettings;
1097  zoneSettings << *oldZone;
1098  int dialogResult;
1099 
1100  if( oldZone->GetIsKeepout() )
1101  dialogResult = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
1102  else if( oldZone->IsOnCopperLayer() )
1103  dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
1104  else
1105  dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
1106 
1107  if( dialogResult != wxID_OK )
1108  return 0;
1109 
1110  // duplicate the zone
1111  BOARD_COMMIT commit( m_frame );
1112 
1113  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
1114  newZone->ClearSelected();
1115  newZone->UnFill();
1116  zoneSettings.ExportSetting( *newZone );
1117 
1118  // If the new zone is on the same layer(s) as the the initial zone,
1119  // offset it a bit so it can more easily be picked.
1120  if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
1121  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1122  else if( !oldZone->GetIsKeepout() && zoneSettings.m_Layers.test( oldZone->GetLayer() ) )
1123  newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) );
1124 
1125  commit.Add( newZone.release() );
1126  commit.Push( _( "Duplicate zone" ) );
1127 
1128  return 0;
1129 }
1130 
1131 
1133 {
1136 
1137  if( selection.Empty() )
1138  return 0;
1139 
1140  MODULE* mod = selection.FirstOfKind<MODULE>();
1141 
1142  if( !mod )
1143  return 0;
1144 
1145  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1146 
1147  auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
1148 
1149  editor->Load_Module_From_BOARD( mod );
1150 
1151  editor->Show( true );
1152  editor->Raise(); // Iconize( false );
1153 
1154  if( selection.IsHover() )
1156 
1157  return 0;
1158 }
1159 
1160 
1162  BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
1163 {
1164  aFrame->GetDesignSettings().m_AuxOrigin = (wxPoint) aPosition;
1165  originViewItem->SetPosition( (wxPoint) aPosition );
1166  aView->MarkDirty();
1167  aFrame->OnModify();
1168 }
1169 
1170 
1172 {
1173  std::string tool = aEvent.GetCommandStr().get();
1175 
1176  // Deactivate other tools; particularly important if another PICKER is currently running
1177  Activate();
1178 
1179  picker->SetClickHandler(
1180  [this] ( const VECTOR2D& pt ) -> bool
1181  {
1183  DoSetDrillOrigin( getView(), m_frame, m_placeOrigin.get(), pt );
1184  return false; // drill origin is a one-shot; don't continue with tool
1185  } );
1186 
1187  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1188 
1189  return 0;
1190 }
1191 
1192 
1194 {
1195  view()->SetMirror( !view()->IsMirroredX(), false );
1196  view()->RecacheAllItems();
1197  frame()->Refresh();
1198  return 0;
1199 }
1200 
1201 
1203 {
1204  Go( &PCB_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1205  Go( &PCB_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1206  Go( &PCB_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1210  Go( &PCB_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1211 
1222 
1223  // Track & via size control
1228 
1229  // Zone actions
1232 
1233  // Placing tools
1237 
1239 
1240  // Other
1244 
1252 }
1253 
1254 
1255 const int PCB_EDITOR_CONTROL::WIDTH_STEP = 100000;
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:398
void RollbackFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
Definition: undo_redo.cpp:612
void SetLink(const KIID &aLink)
Definition: class_module.h:547
Struct VIA_DIMENSION is a small helper container to handle a stock of specific vias each with unique ...
void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
static TOOL_ACTION placeModule
Definition: pcb_actions.h:153
bool IsCurrentTool(const TOOL_ACTION &aAction) const
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h: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:400
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...
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
bool IsHover() const
Definition: selection.h:71
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Pointer to the currently used edit frame.
static TOOL_ACTION generateGerbers
Definition: pcb_actions.h:315
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.
LSET m_Layers
Layers that this zone exists on.
Definition: zone_settings.h:97
BOARD * board() const
static TOOL_ACTION editFpInFpEditor
Definition: pcb_actions.h:325
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:160
virtual void SetPosition(const wxPoint &aPos)=0
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:288
Model changes (required full reload)
Definition: tool_base.h:82
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:151
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:407
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:399
ACTION_MENU.
Definition: action_menu.h:44
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: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.
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: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
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
int BoardSetup(const TOOL_EVENT &aEvent)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h: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:236
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:112
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:140
static TOOL_ACTION getAndPlace
Find an item and start moving.
Definition: pcb_actions.h:432
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:328
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
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:326
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:157
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:255
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:318
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:207
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
static TOOL_ACTION generateD356File
Definition: pcb_actions.h:319
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:163
static TOOL_ACTION saveCopyAs
Definition: actions.h:56
void SetWidth(int aWidth)
Definition: class_track.h:111
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:149
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
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:59
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:245
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:158
Generic tool for picking a point.
const PCBNEW_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
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:186
static TOOL_ACTION importNetlist
Definition: pcb_actions.h:310
#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:342
DRAWING_TOOL.
Definition: drawing_tool.h:50
int TrackWidthInc(const TOOL_EVENT &aEvent)
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
static TOOL_ACTION open
Definition: actions.h:53
int Plot(const TOOL_EVENT &aEvent)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION doNew
Definition: actions.h:47
int ExportSpecctraDSN(const TOOL_EVENT &aEvent)
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void SetPosition(const wxPoint &aPos) override
TOOL_EVENT.
Definition: tool_event.h:171
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:292
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
int SaveAs(const TOOL_EVENT &aEvent)
KIGFX::PCB_VIEW * view() const
Definition of file extensions used in Kicad.
bool ToolStackIsEmpty()
Definition: tools_holder.h:84
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:410
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:317
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:150
static TOOL_ACTION placeTarget
Definition: pcb_actions.h:152
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:702
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
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:67
int New(const TOOL_EVENT &aEvent)
static TOOL_ACTION importSpecctraSession
Definition: pcb_actions.h:312
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
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:428
static TOOL_ACTION generateBOM
Definition: pcb_actions.h:320
static const KICAD_T LockableItems[]
A scan list for TRACKS, VIAS, MODULES.
Definition: collectors.h:318
MODE
The possible drawing modes of DRAWING_TOOL
Definition: drawing_tool.h:63
int TogglePythonConsole(const TOOL_EVENT &aEvent)
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
int GenerateFabFiles(const TOOL_EVENT &aEvent)
virtual bool IsLocked() const
Function IsLocked.
static TOOL_ACTION exportSpecctraDSN
Definition: pcb_actions.h:313
static TOOL_ACTION showMicrowaveToolbar
Definition: pcb_actions.h:327
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:101
PCBNEW_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, std::vector< BOARD_ITEM * > *aFiltered=nullptr, bool aConfirmLockedItems=false)
Function RequestSelection()
KIGFX::VIEW_CONTROLS * controls() const
int GetWidth() const
Definition: class_track.h:112
int FlipPcbView(const TOOL_EVENT &aEvent)
const char * name
Definition: DXF_plotter.cpp:60
Common, abstract interface for edit frames.
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:180
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)
int EditFpInFpEditor(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:65
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:447
PCBNEW_SETTINGS & Settings()
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
std::vector< VIA_DIMENSION > m_ViasDimensionsList
T * FirstOfKind() const
Definition: selection.h:195
void SetWidth(int aWidth)
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
bool Files_io_from_id(int aId)
Function Files_io_from_id Read and write board files.
void Activate()
Function Activate() Runs the tool.
Definition: id.h:97
const BITMAP_OPAQUE add_zone_xpm[1]
Definition: add_zone.cpp:74
PCB_TARGET class definition.
wxString SpecctraDsnFileWildcard()
ACTION_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp: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
wxPoint GetPosition() const override
Definition: class_module.h:206
ACTION_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes.
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:277
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter() A selection filter which prunes the selection to contain only items of typ...
Definition: edit_tool.cpp:1345
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:268
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()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:283
void setTransitions() override
Sets up handlers for various events.
wxPoint m_AuxOrigin
origin for plot exports
bool FetchNetlistFromSchematic(NETLIST &aNetlist, FETCH_NETLIST_MODE aMode)
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:59
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:610
static TOOL_ACTION refreshPreview
Definition: actions.h:102
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:119
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:316
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:99