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-2017 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 <cstdint>
26 #include <thread>
27 #include <mutex>
28 
29 #include "pcb_editor_control.h"
30 #include "pcb_actions.h"
31 #include <tool/tool_manager.h>
32 #include <wx/progdlg.h>
33 
34 #include "edit_tool.h"
35 #include "selection_tool.h"
36 #include "drawing_tool.h"
37 #include "picker_tool.h"
38 
39 #include <painter.h>
40 #include <project.h>
41 #include <pcbnew_id.h>
42 #include <pcb_edit_frame.h>
43 #include <class_board.h>
44 #include <class_zone.h>
45 #include <pcb_draw_panel_gal.h>
46 #include <class_module.h>
47 #include <class_pcb_target.h>
48 #include <connectivity_data.h>
49 #include <collectors.h>
51 #include <board_commit.h>
52 #include <confirm.h>
53 #include <bitmaps.h>
54 #include <hotkeys.h>
55 
56 #include <view/view_group.h>
57 #include <view/view_controls.h>
58 #include <origin_viewitem.h>
59 #include <profile.h>
60 
62 
63 #ifdef USE_OPENMP
64 #include <omp.h>
65 #endif /* USE_OPENMP */
66 
67 #include <tools/tool_event_utils.h>
68 
69 #include <functional>
70 using namespace std::placeholders;
71 
72 
73 // Track & via size control
74 TOOL_ACTION PCB_ACTIONS::trackWidthInc( "pcbnew.EditorControl.trackWidthInc",
76  "", "" );
77 
78 TOOL_ACTION PCB_ACTIONS::trackWidthDec( "pcbnew.EditorControl.trackWidthDec",
80  "", "" );
81 
82 TOOL_ACTION PCB_ACTIONS::viaSizeInc( "pcbnew.EditorControl.viaSizeInc",
84  "", "" );
85 
86 TOOL_ACTION PCB_ACTIONS::viaSizeDec( "pcbnew.EditorControl.viaSizeDec",
88  "", "" );
89 
90 TOOL_ACTION PCB_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaSizeChanged",
91  AS_GLOBAL, 0,
92  "", "", NULL, AF_NOTIFY );
93 
94 TOOL_ACTION PCB_ACTIONS::zoneMerge( "pcbnew.EditorControl.zoneMerge",
95  AS_GLOBAL, 0,
96  _( "Merge Zones" ), _( "Merge zones" ) );
97 
98 TOOL_ACTION PCB_ACTIONS::zoneDuplicate( "pcbnew.EditorControl.zoneDuplicate",
99  AS_GLOBAL, 0,
100  _( "Duplicate Zone onto Layer..." ), _( "Duplicate zone outline onto a different layer" ),
101  zone_duplicate_xpm );
102 
103 
104 TOOL_ACTION PCB_ACTIONS::placeTarget( "pcbnew.EditorControl.placeTarget",
105  AS_GLOBAL, 0,
106  _( "Add Layer Alignment Target" ), _( "Add a layer alignment target" ), NULL, AF_ACTIVATE );
107 
108 TOOL_ACTION PCB_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule",
110  _( "Add Footprint" ), _( "Add a footprint" ), NULL, AF_ACTIVATE );
111 
112 TOOL_ACTION PCB_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin",
113  AS_GLOBAL, 0,
114  "", "" );
115 
116 TOOL_ACTION PCB_ACTIONS::crossProbeSchToPcb( "pcbnew.EditorControl.crossProbSchToPcb",
117  AS_GLOBAL, 0,
118  "", "" );
119 
120 TOOL_ACTION PCB_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock",
122  "Toggle Lock", "" );
123 
124 TOOL_ACTION PCB_ACTIONS::lock( "pcbnew.EditorControl.lock",
125  AS_GLOBAL, 0,
126  _( "Lock" ), "" );
127 
128 TOOL_ACTION PCB_ACTIONS::unlock( "pcbnew.EditorControl.unlock",
129  AS_GLOBAL, 0,
130  _( "Unlock" ), "" );
131 
132 TOOL_ACTION PCB_ACTIONS::appendBoard( "pcbnew.EditorControl.appendBoard",
133  AS_GLOBAL, 0,
134  "", "" );
135 
136 TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
137  AS_GLOBAL, 0,
138  "", "" );
139 
140 TOOL_ACTION PCB_ACTIONS::highlightNetCursor( "pcbnew.EditorControl.highlightNetCursor",
141  AS_GLOBAL, 0,
142  "", "" );
143 
144 TOOL_ACTION PCB_ACTIONS::highlightNetSelection( "pcbnew.EditorControl.highlightNetSelection",
146  "", "" );
147 
148 TOOL_ACTION PCB_ACTIONS::showLocalRatsnest( "pcbnew.Control.showLocalRatsnest",
149  AS_GLOBAL, 0,
150  "", "" );
151 
153 {
154 public:
156  {
157  SetIcon( add_zone_xpm );
158  SetTitle( _( "Zones" ) );
159 
160  Add( PCB_ACTIONS::zoneFill );
164 
165  AppendSeparator();
166 
167  Add( PCB_ACTIONS::zoneMerge );
171  }
172 
173 
174 protected:
175  CONTEXT_MENU* create() const override
176  {
177  return new ZONE_CONTEXT_MENU();
178  }
179 
180 private:
181  void update() override
182  {
183  SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
184 
185  // enable zone actions that act on a single zone
186  bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 )
188  )( selTool->GetSelection() );
189 
190  Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
191  Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
192  Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
193 
194  // enable zone actions that ably to a specific set of zones (as opposed to all of them)
195  bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
196 
197  Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
198  Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
199 
200  // lines like this make me really think about a better name for SELECTION_CONDITIONS class
201  bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
202  /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
205 
206  Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
207  }
208 };
209 
210 
212 {
213 public:
215  {
216  SetIcon( locked_xpm );
217  SetTitle( _( "Locking" ) );
218 
219  Add( PCB_ACTIONS::lock );
220  Add( PCB_ACTIONS::unlock );
222  }
223 
224  CONTEXT_MENU* create() const override
225  {
226  return new LOCK_CONTEXT_MENU();
227  }
228 };
229 
230 
232  PCB_TOOL( "pcbnew.EditorControl" ),
233  m_frame( nullptr ),
234  m_menu( *this )
235 {
236  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
238  m_probingSchToPcb = false;
239  m_slowRatsnest = false;
240 }
241 
242 
244 {
245 }
246 
247 
249 {
250  m_frame = getEditFrame<PCB_EDIT_FRAME>();
251 
252  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
253  {
254  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
255  getView()->Remove( m_placeOrigin.get() );
256  getView()->Add( m_placeOrigin.get() );
257  }
258 }
259 
260 
262 {
263  auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
264  return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
265  };
266 
267  auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
268  return ( m_frame->GetToolId() == ID_NO_TOOL_SELECTED && aSel.Size() == 0 );
269  };
270 
271  auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
272  return ( m_frame->GetToolId() == ID_PCB_MODULE_BUTT && aSel.GetSize() == 0 );
273  };
274 
275  auto& ctxMenu = m_menu.GetMenu();
276 
277  // "Cancel" goes at the top of the context menu when a tool is active
278  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1000 );
279  ctxMenu.AddSeparator( activeToolCondition, 1000 );
280 
281  // "Get and Place Footprint" should be available for Place Footprint tool
282  ctxMenu.AddItem( PCB_ACTIONS::findMove, placeModuleCondition, 1000 );
283  ctxMenu.AddSeparator( placeModuleCondition, 1000 );
284 
285  // Finally, add the standard zoom & grid items
286  m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
287 
288  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
289  zoneMenu->SetTool( this );
290 
291  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
292  lockMenu->SetTool( this );
293 
294  // Add the PCB control menus to relevant other tools
295 
297 
298  if( selTool )
299  {
300  auto& toolMenu = selTool->GetToolMenu();
301  auto& menu = toolMenu.GetMenu();
302 
303  // Add "Get and Place Footprint" when Selection tool is in an inactive state
304  menu.AddItem( PCB_ACTIONS::findMove, inactiveStateCondition );
305  menu.AddSeparator( inactiveStateCondition );
306 
307  toolMenu.AddSubMenu( zoneMenu );
308  toolMenu.AddSubMenu( lockMenu );
309 
310  menu.AddMenu( zoneMenu.get(), false,
312 
313  menu.AddMenu( lockMenu.get(), false,
315  }
316 
317  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
318 
319  if( drawingTool )
320  {
321  auto& toolMenu = drawingTool->GetToolMenu();
322  auto& menu = toolMenu.GetMenu();
323 
324  toolMenu.AddSubMenu( zoneMenu );
325 
326  // Functor to say if the PCB_EDIT_FRAME is in a given mode
327  // Capture the tool pointer and tool mode by value
328  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
329  {
330  return [=]( const SELECTION& sel )
331  {
332  return drawingTool->GetDrawingMode() == aMode;
333  };
334  };
335 
336  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
337  }
338 
339  m_ratsnestTimer.SetOwner( this );
340  Connect( m_ratsnestTimer.GetId(), wxEVT_TIMER,
341  wxTimerEventHandler( PCB_EDITOR_CONTROL::ratsnestTimer ), NULL, this );
342 
343  return true;
344 }
345 
346 
347 // Track & via size control
349 {
350  BOARD* board = getModel<BOARD>();
351  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
352 
353  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
354  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
355 
356  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
357  board->GetDesignSettings().UseCustomTrackViaSize( false );
358 
360 
361  return 0;
362 }
363 
364 
366 {
367  BOARD* board = getModel<BOARD>();
368  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
369 
370  if( widthIndex < 0 )
371  widthIndex = 0;
372 
373  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
374  board->GetDesignSettings().UseCustomTrackViaSize( false );
375 
377 
378  return 0;
379 }
380 
381 
383 {
384  BOARD* board = getModel<BOARD>();
385  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
386 
387  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
388  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
389 
390  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
391  board->GetDesignSettings().UseCustomTrackViaSize( false );
392 
394 
395  return 0;
396 }
397 
398 
400 {
401  BOARD* board = getModel<BOARD>();
402  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
403 
404  if( sizeIndex < 0 )
405  sizeIndex = 0;
406 
407  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
408  board->GetDesignSettings().UseCustomTrackViaSize( false );
409 
411 
412  return 0;
413 }
414 
415 
417 {
418  MODULE* module = aEvent.Parameter<MODULE*>();
421  SELECTION& selection = selTool->GetSelection();
422  BOARD_COMMIT commit( m_frame );
423 
425  controls->ShowCursor( true );
426  controls->SetSnapping( true );
427 
428  Activate();
429  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_PENCIL, _( "Add footprint" ) );
430 
431  // Add all the drawable parts to preview
432  VECTOR2I cursorPos = controls->GetCursorPosition();
433 
434  if( module )
435  {
436  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
437  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
438  }
439 
440  bool reselect = false;
441 
442  // Main loop: keep receiving events
443  while( OPT_TOOL_EVENT evt = Wait() )
444  {
445  cursorPos = controls->GetCursorPosition();
446 
447  if( reselect && module )
448  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
449 
450  if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
451  {
452  if( module )
453  {
455  commit.Revert();
456  module = NULL;
457  }
458  else // let's have another chance placing a module
459  break;
460 
461  if( evt->IsActivate() ) // now finish unconditionally
462  break;
463  }
464 
465  else if( evt->IsClick( BUT_LEFT ) )
466  {
467  if( !module )
468  {
469  // Pick the module to be placed
470  module = m_frame->LoadModuleFromLibrary( wxEmptyString );
471 
472  if( module == NULL )
473  continue;
474 
475  m_frame->AddModuleToBoard( module );
476  commit.Added( module );
477  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
478  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
479  controls->SetCursorPosition( cursorPos, false );
480  }
481  else
482  {
484  commit.Push( _( "Place a module" ) );
485  module = NULL; // to indicate that there is no module that we currently modify
486  }
487  }
488 
489  else if( evt->IsClick( BUT_RIGHT ) )
490  {
491  m_menu.ShowContextMenu( selTool->GetSelection() );
492  }
493 
494  else if( module && evt->IsMotion() )
495  {
496  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
497  selection.SetReferencePoint( cursorPos );
498  getView()->Update( &selection );
499  }
500 
501  else if( module && evt->IsAction( &PCB_ACTIONS::properties ) )
502  {
503  // Calling 'Properties' action clears the selection, so we need to restore it
504  reselect = true;
505  }
506 
507  // Enable autopanning and cursor capture only when there is a module to be placed
508  controls->SetAutoPan( !!module );
509  controls->CaptureCursor( !!module );
510  }
511 
513 
514  return 0;
515 }
516 
517 
519 {
520  return modifyLockSelected( TOGGLE );
521 }
522 
523 
525 {
526  return modifyLockSelected( ON );
527 }
528 
529 
531 {
532  return modifyLockSelected( OFF );
533 }
534 
535 
537 {
539  const SELECTION& selection = selTool->GetSelection();
540 
541  if( selection.Empty() )
543 
544  bool modified = false;
545 
546  for( auto i : selection )
547  {
548  auto item = static_cast<BOARD_ITEM*>( i );
549  bool prevState = item->IsLocked();
550 
551  switch( aMode )
552  {
553  case ON:
554  item->SetLocked( true );
555  break;
556 
557  case OFF:
558  item->SetLocked( false );
559  break;
560 
561  case TOGGLE:
562  item->SetLocked( !prevState );
563  break;
564  }
565 
566  // Check if we really modified an item
567  if( !modified && prevState != item->IsLocked() )
568  modified = true;
569  }
570 
571  if( modified )
572  m_frame->OnModify();
573 
574  return 0;
575 }
576 
577 
579 {
580  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
581  KIGFX::VIEW* view = getView();
583  BOARD* board = getModel<BOARD>();
584  PCB_TARGET* target = new PCB_TARGET( board );
585 
586  // Init the new item attributes
587  target->SetLayer( Edge_Cuts );
588  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
589  target->SetSize( Millimeter2iu( 5 ) );
590  VECTOR2I cursorPos = controls->GetCursorPosition();
591  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
592 
593  // Add a VIEW_GROUP that serves as a preview for the new item
594  KIGFX::VIEW_GROUP preview( view );
595  preview.Add( target );
596  view->Add( &preview );
597 
599  controls->SetSnapping( true );
600 
601  Activate();
602  m_frame->SetToolID( ID_PCB_TARGET_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
603 
604  // Main loop: keep receiving events
605  while( OPT_TOOL_EVENT evt = Wait() )
606  {
607  cursorPos = controls->GetCursorPosition();
608 
609  if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
610  break;
611 
612  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
613  {
614  target->SetWidth( target->GetWidth() + WIDTH_STEP );
615  view->Update( &preview );
616  }
617 
618  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
619  {
620  int width = target->GetWidth();
621 
622  if( width > WIDTH_STEP )
623  {
624  target->SetWidth( width - WIDTH_STEP );
625  view->Update( &preview );
626  }
627  }
628 
629  else if( evt->IsClick( BUT_LEFT ) )
630  {
631  assert( target->GetSize() > 0 );
632  assert( target->GetWidth() > 0 );
633 
634  BOARD_COMMIT commit( m_frame );
635  commit.Add( target );
636  commit.Push( _( "Place a layer alignment target" ) );
637 
638  preview.Remove( target );
639 
640  // Create next PCB_TARGET
641  target = new PCB_TARGET( *target );
642  preview.Add( target );
643  }
644 
645  else if( evt->IsClick( BUT_RIGHT ) )
646  {
647  m_menu.ShowContextMenu( selTool->GetSelection() );
648  }
649 
650  else if( evt->IsMotion() )
651  {
652  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
653  view->Update( &preview );
654  }
655  }
656 
657  delete target;
658 
659  controls->SetSnapping( false );
660  view->Remove( &preview );
661 
663 
664  return 0;
665 }
666 
667 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
668  std::vector<ZONE_CONTAINER *>& aMergedZones )
669 {
670  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
671  {
672  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
674  }
675 
676  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
677 
678  // We should have one polygon with hole
679  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
680  // and therefore cannot be merged (they are dectected as intersecting)
681  // but we should never have more than 2 polys
682  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
683  {
684  wxLogMessage( wxT( "BOARD::CombineAreas error: more than 2 polys after merging" ) );
685  return false;
686  }
687 
688  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
689  {
690  aCommit.Remove( aOriginZones[i] );
691  }
692 
693  aCommit.Modify( aOriginZones[0] );
694  aMergedZones.push_back( aOriginZones[0] );
695 
696  aOriginZones[0]->SetLocalFlags( 1 );
697  aOriginZones[0]->Hatch();
698  aOriginZones[0]->CacheTriangulation();
699 
700  return true;
701 }
702 
704 {
705  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
706  BOARD* board = getModel<BOARD>();
707  BOARD_COMMIT commit( m_frame );
708 
709  if( selection.Size() < 2 )
710  return 0;
711 
712  int netcode = -1;
713 
714  ZONE_CONTAINER* firstZone = nullptr;
715  std::vector<ZONE_CONTAINER*> toMerge, merged;
716 
717  for( auto item : selection )
718  {
719  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
720 
721  if( !curr_area )
722  continue;
723 
724  if( !firstZone )
725  firstZone = curr_area;
726 
727  netcode = curr_area->GetNetCode();
728 
729  if( firstZone )
730  {
731  if( firstZone->GetNetCode() != netcode )
732  continue;
733 
734  if( curr_area->GetPriority() != firstZone->GetPriority() )
735  continue;
736 
737  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
738  continue;
739 
740  if( curr_area->GetLayer() != firstZone->GetLayer() )
741  continue;
742 
743  if( !board->TestAreaIntersection( curr_area, firstZone ) )
744  continue;
745 
746  toMerge.push_back( curr_area );
747  }
748  else
749  {
750  toMerge.push_back( curr_area );
751  }
752  }
753 
755 
756  if( mergeZones( commit, toMerge, merged ) )
757  {
758  commit.Push( _( "Merge zones" ) );
759 
760  for( auto item : merged )
762  }
763 
764  return 0;
765 }
766 
767 
769 {
770  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
771  const auto& selection = selTool->GetSelection();
772 
773  // because this pops up the zone editor, it would be confusing
774  // to handle multiple zones, so just handle single selections
775  // containing exactly one zone
776  if( selection.Size() != 1 )
777  return 0;
778 
779  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
780 
781  if( !oldZone )
782  return 0;
783 
784  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
785  newZone->ClearSelected();
786  newZone->UnFill();
787  ZONE_SETTINGS zoneSettings;
788  zoneSettings << *oldZone;
789 
790  bool success = false;
791 
792  if( oldZone->GetIsKeepout() )
793  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
794  else if( oldZone->IsOnCopperLayer() )
795  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
796  else
797  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
798 
799  // If the new zone is on the same layer as the the initial zone,
800  // do nothing
801  if( success )
802  {
803  if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
804  {
805  DisplayError(
806  m_frame, _( "The duplicated keepout zone cannot be on the same layers as the original zone." ) );
807  success = false;
808  }
809  else if( !oldZone->GetIsKeepout() && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
810  {
811  DisplayError(
812  m_frame, _( "The duplicated zone cannot be on the same layer as the original zone." ) );
813  success = false;
814  }
815  }
816 
817  // duplicate the zone
818  if( success )
819  {
820  BOARD_COMMIT commit( m_frame );
821  zoneSettings.ExportSetting( *newZone );
822 
823  commit.Add( newZone.release() );
824  commit.Push( _( "Duplicate zone" ) );
825  }
826 
827  return 0;
828 }
829 
830 
832 {
833  if( m_probingSchToPcb )
834  {
835  m_probingSchToPcb = false;
836  return 0;
837  }
838 
840  const SELECTION& selection = selTool->GetSelection();
841 
842  if( selection.Size() == 1 )
843  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
844 
845  return 0;
846 }
847 
848 
850 {
851  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
852 
853  if( item )
854  {
855  m_probingSchToPcb = true;
856  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
858 
859  // If it is a pad and the net highlighting tool is enabled, highlight the net
860  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
861  {
862  int net = static_cast<D_PAD*>( item )->GetNetCode();
864  }
865  else
866  // Otherwise simply select the corresponding item
867  {
869  // Ensure the display is refreshed, because in some installs
870  // the refresh is done only when the gal canvas has the focus, and
871  // that is not the case when crossprobing from Eeschema:
873  }
874  }
875 
876  return 0;
877 }
878 
879 
881  BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
882 {
883  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
884  originViewItem->SetPosition( wxPoint( aPosition.x, aPosition.y ) );
885  aView->MarkDirty();
886  aFrame->OnModify();
887  return true;
888 }
889 
890 
892  BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
893 {
894  aFrame->SaveCopyInUndoList( originViewItem, UR_DRILLORIGIN );
895  return DoSetDrillOrigin( aView, aFrame, originViewItem, aPosition );
896 }
897 
898 
900 {
901  Activate();
902 
904  assert( picker );
905 
906  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) );
907  picker->SetClickHandler( std::bind( SetDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
908  picker->Activate();
909  Wait();
910 
911  return 0;
912 }
913 
922 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition,
923  bool aUseSelection = false )
924 {
925  auto render = aToolMgr->GetView()->GetPainter()->GetSettings();
926  auto frame = static_cast<PCB_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
927 
928  BOARD* board = static_cast<BOARD*>( aToolMgr->GetModel() );
929 
930  int net = -1;
931  bool enableHighlight = false;
932 
933  if( aUseSelection )
934  {
935  auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
936 
937  const SELECTION& selection = selectionTool->GetSelection();
938 
939  for( auto item : selection )
940  {
941  if( BOARD_CONNECTED_ITEM::ClassOf( item ) )
942  {
943  auto ci = static_cast<BOARD_CONNECTED_ITEM*>( item );
944 
945  int item_net = ci->GetNetCode();
946 
947  if( net < 0 )
948  {
949  net = item_net;
950  }
951  else if( net != item_net )
952  {
953  // more than one net selected: do nothing
954  return 0;
955  }
956  }
957  }
958 
959  enableHighlight = ( net >= 0 && net != render->GetHighlightNetCode() );
960  }
961 
962  // If we didn't get a net to highlight from the selection, use the cursor
963  if( net < 0 )
964  {
965  auto guide = frame->GetCollectorsGuide();
966  GENERAL_COLLECTOR collector;
967 
968  // Find a connected item for which we are going to highlight a net
970  wxPoint( aPosition.x, aPosition.y ), guide );
971 
972  for( int i = 0; i < collector.GetCount(); i++ )
973  {
974  if( collector[i]->Type() == PCB_PAD_T )
975  {
976  frame->SendMessageToEESCHEMA( static_cast<BOARD_CONNECTED_ITEM*>( collector[i] ) );
977  break;
978  }
979  }
980 
981  enableHighlight = ( collector.GetCount() > 0 );
982 
983  // Obtain net code for the clicked item
984  if( enableHighlight )
985  net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
986  }
987 
988  // Toggle highlight when the same net was picked
989  if( net > 0 && net == render->GetHighlightNetCode() )
990  enableHighlight = !render->IsHighlightEnabled();
991 
992  if( enableHighlight != render->IsHighlightEnabled() || net != render->GetHighlightNetCode() )
993  {
994  render->SetHighlight( enableHighlight, net );
995  aToolMgr->GetView()->UpdateAllLayersColor();
996  }
997 
998  // Store the highlighted netcode in the current board (for dialogs for instance)
999  if( enableHighlight && net >= 0 )
1000  {
1001  board->SetHighLightNet( net );
1002 
1003  NETINFO_ITEM* netinfo = board->FindNet( net );
1004 
1005  if( netinfo )
1006  {
1007  MSG_PANEL_ITEMS items;
1008  netinfo->GetMsgPanelInfo( items );
1009  frame->SetMsgPanel( items );
1010  frame->SendCrossProbeNetName( netinfo->GetNetname() );
1011  }
1012  }
1013  else
1014  {
1015  board->ResetHighLight();
1016  frame->SetMsgPanel( board );
1018  }
1019 
1020  return true;
1021 }
1022 
1023 
1025 {
1026  int netcode = aEvent.Parameter<intptr_t>();
1027 
1028  if( netcode > 0 )
1029  {
1031  render->SetHighlight( true, netcode );
1033  }
1034  else
1035  {
1036  // No net code specified, pick the net code belonging to the item under the cursor
1037  highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
1038  }
1039 
1040  return 0;
1041 }
1042 
1043 
1045 {
1046  // If the keyboard hotkey was triggered, the behavior is as follows:
1047  // If we are already in the highlight tool, behave the same as a left click.
1048  // If we are not, highlight the net of the selected item(s), or if there is
1049  // no selection, then behave like a Ctrl+Left Click.
1051  {
1052  bool use_selection = ( m_frame->GetToolId() != ID_PCB_HIGHLIGHT_BUTT );
1053  highlightNet( m_toolMgr, getViewControls()->GetMousePosition(),
1054  use_selection );
1055  }
1056 
1057  Activate();
1058 
1059  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1060  assert( picker );
1061 
1062  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
1063  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1, false ) );
1064  picker->SetSnapping( false );
1065  picker->Activate();
1066  Wait();
1067 
1068  return 0;
1069 }
1070 
1071 
1072 static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
1073 {
1074  auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
1075 
1076  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
1078 
1079  const SELECTION& selection = selectionTool->GetSelection();
1080 
1081  if( selection.Empty() )
1082  return true;
1083 
1084  for( auto item : selection )
1085  {
1086  if( item->Type() == PCB_MODULE_T )
1087  {
1088  for( auto pad : static_cast<MODULE *> (item)->Pads() )
1089  {
1090  pad->SetLocalRatsnestVisible( true );
1091  }
1092  }
1093  }
1094 
1095  return true;
1096 }
1097 
1098 
1100 {
1101  Activate();
1102 
1103  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
1104  assert( picker );
1105 
1106  m_frame->SetToolID( ID_PCB_SHOW_1_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) );
1107  picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, _1 ) );
1108  picker->SetSnapping( false );
1109  picker->Activate();
1110  Wait();
1111 
1112  return 0;
1113 }
1114 
1115 
1117 {
1118  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1119  auto& selection = selectionTool->GetSelection();
1120  auto connectivity = getModel<BOARD>()->GetConnectivity();
1121 
1122  if( selection.Empty() )
1123  {
1124  connectivity->ClearDynamicRatsnest();
1125  }
1126  else if( m_slowRatsnest )
1127  {
1128  // Compute ratsnest only when user stops dragging for a moment
1129  connectivity->HideDynamicRatsnest();
1130  m_ratsnestTimer.Start( 20 );
1131  }
1132  else
1133  {
1134  // Check how much time doest it take to calculate ratsnest
1135  PROF_COUNTER counter;
1137  counter.Stop();
1138 
1139  // If it is too slow, then switch to 'slow ratsnest' mode when
1140  // ratsnest is calculated when user stops dragging items for a moment
1141  if( counter.msecs() > 25 )
1142  {
1143  m_slowRatsnest = true;
1144  connectivity->HideDynamicRatsnest();
1145  }
1146  }
1147 
1148  return 0;
1149 }
1150 
1151 
1153 {
1154  getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
1155  m_slowRatsnest = false;
1156  return 0;
1157 }
1158 
1159 
1160 void PCB_EDITOR_CONTROL::ratsnestTimer( wxTimerEvent& aEvent )
1161 {
1162  m_ratsnestTimer.Stop();
1164  static_cast<PCB_DRAW_PANEL_GAL*>( m_frame->GetGalCanvas() )->RedrawRatsnest();
1166 }
1167 
1168 
1170 {
1171  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1172  auto& selection = selectionTool->GetSelection();
1173  auto connectivity = board()->GetConnectivity();
1174 
1175  std::vector<BOARD_ITEM*> items;
1176  items.reserve( selection.Size() );
1177 
1178  for( auto item : selection )
1179  items.push_back( static_cast<BOARD_ITEM*>( item ) );
1180 
1181  connectivity->ComputeDynamicRatsnest( items );
1182 }
1183 
1184 
1186 {
1187  // Track & via size control
1192 
1193  // Zone actions
1196 
1197  // Placing tools
1200 
1201  // Other
1214 }
1215 
1216 
1217 const int PCB_EDITOR_CONTROL::WIDTH_STEP = 100000;
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
void Stop()
save the time when this function was called, and set the counter stane to stop
Definition: profile.h:82
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:373
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:106
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
static TOOL_ACTION placeModule
Activation of the drawing tool (placing a MODULE)
Definition: pcb_actions.h:175
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:56
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
MODULE * LoadModuleFromLibrary(const wxString &aLibrary, bool aUseFootprintViewer=true)
Function LoadModuleFromLibrary opens a dialog to select a footprint.
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
COMMIT & Added(EDA_ITEM *aItem)
Notifies observers that aItem has been added
Definition: commit.h:84
int ZoneMerge(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:375
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 void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to eeschema for highlighting.
static const KICAD_T PadsTracksOrZones[]
A scan list for PADs, TRACKs, VIAs, or ZONEs.
Definition: collectors.h:290
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:305
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:184
virtual void SetPosition(const wxPoint &aPos)=0
Class RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output ...
Definition: painter.h:56
MODE GetDrawingMode() const
Function GetDrawingMode.
Model changes (required full reload)
Definition: tool_base.h:83
static TOOL_ACTION drawSimilarZone
Activation of the drawing tool (drawing a similar ZONE to another one)
Definition: pcb_actions.h:169
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:388
static TOOL_ACTION lock
Definition: pcb_actions.h:374
This file is part of the common library.
Class 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:295
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:288
std::vector< int > m_TrackWidthList
Track width list.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:97
void ClearSelected()
Definition: base_struct.h:242
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
Class CONTEXT_MENU.
Definition: context_menu.h:44
VIEW_CONTROLS class definition.
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class&#39;s Inspector method, which does the collection. ...
Definition: collectors.cpp:450
int TrackWidthDec(const TOOL_EVENT &aEvent)
Class SELECTION_TOOL.
wxWindow * GetEditFrame() const
Definition: tool_manager.h:267
Class BOARD to handle a board.
virtual void Revert() override
Revertes the commit by restoring the modifed items state.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
int HideSelectionRatsnest(const TOOL_EVENT &aEvent)
Hides ratsnest for selected items. Called when there are no items selected.
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
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:364
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:175
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:108
void ResetHighLight()
Function ResetHighLight Reset all high light data to the init state.
Definition: class_board.h:356
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:287
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Action activates a tool
Definition: tool_event.h:146
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:125
static int LegacyHotKey(int aHotKey)
Creates a hot key code that refers to a legacy hot key setting, instead of a particular key...
Definition: tool_action.h:174
Classes to handle copper zones.
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:54
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:291
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
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...
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo returns the information about the NETINFO_ITEM in aList to display in the me...
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...
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:45
static TOOL_ACTION highlightNetCursor
Definition: pcb_actions.h:386
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
wxTimer m_ratsnestTimer
Timer that start ratsnest calculation when it is slow to compute.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION showLocalRatsnest
Definition: pcb_actions.h:392
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:294
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:111
static TOOL_ACTION crossProbeSchToPcb
Definition: pcb_actions.h:389
TOOL_MENU & GetToolMenu()
Get the DRAWING_TOOL top-level context menu
Definition: drawing_tool.h:62
Pcbnew hotkeys.
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:187
MODIFY_MODE
How to modify a property for selected items.
Generic tool for picking a point.
Definition: picker_tool.h:34
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
void ExportSetting(ZONE_CONTAINER &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:602
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
Class TOOL_MANAGER.
Definition: tool_manager.h:49
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:134
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:286
class MODULE, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:390
static SELECTION_CONDITION SameLayer()
Function SameLayer Creates a functor that tests if selection contains items that belong exclusively t...
void AddStandardSubMenus(EDA_DRAW_FRAME &aFrame)
Function CreateBasicMenu.
Definition: tool_menu.cpp:95
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
int ShowLocalRatsnest(const TOOL_EVENT &aEvent)
Shows local ratsnest of a component
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:587
int ViaSizeDec(const TOOL_EVENT &aEvent)
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
Definition: draw_frame.cpp:832
Class DRAWING_TOOL.
Definition: drawing_tool.h:49
int TrackWidthInc(const TOOL_EVENT &aEvent)
static SELECTION_CONDITION OnlyTypes(const std::vector< KICAD_T > &aTypes)
Function OnlyTypes Creates a functor that tests if the selected items are only of given types...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:135
Class TOOL_EVENT.
Definition: tool_event.h:162
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:298
SELECTION & GetSelection()
Function GetSelection()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
int DrillOrigin(const TOOL_EVENT &aEvent)
Runs the drill origin tool for setting the origin for drill and pick-and-place files.
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
MODULE * module() const
Definition: pcb_tool.h:137
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.
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
ZONE_EDIT_T InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_CONTAINER *aZone, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing...
void SetPosition(const wxPoint &aPos) override
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
void ratsnestTimer(wxTimerEvent &aEvent)
Event handler to recalculate dynamic ratsnest
int ViaSizeInc(const TOOL_EVENT &aEvent)
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
All active tools
Definition: tool_event.h:138
static bool DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *aItem, const VECTOR2D &aPoint)
Low-level access (below undo) to setting the drill origin
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:1499
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:166
static TOOL_ACTION placeTarget
Activation of the drawing tool (placing a TARGET)
Definition: pcb_actions.h:172
void AddModuleToBoard(MODULE *module, wxDC *aDC=nullptr)
Adds the given module to the board.
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:297
int UnlockSelected(const TOOL_EVENT &aEvent)
Unlocks selected items.
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
static bool ClassOf(const EDA_ITEM *aItem)
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
virtual const wxPoint GetPosition() const =0
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launches a tool to pick the item whose net is going to be highlighted.
static TOOL_ACTION zoneUnfill
Definition: pcb_actions.h:296
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
Class ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:49
int GetNetCode() const
Function GetNetCode.
void SetHighLightNet(int aNetCode)
Function SetHighLightNet.
Definition: class_board.h:372
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:301
CONTEXT_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes. ...
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:616
double msecs() const
Definition: profile.h:124
void SendMessageToEESCHEMA(BOARD_ITEM *objectToSync)
Function SendMessageToEESCHEMA sends a message to the schematic editor so that it may move its cursor...
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
MODE
The possible drawing modes of DRAWING_TOOL
Definition: drawing_tool.h:68
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
CONTEXT_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes. ...
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Updates ratsnest for selected items.
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:385
static TOOL_ACTION highlightNetSelection
Definition: pcb_actions.h:387
EDA_ITEM * GetModel() const
Definition: tool_manager.h:262
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int PlaceTarget(const TOOL_EVENT &aEvent)
Function PlaceTarget() Allows user to place a layer alignment target.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:133
static const int WIDTH_STEP
virtual bool IsLocked() const
Function IsLocked.
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddItem()
int modifyLockSelected(MODIFY_MODE aMode)
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:232
static bool showLocalRatsnest(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
int GetToolId() const
Definition: draw_frame.h:488
void update() override
Update menu state stub.
Class TOOL_ACTION.
Definition: tool_action.h:46
size_t i
Definition: json11.cpp:597
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type...
bool m_probingSchToPcb
Flag to ignore a single crossprobe message from eeschema.
virtual void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))=0
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
ZONE_EDIT_T InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing...
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Vias size and drill list.
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
void Activate()
Function Activate() Runs the tool.
TOOL_MENU m_menu
Menu model displayed by the tool.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:895
PCB_TARGET class definition.
void SetAuxOrigin(const wxPoint &aPoint) override
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Notifies eeschema about the selected item.
ZONE_EDIT_T InvokeKeepoutAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeKeepoutAreaEditor invokes up a modal dialog window for copper zone editing...
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:334
static TOOL_ACTION findMove
Find an item and start moving.
Definition: pcb_actions.h:399
Module description (excepted pads)
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:235
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter()
Definition: edit_tool.cpp:1098
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition, bool aUseSelection=false)
Function highlightNet() Looks for a BOARD_CONNECTED_ITEM in a given spot, and if one is found - it en...
int CrossProbeSchToPcb(const TOOL_EVENT &aEvent)
Reacts to selection change in eeschema.
Class VIEW.
Definition: view.h:58
int m_EdgeSegmentWidth
current graphic line width (EDGE layer only)
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:101
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:743
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE_CONTAINER * > &aOriginZones, std::vector< ZONE_CONTAINER * > &aMergedZones)
static bool SetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *aItem, const VECTOR2D &aPoint)
UI-level access (including undo) to setting the drill origin
void SetHighlight(bool aEnabled, int aNetcode=-1)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
Definition: painter.h:140
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Toggles &#39;lock&#39; property for selected items.
Rendering engine changes.
Definition: tool_base.h:84
bool m_slowRatsnest
Flag to indicate whether the current selection ratsnest is slow to calculate.
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
void calculateSelectionRatsnest()
Recalculates dynamic ratsnest for the current selection
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:289
void setTransitions() override
Sets up handlers for various events.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
Definition: zone_settings.h:69
class 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:50
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:603
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
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 * board() const
Definition: pcb_tool.h:136
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39