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::showLocalRatsnest( "pcbnew.Control.showLocalRatsnest",
145  AS_GLOBAL, 0,
146  "", "" );
147 
149 {
150 public:
152  {
153  SetIcon( add_zone_xpm );
154  SetTitle( _( "Zones" ) );
155 
156  Add( PCB_ACTIONS::zoneFill );
160 
161  AppendSeparator();
162 
163  Add( PCB_ACTIONS::zoneMerge );
167  }
168 
169 
170 protected:
171  CONTEXT_MENU* create() const override
172  {
173  return new ZONE_CONTEXT_MENU();
174  }
175 
176 private:
177  void update() override
178  {
179  SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
180 
181  // enable zone actions that act on a single zone
182  bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 )
184  )( selTool->GetSelection() );
185 
186  Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
187  Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
188  Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
189 
190  // enable zone actions that ably to a specific set of zones (as opposed to all of them)
191  bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
192 
193  Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
194  Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
195 
196  // lines like this make me really think about a better name for SELECTION_CONDITIONS class
197  bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
198  /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
201 
202  Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
203  }
204 };
205 
206 
208 {
209 public:
211  {
212  SetIcon( locked_xpm );
213  SetTitle( _( "Locking" ) );
214 
215  Add( PCB_ACTIONS::lock );
216  Add( PCB_ACTIONS::unlock );
218  }
219 
220  CONTEXT_MENU* create() const override
221  {
222  return new LOCK_CONTEXT_MENU();
223  }
224 };
225 
226 
228  PCB_TOOL( "pcbnew.EditorControl" ),
229  m_frame( nullptr ),
230  m_menu( *this )
231 {
232  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
234  m_probingSchToPcb = false;
235  m_slowRatsnest = false;
236 }
237 
238 
240 {
241 }
242 
243 
245 {
246  m_frame = getEditFrame<PCB_EDIT_FRAME>();
247 
248  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
249  {
250  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
251  getView()->Remove( m_placeOrigin.get() );
252  getView()->Add( m_placeOrigin.get() );
253  }
254 }
255 
256 
258 {
259  auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
260  return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
261  };
262 
263  auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
264  return ( m_frame->GetToolId() == ID_NO_TOOL_SELECTED && aSel.Size() == 0 );
265  };
266 
267  auto placeModuleCondition = [ this ] ( const SELECTION& aSel ) {
268  return ( m_frame->GetToolId() == ID_PCB_MODULE_BUTT && aSel.GetSize() == 0 );
269  };
270 
271  auto& ctxMenu = m_menu.GetMenu();
272 
273  // "Cancel" goes at the top of the context menu when a tool is active
274  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1000 );
275  ctxMenu.AddSeparator( activeToolCondition, 1000 );
276 
277  // "Get and Place Footprint" should be available for Place Footprint tool
278  ctxMenu.AddItem( PCB_ACTIONS::findMove, placeModuleCondition, 1000 );
279  ctxMenu.AddSeparator( placeModuleCondition, 1000 );
280 
281  // Finally, add the standard zoom & grid items
282  m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
283 
284  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
285  zoneMenu->SetTool( this );
286 
287  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
288  lockMenu->SetTool( this );
289 
290  // Add the PCB control menus to relevant other tools
291 
293 
294  if( selTool )
295  {
296  auto& toolMenu = selTool->GetToolMenu();
297  auto& menu = toolMenu.GetMenu();
298 
299  // Add "Get and Place Footprint" when Selection tool is in an inactive state
300  menu.AddItem( PCB_ACTIONS::findMove, inactiveStateCondition );
301  menu.AddSeparator( inactiveStateCondition );
302 
303  toolMenu.AddSubMenu( zoneMenu );
304  toolMenu.AddSubMenu( lockMenu );
305 
306  menu.AddMenu( zoneMenu.get(), false,
308 
309  menu.AddMenu( lockMenu.get(), false,
311  }
312 
313  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
314 
315  if( drawingTool )
316  {
317  auto& toolMenu = drawingTool->GetToolMenu();
318  auto& menu = toolMenu.GetMenu();
319 
320  toolMenu.AddSubMenu( zoneMenu );
321 
322  // Functor to say if the PCB_EDIT_FRAME is in a given mode
323  // Capture the tool pointer and tool mode by value
324  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
325  {
326  return [=]( const SELECTION& sel )
327  {
328  return drawingTool->GetDrawingMode() == aMode;
329  };
330  };
331 
332  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
333  }
334 
335  m_ratsnestTimer.SetOwner( this );
336  Connect( m_ratsnestTimer.GetId(), wxEVT_TIMER,
337  wxTimerEventHandler( PCB_EDITOR_CONTROL::ratsnestTimer ), NULL, this );
338 
339  return true;
340 }
341 
342 
343 // Track & via size control
345 {
346  BOARD* board = getModel<BOARD>();
347  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
348 
349  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
350  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
351 
352  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
353  board->GetDesignSettings().UseCustomTrackViaSize( false );
354 
356 
357  return 0;
358 }
359 
360 
362 {
363  BOARD* board = getModel<BOARD>();
364  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
365 
366  if( widthIndex < 0 )
367  widthIndex = 0;
368 
369  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
370  board->GetDesignSettings().UseCustomTrackViaSize( false );
371 
373 
374  return 0;
375 }
376 
377 
379 {
380  BOARD* board = getModel<BOARD>();
381  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
382 
383  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
384  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
385 
386  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
387  board->GetDesignSettings().UseCustomTrackViaSize( false );
388 
390 
391  return 0;
392 }
393 
394 
396 {
397  BOARD* board = getModel<BOARD>();
398  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
399 
400  if( sizeIndex < 0 )
401  sizeIndex = 0;
402 
403  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
404  board->GetDesignSettings().UseCustomTrackViaSize( false );
405 
407 
408  return 0;
409 }
410 
411 
413 {
414  MODULE* module = aEvent.Parameter<MODULE*>();
417  SELECTION& selection = selTool->GetSelection();
418  BOARD_COMMIT commit( m_frame );
419 
421  controls->ShowCursor( true );
422  controls->SetSnapping( true );
423 
424  Activate();
425  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_PENCIL, _( "Add footprint" ) );
426 
427  // Add all the drawable parts to preview
428  VECTOR2I cursorPos = controls->GetCursorPosition();
429 
430  if( module )
431  {
432  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
433  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
434  }
435 
436  bool reselect = false;
437 
438  // Main loop: keep receiving events
439  while( OPT_TOOL_EVENT evt = Wait() )
440  {
441  cursorPos = controls->GetCursorPosition();
442 
443  if( reselect && module )
444  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
445 
446  if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
447  {
448  if( module )
449  {
451  commit.Revert();
452  module = NULL;
453  }
454  else // let's have another chance placing a module
455  break;
456 
457  if( evt->IsActivate() ) // now finish unconditionally
458  break;
459  }
460 
461  else if( evt->IsClick( BUT_LEFT ) )
462  {
463  if( !module )
464  {
465  // Pick the module to be placed
466  module = m_frame->LoadModuleFromLibrary( wxEmptyString,
468  true, NULL );
469 
470  if( module == NULL )
471  continue;
472 
473  // NOTE: Module has been already added in LoadModuleFromLibrary(),
474  commit.Added( module );
475  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
476  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, module );
477  controls->SetCursorPosition( cursorPos, false );
478  }
479  else
480  {
482  commit.Push( _( "Place a module" ) );
483  module = NULL; // to indicate that there is no module that we currently modify
484  }
485  }
486 
487  else if( evt->IsClick( BUT_RIGHT ) )
488  {
489  m_menu.ShowContextMenu( selTool->GetSelection() );
490  }
491 
492  else if( module && evt->IsMotion() )
493  {
494  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
495  selection.SetReferencePoint( cursorPos );
496  getView()->Update( &selection );
497  }
498 
499  else if( module && evt->IsAction( &PCB_ACTIONS::properties ) )
500  {
501  // Calling 'Properties' action clears the selection, so we need to restore it
502  reselect = true;
503  }
504 
505  // Enable autopanning and cursor capture only when there is a module to be placed
506  controls->SetAutoPan( !!module );
507  controls->CaptureCursor( !!module );
508  }
509 
511 
512  return 0;
513 }
514 
515 
517 {
518  return modifyLockSelected( TOGGLE );
519 }
520 
521 
523 {
524  return modifyLockSelected( ON );
525 }
526 
527 
529 {
530  return modifyLockSelected( OFF );
531 }
532 
533 
535 {
537  const SELECTION& selection = selTool->GetSelection();
538 
539  if( selection.Empty() )
541 
542  bool modified = false;
543 
544  for( auto i : selection )
545  {
546  auto item = static_cast<BOARD_ITEM*>( i );
547  bool prevState = item->IsLocked();
548 
549  switch( aMode )
550  {
551  case ON:
552  item->SetLocked( true );
553  break;
554 
555  case OFF:
556  item->SetLocked( false );
557  break;
558 
559  case TOGGLE:
560  item->SetLocked( !prevState );
561  break;
562  }
563 
564  // Check if we really modified an item
565  if( !modified && prevState != item->IsLocked() )
566  modified = true;
567  }
568 
569  if( modified )
570  m_frame->OnModify();
571 
572  return 0;
573 }
574 
575 
577 {
578  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
579  KIGFX::VIEW* view = getView();
581  BOARD* board = getModel<BOARD>();
582  PCB_TARGET* target = new PCB_TARGET( board );
583 
584  // Init the new item attributes
585  target->SetLayer( Edge_Cuts );
586  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
587  target->SetSize( Millimeter2iu( 5 ) );
588  VECTOR2I cursorPos = controls->GetCursorPosition();
589  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
590 
591  // Add a VIEW_GROUP that serves as a preview for the new item
592  KIGFX::VIEW_GROUP preview( view );
593  preview.Add( target );
594  view->Add( &preview );
595 
597  controls->SetSnapping( true );
598 
599  Activate();
600  m_frame->SetToolID( ID_PCB_TARGET_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
601 
602  // Main loop: keep receiving events
603  while( OPT_TOOL_EVENT evt = Wait() )
604  {
605  cursorPos = controls->GetCursorPosition();
606 
607  if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
608  break;
609 
610  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
611  {
612  target->SetWidth( target->GetWidth() + WIDTH_STEP );
613  view->Update( &preview );
614  }
615 
616  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
617  {
618  int width = target->GetWidth();
619 
620  if( width > WIDTH_STEP )
621  {
622  target->SetWidth( width - WIDTH_STEP );
623  view->Update( &preview );
624  }
625  }
626 
627  else if( evt->IsClick( BUT_LEFT ) )
628  {
629  assert( target->GetSize() > 0 );
630  assert( target->GetWidth() > 0 );
631 
632  BOARD_COMMIT commit( m_frame );
633  commit.Add( target );
634  commit.Push( _( "Place a layer alignment target" ) );
635 
636  preview.Remove( target );
637 
638  // Create next PCB_TARGET
639  target = new PCB_TARGET( *target );
640  preview.Add( target );
641  }
642 
643  else if( evt->IsClick( BUT_RIGHT ) )
644  {
645  m_menu.ShowContextMenu( selTool->GetSelection() );
646  }
647 
648  else if( evt->IsMotion() )
649  {
650  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
651  view->Update( &preview );
652  }
653  }
654 
655  delete target;
656 
657  controls->SetSnapping( false );
658  view->Remove( &preview );
659 
661 
662  return 0;
663 }
664 
665 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
666  std::vector<ZONE_CONTAINER *>& aMergedZones )
667 {
668  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
669  {
670  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
672  }
673 
674  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
675 
676  // We should have one polygon with hole
677  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
678  // and therefore cannot be merged (they are dectected as intersecting)
679  // but we should never have more than 2 polys
680  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
681  {
682  wxLogMessage( wxT( "BOARD::CombineAreas error: more than 2 polys after merging" ) );
683  return false;
684  }
685 
686  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
687  {
688  aCommit.Remove( aOriginZones[i] );
689  }
690 
691  aCommit.Modify( aOriginZones[0] );
692  aMergedZones.push_back( aOriginZones[0] );
693 
694  aOriginZones[0]->SetLocalFlags( 1 );
695  aOriginZones[0]->Hatch();
696  aOriginZones[0]->CacheTriangulation();
697 
698  return true;
699 }
700 
702 {
703  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
704  BOARD* board = getModel<BOARD>();
705  BOARD_COMMIT commit( m_frame );
706 
707  if( selection.Size() < 2 )
708  return 0;
709 
710  int netcode = -1;
711 
712  ZONE_CONTAINER* firstZone = nullptr;
713  std::vector<ZONE_CONTAINER*> toMerge, merged;
714 
715  for( auto item : selection )
716  {
717  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
718 
719  if( !curr_area )
720  continue;
721 
722  if( !firstZone )
723  firstZone = curr_area;
724 
725  netcode = curr_area->GetNetCode();
726 
727  if( firstZone )
728  {
729  if( firstZone->GetNetCode() != netcode )
730  continue;
731 
732  if( curr_area->GetPriority() != firstZone->GetPriority() )
733  continue;
734 
735  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
736  continue;
737 
738  if( curr_area->GetLayer() != firstZone->GetLayer() )
739  continue;
740 
741  if( !board->TestAreaIntersection( curr_area, firstZone ) )
742  continue;
743 
744  toMerge.push_back( curr_area );
745  }
746  else
747  {
748  toMerge.push_back( curr_area );
749  }
750  }
751 
753 
754  if( mergeZones( commit, toMerge, merged ) )
755  {
756  commit.Push( _( "Merge zones" ) );
757 
758  for( auto item : merged )
760  }
761 
762  return 0;
763 }
764 
765 
767 {
768  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
769  const auto& selection = selTool->GetSelection();
770 
771  // because this pops up the zone editor, it would be confusing
772  // to handle multiple zones, so just handle single selections
773  // containing exactly one zone
774  if( selection.Size() != 1 )
775  return 0;
776 
777  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
778 
779  if( !oldZone )
780  return 0;
781 
782  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
783  newZone->ClearSelected();
784  newZone->UnFill();
785  ZONE_SETTINGS zoneSettings;
786  zoneSettings << *oldZone;
787 
788  bool success = false;
789 
790  if( oldZone->GetIsKeepout() )
791  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
792  else if( oldZone->IsOnCopperLayer() )
793  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
794  else
795  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
796 
797  // If the new zone is on the same layer as the the initial zone,
798  // do nothing
799  if( success )
800  {
801  if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
802  {
803  DisplayError(
804  m_frame, _( "The duplicated keepout zone cannot be on the same layers as the original zone." ) );
805  success = false;
806  }
807  else if( !oldZone->GetIsKeepout() && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
808  {
809  DisplayError(
810  m_frame, _( "The duplicated zone cannot be on the same layer as the original zone." ) );
811  success = false;
812  }
813  }
814 
815  // duplicate the zone
816  if( success )
817  {
818  BOARD_COMMIT commit( m_frame );
819  zoneSettings.ExportSetting( *newZone );
820 
821  commit.Add( newZone.release() );
822  commit.Push( _( "Duplicate zone" ) );
823  }
824 
825  return 0;
826 }
827 
828 
830 {
831  if( m_probingSchToPcb )
832  {
833  m_probingSchToPcb = false;
834  return 0;
835  }
836 
838  const SELECTION& selection = selTool->GetSelection();
839 
840  if( selection.Size() == 1 )
841  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
842 
843  return 0;
844 }
845 
846 
848 {
849  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
850 
851  if( item )
852  {
853  m_probingSchToPcb = true;
854  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
856 
857  // If it is a pad and the net highlighting tool is enabled, highlight the net
858  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
859  {
860  int net = static_cast<D_PAD*>( item )->GetNetCode();
862  }
863  else
864  // Otherwise simply select the corresponding item
865  {
867  // Ensure the display is refreshed, because in some installs
868  // the refresh is done only when the gal canvas has the focus, and
869  // that is not the case when crossprobing from Eeschema:
871  }
872  }
873 
874  return 0;
875 }
876 
877 
879  BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
880 {
881  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
882  originViewItem->SetPosition( wxPoint( aPosition.x, aPosition.y ) );
883  aView->MarkDirty();
884  aFrame->OnModify();
885  return true;
886 }
887 
888 
890  BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
891 {
892  aFrame->SaveCopyInUndoList( originViewItem, UR_DRILLORIGIN );
893  return DoSetDrillOrigin( aView, aFrame, originViewItem, aPosition );
894 }
895 
896 
898 {
899  Activate();
900 
902  assert( picker );
903 
904  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) );
905  picker->SetClickHandler( std::bind( SetDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
906  picker->Activate();
907  Wait();
908 
909  return 0;
910 }
911 
919 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
920 {
921  auto render = aToolMgr->GetView()->GetPainter()->GetSettings();
922  auto frame = static_cast<PCB_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
923  auto guide = frame->GetCollectorsGuide();
924  BOARD* board = static_cast<BOARD*>( aToolMgr->GetModel() );
925  GENERAL_COLLECTOR collector;
926  int net = -1;
927 
928  // Find a connected item for which we are going to highlight a net
930  wxPoint( aPosition.x, aPosition.y ), guide );
931 
932  for( int i = 0; i < collector.GetCount(); i++ )
933  {
934  if( collector[i]->Type() == PCB_PAD_T )
935  {
936  frame->SendMessageToEESCHEMA( static_cast<BOARD_CONNECTED_ITEM*>( collector[i] ) );
937  break;
938  }
939  }
940 
941  bool enableHighlight = ( collector.GetCount() > 0 );
942 
943  // Obtain net code for the clicked item
944  if( enableHighlight )
945  net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
946 
947  // Toggle highlight when the same net was picked
948  if( net > 0 && net == render->GetHighlightNetCode() )
949  enableHighlight = !render->IsHighlightEnabled();
950 
951  if( enableHighlight != render->IsHighlightEnabled() || net != render->GetHighlightNetCode() )
952  {
953  render->SetHighlight( enableHighlight, net );
954  aToolMgr->GetView()->UpdateAllLayersColor();
955  }
956 
957  // Store the highlighted netcode in the current board (for dialogs for instance)
958  if( enableHighlight && net >= 0 )
959  {
960  board->SetHighLightNet( net );
961 
962  NETINFO_ITEM* netinfo = board->FindNet( net );
963 
964  if( netinfo )
965  {
966  MSG_PANEL_ITEMS items;
967  netinfo->GetMsgPanelInfo( items );
968  frame->SetMsgPanel( items );
969  frame->SendCrossProbeNetName( netinfo->GetNetname() );
970  }
971  }
972  else
973  {
974  board->ResetHighLight();
975  frame->SetMsgPanel( board );
977  }
978 
979  return true;
980 }
981 
982 
984 {
985  int netcode = aEvent.Parameter<intptr_t>();
986 
987  if( netcode > 0 )
988  {
990  render->SetHighlight( true, netcode );
992  }
993  else
994  {
995  // No net code specified, pick the net code belonging to the item under the cursor
996  highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
997  }
998 
999  return 0;
1000 }
1001 
1002 
1004 {
1005  Activate();
1006 
1007  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1008  assert( picker );
1009 
1010  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
1011  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1 ) );
1012  picker->SetSnapping( false );
1013  picker->Activate();
1014  Wait();
1015 
1016  return 0;
1017 }
1018 
1019 
1020 static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
1021 {
1022  auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
1023 
1024  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
1026 
1027  const SELECTION& selection = selectionTool->GetSelection();
1028 
1029  if( selection.Empty() )
1030  return true;
1031 
1032  for( auto item : selection )
1033  {
1034  if( item->Type() == PCB_MODULE_T )
1035  {
1036  for( auto pad : static_cast<MODULE *> (item)->Pads() )
1037  {
1038  pad->SetLocalRatsnestVisible( true );
1039  }
1040  }
1041  }
1042 
1043  return true;
1044 }
1045 
1046 
1048 {
1049  Activate();
1050 
1051  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
1052  assert( picker );
1053 
1054  m_frame->SetToolID( ID_PCB_SHOW_1_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) );
1055  picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, _1 ) );
1056  picker->SetSnapping( false );
1057  picker->Activate();
1058  Wait();
1059 
1060  return 0;
1061 }
1062 
1063 
1065 {
1066  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1067  auto& selection = selectionTool->GetSelection();
1068  auto connectivity = getModel<BOARD>()->GetConnectivity();
1069 
1070  if( selection.Empty() )
1071  {
1072  connectivity->ClearDynamicRatsnest();
1073  }
1074  else if( m_slowRatsnest )
1075  {
1076  // Compute ratsnest only when user stops dragging for a moment
1077  connectivity->HideDynamicRatsnest();
1078  m_ratsnestTimer.Start( 20 );
1079  }
1080  else
1081  {
1082  // Check how much time doest it take to calculate ratsnest
1083  PROF_COUNTER counter;
1085  counter.Stop();
1086 
1087  // If it is too slow, then switch to 'slow ratsnest' mode when
1088  // ratsnest is calculated when user stops dragging items for a moment
1089  if( counter.msecs() > 25 )
1090  {
1091  m_slowRatsnest = true;
1092  connectivity->HideDynamicRatsnest();
1093  }
1094  }
1095 
1096  return 0;
1097 }
1098 
1099 
1101 {
1102  getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
1103  m_slowRatsnest = false;
1104  return 0;
1105 }
1106 
1107 
1108 void PCB_EDITOR_CONTROL::ratsnestTimer( wxTimerEvent& aEvent )
1109 {
1110  m_ratsnestTimer.Stop();
1112  static_cast<PCB_DRAW_PANEL_GAL*>( m_frame->GetGalCanvas() )->RedrawRatsnest();
1114 }
1115 
1116 
1118 {
1119  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1120  auto& selection = selectionTool->GetSelection();
1121  auto connectivity = board()->GetConnectivity();
1122 
1123  std::vector<BOARD_ITEM*> items;
1124  items.reserve( selection.Size() );
1125 
1126  for( auto item : selection )
1127  items.push_back( static_cast<BOARD_ITEM*>( item ) );
1128 
1129  connectivity->ComputeDynamicRatsnest( items );
1130 }
1131 
1132 
1134 {
1135  // Track & via size control
1140 
1141  // Zone actions
1144 
1145  // Placing tools
1148 
1149  // Other
1161 }
1162 
1163 
1164 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:107
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
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
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:387
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:260
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:339
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:171
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
MODULE * LoadModuleFromLibrary(const wxString &aLibrary, FP_LIB_TABLE *aTable, bool aUseFootprintViewer=true, wxDC *aDC=NULL)
Function LoadModuleFromLibrary opens a dialog to select a footprint, and loads it into current board...
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.
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:391
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:294
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true) override
Executes the changes.
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:111
static TOOL_ACTION crossProbeSchToPcb
Definition: pcb_actions.h:388
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
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:133
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:389
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:562
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:790
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:134
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:136
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:218
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:1382
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
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...
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
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
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:574
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
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:132
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:476
void update() override
Update menu state stub.
Class TOOL_ACTION.
Definition: tool_action.h:46
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...
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
Function highlightNet() Looks for a BOARD_CONNECTED_ITEM in a given spot, and if one is found - it en...
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...
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:882
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:112
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:309
static TOOL_ACTION findMove
Find an item and start moving.
Definition: pcb_actions.h:398
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:1095
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:672
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:241
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:594
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:135
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39