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 
27 #include "pcb_editor_control.h"
28 #include "pcb_actions.h"
29 #include <tool/tool_manager.h>
30 
31 #include "selection_tool.h"
32 #include "drawing_tool.h"
33 #include "picker_tool.h"
34 
35 #include <painter.h>
36 #include <project.h>
37 #include <pcbnew_id.h>
38 #include <wxPcbStruct.h>
39 #include <class_board.h>
40 #include <class_zone.h>
41 #include <class_draw_panel_gal.h>
42 #include <class_module.h>
43 #include <class_mire.h>
44 #include <ratsnest_data.h>
45 #include <ratsnest_data.h>
46 #include <collectors.h>
48 #include <board_commit.h>
49 #include <confirm.h>
50 #include <bitmaps.h>
51 #include <hotkeys.h>
52 
53 #include <view/view_group.h>
54 #include <view/view_controls.h>
55 #include <origin_viewitem.h>
56 
57 #include <tools/tool_event_utils.h>
58 
59 #include <functional>
60 using namespace std::placeholders;
61 
62 
63 // Track & via size control
64 TOOL_ACTION PCB_ACTIONS::trackWidthInc( "pcbnew.EditorControl.trackWidthInc",
66  "", "" );
67 
68 TOOL_ACTION PCB_ACTIONS::trackWidthDec( "pcbnew.EditorControl.trackWidthDec",
70  "", "" );
71 
72 TOOL_ACTION PCB_ACTIONS::viaSizeInc( "pcbnew.EditorControl.viaSizeInc",
73  AS_GLOBAL, '\'',
74  "", "" );
75 
76 TOOL_ACTION PCB_ACTIONS::viaSizeDec( "pcbnew.EditorControl.viaSizeDec",
77  AS_GLOBAL, '\\',
78  "", "" );
79 
80 TOOL_ACTION PCB_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaSizeChanged",
81  AS_GLOBAL, 0,
82  "", "", NULL, AF_NOTIFY );
83 
84 
85 // Zone actions
86 TOOL_ACTION PCB_ACTIONS::zoneFill( "pcbnew.EditorControl.zoneFill",
87  AS_GLOBAL, 0,
88  _( "Fill" ), _( "Fill zone(s)" ), fill_zone_xpm );
89 
90 TOOL_ACTION PCB_ACTIONS::zoneFillAll( "pcbnew.EditorControl.zoneFillAll",
92  _( "Fill All" ), _( "Fill all zones" ) );
93 
94 TOOL_ACTION PCB_ACTIONS::zoneUnfill( "pcbnew.EditorControl.zoneUnfill",
95  AS_GLOBAL, 0,
96  _( "Unfill" ), _( "Unfill zone(s)" ), zone_unfill_xpm );
97 
98 TOOL_ACTION PCB_ACTIONS::zoneUnfillAll( "pcbnew.EditorControl.zoneUnfillAll",
100  _( "Unfill All" ), _( "Unfill all zones" ) );
101 
102 TOOL_ACTION PCB_ACTIONS::zoneMerge( "pcbnew.EditorControl.zoneMerge",
103  AS_GLOBAL, 0,
104  _( "Merge Zones" ), _( "Merge zones" ) );
105 
106 TOOL_ACTION PCB_ACTIONS::zoneDuplicate( "pcbnew.EditorControl.zoneDuplicate",
107  AS_GLOBAL, 0,
108  _( "Duplicate Zone onto Layer" ), _( "Duplicate zone outline onto a different layer" ),
109  zone_duplicate_xpm );
110 
111 
112 TOOL_ACTION PCB_ACTIONS::placeTarget( "pcbnew.EditorControl.placeTarget",
113  AS_GLOBAL, 0,
114  _( "Add Layer Alignment Target" ), _( "Add a layer alignment target" ), NULL, AF_ACTIVATE );
115 
116 TOOL_ACTION PCB_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule",
118  _( "Add Footprint" ), _( "Add a footprint" ), NULL, AF_ACTIVATE );
119 
120 TOOL_ACTION PCB_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin",
121  AS_GLOBAL, 0,
122  "", "" );
123 
124 TOOL_ACTION PCB_ACTIONS::crossProbeSchToPcb( "pcbnew.EditorControl.crossProbSchToPcb",
125  AS_GLOBAL, 0,
126  "", "" );
127 
128 TOOL_ACTION PCB_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock",
129  AS_GLOBAL, 'L',
130  "Toggle Lock", "" );
131 
132 TOOL_ACTION PCB_ACTIONS::lock( "pcbnew.EditorControl.lock",
133  AS_GLOBAL, 0,
134  _( "Lock" ), "" );
135 
136 TOOL_ACTION PCB_ACTIONS::unlock( "pcbnew.EditorControl.unlock",
137  AS_GLOBAL, 0,
138  _( "Unlock" ), "" );
139 
140 TOOL_ACTION PCB_ACTIONS::appendBoard( "pcbnew.EditorControl.appendBoard",
141  AS_GLOBAL, 0,
142  "", "" );
143 
144 TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
145  AS_GLOBAL, 0,
146  "", "" );
147 
148 TOOL_ACTION PCB_ACTIONS::highlightNetCursor( "pcbnew.EditorControl.highlightNetCursor",
149  AS_GLOBAL, 0,
150  "", "" );
151 
152 
154 {
155 public:
157  {
158  SetIcon( add_zone_xpm );
159  SetTitle( _( "Zones" ) );
160 
161  Add( PCB_ACTIONS::zoneFill );
165 
166  AppendSeparator();
167 
168  Add( PCB_ACTIONS::zoneMerge );
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 {
235  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
237  m_probingSchToPcb = false;
238 }
239 
240 
242 {
243 }
244 
245 
247 {
248  m_frame = getEditFrame<PCB_EDIT_FRAME>();
249 
250  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
251  {
252  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
253  getView()->Remove( m_placeOrigin.get() );
254  getView()->Add( m_placeOrigin.get() );
255  }
256 }
257 
258 
260 {
261  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
262  zoneMenu->SetTool( this );
263 
264  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
265  lockMenu->SetTool( this );
266 
267  // Add the PCB control menus to relevant other tools
268 
270 
271  if( selTool )
272  {
273  auto& toolMenu = selTool->GetToolMenu();
274  auto& menu = toolMenu.GetMenu();
275 
276  toolMenu.AddSubMenu( zoneMenu );
277  toolMenu.AddSubMenu( lockMenu );
278 
279  menu.AddMenu( zoneMenu.get(), false,
281 
282  menu.AddMenu( lockMenu.get(), false,
284  }
285 
286  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
287 
288  if( drawingTool )
289  {
290  auto& toolMenu = drawingTool->GetToolMenu();
291  auto& menu = toolMenu.GetMenu();
292 
293  toolMenu.AddSubMenu( zoneMenu );
294 
295  // Functor to say if the PCB_EDIT_FRAME is in a given mode
296  // Capture the tool pointer and tool mode by value
297  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
298  {
299  return [=]( const SELECTION& sel )
300  {
301  return drawingTool->GetDrawingMode() == aMode;
302  };
303  };
304 
305  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
306  }
307 
308  return true;
309 }
310 
311 
312 // Track & via size control
314 {
315  BOARD* board = getModel<BOARD>();
316  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
317 
318  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
319  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
320 
321  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
322  board->GetDesignSettings().UseCustomTrackViaSize( false );
323 
325 
326  return 0;
327 }
328 
329 
331 {
332  BOARD* board = getModel<BOARD>();
333  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
334 
335  if( widthIndex < 0 )
336  widthIndex = 0;
337 
338  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
339  board->GetDesignSettings().UseCustomTrackViaSize( false );
340 
342 
343  return 0;
344 }
345 
346 
348 {
349  BOARD* board = getModel<BOARD>();
350  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
351 
352  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
353  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
354 
355  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
356  board->GetDesignSettings().UseCustomTrackViaSize( false );
357 
359 
360  return 0;
361 }
362 
363 
365 {
366  BOARD* board = getModel<BOARD>();
367  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
368 
369  if( sizeIndex < 0 )
370  sizeIndex = 0;
371 
372  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
373  board->GetDesignSettings().UseCustomTrackViaSize( false );
374 
376 
377  return 0;
378 }
379 
380 
382 {
383  MODULE* module = NULL;
384  KIGFX::VIEW* view = getView();
386  BOARD* board = getModel<BOARD>();
387 
388  // Add a VIEW_GROUP that serves as a preview for the new item
389  KIGFX::VIEW_GROUP preview( view );
390  view->Add( &preview );
391 
393  controls->ShowCursor( true );
394  controls->SetSnapping( true );
395 
396  Activate();
397  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_HAND, _( "Add footprint" ) );
398 
399  // Main loop: keep receiving events
400  while( OPT_TOOL_EVENT evt = Wait() )
401  {
402  VECTOR2I cursorPos = controls->GetCursorPosition();
403 
404  if( evt->IsCancel() || evt->IsActivate() )
405  {
406  if( module )
407  {
408  delete module;
409  module = NULL;
410 
411  preview.Clear();
412  controls->ShowCursor( true );
413  }
414  else
415  break;
416 
417  if( evt->IsActivate() ) // now finish unconditionally
418  break;
419  }
420 
421  else if( module && evt->Category() == TC_COMMAND )
422  {
423  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
424  {
425  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
426  *m_frame, *evt );
427  module->Rotate( module->GetPosition(), rotationAngle );
428  view->Update( &preview );
429  }
430  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
431  {
432  module->Flip( module->GetPosition() );
433  view->Update( &preview );
434  }
435  }
436 
437  else if( evt->IsClick( BUT_LEFT ) )
438  {
439  if( !module )
440  {
441  // Pick the module to be placed
442  module = m_frame->LoadModuleFromLibrary( wxEmptyString,
444  true, NULL );
445 
446  if( module == NULL )
447  continue;
448 
449  // Module has been added in LoadModuleFromLibrary(),
450  // so we have to remove it before committing the change @todo LEGACY
451  board->Remove( module );
452  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
453 
454  // Add all the drawable parts to preview
455  preview.Add( module );
456  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
457  }
458  else
459  {
460  BOARD_COMMIT commit( m_frame );
461  commit.Add( module );
462  commit.Push( _( "Place a module" ) );
463 
464  // Remove from preview
465  preview.Remove( module );
466  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
467  module = NULL; // to indicate that there is no module that we currently modify
468  }
469 
470  bool placing = ( module != NULL );
471 
472  controls->SetAutoPan( placing );
473  controls->CaptureCursor( placing );
474  controls->ShowCursor( !placing );
475  }
476 
477  else if( module && evt->IsMotion() )
478  {
479  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
480  view->Update( &preview );
481  }
482  }
483 
484  view->Remove( &preview );
485  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
486 
487  return 0;
488 }
489 
490 
492 {
493  return modifyLockSelected( TOGGLE );
494 }
495 
496 
498 {
499  return modifyLockSelected( ON );
500 }
501 
502 
504 {
505  return modifyLockSelected( OFF );
506 }
507 
508 
510 {
512  const SELECTION& selection = selTool->GetSelection();
513 
514  if( selection.Empty() )
516 
517  bool modified = false;
518 
519  for( auto i : selection )
520  {
521  auto item = static_cast<BOARD_ITEM*>( i );
522  bool prevState = item->IsLocked();
523 
524  switch( aMode )
525  {
526  case ON:
527  item->SetLocked( true );
528  break;
529 
530  case OFF:
531  item->SetLocked( false );
532  break;
533 
534  case TOGGLE:
535  item->SetLocked( !prevState );
536  break;
537  }
538 
539  // Check if we really modified an item
540  if( !modified && prevState != item->IsLocked() )
541  modified = true;
542  }
543 
544  if( modified )
545  m_frame->OnModify();
546 
547  return 0;
548 }
549 
550 
552 {
553  KIGFX::VIEW* view = getView();
555  BOARD* board = getModel<BOARD>();
556  PCB_TARGET* target = new PCB_TARGET( board );
557 
558  // Init the new item attributes
559  target->SetLayer( Edge_Cuts );
560  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
561  target->SetSize( Millimeter2iu( 5 ) );
562  VECTOR2I cursorPos = controls->GetCursorPosition();
563  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
564 
565  // Add a VIEW_GROUP that serves as a preview for the new item
566  KIGFX::VIEW_GROUP preview( view );
567  preview.Add( target );
568  view->Add( &preview );
569 
571  controls->SetSnapping( true );
572 
573  Activate();
574  m_frame->SetToolID( ID_PCB_MIRE_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
575 
576  // Main loop: keep receiving events
577  while( OPT_TOOL_EVENT evt = Wait() )
578  {
579  cursorPos = controls->GetCursorPosition();
580 
581  if( evt->IsCancel() || evt->IsActivate() )
582  break;
583 
584  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
585  {
586  target->SetWidth( target->GetWidth() + WIDTH_STEP );
587  view->Update( &preview );
588  }
589 
590  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
591  {
592  int width = target->GetWidth();
593 
594  if( width > WIDTH_STEP )
595  {
596  target->SetWidth( width - WIDTH_STEP );
597  view->Update( &preview );
598  }
599  }
600 
601  else if( evt->IsClick( BUT_LEFT ) )
602  {
603  assert( target->GetSize() > 0 );
604  assert( target->GetWidth() > 0 );
605 
606  BOARD_COMMIT commit( m_frame );
607  commit.Add( target );
608  commit.Push( _( "Place a layer alignment target" ) );
609 
610  preview.Remove( target );
611 
612  // Create next PCB_TARGET
613  target = new PCB_TARGET( *target );
614  preview.Add( target );
615  }
616 
617  else if( evt->IsMotion() )
618  {
619  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
620  view->Update( &preview );
621  }
622  }
623 
624  delete target;
625 
626  controls->SetSnapping( false );
627  view->Remove( &preview );
628 
629  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
630 
631  return 0;
632 }
633 
634 
635 // Zone actions
637 {
638  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
639  const auto& selection = selTool->GetSelection();
640  RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
641 
642  BOARD_COMMIT commit( this );
643 
644  for( auto item : selection )
645  {
646  assert( item->Type() == PCB_ZONE_AREA_T );
647 
648  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( item );
649 
650  commit.Modify( zone );
651 
652  m_frame->Fill_Zone( zone );
653  zone->SetIsFilled( true );
654  ratsnest->Update( zone );
655  getView()->Update( zone );
656  }
657 
658  commit.Push( _( "Fill Zone" ) );
659 
660  ratsnest->Recalculate();
661 
662  return 0;
663 }
664 
665 
667 {
668  BOARD* board = getModel<BOARD>();
669  RN_DATA* ratsnest = board->GetRatsnest();
670 
671  BOARD_COMMIT commit( this );
672 
673  for( int i = 0; i < board->GetAreaCount(); ++i )
674  {
675  ZONE_CONTAINER* zone = board->GetArea( i );
676 
677  commit.Modify( zone );
678 
679  m_frame->Fill_Zone( zone );
680  zone->SetIsFilled( true );
681  ratsnest->Update( zone );
682  getView()->Update( zone );
683  }
684 
685  commit.Push( _( "Fill All Zones" ) );
686 
687  ratsnest->Recalculate();
688 
689  return 0;
690 }
691 
692 
694 {
695  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
696  const auto& selection = selTool->GetSelection();
697  RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
698 
699  BOARD_COMMIT commit( this );
700 
701  for( auto item : selection )
702  {
703  assert( item->Type() == PCB_ZONE_AREA_T );
704 
705  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
706 
707  commit.Modify( zone );
708 
709  zone->SetIsFilled( false );
710  zone->ClearFilledPolysList();
711  ratsnest->Update( zone );
712  getView()->Update( zone );
713  }
714 
715  commit.Push( _( "Unfill Zone" ) );
716 
717  ratsnest->Recalculate();
718 
719  return 0;
720 }
721 
722 
724 {
725  BOARD* board = getModel<BOARD>();
726  RN_DATA* ratsnest = board->GetRatsnest();
727 
728  BOARD_COMMIT commit( this );
729 
730  for( int i = 0; i < board->GetAreaCount(); ++i )
731  {
732  ZONE_CONTAINER* zone = board->GetArea( i );
733 
734  commit.Modify( zone );
735 
736  zone->SetIsFilled( false );
737  zone->ClearFilledPolysList();
738  ratsnest->Update( zone );
739  getView()->Update( zone );
740  }
741 
742  commit.Push( _( "Unfill All Zones" ) );
743 
744  ratsnest->Recalculate();
745 
746  return 0;
747 }
748 
749 
750 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
751  std::vector<ZONE_CONTAINER *>& aMergedZones )
752 {
753  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
754  {
755  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
757  }
758 
759  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
760 
761  // We should have one polygon with hole
762  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
763  // and therefore cannot be merged (they are dectected as intersecting)
764  // but we should never have more than 2 polys
765  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
766  {
767  wxLogMessage( wxT( "BOARD::CombineAreas error: more than 2 polys after merging" ) );
768  return false;
769  }
770 
771  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
772  {
773  aCommit.Remove( aOriginZones[i] );
774  }
775 
776  aCommit.Modify( aOriginZones[0] );
777  aMergedZones.push_back( aOriginZones[0] );
778 
779  aOriginZones[0]->SetLocalFlags( 1 );
780  aOriginZones[0]->Hatch();
781 
782  return true;
783 }
784 
786 {
787  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
788  BOARD* board = getModel<BOARD>();
789  BOARD_COMMIT commit( m_frame );
790 
791  if( selection.Size() < 2 )
792  return 0;
793 
794  int netcode = -1;
795 
796  ZONE_CONTAINER* firstZone = nullptr;
797  std::vector<ZONE_CONTAINER*> toMerge, merged;
798 
799  for( auto item : selection )
800  {
801  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
802 
803  if( !curr_area )
804  continue;
805 
806  if( !firstZone )
807  firstZone = curr_area;
808 
809  netcode = curr_area->GetNetCode();
810 
811  if( firstZone->GetNetCode() != netcode )
812  continue;
813 
814  if( curr_area->GetPriority() != firstZone->GetPriority() )
815  continue;
816 
817  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
818  continue;
819 
820  if( curr_area->GetLayer() != firstZone->GetLayer() )
821  continue;
822 
823  if( !board->TestAreaIntersection( curr_area, firstZone ) )
824  continue;
825 
826  toMerge.push_back( curr_area );
827  }
828 
830 
831  if( mergeZones( commit, toMerge, merged ) )
832  {
833  commit.Push( _( "Merge zones" ) );
834 
835  for( auto item : merged )
837  }
838 
839  return 0;
840 }
841 
842 
844 {
845  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
846  const auto& selection = selTool->GetSelection();
847 
848  // because this pops up the zone editor, it would be confusing
849  // to handle multiple zones, so just handle single selections
850  // containing exactly one zone
851  if( selection.Size() != 1 )
852  return 0;
853 
854  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
855 
856  if( !oldZone )
857  return 0;
858 
859  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
860  newZone->ClearSelected();
861  newZone->UnFill();
862  ZONE_SETTINGS zoneSettings;
863  zoneSettings << *oldZone;
864 
865  bool success = false;
866 
867  if( oldZone->GetIsKeepout() )
868  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
869  else if( oldZone->IsOnCopperLayer() )
870  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
871  else
872  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
873 
874  // If the new zone is on the same layer as the the initial zone,
875  // do nothing
876  if( success && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
877  {
879  _( "The duplicated zone cannot be on the same layer as the original zone." ) );
880  success = false;
881  }
882 
883  // duplicate the zone
884  if( success )
885  {
886  BOARD_COMMIT commit( m_frame );
887  zoneSettings.ExportSetting( *newZone );
888 
889  commit.Add( newZone.release() );
890  commit.Push( _( "Duplicate zone" ) );
891  }
892 
893  return 0;
894 }
895 
896 
898 {
899  if( m_probingSchToPcb )
900  {
901  m_probingSchToPcb = false;
902  return 0;
903  }
904 
906  const SELECTION& selection = selTool->GetSelection();
907 
908  if( selection.Size() == 1 )
909  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
910 
911  return 0;
912 }
913 
914 
916 {
917  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
918 
919  if( item )
920  {
921  m_probingSchToPcb = true;
922  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
924 
925  // If it is a pad and the net highlighting tool is enabled, highlight the net
926  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
927  {
928  int net = static_cast<D_PAD*>( item )->GetNetCode();
930  }
931  else
932  // Otherwise simply select the corresponding item
933  {
935  }
936  }
937 
938  return 0;
939 }
940 
941 
942 static bool setDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
943  KIGFX::ORIGIN_VIEWITEM* aItem, const VECTOR2D& aPosition )
944 {
945  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
946  aItem->SetPosition( aPosition );
947  aView->MarkDirty();
948 
949  return true;
950 }
951 
952 
954 {
955  Activate();
956 
958  assert( picker );
959 
960  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust zero" ) );
961  picker->SetClickHandler( std::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
962  picker->Activate();
963  Wait();
964 
965  return 0;
966 }
967 
974 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
975 {
976  auto render = aToolMgr->GetView()->GetPainter()->GetSettings();
977  auto frame = static_cast<PCB_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
978  auto guide = frame->GetCollectorsGuide();
979  BOARD* board = static_cast<BOARD*>( aToolMgr->GetModel() );
980  GENERAL_COLLECTOR collector;
981  int net = -1;
982 
983  // Find a connected item for which we are going to highlight a net
985  wxPoint( aPosition.x, aPosition.y ), guide );
986 
987  for( int i = 0; i < collector.GetCount(); i++ )
988  {
989  if( collector[i]->Type() == PCB_PAD_T )
990  {
991  frame->SendMessageToEESCHEMA( static_cast<BOARD_CONNECTED_ITEM*>( collector[i] ) );
992  break;
993  }
994  }
995 
996  bool enableHighlight = ( collector.GetCount() > 0 );
997 
998  // Obtain net code for the clicked item
999  if( enableHighlight )
1000  net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
1001 
1002  // Toggle highlight when the same net was picked
1003  if( net > 0 && net == render->GetHighlightNetCode() )
1004  enableHighlight = !render->IsHighlightEnabled();
1005 
1006  if( enableHighlight != render->IsHighlightEnabled() || net != render->GetHighlightNetCode() )
1007  {
1008  render->SetHighlight( enableHighlight, net );
1009  aToolMgr->GetView()->UpdateAllLayersColor();
1010  }
1011 
1012  // Store the highlighted netcode in the current board (for dialogs for instance)
1013  if( enableHighlight && net >= 0 )
1014  board->SetHighLightNet( net );
1015  else
1016  board->ResetHighLight();
1017 
1018  return true;
1019 }
1020 
1021 
1023 {
1024  int netcode = aEvent.Parameter<intptr_t>();
1025 
1026  if( netcode > 0 )
1027  {
1029  render->SetHighlight( true, netcode );
1031  }
1032  else
1033  {
1034  // No net code specified, pick the net code belonging to the item under the cursor
1035  highlightNet( m_toolMgr, getView()->ToWorld( getViewControls()->GetMousePosition() ) );
1036  }
1037 
1038  return 0;
1039 }
1040 
1041 
1043 {
1044  Activate();
1045 
1046  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1047  assert( picker );
1048 
1049  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_PENCIL, _( "Highlight net" ) );
1050  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1 ) );
1051  picker->SetSnapping( false );
1052  picker->Activate();
1053  Wait();
1054 
1055  return 0;
1056 }
1057 
1058 
1060 {
1061  // Track & via size control
1066 
1067  // Zone actions
1074 
1075  // Placing tools
1078 
1079  // Other
1088 }
1089 
1090 
1091 const int PCB_EDITOR_CONTROL::WIDTH_STEP = 100000;
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:329
int GetCount() const
Function GetCount returns the number of objects in the list.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:1004
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
static TOOL_ACTION placeModule
Activation of the drawing tool (placing a MODULE)
Definition: pcb_actions.h:149
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:54
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
void RunOnChildren(std::function< void(BOARD_ITEM *)> aFunction)
Function RunOnChildren.
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
int ZoneMerge(const TOOL_EVENT &aEvent)
static TOOL_ACTION unlock
Definition: pcb_actions.h:331
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.
PCB_TARGET class definition.
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_placeOrigin
Place & drill origin marker.
static const KICAD_T PadsTracksOrZones[]
A scan list for PADs, TRACKs, VIAs, or ZONEs.
Definition: collectors.h:276
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:294
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:158
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
Class RN_DATA.
static TOOL_ACTION drawSimilarZone
Activation of the drawing tool (drawing a similar ZONE to another one)
Definition: pcb_actions.h:143
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:344
static TOOL_ACTION lock
Definition: pcb_actions.h:330
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:257
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:250
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:95
void ClearSelected()
Definition: base_struct.h:231
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)
Function Collect scans a BOARD_ITEM using this class's Inspector method, which does the collection...
Definition: collectors.cpp:447
int TrackWidthDec(const TOOL_EVENT &aEvent)
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
Class SELECTION_TOOL.
wxWindow * GetEditFrame() const
Definition: tool_manager.h:258
Class BOARD to handle a board.
const wxPoint & GetPosition() const override
Definition: class_module.h:143
Class that computes missing connections on a PCB.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
TOOL_MENU & GetToolMenu()
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
void ResetHighLight()
Function ResetHighLight Reset all high light data to the init state.
Definition: class_board.h:345
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:249
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 const wxPoint & GetPosition() const =0
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...
Definition: loadcmp.cpp:163
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:253
void SetTransitions() override
Sets up handlers for various events.
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
bool Update(const BOARD_ITEM *aItem)
Function Update() Updates the ratsnest data for an item.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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...
void SetIsFilled(bool isFilled)
Definition: class_zone.h:201
static TOOL_ACTION highlightNetCursor
Definition: pcb_actions.h:343
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:256
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true) override
Executes the changes.
static TOOL_ACTION crossProbeSchToPcb
Definition: pcb_actions.h:345
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:161
MODIFY_MODE
How to modify a property for selected items.
Generic tool for picking a point.
Definition: picker_tool.h:35
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:644
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.
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:248
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:346
static SELECTION_CONDITION SameLayer()
Function SameLayer Creates a functor that tests if selection contains items that belong exclusively t...
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:563
int ViaSizeDec(const TOOL_EVENT &aEvent)
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
void SetPosition(const VECTOR2D &aPosition)
Class DRAWING_TOOL.
Definition: drawing_tool.h:49
int TrackWidthInc(const TOOL_EVENT &aEvent)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
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...
Class TOOL_EVENT.
Definition: tool_event.h:162
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:260
SELECTION & GetSelection()
Function GetSelection()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
int DrillOrigin(const TOOL_EVENT &aEvent)
Places the origin point for drill and pick-and-place files.
int ZoneUnfill(const TOOL_EVENT &aEvent)
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
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
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1051
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
int ViaSizeInc(const TOOL_EVENT &aEvent)
int Fill_Zone(ZONE_CONTAINER *aZone)
Function Fill_Zone Calculate the zone filling for the outline zone_container The zone outline is a fr...
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
Class PCB_TOOL.
Definition: pcb_tool.h:45
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:140
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
static TOOL_ACTION placeTarget
Activation of the drawing tool (placing a TARGET)
Definition: pcb_actions.h:146
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:259
int UnlockSelected(const TOOL_EVENT &aEvent)
Unlocks selected items.
RN_DATA * GetRatsnest() const
Function GetRatsnest() returns list of missing connections between components/tracks.
Definition: class_board.h:287
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
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:258
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
Class ZONE_SETTINGS handles zones parameters.
void Recalculate(int aNet=-1)
Function Recalculate() Recomputes ratsnest for selected net number or all nets that need updating...
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:361
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:263
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:90
CONTEXT_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes. ...
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
int ZoneFill(const TOOL_EVENT &aEvent)
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:373
static bool setDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, KIGFX::ORIGIN_VIEWITEM *aItem, const VECTOR2D &aPosition)
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:1022
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:342
void AddMenu(CONTEXT_MENU *aMenu, bool aExpand=false, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
EDA_ITEM * GetModel() const
Definition: tool_manager.h:253
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:166
static const int WIDTH_STEP
virtual bool IsLocked() const
Function IsLocked.
int modifyLockSelected(MODIFY_MODE aMode)
Class GENERAL_COLLECTOR is intended for use when the right click button is pressed, or when the plain "arrow" tool is in effect.
Definition: collectors.h:211
int GetToolId() const
Definition: draw_frame.h:406
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...
LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
bool m_probingSchToPcb
Flag to ignore a single crossprobe message from eeschema.
int ZoneFillAll(const TOOL_EVENT &aEvent)
ZONE_EDIT_T InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing...
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.
int ZoneUnfillAll(const TOOL_EVENT &aEvent)
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
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
Module description (excepted pads)
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:243
unsigned GetPriority() const
Function GetPriority.
Definition: class_zone.h:119
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:673
static bool mergeZones(BOARD_COMMIT &aCommit, std::vector< ZONE_CONTAINER * > &aOriginZones, std::vector< ZONE_CONTAINER * > &aMergedZones)
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
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:139
int ToggleLockSelected(const TOOL_EVENT &aEvent)
Toggles 'lock' property for selected items.
Rendering engine changes.
Definition: tool_base.h:84
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:251
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
void Remove(BOARD_ITEM *aBoardItem) override
>
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:601
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.
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
Definition: class_zone.h:577
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:110
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39