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 = aEvent.Parameter<MODULE*>();
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  // Add all the drawable parts to preview
410  VECTOR2I cursorPos = controls->GetCursorPosition();
411  if( module )
412  {
413  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
414  preview.Add( module );
415  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
416  view->Update( &preview );
417  }
418 
419  // Main loop: keep receiving events
420  while( OPT_TOOL_EVENT evt = Wait() )
421  {
422  cursorPos = controls->GetCursorPosition();
423 
424  if( evt->IsCancel() || evt->IsActivate() )
425  {
426  if( module )
427  {
428  delete module;
429  module = NULL;
430 
431  preview.Clear();
432  controls->ShowCursor( true );
433  }
434  else
435  break;
436 
437  if( evt->IsActivate() ) // now finish unconditionally
438  break;
439  }
440 
441  else if( module && evt->Category() == TC_COMMAND )
442  {
443  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
444  {
445  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
446  *m_frame, *evt );
447  module->Rotate( module->GetPosition(), rotationAngle );
448  view->Update( &preview );
449  }
450  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
451  {
452  module->Flip( module->GetPosition() );
453  view->Update( &preview );
454  }
455  }
456 
457  else if( evt->IsClick( BUT_LEFT ) )
458  {
459  if( !module )
460  {
461  // Pick the module to be placed
462  module = m_frame->LoadModuleFromLibrary( wxEmptyString,
464  true, NULL );
465 
466  if( module == NULL )
467  continue;
468 
469  // Module has been added in LoadModuleFromLibrary(),
470  // so we have to remove it before committing the change @todo LEGACY
471  board->Remove( module );
472  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
473 
474  // Add all the drawable parts to preview
475  preview.Add( module );
476  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
477  }
478  else
479  {
480  BOARD_COMMIT commit( m_frame );
481  commit.Add( module );
482  commit.Push( _( "Place a module" ) );
483 
484  // Remove from preview
485  preview.Remove( module );
486  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
487  module = NULL; // to indicate that there is no module that we currently modify
488  }
489 
490  bool placing = ( module != NULL );
491 
492  controls->SetAutoPan( placing );
493  controls->CaptureCursor( placing );
494  controls->ShowCursor( !placing );
495  }
496 
497  else if( module && evt->IsMotion() )
498  {
499  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
500  view->Update( &preview );
501  }
502  }
503 
504  controls->ShowCursor( false );
505  controls->SetSnapping( false );
506  controls->SetAutoPan( false );
507  controls->CaptureCursor( false );
508 
509  view->Remove( &preview );
511 
512  return 0;
513 }
514 
515 
517 {
518  return modifyLockSelected( TOGGLE );
519 }
520 
521 
523 {
524  return modifyLockSelected( ON );
525 }
526 
527 
529 {
530  return modifyLockSelected( OFF );
531 }
532 
533 
535 {
537  const SELECTION& selection = selTool->GetSelection();
538 
539  if( selection.Empty() )
541 
542  bool modified = false;
543 
544  for( auto i : selection )
545  {
546  auto item = static_cast<BOARD_ITEM*>( i );
547  bool prevState = item->IsLocked();
548 
549  switch( aMode )
550  {
551  case ON:
552  item->SetLocked( true );
553  break;
554 
555  case OFF:
556  item->SetLocked( false );
557  break;
558 
559  case TOGGLE:
560  item->SetLocked( !prevState );
561  break;
562  }
563 
564  // Check if we really modified an item
565  if( !modified && prevState != item->IsLocked() )
566  modified = true;
567  }
568 
569  if( modified )
570  m_frame->OnModify();
571 
572  return 0;
573 }
574 
575 
577 {
578  KIGFX::VIEW* view = getView();
580  BOARD* board = getModel<BOARD>();
581  PCB_TARGET* target = new PCB_TARGET( board );
582 
583  // Init the new item attributes
584  target->SetLayer( Edge_Cuts );
585  target->SetWidth( board->GetDesignSettings().m_EdgeSegmentWidth );
586  target->SetSize( Millimeter2iu( 5 ) );
587  VECTOR2I cursorPos = controls->GetCursorPosition();
588  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
589 
590  // Add a VIEW_GROUP that serves as a preview for the new item
591  KIGFX::VIEW_GROUP preview( view );
592  preview.Add( target );
593  view->Add( &preview );
594 
596  controls->SetSnapping( true );
597 
598  Activate();
599  m_frame->SetToolID( ID_PCB_MIRE_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
600 
601  // Main loop: keep receiving events
602  while( OPT_TOOL_EVENT evt = Wait() )
603  {
604  cursorPos = controls->GetCursorPosition();
605 
606  if( evt->IsCancel() || evt->IsActivate() )
607  break;
608 
609  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
610  {
611  target->SetWidth( target->GetWidth() + WIDTH_STEP );
612  view->Update( &preview );
613  }
614 
615  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
616  {
617  int width = target->GetWidth();
618 
619  if( width > WIDTH_STEP )
620  {
621  target->SetWidth( width - WIDTH_STEP );
622  view->Update( &preview );
623  }
624  }
625 
626  else if( evt->IsClick( BUT_LEFT ) )
627  {
628  assert( target->GetSize() > 0 );
629  assert( target->GetWidth() > 0 );
630 
631  BOARD_COMMIT commit( m_frame );
632  commit.Add( target );
633  commit.Push( _( "Place a layer alignment target" ) );
634 
635  preview.Remove( target );
636 
637  // Create next PCB_TARGET
638  target = new PCB_TARGET( *target );
639  preview.Add( target );
640  }
641 
642  else if( evt->IsMotion() )
643  {
644  target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
645  view->Update( &preview );
646  }
647  }
648 
649  delete target;
650 
651  controls->SetSnapping( false );
652  view->Remove( &preview );
653 
655 
656  return 0;
657 }
658 
659 
660 // Zone actions
662 {
663  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
664  const auto& selection = selTool->GetSelection();
665  auto connectivity = getModel<BOARD>()->GetConnectivity();
666 
667  BOARD_COMMIT commit( this );
668 
669  for( auto item : selection )
670  {
671  assert( item->Type() == PCB_ZONE_AREA_T );
672 
673  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( item );
674 
675  commit.Modify( zone );
676 
677  m_frame->Fill_Zone( zone );
678  zone->SetIsFilled( true );
679  }
680 
681  commit.Push( _( "Fill Zone" ) );
682 
683  connectivity->RecalculateRatsnest();
684 
685  return 0;
686 }
687 
688 
690 {
691  BOARD* board = getModel<BOARD>();
692  auto connectivity = getModel<BOARD>()->GetConnectivity();
693  int areaCount = board->GetAreaCount();
694  const wxString fmt = _( "Filling zone %d out of %d (net %s)..." );
695  wxString msg;
696  bool aborted = false;
697 
698  // Create a message with a long net name, and build a wxProgressDialog
699  // with a correct size to show this long net name
700  msg.Printf( fmt, 000, areaCount, wxT("XXXXXXXXXXXXXXXXX" ) );
701 
702  auto progressDialog = new wxProgressDialog( _( "Fill All Zones" ), msg,
703  areaCount, frame(),
704  wxPD_AUTO_HIDE | wxPD_CAN_ABORT |
705  wxPD_APP_MODAL | wxPD_ELAPSED_TIME );
706 
707  BOARD_COMMIT commit( this );
708 
709  for( int i = 0; i < areaCount; ++i )
710  {
711  ZONE_CONTAINER* zone = board->GetArea( i );
712 
713  msg.Printf( fmt, i, areaCount, GetChars( zone->GetNetname() ) );
714 
715  commit.Modify( zone );
716 
717  if( !progressDialog->Update( i, msg ) )
718  {
719  aborted = true;
720  break; // Aborted by user
721  }
722 
723  m_frame->Fill_Zone( zone );
724  zone->SetIsFilled( true );
725  }
726 
727  if( aborted )
728  commit.Revert();
729  else
730  commit.Push( _( "Fill All Zones" ) );
731 
732  connectivity->RecalculateRatsnest();
733  progressDialog->Destroy();
734 
735  return 0;
736 }
737 
738 
740 {
741  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
742  const auto& selection = selTool->GetSelection();
743  auto connectivity = getModel<BOARD>()->GetConnectivity();
744 
745  BOARD_COMMIT commit( this );
746 
747  for( auto item : selection )
748  {
749  assert( item->Type() == PCB_ZONE_AREA_T );
750 
751  ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
752 
753  commit.Modify( zone );
754 
755  zone->SetIsFilled( false );
756  zone->ClearFilledPolysList();
757  }
758 
759  commit.Push( _( "Unfill Zone" ) );
760 
761  connectivity->RecalculateRatsnest();
762 
763  return 0;
764 }
765 
766 
768 {
769  BOARD* board = getModel<BOARD>();
770  auto connectivity = getModel<BOARD>()->GetConnectivity();
771 
772  BOARD_COMMIT commit( this );
773 
774  for( int i = 0; i < board->GetAreaCount(); ++i )
775  {
776  ZONE_CONTAINER* zone = board->GetArea( i );
777 
778  commit.Modify( zone );
779 
780  zone->SetIsFilled( false );
781  zone->ClearFilledPolysList();
782  }
783 
784  commit.Push( _( "Unfill All Zones" ) );
785 
786  connectivity->RecalculateRatsnest();
787 
788  return 0;
789 }
790 
791 
792 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
793  std::vector<ZONE_CONTAINER *>& aMergedZones )
794 {
795  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
796  {
797  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
799  }
800 
801  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
802 
803  // We should have one polygon with hole
804  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
805  // and therefore cannot be merged (they are dectected as intersecting)
806  // but we should never have more than 2 polys
807  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
808  {
809  wxLogMessage( wxT( "BOARD::CombineAreas error: more than 2 polys after merging" ) );
810  return false;
811  }
812 
813  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
814  {
815  aCommit.Remove( aOriginZones[i] );
816  }
817 
818  aCommit.Modify( aOriginZones[0] );
819  aMergedZones.push_back( aOriginZones[0] );
820 
821  aOriginZones[0]->SetLocalFlags( 1 );
822  aOriginZones[0]->Hatch();
823 
824  return true;
825 }
826 
828 {
829  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
830  BOARD* board = getModel<BOARD>();
831  BOARD_COMMIT commit( m_frame );
832 
833  if( selection.Size() < 2 )
834  return 0;
835 
836  int netcode = -1;
837 
838  ZONE_CONTAINER* firstZone = nullptr;
839  std::vector<ZONE_CONTAINER*> toMerge, merged;
840 
841  for( auto item : selection )
842  {
843  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
844 
845  if( !curr_area )
846  continue;
847 
848  if( !firstZone )
849  firstZone = curr_area;
850 
851  netcode = curr_area->GetNetCode();
852 
853  if( firstZone )
854  {
855  if( firstZone->GetNetCode() != netcode )
856  continue;
857 
858  if( curr_area->GetPriority() != firstZone->GetPriority() )
859  continue;
860 
861  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
862  continue;
863 
864  if( curr_area->GetLayer() != firstZone->GetLayer() )
865  continue;
866 
867  if( !board->TestAreaIntersection( curr_area, firstZone ) )
868  continue;
869 
870  toMerge.push_back( curr_area );
871  }
872  else
873  {
874  toMerge.push_back( curr_area );
875  }
876  }
877 
879 
880  if( mergeZones( commit, toMerge, merged ) )
881  {
882  commit.Push( _( "Merge zones" ) );
883 
884  for( auto item : merged )
886  }
887 
888  return 0;
889 }
890 
891 
893 {
894  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
895  const auto& selection = selTool->GetSelection();
896 
897  // because this pops up the zone editor, it would be confusing
898  // to handle multiple zones, so just handle single selections
899  // containing exactly one zone
900  if( selection.Size() != 1 )
901  return 0;
902 
903  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
904 
905  if( !oldZone )
906  return 0;
907 
908  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
909  newZone->ClearSelected();
910  newZone->UnFill();
911  ZONE_SETTINGS zoneSettings;
912  zoneSettings << *oldZone;
913 
914  bool success = false;
915 
916  if( oldZone->GetIsKeepout() )
917  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
918  else if( oldZone->IsOnCopperLayer() )
919  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
920  else
921  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
922 
923  // If the new zone is on the same layer as the the initial zone,
924  // do nothing
925  if( success )
926  {
927  if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
928  {
929  DisplayError(
930  m_frame, _( "The duplicated keepout zone cannot be on the same layers as the original zone." ) );
931  success = false;
932  }
933  else if( !oldZone->GetIsKeepout() && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
934  {
935  DisplayError(
936  m_frame, _( "The duplicated zone cannot be on the same layer as the original zone." ) );
937  success = false;
938  }
939  }
940 
941  // duplicate the zone
942  if( success )
943  {
944  BOARD_COMMIT commit( m_frame );
945  zoneSettings.ExportSetting( *newZone );
946 
947  commit.Add( newZone.release() );
948  commit.Push( _( "Duplicate zone" ) );
949  }
950 
951  return 0;
952 }
953 
954 
956 {
957  if( m_probingSchToPcb )
958  {
959  m_probingSchToPcb = false;
960  return 0;
961  }
962 
964  const SELECTION& selection = selTool->GetSelection();
965 
966  if( selection.Size() == 1 )
967  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
968 
969  return 0;
970 }
971 
972 
974 {
975  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
976 
977  if( item )
978  {
979  m_probingSchToPcb = true;
980  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
982 
983  // If it is a pad and the net highlighting tool is enabled, highlight the net
984  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
985  {
986  int net = static_cast<D_PAD*>( item )->GetNetCode();
988  }
989  else
990  // Otherwise simply select the corresponding item
991  {
993  }
994  }
995 
996  return 0;
997 }
998 
999 
1000 static bool setDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
1001  KIGFX::ORIGIN_VIEWITEM* aItem, const VECTOR2D& aPosition )
1002 {
1003  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
1004  aItem->SetPosition( aPosition );
1005  aView->MarkDirty();
1006 
1007  return true;
1008 }
1009 
1010 
1012 {
1013  Activate();
1014 
1015  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1016  assert( picker );
1017 
1018  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) );
1019  picker->SetClickHandler( std::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
1020  picker->Activate();
1021  Wait();
1022 
1023  return 0;
1024 }
1025 
1033 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
1034 {
1035  auto render = aToolMgr->GetView()->GetPainter()->GetSettings();
1036  auto frame = static_cast<PCB_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
1037  auto guide = frame->GetCollectorsGuide();
1038  BOARD* board = static_cast<BOARD*>( aToolMgr->GetModel() );
1039  GENERAL_COLLECTOR collector;
1040  int net = -1;
1041 
1042  // Find a connected item for which we are going to highlight a net
1044  wxPoint( aPosition.x, aPosition.y ), guide );
1045 
1046  for( int i = 0; i < collector.GetCount(); i++ )
1047  {
1048  if( collector[i]->Type() == PCB_PAD_T )
1049  {
1050  frame->SendMessageToEESCHEMA( static_cast<BOARD_CONNECTED_ITEM*>( collector[i] ) );
1051  break;
1052  }
1053  }
1054 
1055  bool enableHighlight = ( collector.GetCount() > 0 );
1056 
1057  // Obtain net code for the clicked item
1058  if( enableHighlight )
1059  net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
1060 
1061  // Toggle highlight when the same net was picked
1062  if( net > 0 && net == render->GetHighlightNetCode() )
1063  enableHighlight = !render->IsHighlightEnabled();
1064 
1065  if( enableHighlight != render->IsHighlightEnabled() || net != render->GetHighlightNetCode() )
1066  {
1067  render->SetHighlight( enableHighlight, net );
1068  aToolMgr->GetView()->UpdateAllLayersColor();
1069  }
1070 
1071  // Store the highlighted netcode in the current board (for dialogs for instance)
1072  if( enableHighlight && net >= 0 )
1073  board->SetHighLightNet( net );
1074  else
1075  board->ResetHighLight();
1076 
1077  return true;
1078 }
1079 
1080 
1082 {
1083  int netcode = aEvent.Parameter<intptr_t>();
1084 
1085  if( netcode > 0 )
1086  {
1088  render->SetHighlight( true, netcode );
1090  }
1091  else
1092  {
1093  // No net code specified, pick the net code belonging to the item under the cursor
1094  highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
1095  }
1096 
1097  return 0;
1098 }
1099 
1100 
1102 {
1103  Activate();
1104 
1105  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1106  assert( picker );
1107 
1108  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
1109  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1 ) );
1110  picker->SetSnapping( false );
1111  picker->Activate();
1112  Wait();
1113 
1114  return 0;
1115 }
1116 
1117 
1118 static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
1119 {
1120  auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
1121 
1122  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
1123  aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
1124 
1125  const SELECTION& selection = selectionTool->GetSelection();
1126 
1127  if( selection.Empty() )
1128  return true;
1129 
1130  for( auto item : selection )
1131  {
1132  if( item->Type() == PCB_MODULE_T )
1133  {
1134  for( auto pad : static_cast<MODULE *> (item)->Pads() )
1135  {
1136  pad->SetLocalRatsnestVisible( true );
1137  }
1138  }
1139  }
1140 
1141  return true;
1142 }
1143 
1144 
1146 {
1147  Activate();
1148 
1149  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
1150  assert( picker );
1151 
1152  m_frame->SetToolID( ID_PCB_SHOW_1_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) );
1153  picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, _1 ) );
1154  picker->SetSnapping( false );
1155  picker->Activate();
1156  Wait();
1157 
1158  return 0;
1159 }
1160 
1161 
1163 {
1164  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1165  auto& selection = selectionTool->GetSelection();
1166  auto connectivity = getModel<BOARD>()->GetConnectivity();
1167 
1168  if( selection.Empty() )
1169  {
1170  connectivity->ClearDynamicRatsnest();
1171  }
1172  else if( m_slowRatsnest )
1173  {
1174  // Compute ratsnest only when user stops dragging for a moment
1175  connectivity->HideDynamicRatsnest();
1176  m_ratsnestTimer.Start( 20 );
1177  }
1178  else
1179  {
1180  // Check how much time doest it take to calculate ratsnest
1181  PROF_COUNTER counter;
1183  counter.Stop();
1184 
1185  // If it is too slow, then switch to 'slow ratsnest' mode when
1186  // ratsnest is calculated when user stops dragging items for a moment
1187  if( counter.msecs() > 25 )
1188  {
1189  m_slowRatsnest = true;
1190  connectivity->HideDynamicRatsnest();
1191  }
1192  }
1193 
1194  return 0;
1195 }
1196 
1197 
1199 {
1200  getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
1201  m_slowRatsnest = false;
1202  return 0;
1203 }
1204 
1205 
1206 void PCB_EDITOR_CONTROL::ratsnestTimer( wxTimerEvent& aEvent )
1207 {
1208  m_ratsnestTimer.Stop();
1210  static_cast<PCB_DRAW_PANEL_GAL*>( m_frame->GetGalCanvas() )->RedrawRatsnest();
1212 }
1213 
1214 
1216 {
1217  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1218  auto& selection = selectionTool->GetSelection();
1219  auto connectivity = board()->GetConnectivity();
1220 
1221  std::vector<BOARD_ITEM*> items;
1222  items.reserve( selection.Size() );
1223 
1224  for( auto item : selection )
1225  items.push_back( static_cast<BOARD_ITEM*>( item ) );
1226 
1227  connectivity->ComputeDynamicRatsnest( items );
1228 }
1229 
1230 
1232 {
1233  // Track & via size control
1238 
1239  // Zone actions
1246 
1247  // Placing tools
1250 
1251  // Other
1263 }
1264 
1265 
1266 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:360
int GetCount() const
Function GetCount returns the number of objects in the list.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:1001
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:169
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:53
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:362
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:270
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:285
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:178
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:163
static TOOL_ACTION drillOrigin
Definition: pcb_actions.h:374
static TOOL_ACTION lock
Definition: pcb_actions.h:361
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:282
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:275
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:94
void ClearSelected()
Definition: base_struct.h:245
static SELECTION_CONDITION MoreThan(int aNumber)
Function MoreThan Creates a functor that tests if the number of selected items is greater than the va...
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
Class CONTEXT_MENU.
Definition: context_menu.h:44
VIEW_CONTROLS class definition.
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection. ...
Definition: collectors.cpp:435
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:267
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_MANAGER * m_toolMgr
Definition: tool_base.h:215
int HideSelectionRatsnest(const TOOL_EVENT &aEvent)
Hides ratsnest for selected items. Called when there are no items selected.
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:342
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:182
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:274
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:278
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:216
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:45
static TOOL_ACTION highlightNetCursor
Definition: pcb_actions.h:373
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:378
static TOOL_ACTION zoneFill
Definition: pcb_actions.h:281
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:375
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:181
MODIFY_MODE
How to modify a property for selected items.
Generic tool for picking a point.
Definition: picker_tool.h:34
unsigned GetViaSizeIndex() const
Function GetViaSizeIndex.
void ExportSetting(ZONE_CONTAINER &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:672
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:273
class MODULE, a footprint
Definition: typeinfo.h:101
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:376
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:565
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:285
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 (...
MODULE * module() const
Definition: pcb_tool.h:127
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:1385
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:160
static TOOL_ACTION placeTarget
Activation of the drawing tool (placing a TARGET)
Definition: pcb_actions.h:166
int LockSelected(const TOOL_EVENT &aEvent)
Locks selected items.
static TOOL_ACTION zoneUnfillAll
Definition: pcb_actions.h:284
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
Update the board display after modifying it bu a python script (note: it is automatically called by a...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
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:283
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
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:288
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:571
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
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:372
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:262
PCB_EDIT_FRAME * m_frame
Pointer to the currently used edit frame.
int PlaceTarget(const TOOL_EVENT &aEvent)
Function PlaceTarget() Allows user to place a layer alignment target.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
static const int WIDTH_STEP
virtual bool IsLocked() const
Function IsLocked.
int modifyLockSelected(MODIFY_MODE aMode)
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:212
static bool showLocalRatsnest(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
int GetToolId() const
Definition: draw_frame.h:471
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:870
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:312
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:252
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:675
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:276
void setTransitions() override
Sets up handlers for various events.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
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:587
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