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 <pcb_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 #include <profile.h>
57 
58 #include <tools/tool_event_utils.h>
59 
60 #include <functional>
61 using namespace std::placeholders;
62 
63 
64 // Track & via size control
65 TOOL_ACTION PCB_ACTIONS::trackWidthInc( "pcbnew.EditorControl.trackWidthInc",
67  "", "" );
68 
69 TOOL_ACTION PCB_ACTIONS::trackWidthDec( "pcbnew.EditorControl.trackWidthDec",
71  "", "" );
72 
73 TOOL_ACTION PCB_ACTIONS::viaSizeInc( "pcbnew.EditorControl.viaSizeInc",
75  "", "" );
76 
77 TOOL_ACTION PCB_ACTIONS::viaSizeDec( "pcbnew.EditorControl.viaSizeDec",
79  "", "" );
80 
81 TOOL_ACTION PCB_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaSizeChanged",
82  AS_GLOBAL, 0,
83  "", "", NULL, AF_NOTIFY );
84 
85 
86 // Zone actions
87 TOOL_ACTION PCB_ACTIONS::zoneFill( "pcbnew.EditorControl.zoneFill",
88  AS_GLOBAL, 0,
89  _( "Fill" ), _( "Fill zone(s)" ), fill_zone_xpm );
90 
91 TOOL_ACTION PCB_ACTIONS::zoneFillAll( "pcbnew.EditorControl.zoneFillAll",
93  _( "Fill All" ), _( "Fill all zones" ) );
94 
95 TOOL_ACTION PCB_ACTIONS::zoneUnfill( "pcbnew.EditorControl.zoneUnfill",
96  AS_GLOBAL, 0,
97  _( "Unfill" ), _( "Unfill zone(s)" ), zone_unfill_xpm );
98 
99 TOOL_ACTION PCB_ACTIONS::zoneUnfillAll( "pcbnew.EditorControl.zoneUnfillAll",
101  _( "Unfill All" ), _( "Unfill all zones" ) );
102 
103 TOOL_ACTION PCB_ACTIONS::zoneMerge( "pcbnew.EditorControl.zoneMerge",
104  AS_GLOBAL, 0,
105  _( "Merge Zones" ), _( "Merge zones" ) );
106 
107 TOOL_ACTION PCB_ACTIONS::zoneDuplicate( "pcbnew.EditorControl.zoneDuplicate",
108  AS_GLOBAL, 0,
109  _( "Duplicate Zone onto Layer" ), _( "Duplicate zone outline onto a different layer" ),
110  zone_duplicate_xpm );
111 
112 
113 TOOL_ACTION PCB_ACTIONS::placeTarget( "pcbnew.EditorControl.placeTarget",
114  AS_GLOBAL, 0,
115  _( "Add Layer Alignment Target" ), _( "Add a layer alignment target" ), NULL, AF_ACTIVATE );
116 
117 TOOL_ACTION PCB_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule",
119  _( "Add Footprint" ), _( "Add a footprint" ), NULL, AF_ACTIVATE );
120 
121 TOOL_ACTION PCB_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin",
122  AS_GLOBAL, 0,
123  "", "" );
124 
125 TOOL_ACTION PCB_ACTIONS::crossProbeSchToPcb( "pcbnew.EditorControl.crossProbSchToPcb",
126  AS_GLOBAL, 0,
127  "", "" );
128 
129 TOOL_ACTION PCB_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock",
131  "Toggle Lock", "" );
132 
133 TOOL_ACTION PCB_ACTIONS::lock( "pcbnew.EditorControl.lock",
134  AS_GLOBAL, 0,
135  _( "Lock" ), "" );
136 
137 TOOL_ACTION PCB_ACTIONS::unlock( "pcbnew.EditorControl.unlock",
138  AS_GLOBAL, 0,
139  _( "Unlock" ), "" );
140 
141 TOOL_ACTION PCB_ACTIONS::appendBoard( "pcbnew.EditorControl.appendBoard",
142  AS_GLOBAL, 0,
143  "", "" );
144 
145 TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
146  AS_GLOBAL, 0,
147  "", "" );
148 
149 TOOL_ACTION PCB_ACTIONS::highlightNetCursor( "pcbnew.EditorControl.highlightNetCursor",
150  AS_GLOBAL, 0,
151  "", "" );
152 
153 TOOL_ACTION PCB_ACTIONS::showLocalRatsnest( "pcbnew.Control.showLocalRatsnest",
154  AS_GLOBAL, 0,
155  "", "" );
156 
157 
159 {
160 public:
162  {
163  SetIcon( add_zone_xpm );
164  SetTitle( _( "Zones" ) );
165 
166  Add( PCB_ACTIONS::zoneFill );
170 
171  AppendSeparator();
172 
173  Add( PCB_ACTIONS::zoneMerge );
177  }
178 
179 protected:
180  CONTEXT_MENU* create() const override
181  {
182  return new ZONE_CONTEXT_MENU();
183  }
184 
185 private:
186  void update() override
187  {
188  SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
189 
190  // enable zone actions that act on a single zone
191  bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 )
193  )( selTool->GetSelection() );
194 
195  Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
196  Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
197  Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
198 
199  // enable zone actions that ably to a specific set of zones (as opposed to all of them)
200  bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
201 
202  Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
203  Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
204 
205  // lines like this make me really think about a better name for SELECTION_CONDITIONS class
206  bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
207  /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
210 
211  Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
212  }
213 };
214 
215 
217 {
218 public:
220  {
221  SetIcon( locked_xpm );
222  SetTitle( _( "Locking" ) );
223 
224  Add( PCB_ACTIONS::lock );
225  Add( PCB_ACTIONS::unlock );
227  }
228 
229  CONTEXT_MENU* create() const override
230  {
231  return new LOCK_CONTEXT_MENU();
232  }
233 };
234 
235 
237  PCB_TOOL( "pcbnew.EditorControl" ),
238  m_frame( nullptr )
239 {
240  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
242  m_probingSchToPcb = false;
243  m_slowRatsnest = false;
244 }
245 
246 
248 {
249 }
250 
251 
253 {
254  m_frame = getEditFrame<PCB_EDIT_FRAME>();
255 
256  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
257  {
258  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
259  getView()->Remove( m_placeOrigin.get() );
260  getView()->Add( m_placeOrigin.get() );
261  }
262 }
263 
264 
266 {
267  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
268  zoneMenu->SetTool( this );
269 
270  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
271  lockMenu->SetTool( this );
272 
273  // Add the PCB control menus to relevant other tools
274 
276 
277  if( selTool )
278  {
279  auto& toolMenu = selTool->GetToolMenu();
280  auto& menu = toolMenu.GetMenu();
281 
282  toolMenu.AddSubMenu( zoneMenu );
283  toolMenu.AddSubMenu( lockMenu );
284 
285  menu.AddMenu( zoneMenu.get(), false,
287 
288  menu.AddMenu( lockMenu.get(), false,
290  }
291 
292  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
293 
294  if( drawingTool )
295  {
296  auto& toolMenu = drawingTool->GetToolMenu();
297  auto& menu = toolMenu.GetMenu();
298 
299  toolMenu.AddSubMenu( zoneMenu );
300 
301  // Functor to say if the PCB_EDIT_FRAME is in a given mode
302  // Capture the tool pointer and tool mode by value
303  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
304  {
305  return [=]( const SELECTION& sel )
306  {
307  return drawingTool->GetDrawingMode() == aMode;
308  };
309  };
310 
311  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
312  }
313 
314  m_ratsnestTimer.SetOwner( this );
315  Connect( m_ratsnestTimer.GetId(), wxEVT_TIMER,
316  wxTimerEventHandler( PCB_EDITOR_CONTROL::ratsnestTimer ), NULL, this );
317 
318  return true;
319 }
320 
321 
322 // Track & via size control
324 {
325  BOARD* board = getModel<BOARD>();
326  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
327 
328  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
329  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
330 
331  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
332  board->GetDesignSettings().UseCustomTrackViaSize( false );
333 
335 
336  return 0;
337 }
338 
339 
341 {
342  BOARD* board = getModel<BOARD>();
343  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
344 
345  if( widthIndex < 0 )
346  widthIndex = 0;
347 
348  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
349  board->GetDesignSettings().UseCustomTrackViaSize( false );
350 
352 
353  return 0;
354 }
355 
356 
358 {
359  BOARD* board = getModel<BOARD>();
360  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
361 
362  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
363  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
364 
365  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
366  board->GetDesignSettings().UseCustomTrackViaSize( false );
367 
369 
370  return 0;
371 }
372 
373 
375 {
376  BOARD* board = getModel<BOARD>();
377  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
378 
379  if( sizeIndex < 0 )
380  sizeIndex = 0;
381 
382  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
383  board->GetDesignSettings().UseCustomTrackViaSize( false );
384 
386 
387  return 0;
388 }
389 
390 
392 {
393  MODULE* module = NULL;
394  KIGFX::VIEW* view = getView();
396  BOARD* board = getModel<BOARD>();
397 
398  // Add a VIEW_GROUP that serves as a preview for the new item
399  KIGFX::VIEW_GROUP preview( view );
400  view->Add( &preview );
401 
403  controls->ShowCursor( true );
404  controls->SetSnapping( true );
405 
406  Activate();
407  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_PENCIL, _( "Add footprint" ) );
408 
409  // Main loop: keep receiving events
410  while( OPT_TOOL_EVENT evt = Wait() )
411  {
412  VECTOR2I cursorPos = controls->GetCursorPosition();
413 
414  if( evt->IsCancel() || evt->IsActivate() )
415  {
416  if( module )
417  {
418  delete module;
419  module = NULL;
420 
421  preview.Clear();
422  controls->ShowCursor( true );
423  }
424  else
425  break;
426 
427  if( evt->IsActivate() ) // now finish unconditionally
428  break;
429  }
430 
431  else if( module && evt->Category() == TC_COMMAND )
432  {
433  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
434  {
435  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
436  *m_frame, *evt );
437  module->Rotate( module->GetPosition(), rotationAngle );
438  view->Update( &preview );
439  }
440  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
441  {
442  module->Flip( module->GetPosition() );
443  view->Update( &preview );
444  }
445  }
446 
447  else if( evt->IsClick( BUT_LEFT ) )
448  {
449  if( !module )
450  {
451  // Pick the module to be placed
452  module = m_frame->LoadModuleFromLibrary( wxEmptyString,
454  true, NULL );
455 
456  if( module == NULL )
457  continue;
458 
459  // Module has been added in LoadModuleFromLibrary(),
460  // so we have to remove it before committing the change @todo LEGACY
461  board->Remove( module );
462  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
463 
464  // Add all the drawable parts to preview
465  preview.Add( module );
466  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
467  }
468  else
469  {
470  BOARD_COMMIT commit( m_frame );
471  commit.Add( module );
472  commit.Push( _( "Place a module" ) );
473 
474  // Remove from preview
475  preview.Remove( module );
476  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
477  module = NULL; // to indicate that there is no module that we currently modify
478  }
479 
480  bool placing = ( module != NULL );
481 
482  controls->SetAutoPan( placing );
483  controls->CaptureCursor( placing );
484  controls->ShowCursor( !placing );
485  }
486 
487  else if( module && evt->IsMotion() )
488  {
489  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
490  view->Update( &preview );
491  }
492  }
493 
494  controls->ShowCursor( false );
495  controls->SetSnapping( false );
496  controls->SetAutoPan( false );
497  controls->CaptureCursor( false );
498 
499  view->Remove( &preview );
501 
502  return 0;
503 }
504 
505 
507 {
508  return modifyLockSelected( TOGGLE );
509 }
510 
511 
513 {
514  return modifyLockSelected( ON );
515 }
516 
517 
519 {
520  return modifyLockSelected( OFF );
521 }
522 
523 
525 {
527  const SELECTION& selection = selTool->GetSelection();
528 
529  if( selection.Empty() )
531 
532  bool modified = false;
533 
534  for( auto i : selection )
535  {
536  auto item = static_cast<BOARD_ITEM*>( i );
537  bool prevState = item->IsLocked();
538 
539  switch( aMode )
540  {
541  case ON:
542  item->SetLocked( true );
543  break;
544 
545  case OFF:
546  item->SetLocked( false );
547  break;
548 
549  case TOGGLE:
550  item->SetLocked( !prevState );
551  break;
552  }
553 
554  // Check if we really modified an item
555  if( !modified && prevState != item->IsLocked() )
556  modified = true;
557  }
558 
559  if( modified )
560  m_frame->OnModify();
561 
562  return 0;
563 }
564 
565 
567 {
568  KIGFX::VIEW* view = getView();
570  BOARD* board = getModel<BOARD>();
571  PCB_TARGET* target = new PCB_TARGET( board );
572 
573  // Init the new item attributes
574  target->SetLayer( Edge_Cuts );
575  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
576  target->SetSize( Millimeter2iu( 5 ) );
577  VECTOR2I cursorPos = controls->GetCursorPosition();
578  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
579 
580  // Add a VIEW_GROUP that serves as a preview for the new item
581  KIGFX::VIEW_GROUP preview( view );
582  preview.Add( target );
583  view->Add( &preview );
584 
586  controls->SetSnapping( true );
587 
588  Activate();
589  m_frame->SetToolID( ID_PCB_MIRE_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
590 
591  // Main loop: keep receiving events
592  while( OPT_TOOL_EVENT evt = Wait() )
593  {
594  cursorPos = controls->GetCursorPosition();
595 
596  if( evt->IsCancel() || evt->IsActivate() )
597  break;
598 
599  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
600  {
601  target->SetWidth( target->GetWidth() + WIDTH_STEP );
602  view->Update( &preview );
603  }
604 
605  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
606  {
607  int width = target->GetWidth();
608 
609  if( width > WIDTH_STEP )
610  {
611  target->SetWidth( width - WIDTH_STEP );
612  view->Update( &preview );
613  }
614  }
615 
616  else if( evt->IsClick( BUT_LEFT ) )
617  {
618  assert( target->GetSize() > 0 );
619  assert( target->GetWidth() > 0 );
620 
621  BOARD_COMMIT commit( m_frame );
622  commit.Add( target );
623  commit.Push( _( "Place a layer alignment target" ) );
624 
625  preview.Remove( target );
626 
627  // Create next PCB_TARGET
628  target = new PCB_TARGET( *target );
629  preview.Add( target );
630  }
631 
632  else if( evt->IsMotion() )
633  {
634  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
635  view->Update( &preview );
636  }
637  }
638 
639  delete target;
640 
641  controls->SetSnapping( false );
642  view->Remove( &preview );
643 
645 
646  return 0;
647 }
648 
649 
650 // Zone actions
652 {
653  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
654  const auto& selection = selTool->GetSelection();
655  auto connectivity = getModel<BOARD>()->GetConnectivity();
656 
657  BOARD_COMMIT commit( this );
658 
659  for( auto item : selection )
660  {
661  assert( item->Type() == PCB_ZONE_AREA_T );
662 
663  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( item );
664 
665  commit.Modify( zone );
666 
667  m_frame->Fill_Zone( zone );
668  zone->SetIsFilled( true );
669  }
670 
671  commit.Push( _( "Fill Zone" ) );
672 
673  connectivity->RecalculateRatsnest();
674 
675  return 0;
676 }
677 
678 
680 {
681  BOARD* board = getModel<BOARD>();
682  auto connectivity = getModel<BOARD>()->GetConnectivity();
683  int areaCount = board->GetAreaCount();
684  const wxString fmt = _( "Filling zone %d out of %d (net %s)..." );
685  wxString msg;
686  bool aborted = false;
687 
688  // Create a message with a long net name, and build a wxProgressDialog
689  // with a correct size to show this long net name
690  msg.Printf( fmt, 000, areaCount, wxT("XXXXXXXXXXXXXXXXX" ) );
691 
692  auto progressDialog = new wxProgressDialog( _( "Fill All Zones" ), msg,
693  areaCount, frame(),
694  wxPD_AUTO_HIDE | wxPD_CAN_ABORT |
695  wxPD_APP_MODAL | wxPD_ELAPSED_TIME );
696 
697  BOARD_COMMIT commit( this );
698 
699  for( int i = 0; i < areaCount; ++i )
700  {
701  ZONE_CONTAINER* zone = board->GetArea( i );
702 
703  msg.Printf( fmt, i, areaCount, GetChars( zone->GetNetname() ) );
704 
705  commit.Modify( zone );
706 
707  if( !progressDialog->Update( i, msg ) )
708  {
709  aborted = true;
710  break; // Aborted by user
711  }
712 
713  m_frame->Fill_Zone( zone );
714  zone->SetIsFilled( true );
715  }
716 
717  if( aborted )
718  commit.Revert();
719  else
720  commit.Push( _( "Fill All Zones" ) );
721 
722  connectivity->RecalculateRatsnest();
723  progressDialog->Destroy();
724 
725  return 0;
726 }
727 
728 
730 {
731  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
732  const auto& selection = selTool->GetSelection();
733  auto connectivity = getModel<BOARD>()->GetConnectivity();
734 
735  BOARD_COMMIT commit( this );
736 
737  for( auto item : selection )
738  {
739  assert( item->Type() == PCB_ZONE_AREA_T );
740 
741  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
742 
743  commit.Modify( zone );
744 
745  zone->SetIsFilled( false );
746  zone->ClearFilledPolysList();
747  }
748 
749  commit.Push( _( "Unfill Zone" ) );
750 
751  connectivity->RecalculateRatsnest();
752 
753  return 0;
754 }
755 
756 
758 {
759  BOARD* board = getModel<BOARD>();
760  auto connectivity = getModel<BOARD>()->GetConnectivity();
761 
762  BOARD_COMMIT commit( this );
763 
764  for( int i = 0; i < board->GetAreaCount(); ++i )
765  {
766  ZONE_CONTAINER* zone = board->GetArea( i );
767 
768  commit.Modify( zone );
769 
770  zone->SetIsFilled( false );
771  zone->ClearFilledPolysList();
772  }
773 
774  commit.Push( _( "Unfill All Zones" ) );
775 
776  connectivity->RecalculateRatsnest();
777 
778  return 0;
779 }
780 
781 
782 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
783  std::vector<ZONE_CONTAINER *>& aMergedZones )
784 {
785  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
786  {
787  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
789  }
790 
791  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
792 
793  // We should have one polygon with hole
794  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
795  // and therefore cannot be merged (they are dectected as intersecting)
796  // but we should never have more than 2 polys
797  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
798  {
799  wxLogMessage( wxT( "BOARD::CombineAreas error: more than 2 polys after merging" ) );
800  return false;
801  }
802 
803  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
804  {
805  aCommit.Remove( aOriginZones[i] );
806  }
807 
808  aCommit.Modify( aOriginZones[0] );
809  aMergedZones.push_back( aOriginZones[0] );
810 
811  aOriginZones[0]->SetLocalFlags( 1 );
812  aOriginZones[0]->Hatch();
813 
814  return true;
815 }
816 
818 {
819  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
820  BOARD* board = getModel<BOARD>();
821  BOARD_COMMIT commit( m_frame );
822 
823  if( selection.Size() < 2 )
824  return 0;
825 
826  int netcode = -1;
827 
828  ZONE_CONTAINER* firstZone = nullptr;
829  std::vector<ZONE_CONTAINER*> toMerge, merged;
830 
831  for( auto item : selection )
832  {
833  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
834 
835  if( !curr_area )
836  continue;
837 
838  if( !firstZone )
839  firstZone = curr_area;
840 
841  netcode = curr_area->GetNetCode();
842 
843  if( firstZone )
844  {
845  if( firstZone->GetNetCode() != netcode )
846  continue;
847 
848  if( curr_area->GetPriority() != firstZone->GetPriority() )
849  continue;
850 
851  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
852  continue;
853 
854  if( curr_area->GetLayer() != firstZone->GetLayer() )
855  continue;
856 
857  if( !board->TestAreaIntersection( curr_area, firstZone ) )
858  continue;
859 
860  toMerge.push_back( curr_area );
861  }
862  else
863  {
864  toMerge.push_back( curr_area );
865  }
866  }
867 
869 
870  if( mergeZones( commit, toMerge, merged ) )
871  {
872  commit.Push( _( "Merge zones" ) );
873 
874  for( auto item : merged )
876  }
877 
878  return 0;
879 }
880 
881 
883 {
884  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
885  const auto& selection = selTool->GetSelection();
886 
887  // because this pops up the zone editor, it would be confusing
888  // to handle multiple zones, so just handle single selections
889  // containing exactly one zone
890  if( selection.Size() != 1 )
891  return 0;
892 
893  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
894 
895  if( !oldZone )
896  return 0;
897 
898  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
899  newZone->ClearSelected();
900  newZone->UnFill();
901  ZONE_SETTINGS zoneSettings;
902  zoneSettings << *oldZone;
903 
904  bool success = false;
905 
906  if( oldZone->GetIsKeepout() )
907  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
908  else if( oldZone->IsOnCopperLayer() )
909  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
910  else
911  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
912 
913  // If the new zone is on the same layer as the the initial zone,
914  // do nothing
915  if( success && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
916  {
918  _( "The duplicated zone cannot be on the same layer as the original zone." ) );
919  success = false;
920  }
921 
922  // duplicate the zone
923  if( success )
924  {
925  BOARD_COMMIT commit( m_frame );
926  zoneSettings.ExportSetting( *newZone );
927 
928  commit.Add( newZone.release() );
929  commit.Push( _( "Duplicate zone" ) );
930  }
931 
932  return 0;
933 }
934 
935 
937 {
938  if( m_probingSchToPcb )
939  {
940  m_probingSchToPcb = false;
941  return 0;
942  }
943 
945  const SELECTION& selection = selTool->GetSelection();
946 
947  if( selection.Size() == 1 )
948  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
949 
950  return 0;
951 }
952 
953 
955 {
956  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
957 
958  if( item )
959  {
960  m_probingSchToPcb = true;
961  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
963 
964  // If it is a pad and the net highlighting tool is enabled, highlight the net
965  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
966  {
967  int net = static_cast<D_PAD*>( item )->GetNetCode();
969  }
970  else
971  // Otherwise simply select the corresponding item
972  {
974  }
975  }
976 
977  return 0;
978 }
979 
980 
981 static bool setDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
982  KIGFX::ORIGIN_VIEWITEM* aItem, const VECTOR2D& aPosition )
983 {
984  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
985  aItem->SetPosition( aPosition );
986  aView->MarkDirty();
987 
988  return true;
989 }
990 
991 
993 {
994  Activate();
995 
997  assert( picker );
998 
999  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) );
1000  picker->SetClickHandler( std::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
1001  picker->Activate();
1002  Wait();
1003 
1004  return 0;
1005 }
1006 
1014 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
1015 {
1016  auto render = aToolMgr->GetView()->GetPainter()->GetSettings();
1017  auto frame = static_cast<PCB_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
1018  auto guide = frame->GetCollectorsGuide();
1019  BOARD* board = static_cast<BOARD*>( aToolMgr->GetModel() );
1020  GENERAL_COLLECTOR collector;
1021  int net = -1;
1022 
1023  // Find a connected item for which we are going to highlight a net
1025  wxPoint( aPosition.x, aPosition.y ), guide );
1026 
1027  for( int i = 0; i < collector.GetCount(); i++ )
1028  {
1029  if( collector[i]->Type() == PCB_PAD_T )
1030  {
1031  frame->SendMessageToEESCHEMA( static_cast<BOARD_CONNECTED_ITEM*>( collector[i] ) );
1032  break;
1033  }
1034  }
1035 
1036  bool enableHighlight = ( collector.GetCount() > 0 );
1037 
1038  // Obtain net code for the clicked item
1039  if( enableHighlight )
1040  net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
1041 
1042  // Toggle highlight when the same net was picked
1043  if( net > 0 && net == render->GetHighlightNetCode() )
1044  enableHighlight = !render->IsHighlightEnabled();
1045 
1046  if( enableHighlight != render->IsHighlightEnabled() || net != render->GetHighlightNetCode() )
1047  {
1048  render->SetHighlight( enableHighlight, net );
1049  aToolMgr->GetView()->UpdateAllLayersColor();
1050  }
1051 
1052  // Store the highlighted netcode in the current board (for dialogs for instance)
1053  if( enableHighlight && net >= 0 )
1054  board->SetHighLightNet( net );
1055  else
1056  board->ResetHighLight();
1057 
1058  return true;
1059 }
1060 
1061 
1063 {
1064  int netcode = aEvent.Parameter<intptr_t>();
1065 
1066  if( netcode > 0 )
1067  {
1069  render->SetHighlight( true, netcode );
1071  }
1072  else
1073  {
1074  // No net code specified, pick the net code belonging to the item under the cursor
1075  highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
1076  }
1077 
1078  return 0;
1079 }
1080 
1081 
1083 {
1084  Activate();
1085 
1086  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1087  assert( picker );
1088 
1089  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
1090  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1 ) );
1091  picker->SetSnapping( false );
1092  picker->Activate();
1093  Wait();
1094 
1095  return 0;
1096 }
1097 
1098 
1099 static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
1100 {
1101  auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
1102 
1103  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
1104  aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
1105 
1106  const SELECTION& selection = selectionTool->GetSelection();
1107 
1108  if( selection.Empty() )
1109  return true;
1110 
1111  for( auto item : selection )
1112  {
1113  if( item->Type() == PCB_MODULE_T )
1114  {
1115  for( auto pad : static_cast<MODULE *> (item)->Pads() )
1116  {
1117  pad->SetLocalRatsnestVisible( true );
1118  }
1119  }
1120  }
1121 
1122  return true;
1123 }
1124 
1125 
1127 {
1128  Activate();
1129 
1130  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
1131  assert( picker );
1132 
1133  m_frame->SetToolID( ID_PCB_SHOW_1_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) );
1134  picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, _1 ) );
1135  picker->SetSnapping( false );
1136  picker->Activate();
1137  Wait();
1138 
1139  return 0;
1140 }
1141 
1142 
1144 {
1145  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1146  auto& selection = selectionTool->GetSelection();
1147  auto connectivity = getModel<BOARD>()->GetConnectivity();
1148 
1149  if( selection.Empty() )
1150  {
1151  connectivity->ClearDynamicRatsnest();
1152  }
1153  else if( m_slowRatsnest )
1154  {
1155  // Compute ratsnest only when user stops dragging for a moment
1156  connectivity->HideDynamicRatsnest();
1157  m_ratsnestTimer.Start( 20 );
1158  }
1159  else
1160  {
1161  // Check how much time doest it take to calculate ratsnest
1162  PROF_COUNTER counter;
1164  counter.Stop();
1165 
1166  // If it is too slow, then switch to 'slow ratsnest' mode when
1167  // ratsnest is calculated when user stops dragging items for a moment
1168  if( counter.msecs() > 25 )
1169  {
1170  m_slowRatsnest = true;
1171  connectivity->HideDynamicRatsnest();
1172  }
1173  }
1174 
1175  return 0;
1176 }
1177 
1178 
1180 {
1181  getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
1182  m_slowRatsnest = false;
1183  return 0;
1184 }
1185 
1186 
1187 void PCB_EDITOR_CONTROL::ratsnestTimer( wxTimerEvent& aEvent )
1188 {
1189  m_ratsnestTimer.Stop();
1191  static_cast<PCB_DRAW_PANEL_GAL*>( m_frame->GetGalCanvas() )->RedrawRatsnest();
1193 }
1194 
1195 
1197 {
1198  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1199  auto& selection = selectionTool->GetSelection();
1200  auto connectivity = getModel<BOARD>()->GetConnectivity();
1201  std::vector<BOARD_ITEM*> items;
1202  items.reserve( selection.Size() );
1203 
1204  for( auto item : selection )
1205  items.push_back( static_cast<BOARD_ITEM*>( item ) );
1206 
1207  connectivity->ComputeDynamicRatsnest( items );
1208 }
1209 
1210 
1212 {
1213  // Track & via size control
1218 
1219  // Zone actions
1226 
1227  // Placing tools
1230 
1231  // Other
1243 }
1244 
1245 
1246 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.
void Stop()
save the time when this function was called, and set the counter stane to stop
Definition: profile.h:82
static TOOL_ACTION toggleLock
Definition: pcb_actions.h:351
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:994
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:166
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:353
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:175
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:160
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:366
static TOOL_ACTION lock
Definition: pcb_actions.h:352
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:279
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:272
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:213
int HideSelectionRatsnest(const TOOL_EVENT &aEvent)
Hides ratsnest for selected items. Called when there are no items selected.
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:356
static TOOL_ACTION trackWidthDec
Definition: pcb_actions.h:271
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:275
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
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
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:45
static TOOL_ACTION highlightNetCursor
Definition: pcb_actions.h:365
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
wxTimer m_ratsnestTimer
Timer that start ratsnest calculation when it is slow to compute.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION showLocalRatsnest
Definition: pcb_actions.h:370
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:278
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:108
static TOOL_ACTION crossProbeSchToPcb
Definition: pcb_actions.h:367
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:178
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:270
class MODULE, a footprint
Definition: typeinfo.h:101
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:368
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
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...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
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:282
SELECTION & GetSelection()
Function GetSelection()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
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:1011
ZONE_EDIT_T InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_CONTAINER *aZone, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing...
void SetPosition(const wxPoint &aPos) override
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
void ratsnestTimer(wxTimerEvent &aEvent)
Event handler to recalculate dynamic ratsnest
int ViaSizeInc(const TOOL_EVENT &aEvent)
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:1377
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:157
static TOOL_ACTION placeTarget
Activation of the drawing tool (placing a TARGET)
Definition: pcb_actions.h:163
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:281
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...
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
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:280
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:372
static TOOL_ACTION zoneDuplicate
Duplicate zone onto another layer.
Definition: pcb_actions.h:285
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
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
double msecs() const
Definition: profile.h:124
void SendMessageToEESCHEMA(BOARD_ITEM *objectToSync)
Function SendMessageToEESCHEMA sends a message to the schematic editor so that it may move its cursor...
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
MODE
The possible drawing modes of DRAWING_TOOL
Definition: drawing_tool.h:68
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:982
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:364
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)
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:817
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 m_slowRatsnest
Flag to indicate whether the current selection ratsnest is slow to calculate.
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
void calculateSelectionRatsnest()
Recalculates dynamic ratsnest for the current selection
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:273
void setTransitions() override
Sets up handlers for various events.
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:594
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
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