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 #include <wx/progdlg.h>
31 
32 #include "selection_tool.h"
33 #include "drawing_tool.h"
34 #include "picker_tool.h"
35 
36 #include <painter.h>
37 #include <project.h>
38 #include <pcbnew_id.h>
39 #include <wxPcbStruct.h>
40 #include <class_board.h>
41 #include <class_zone.h>
42 #include <class_draw_panel_gal.h>
43 #include <class_module.h>
44 #include <class_mire.h>
45 #include <connectivity.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 TOOL_ACTION PCB_ACTIONS::showLocalRatsnest( "pcbnew.Control.showLocalRatsnest",
153  AS_GLOBAL, 0,
154  "", "" );
155 
156 
158 {
159 public:
161  {
162  SetIcon( add_zone_xpm );
163  SetTitle( _( "Zones" ) );
164 
165  Add( PCB_ACTIONS::zoneFill );
169 
170  AppendSeparator();
171 
172  Add( PCB_ACTIONS::zoneMerge );
176  }
177 
178 protected:
179  CONTEXT_MENU* create() const override
180  {
181  return new ZONE_CONTEXT_MENU();
182  }
183 
184 private:
185  void update() override
186  {
187  SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
188 
189  // enable zone actions that act on a single zone
190  bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 )
192  )( selTool->GetSelection() );
193 
194  Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
195  Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
196  Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
197 
198  // enable zone actions that ably to a specific set of zones (as opposed to all of them)
199  bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
200 
201  Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
202  Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
203 
204  // lines like this make me really think about a better name for SELECTION_CONDITIONS class
205  bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
206  /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
209 
210  Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
211  }
212 };
213 
214 
216 {
217 public:
219  {
220  SetIcon( locked_xpm );
221  SetTitle( _( "Locking" ) );
222 
223  Add( PCB_ACTIONS::lock );
224  Add( PCB_ACTIONS::unlock );
226  }
227 
228  CONTEXT_MENU* create() const override
229  {
230  return new LOCK_CONTEXT_MENU();
231  }
232 };
233 
234 
236  PCB_TOOL( "pcbnew.EditorControl" ),
237  m_frame( nullptr )
238 {
239  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
241  m_probingSchToPcb = false;
242 }
243 
244 
246 {
247 }
248 
249 
251 {
252  m_frame = getEditFrame<PCB_EDIT_FRAME>();
253 
254  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
255  {
256  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
257  getView()->Remove( m_placeOrigin.get() );
258  getView()->Add( m_placeOrigin.get() );
259  }
260 }
261 
262 
264 {
265  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
266  zoneMenu->SetTool( this );
267 
268  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
269  lockMenu->SetTool( this );
270 
271  // Add the PCB control menus to relevant other tools
272 
274 
275  if( selTool )
276  {
277  auto& toolMenu = selTool->GetToolMenu();
278  auto& menu = toolMenu.GetMenu();
279 
280  toolMenu.AddSubMenu( zoneMenu );
281  toolMenu.AddSubMenu( lockMenu );
282 
283  menu.AddMenu( zoneMenu.get(), false,
285 
286  menu.AddMenu( lockMenu.get(), false,
288  }
289 
290  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
291 
292  if( drawingTool )
293  {
294  auto& toolMenu = drawingTool->GetToolMenu();
295  auto& menu = toolMenu.GetMenu();
296 
297  toolMenu.AddSubMenu( zoneMenu );
298 
299  // Functor to say if the PCB_EDIT_FRAME is in a given mode
300  // Capture the tool pointer and tool mode by value
301  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
302  {
303  return [=]( const SELECTION& sel )
304  {
305  return drawingTool->GetDrawingMode() == aMode;
306  };
307  };
308 
309  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
310  }
311 
312  return true;
313 }
314 
315 
316 // Track & via size control
318 {
319  BOARD* board = getModel<BOARD>();
320  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
321 
322  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
323  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
324 
325  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
326  board->GetDesignSettings().UseCustomTrackViaSize( false );
327 
329 
330  return 0;
331 }
332 
333 
335 {
336  BOARD* board = getModel<BOARD>();
337  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
338 
339  if( widthIndex < 0 )
340  widthIndex = 0;
341 
342  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
343  board->GetDesignSettings().UseCustomTrackViaSize( false );
344 
346 
347  return 0;
348 }
349 
350 
352 {
353  BOARD* board = getModel<BOARD>();
354  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
355 
356  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
357  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
358 
359  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
360  board->GetDesignSettings().UseCustomTrackViaSize( false );
361 
363 
364  return 0;
365 }
366 
367 
369 {
370  BOARD* board = getModel<BOARD>();
371  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
372 
373  if( sizeIndex < 0 )
374  sizeIndex = 0;
375 
376  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
377  board->GetDesignSettings().UseCustomTrackViaSize( false );
378 
380 
381  return 0;
382 }
383 
384 
386 {
387  MODULE* module = NULL;
388  KIGFX::VIEW* view = getView();
390  BOARD* board = getModel<BOARD>();
391 
392  // Add a VIEW_GROUP that serves as a preview for the new item
393  KIGFX::VIEW_GROUP preview( view );
394  view->Add( &preview );
395 
397  controls->ShowCursor( true );
398  controls->SetSnapping( true );
399 
400  Activate();
401  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_PENCIL, _( "Add footprint" ) );
402 
403  // Main loop: keep receiving events
404  while( OPT_TOOL_EVENT evt = Wait() )
405  {
406  VECTOR2I cursorPos = controls->GetCursorPosition();
407 
408  if( evt->IsCancel() || evt->IsActivate() )
409  {
410  if( module )
411  {
412  delete module;
413  module = NULL;
414 
415  preview.Clear();
416  controls->ShowCursor( true );
417  }
418  else
419  break;
420 
421  if( evt->IsActivate() ) // now finish unconditionally
422  break;
423  }
424 
425  else if( module && evt->Category() == TC_COMMAND )
426  {
427  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
428  {
429  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
430  *m_frame, *evt );
431  module->Rotate( module->GetPosition(), rotationAngle );
432  view->Update( &preview );
433  }
434  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
435  {
436  module->Flip( module->GetPosition() );
437  view->Update( &preview );
438  }
439  }
440 
441  else if( evt->IsClick( BUT_LEFT ) )
442  {
443  if( !module )
444  {
445  // Pick the module to be placed
446  module = m_frame->LoadModuleFromLibrary( wxEmptyString,
448  true, NULL );
449 
450  if( module == NULL )
451  continue;
452 
453  // Module has been added in LoadModuleFromLibrary(),
454  // so we have to remove it before committing the change @todo LEGACY
455  board->Remove( module );
456  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
457 
458  // Add all the drawable parts to preview
459  preview.Add( module );
460  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
461  }
462  else
463  {
464  BOARD_COMMIT commit( m_frame );
465  commit.Add( module );
466  commit.Push( _( "Place a module" ) );
467 
468  // Remove from preview
469  preview.Remove( module );
470  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
471  module = NULL; // to indicate that there is no module that we currently modify
472  }
473 
474  bool placing = ( module != NULL );
475 
476  controls->SetAutoPan( placing );
477  controls->CaptureCursor( placing );
478  controls->ShowCursor( !placing );
479  }
480 
481  else if( module && evt->IsMotion() )
482  {
483  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
484  view->Update( &preview );
485  }
486  }
487 
488  controls->ShowCursor( false );
489  controls->SetSnapping( false );
490  controls->SetAutoPan( false );
491  controls->CaptureCursor( false );
492 
493  view->Remove( &preview );
495 
496  return 0;
497 }
498 
499 
501 {
502  return modifyLockSelected( TOGGLE );
503 }
504 
505 
507 {
508  return modifyLockSelected( ON );
509 }
510 
511 
513 {
514  return modifyLockSelected( OFF );
515 }
516 
517 
519 {
521  const SELECTION& selection = selTool->GetSelection();
522 
523  if( selection.Empty() )
525 
526  bool modified = false;
527 
528  for( auto i : selection )
529  {
530  auto item = static_cast<BOARD_ITEM*>( i );
531  bool prevState = item->IsLocked();
532 
533  switch( aMode )
534  {
535  case ON:
536  item->SetLocked( true );
537  break;
538 
539  case OFF:
540  item->SetLocked( false );
541  break;
542 
543  case TOGGLE:
544  item->SetLocked( !prevState );
545  break;
546  }
547 
548  // Check if we really modified an item
549  if( !modified && prevState != item->IsLocked() )
550  modified = true;
551  }
552 
553  if( modified )
554  m_frame->OnModify();
555 
556  return 0;
557 }
558 
559 
561 {
562  KIGFX::VIEW* view = getView();
564  BOARD* board = getModel<BOARD>();
565  PCB_TARGET* target = new PCB_TARGET( board );
566 
567  // Init the new item attributes
568  target->SetLayer( Edge_Cuts );
569  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
570  target->SetSize( Millimeter2iu( 5 ) );
571  VECTOR2I cursorPos = controls->GetCursorPosition();
572  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
573 
574  // Add a VIEW_GROUP that serves as a preview for the new item
575  KIGFX::VIEW_GROUP preview( view );
576  preview.Add( target );
577  view->Add( &preview );
578 
580  controls->SetSnapping( true );
581 
582  Activate();
583  m_frame->SetToolID( ID_PCB_MIRE_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
584 
585  // Main loop: keep receiving events
586  while( OPT_TOOL_EVENT evt = Wait() )
587  {
588  cursorPos = controls->GetCursorPosition();
589 
590  if( evt->IsCancel() || evt->IsActivate() )
591  break;
592 
593  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
594  {
595  target->SetWidth( target->GetWidth() + WIDTH_STEP );
596  view->Update( &preview );
597  }
598 
599  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
600  {
601  int width = target->GetWidth();
602 
603  if( width > WIDTH_STEP )
604  {
605  target->SetWidth( width - WIDTH_STEP );
606  view->Update( &preview );
607  }
608  }
609 
610  else if( evt->IsClick( BUT_LEFT ) )
611  {
612  assert( target->GetSize() > 0 );
613  assert( target->GetWidth() > 0 );
614 
615  BOARD_COMMIT commit( m_frame );
616  commit.Add( target );
617  commit.Push( _( "Place a layer alignment target" ) );
618 
619  preview.Remove( target );
620 
621  // Create next PCB_TARGET
622  target = new PCB_TARGET( *target );
623  preview.Add( target );
624  }
625 
626  else if( evt->IsMotion() )
627  {
628  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
629  view->Update( &preview );
630  }
631  }
632 
633  delete target;
634 
635  controls->SetSnapping( false );
636  view->Remove( &preview );
637 
639 
640  return 0;
641 }
642 
643 
644 // Zone actions
646 {
647  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
648  const auto& selection = selTool->GetSelection();
649  auto connectivity = getModel<BOARD>()->GetConnectivity();
650 
651  BOARD_COMMIT commit( this );
652 
653  for( auto item : selection )
654  {
655  assert( item->Type() == PCB_ZONE_AREA_T );
656 
657  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( item );
658 
659  commit.Modify( zone );
660 
661  m_frame->Fill_Zone( zone );
662  zone->SetIsFilled( true );
663  }
664 
665  commit.Push( _( "Fill Zone" ) );
666 
667  connectivity->RecalculateRatsnest();
668 
669  return 0;
670 }
671 
672 
674 {
675  BOARD* board = getModel<BOARD>();
676  auto connectivity = getModel<BOARD>()->GetConnectivity();
677  int areaCount = board->GetAreaCount();
678  const wxString fmt = _( "Filling zone %d out of %d (net %s)..." );
679  wxString msg;
680  bool aborted = false;
681 
682  // Create a message with a long net name, and build a wxProgressDialog
683  // with a correct size to show this long net name
684  msg.Printf( fmt, 000, areaCount, wxT("XXXXXXXXXXXXXXXXX" ) );
685 
686  auto progressDialog = new wxProgressDialog( _( "Fill All Zones" ), msg,
687  areaCount, frame(),
688  wxPD_AUTO_HIDE | wxPD_CAN_ABORT |
689  wxPD_APP_MODAL | wxPD_ELAPSED_TIME );
690 
691  BOARD_COMMIT commit( this );
692 
693  for( int i = 0; i < areaCount; ++i )
694  {
695  ZONE_CONTAINER* zone = board->GetArea( i );
696 
697  msg.Printf( fmt, i, areaCount, GetChars( zone->GetNetname() ) );
698 
699  commit.Modify( zone );
700 
701  if( !progressDialog->Update( i, msg ) )
702  {
703  aborted = true;
704  break; // Aborted by user
705  }
706 
707  m_frame->Fill_Zone( zone );
708  zone->SetIsFilled( true );
709  }
710 
711  if( aborted )
712  commit.Revert();
713  else
714  commit.Push( _( "Fill All Zones" ) );
715 
716  connectivity->RecalculateRatsnest();
717  progressDialog->Destroy();
718 
719  return 0;
720 }
721 
722 
724 {
725  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
726  const auto& selection = selTool->GetSelection();
727  auto connectivity = getModel<BOARD>()->GetConnectivity();
728 
729  BOARD_COMMIT commit( this );
730 
731  for( auto item : selection )
732  {
733  assert( item->Type() == PCB_ZONE_AREA_T );
734 
735  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
736 
737  commit.Modify( zone );
738 
739  zone->SetIsFilled( false );
740  zone->ClearFilledPolysList();
741  }
742 
743  commit.Push( _( "Unfill Zone" ) );
744 
745  connectivity->RecalculateRatsnest();
746 
747  return 0;
748 }
749 
750 
752 {
753  BOARD* board = getModel<BOARD>();
754  auto connectivity = getModel<BOARD>()->GetConnectivity();
755 
756  BOARD_COMMIT commit( this );
757 
758  for( int i = 0; i < board->GetAreaCount(); ++i )
759  {
760  ZONE_CONTAINER* zone = board->GetArea( i );
761 
762  commit.Modify( zone );
763 
764  zone->SetIsFilled( false );
765  zone->ClearFilledPolysList();
766  }
767 
768  commit.Push( _( "Unfill All Zones" ) );
769 
770  connectivity->RecalculateRatsnest();
771 
772  return 0;
773 }
774 
775 
776 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
777  std::vector<ZONE_CONTAINER *>& aMergedZones )
778 {
779  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
780  {
781  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
783  }
784 
785  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
786 
787  // We should have one polygon with hole
788  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
789  // and therefore cannot be merged (they are dectected as intersecting)
790  // but we should never have more than 2 polys
791  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
792  {
793  wxLogMessage( wxT( "BOARD::CombineAreas error: more than 2 polys after merging" ) );
794  return false;
795  }
796 
797  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
798  {
799  aCommit.Remove( aOriginZones[i] );
800  }
801 
802  aCommit.Modify( aOriginZones[0] );
803  aMergedZones.push_back( aOriginZones[0] );
804 
805  aOriginZones[0]->SetLocalFlags( 1 );
806  aOriginZones[0]->Hatch();
807 
808  return true;
809 }
810 
812 {
813  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
814  BOARD* board = getModel<BOARD>();
815  BOARD_COMMIT commit( m_frame );
816 
817  if( selection.Size() < 2 )
818  return 0;
819 
820  int netcode = -1;
821 
822  ZONE_CONTAINER* firstZone = nullptr;
823  std::vector<ZONE_CONTAINER*> toMerge, merged;
824 
825  for( auto item : selection )
826  {
827  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
828 
829  if( !curr_area )
830  continue;
831 
832  if( !firstZone )
833  firstZone = curr_area;
834 
835  netcode = curr_area->GetNetCode();
836 
837  if( firstZone )
838  {
839  if( firstZone->GetNetCode() != netcode )
840  continue;
841 
842  if( curr_area->GetPriority() != firstZone->GetPriority() )
843  continue;
844 
845  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
846  continue;
847 
848  if( curr_area->GetLayer() != firstZone->GetLayer() )
849  continue;
850 
851  if( !board->TestAreaIntersection( curr_area, firstZone ) )
852  continue;
853 
854  toMerge.push_back( curr_area );
855  }
856  else
857  {
858  toMerge.push_back( curr_area );
859  }
860  }
861 
863 
864  if( mergeZones( commit, toMerge, merged ) )
865  {
866  commit.Push( _( "Merge zones" ) );
867 
868  for( auto item : merged )
870  }
871 
872  return 0;
873 }
874 
875 
877 {
878  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
879  const auto& selection = selTool->GetSelection();
880 
881  // because this pops up the zone editor, it would be confusing
882  // to handle multiple zones, so just handle single selections
883  // containing exactly one zone
884  if( selection.Size() != 1 )
885  return 0;
886 
887  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
888 
889  if( !oldZone )
890  return 0;
891 
892  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
893  newZone->ClearSelected();
894  newZone->UnFill();
895  ZONE_SETTINGS zoneSettings;
896  zoneSettings << *oldZone;
897 
898  bool success = false;
899 
900  if( oldZone->GetIsKeepout() )
901  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
902  else if( oldZone->IsOnCopperLayer() )
903  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
904  else
905  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
906 
907  // If the new zone is on the same layer as the the initial zone,
908  // do nothing
909  if( success && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
910  {
912  _( "The duplicated zone cannot be on the same layer as the original zone." ) );
913  success = false;
914  }
915 
916  // duplicate the zone
917  if( success )
918  {
919  BOARD_COMMIT commit( m_frame );
920  zoneSettings.ExportSetting( *newZone );
921 
922  commit.Add( newZone.release() );
923  commit.Push( _( "Duplicate zone" ) );
924  }
925 
926  return 0;
927 }
928 
929 
931 {
932  if( m_probingSchToPcb )
933  {
934  m_probingSchToPcb = false;
935  return 0;
936  }
937 
939  const SELECTION& selection = selTool->GetSelection();
940 
941  if( selection.Size() == 1 )
942  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
943 
944  return 0;
945 }
946 
947 
949 {
950  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
951 
952  if( item )
953  {
954  m_probingSchToPcb = true;
955  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
957 
958  // If it is a pad and the net highlighting tool is enabled, highlight the net
959  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
960  {
961  int net = static_cast<D_PAD*>( item )->GetNetCode();
963  }
964  else
965  // Otherwise simply select the corresponding item
966  {
968  }
969  }
970 
971  return 0;
972 }
973 
974 
975 static bool setDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
976  KIGFX::ORIGIN_VIEWITEM* aItem, const VECTOR2D& aPosition )
977 {
978  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
979  aItem->SetPosition( aPosition );
980  aView->MarkDirty();
981 
982  return true;
983 }
984 
985 
987 {
988  Activate();
989 
991  assert( picker );
992 
993  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) );
994  picker->SetClickHandler( std::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
995  picker->Activate();
996  Wait();
997 
998  return 0;
999 }
1000 
1007 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
1008 {
1009  auto render = aToolMgr->GetView()->GetPainter()->GetSettings();
1010  auto frame = static_cast<PCB_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
1011  auto guide = frame->GetCollectorsGuide();
1012  BOARD* board = static_cast<BOARD*>( aToolMgr->GetModel() );
1013  GENERAL_COLLECTOR collector;
1014  int net = -1;
1015 
1016  // Find a connected item for which we are going to highlight a net
1018  wxPoint( aPosition.x, aPosition.y ), guide );
1019 
1020  for( int i = 0; i < collector.GetCount(); i++ )
1021  {
1022  if( collector[i]->Type() == PCB_PAD_T )
1023  {
1024  frame->SendMessageToEESCHEMA( static_cast<BOARD_CONNECTED_ITEM*>( collector[i] ) );
1025  break;
1026  }
1027  }
1028 
1029  bool enableHighlight = ( collector.GetCount() > 0 );
1030 
1031  // Obtain net code for the clicked item
1032  if( enableHighlight )
1033  net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
1034 
1035  // Toggle highlight when the same net was picked
1036  if( net > 0 && net == render->GetHighlightNetCode() )
1037  enableHighlight = !render->IsHighlightEnabled();
1038 
1039  if( enableHighlight != render->IsHighlightEnabled() || net != render->GetHighlightNetCode() )
1040  {
1041  render->SetHighlight( enableHighlight, net );
1042  aToolMgr->GetView()->UpdateAllLayersColor();
1043  }
1044 
1045  // Store the highlighted netcode in the current board (for dialogs for instance)
1046  if( enableHighlight && net >= 0 )
1047  board->SetHighLightNet( net );
1048  else
1049  board->ResetHighLight();
1050 
1051  return true;
1052 }
1053 
1054 
1056 {
1057  int netcode = aEvent.Parameter<intptr_t>();
1058 
1059  if( netcode > 0 )
1060  {
1062  render->SetHighlight( true, netcode );
1064  }
1065  else
1066  {
1067  // No net code specified, pick the net code belonging to the item under the cursor
1068  highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
1069  }
1070 
1071  return 0;
1072 }
1073 
1074 
1076 {
1077  Activate();
1078 
1079  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1080  assert( picker );
1081 
1082  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
1083  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1 ) );
1084  picker->SetSnapping( false );
1085  picker->Activate();
1086  Wait();
1087 
1088  return 0;
1089 }
1090 
1091 
1092 static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
1093 {
1094  auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
1095 
1096  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
1097  aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
1098 
1099  const SELECTION& selection = selectionTool->GetSelection();
1100 
1101  if( selection.Empty() )
1102  return true;
1103 
1104  for( auto item : selection )
1105  {
1106  if( item->Type() == PCB_MODULE_T )
1107  {
1108  for( auto pad : static_cast<MODULE *> (item)->Pads() )
1109  {
1110  pad->SetLocalRatsnestVisible( true );
1111  }
1112  }
1113  }
1114 
1115  return true;
1116 }
1117 
1118 
1120 {
1121  Activate();
1122 
1123  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
1124  assert( picker );
1125 
1126  m_frame->SetToolID( ID_PCB_SHOW_1_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) );
1127  picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, _1 ) );
1128  picker->SetSnapping( false );
1129  picker->Activate();
1130  Wait();
1131 
1132  return 0;
1133 }
1134 
1135 
1137 {
1138  return 0;
1139 }
1140 
1141 
1143 {
1144  // Track & via size control
1149 
1150  // Zone actions
1157 
1158  // Placing tools
1161 
1162  // Other
1173 }
1174 
1175 
1176 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:343
int GetCount() const
Function GetCount returns the number of objects in the list.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:993
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:158
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:345
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:167
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:152
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:358
static TOOL_ACTION lock
Definition: pcb_actions.h:344
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:271
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:264
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:155
virtual void Revert() override
Revertes the commit by restoring the modifed items state.
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:341
void ResetHighLight()
Function ResetHighLight Reset all high light data to the init state.
Definition: class_board.h:348
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:263
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:267
void SetTransitions() override
Sets up handlers for various events.
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
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()
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:357
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 showLocalRatsnest
Definition: pcb_actions.h:362
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:270
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 selectionModified
Modified selection notification.
Definition: pcb_actions.h:105
static TOOL_ACTION crossProbeSchToPcb
Definition: pcb_actions.h:359
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:170
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:654
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:124
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:262
class MODULE, a footprint
Definition: typeinfo.h:101
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:360
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.
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:564
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...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
Class TOOL_EVENT.
Definition: tool_event.h:162
static TOOL_ACTION zoneMerge
Definition: pcb_actions.h:274
SELECTION & GetSelection()
Function GetSelection()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:533
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:1025
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
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:1385
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:149
static TOOL_ACTION placeTarget
Activation of the drawing tool (placing a TARGET)
Definition: pcb_actions.h:155
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:273
int UnlockSelected(const TOOL_EVENT &aEvent)
Unlocks selected items.
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:272
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
Class ZONE_SETTINGS handles zones parameters.
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:364
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:277
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:96
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:560
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
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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)
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Updates ratsnest for selected items.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
const wxString & GetNetname() const
Function GetNetname.
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:996
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:356
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:169
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
static bool showLocalRatsnest(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
int GetToolId() const
Definition: draw_frame.h:419
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.
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:311
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:674
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:140
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:265
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
void Remove(BOARD_ITEM *aBoardItem) override
Removes an item from the container.
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:602
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:572
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:126
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39