KiCad PCB EDA Suite
pcb_editor_control.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014 CERN
5  * Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 #include <cstdint>
26 #include <thread>
27 #include <mutex>
28 
29 #include "pcb_editor_control.h"
30 #include "pcb_actions.h"
31 #include <tool/tool_manager.h>
32 #include <wx/progdlg.h>
33 
34 #include "selection_tool.h"
35 #include "drawing_tool.h"
36 #include "picker_tool.h"
37 
38 #include <painter.h>
39 #include <project.h>
40 #include <pcbnew_id.h>
41 #include <wxPcbStruct.h>
42 #include <class_board.h>
43 #include <class_zone.h>
44 #include <pcb_draw_panel_gal.h>
45 #include <class_module.h>
46 #include <class_pcb_target.h>
47 #include <connectivity_data.h>
48 #include <collectors.h>
50 #include <board_commit.h>
51 #include <confirm.h>
52 #include <bitmaps.h>
53 #include <hotkeys.h>
54 
55 #include <view/view_group.h>
56 #include <view/view_controls.h>
57 #include <origin_viewitem.h>
58 #include <profile.h>
59 
61 
62 #ifdef USE_OPENMP
63 #include <omp.h>
64 #endif /* USE_OPENMP */
65 
66 #include <tools/tool_event_utils.h>
67 
68 #include <functional>
69 using namespace std::placeholders;
70 
71 
72 // Track & via size control
73 TOOL_ACTION PCB_ACTIONS::trackWidthInc( "pcbnew.EditorControl.trackWidthInc",
75  "", "" );
76 
77 TOOL_ACTION PCB_ACTIONS::trackWidthDec( "pcbnew.EditorControl.trackWidthDec",
79  "", "" );
80 
81 TOOL_ACTION PCB_ACTIONS::viaSizeInc( "pcbnew.EditorControl.viaSizeInc",
83  "", "" );
84 
85 TOOL_ACTION PCB_ACTIONS::viaSizeDec( "pcbnew.EditorControl.viaSizeDec",
87  "", "" );
88 
89 TOOL_ACTION PCB_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaSizeChanged",
90  AS_GLOBAL, 0,
91  "", "", NULL, AF_NOTIFY );
92 
93 TOOL_ACTION PCB_ACTIONS::zoneMerge( "pcbnew.EditorControl.zoneMerge",
94  AS_GLOBAL, 0,
95  _( "Merge Zones" ), _( "Merge zones" ) );
96 
97 TOOL_ACTION PCB_ACTIONS::zoneDuplicate( "pcbnew.EditorControl.zoneDuplicate",
98  AS_GLOBAL, 0,
99  _( "Duplicate Zone onto Layer" ), _( "Duplicate zone outline onto a different layer" ),
100  zone_duplicate_xpm );
101 
102 
103 TOOL_ACTION PCB_ACTIONS::placeTarget( "pcbnew.EditorControl.placeTarget",
104  AS_GLOBAL, 0,
105  _( "Add Layer Alignment Target" ), _( "Add a layer alignment target" ), NULL, AF_ACTIVATE );
106 
107 TOOL_ACTION PCB_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule",
109  _( "Add Footprint" ), _( "Add a footprint" ), NULL, AF_ACTIVATE );
110 
111 TOOL_ACTION PCB_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin",
112  AS_GLOBAL, 0,
113  "", "" );
114 
115 TOOL_ACTION PCB_ACTIONS::crossProbeSchToPcb( "pcbnew.EditorControl.crossProbSchToPcb",
116  AS_GLOBAL, 0,
117  "", "" );
118 
119 TOOL_ACTION PCB_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock",
121  "Toggle Lock", "" );
122 
123 TOOL_ACTION PCB_ACTIONS::lock( "pcbnew.EditorControl.lock",
124  AS_GLOBAL, 0,
125  _( "Lock" ), "" );
126 
127 TOOL_ACTION PCB_ACTIONS::unlock( "pcbnew.EditorControl.unlock",
128  AS_GLOBAL, 0,
129  _( "Unlock" ), "" );
130 
131 TOOL_ACTION PCB_ACTIONS::appendBoard( "pcbnew.EditorControl.appendBoard",
132  AS_GLOBAL, 0,
133  "", "" );
134 
135 TOOL_ACTION PCB_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet",
136  AS_GLOBAL, 0,
137  "", "" );
138 
139 TOOL_ACTION PCB_ACTIONS::highlightNetCursor( "pcbnew.EditorControl.highlightNetCursor",
140  AS_GLOBAL, 0,
141  "", "" );
142 
143 TOOL_ACTION PCB_ACTIONS::showLocalRatsnest( "pcbnew.Control.showLocalRatsnest",
144  AS_GLOBAL, 0,
145  "", "" );
146 
148 {
149 public:
151  {
152  SetIcon( add_zone_xpm );
153  SetTitle( _( "Zones" ) );
154 
155  Add( PCB_ACTIONS::zoneFill );
159 
160  AppendSeparator();
161 
162  Add( PCB_ACTIONS::zoneMerge );
166  }
167 
168 
169 protected:
170  CONTEXT_MENU* create() const override
171  {
172  return new ZONE_CONTEXT_MENU();
173  }
174 
175 private:
176  void update() override
177  {
178  SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
179 
180  // enable zone actions that act on a single zone
181  bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 )
183  )( selTool->GetSelection() );
184 
185  Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
186  Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
187  Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
188 
189  // enable zone actions that ably to a specific set of zones (as opposed to all of them)
190  bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
191 
192  Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
193  Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
194 
195  // lines like this make me really think about a better name for SELECTION_CONDITIONS class
196  bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
197  /*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
200 
201  Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
202  }
203 };
204 
205 
207 {
208 public:
210  {
211  SetIcon( locked_xpm );
212  SetTitle( _( "Locking" ) );
213 
214  Add( PCB_ACTIONS::lock );
215  Add( PCB_ACTIONS::unlock );
217  }
218 
219  CONTEXT_MENU* create() const override
220  {
221  return new LOCK_CONTEXT_MENU();
222  }
223 };
224 
225 
227  PCB_TOOL( "pcbnew.EditorControl" ),
228  m_frame( nullptr )
229 {
230  m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
232  m_probingSchToPcb = false;
233  m_slowRatsnest = false;
234 }
235 
236 
238 {
239 }
240 
241 
243 {
244  m_frame = getEditFrame<PCB_EDIT_FRAME>();
245 
246  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
247  {
248  m_placeOrigin->SetPosition( getModel<BOARD>()->GetAuxOrigin() );
249  getView()->Remove( m_placeOrigin.get() );
250  getView()->Add( m_placeOrigin.get() );
251  }
252 }
253 
254 
256 {
257  auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
258  zoneMenu->SetTool( this );
259 
260  auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
261  lockMenu->SetTool( this );
262 
263  // Add the PCB control menus to relevant other tools
264 
266 
267  if( selTool )
268  {
269  auto& toolMenu = selTool->GetToolMenu();
270  auto& menu = toolMenu.GetMenu();
271 
272  toolMenu.AddSubMenu( zoneMenu );
273  toolMenu.AddSubMenu( lockMenu );
274 
275  menu.AddMenu( zoneMenu.get(), false,
277 
278  menu.AddMenu( lockMenu.get(), false,
280  }
281 
282  DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
283 
284  if( drawingTool )
285  {
286  auto& toolMenu = drawingTool->GetToolMenu();
287  auto& menu = toolMenu.GetMenu();
288 
289  toolMenu.AddSubMenu( zoneMenu );
290 
291  // Functor to say if the PCB_EDIT_FRAME is in a given mode
292  // Capture the tool pointer and tool mode by value
293  auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
294  {
295  return [=]( const SELECTION& sel )
296  {
297  return drawingTool->GetDrawingMode() == aMode;
298  };
299  };
300 
301  menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
302  }
303 
304  m_ratsnestTimer.SetOwner( this );
305  Connect( m_ratsnestTimer.GetId(), wxEVT_TIMER,
306  wxTimerEventHandler( PCB_EDITOR_CONTROL::ratsnestTimer ), NULL, this );
307 
308  return true;
309 }
310 
311 
312 // Track & via size control
314 {
315  BOARD* board = getModel<BOARD>();
316  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() + 1;
317 
318  if( widthIndex >= (int) board->GetDesignSettings().m_TrackWidthList.size() )
319  widthIndex = board->GetDesignSettings().m_TrackWidthList.size() - 1;
320 
321  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
322  board->GetDesignSettings().UseCustomTrackViaSize( false );
323 
325 
326  return 0;
327 }
328 
329 
331 {
332  BOARD* board = getModel<BOARD>();
333  int widthIndex = board->GetDesignSettings().GetTrackWidthIndex() - 1;
334 
335  if( widthIndex < 0 )
336  widthIndex = 0;
337 
338  board->GetDesignSettings().SetTrackWidthIndex( widthIndex );
339  board->GetDesignSettings().UseCustomTrackViaSize( false );
340 
342 
343  return 0;
344 }
345 
346 
348 {
349  BOARD* board = getModel<BOARD>();
350  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() + 1;
351 
352  if( sizeIndex >= (int) board->GetDesignSettings().m_ViasDimensionsList.size() )
353  sizeIndex = board->GetDesignSettings().m_ViasDimensionsList.size() - 1;
354 
355  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
356  board->GetDesignSettings().UseCustomTrackViaSize( false );
357 
359 
360  return 0;
361 }
362 
363 
365 {
366  BOARD* board = getModel<BOARD>();
367  int sizeIndex = board->GetDesignSettings().GetViaSizeIndex() - 1;
368 
369  if( sizeIndex < 0 )
370  sizeIndex = 0;
371 
372  board->GetDesignSettings().SetViaSizeIndex( sizeIndex );
373  board->GetDesignSettings().UseCustomTrackViaSize( false );
374 
376 
377  return 0;
378 }
379 
380 
382 {
383  MODULE* module = aEvent.Parameter<MODULE*>();
384  KIGFX::VIEW* view = getView();
386  BOARD* board = getModel<BOARD>();
387 
388  // Add a VIEW_GROUP that serves as a preview for the new item
389  KIGFX::VIEW_GROUP preview( view );
390  view->Add( &preview );
391 
393  controls->ShowCursor( true );
394  controls->SetSnapping( true );
395 
396  Activate();
397  m_frame->SetToolID( ID_PCB_MODULE_BUTT, wxCURSOR_PENCIL, _( "Add footprint" ) );
398 
399  // Add all the drawable parts to preview
400  VECTOR2I cursorPos = controls->GetCursorPosition();
401  if( module )
402  {
403  module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
404  preview.Add( module );
405  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
406  view->Update( &preview );
407  }
408 
409  // Main loop: keep receiving events
410  while( OPT_TOOL_EVENT evt = Wait() )
411  {
412  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_TARGET_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 static bool mergeZones( BOARD_COMMIT& aCommit, std::vector<ZONE_CONTAINER *>& aOriginZones,
650  std::vector<ZONE_CONTAINER *>& aMergedZones )
651 {
652  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
653  {
654  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
656  }
657 
658  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
659 
660  // We should have one polygon with hole
661  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
662  // and therefore cannot be merged (they are dectected as intersecting)
663  // but we should never have more than 2 polys
664  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
665  {
666  wxLogMessage( wxT( "BOARD::CombineAreas error: more than 2 polys after merging" ) );
667  return false;
668  }
669 
670  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
671  {
672  aCommit.Remove( aOriginZones[i] );
673  }
674 
675  aCommit.Modify( aOriginZones[0] );
676  aMergedZones.push_back( aOriginZones[0] );
677 
678  aOriginZones[0]->SetLocalFlags( 1 );
679  aOriginZones[0]->Hatch();
680  aOriginZones[0]->CacheTriangulation();
681 
682  return true;
683 }
684 
686 {
687  const SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
688  BOARD* board = getModel<BOARD>();
689  BOARD_COMMIT commit( m_frame );
690 
691  if( selection.Size() < 2 )
692  return 0;
693 
694  int netcode = -1;
695 
696  ZONE_CONTAINER* firstZone = nullptr;
697  std::vector<ZONE_CONTAINER*> toMerge, merged;
698 
699  for( auto item : selection )
700  {
701  auto curr_area = dynamic_cast<ZONE_CONTAINER*>( item );
702 
703  if( !curr_area )
704  continue;
705 
706  if( !firstZone )
707  firstZone = curr_area;
708 
709  netcode = curr_area->GetNetCode();
710 
711  if( firstZone )
712  {
713  if( firstZone->GetNetCode() != netcode )
714  continue;
715 
716  if( curr_area->GetPriority() != firstZone->GetPriority() )
717  continue;
718 
719  if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() )
720  continue;
721 
722  if( curr_area->GetLayer() != firstZone->GetLayer() )
723  continue;
724 
725  if( !board->TestAreaIntersection( curr_area, firstZone ) )
726  continue;
727 
728  toMerge.push_back( curr_area );
729  }
730  else
731  {
732  toMerge.push_back( curr_area );
733  }
734  }
735 
737 
738  if( mergeZones( commit, toMerge, merged ) )
739  {
740  commit.Push( _( "Merge zones" ) );
741 
742  for( auto item : merged )
744  }
745 
746  return 0;
747 }
748 
749 
751 {
752  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
753  const auto& selection = selTool->GetSelection();
754 
755  // because this pops up the zone editor, it would be confusing
756  // to handle multiple zones, so just handle single selections
757  // containing exactly one zone
758  if( selection.Size() != 1 )
759  return 0;
760 
761  auto oldZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
762 
763  if( !oldZone )
764  return 0;
765 
766  auto newZone = std::make_unique<ZONE_CONTAINER>( *oldZone );
767  newZone->ClearSelected();
768  newZone->UnFill();
769  ZONE_SETTINGS zoneSettings;
770  zoneSettings << *oldZone;
771 
772  bool success = false;
773 
774  if( oldZone->GetIsKeepout() )
775  success = InvokeKeepoutAreaEditor( m_frame, &zoneSettings );
776  else if( oldZone->IsOnCopperLayer() )
777  success = InvokeCopperZonesEditor( m_frame, &zoneSettings );
778  else
779  success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings );
780 
781  // If the new zone is on the same layer as the the initial zone,
782  // do nothing
783  if( success )
784  {
785  if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) )
786  {
787  DisplayError(
788  m_frame, _( "The duplicated keepout zone cannot be on the same layers as the original zone." ) );
789  success = false;
790  }
791  else if( !oldZone->GetIsKeepout() && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
792  {
793  DisplayError(
794  m_frame, _( "The duplicated zone cannot be on the same layer as the original zone." ) );
795  success = false;
796  }
797  }
798 
799  // duplicate the zone
800  if( success )
801  {
802  BOARD_COMMIT commit( m_frame );
803  zoneSettings.ExportSetting( *newZone );
804 
805  commit.Add( newZone.release() );
806  commit.Push( _( "Duplicate zone" ) );
807  }
808 
809  return 0;
810 }
811 
812 
814 {
815  if( m_probingSchToPcb )
816  {
817  m_probingSchToPcb = false;
818  return 0;
819  }
820 
822  const SELECTION& selection = selTool->GetSelection();
823 
824  if( selection.Size() == 1 )
825  m_frame->SendMessageToEESCHEMA( static_cast<BOARD_ITEM*>( selection.Front() ) );
826 
827  return 0;
828 }
829 
830 
832 {
833  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
834 
835  if( item )
836  {
837  m_probingSchToPcb = true;
838  getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
840 
841  // If it is a pad and the net highlighting tool is enabled, highlight the net
842  if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
843  {
844  int net = static_cast<D_PAD*>( item )->GetNetCode();
846  }
847  else
848  // Otherwise simply select the corresponding item
849  {
851  }
852  }
853 
854  return 0;
855 }
856 
857 
858 static bool setDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
859  KIGFX::ORIGIN_VIEWITEM* aItem, const VECTOR2D& aPosition )
860 {
861  aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) );
862  aItem->SetPosition( aPosition );
863  aView->MarkDirty();
864 
865  return true;
866 }
867 
868 
870 {
871  Activate();
872 
874  assert( picker );
875 
876  m_frame->SetToolID( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxCURSOR_HAND, _( "Adjust zero" ) );
877  picker->SetClickHandler( std::bind( setDrillOrigin, getView(), m_frame, m_placeOrigin.get(), _1 ) );
878  picker->Activate();
879  Wait();
880 
881  return 0;
882 }
883 
891 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
892 {
893  auto render = aToolMgr->GetView()->GetPainter()->GetSettings();
894  auto frame = static_cast<PCB_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
895  auto guide = frame->GetCollectorsGuide();
896  BOARD* board = static_cast<BOARD*>( aToolMgr->GetModel() );
897  GENERAL_COLLECTOR collector;
898  int net = -1;
899 
900  // Find a connected item for which we are going to highlight a net
902  wxPoint( aPosition.x, aPosition.y ), guide );
903 
904  for( int i = 0; i < collector.GetCount(); i++ )
905  {
906  if( collector[i]->Type() == PCB_PAD_T )
907  {
908  frame->SendMessageToEESCHEMA( static_cast<BOARD_CONNECTED_ITEM*>( collector[i] ) );
909  break;
910  }
911  }
912 
913  bool enableHighlight = ( collector.GetCount() > 0 );
914 
915  // Obtain net code for the clicked item
916  if( enableHighlight )
917  net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode();
918 
919  // Toggle highlight when the same net was picked
920  if( net > 0 && net == render->GetHighlightNetCode() )
921  enableHighlight = !render->IsHighlightEnabled();
922 
923  if( enableHighlight != render->IsHighlightEnabled() || net != render->GetHighlightNetCode() )
924  {
925  render->SetHighlight( enableHighlight, net );
926  aToolMgr->GetView()->UpdateAllLayersColor();
927  }
928 
929  // Store the highlighted netcode in the current board (for dialogs for instance)
930  if( enableHighlight && net >= 0 )
931  {
932  board->SetHighLightNet( net );
933 
934  NETINFO_ITEM* netinfo = board->FindNet( net );
935 
936  if( netinfo )
937  {
938  MSG_PANEL_ITEMS items;
939  netinfo->GetMsgPanelInfo( items );
940  frame->SetMsgPanel( items );
941  }
942  }
943  else
944  {
945  board->ResetHighLight();
946  frame->SetMsgPanel( board );
947  }
948 
949  return true;
950 }
951 
952 
954 {
955  int netcode = aEvent.Parameter<intptr_t>();
956 
957  if( netcode > 0 )
958  {
960  render->SetHighlight( true, netcode );
962  }
963  else
964  {
965  // No net code specified, pick the net code belonging to the item under the cursor
966  highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
967  }
968 
969  return 0;
970 }
971 
972 
974 {
975  Activate();
976 
978  assert( picker );
979 
980  m_frame->SetToolID( ID_PCB_HIGHLIGHT_BUTT, wxCURSOR_HAND, _( "Highlight net" ) );
981  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, _1 ) );
982  picker->SetSnapping( false );
983  picker->Activate();
984  Wait();
985 
986  return 0;
987 }
988 
989 
990 static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
991 {
992  auto selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
993 
994  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
995  aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
996 
997  const SELECTION& selection = selectionTool->GetSelection();
998 
999  if( selection.Empty() )
1000  return true;
1001 
1002  for( auto item : selection )
1003  {
1004  if( item->Type() == PCB_MODULE_T )
1005  {
1006  for( auto pad : static_cast<MODULE *> (item)->Pads() )
1007  {
1008  pad->SetLocalRatsnestVisible( true );
1009  }
1010  }
1011  }
1012 
1013  return true;
1014 }
1015 
1016 
1018 {
1019  Activate();
1020 
1021  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
1022  assert( picker );
1023 
1024  m_frame->SetToolID( ID_PCB_SHOW_1_RATSNEST_BUTT, wxCURSOR_PENCIL, _( "Pick Components for Local Ratsnest" ) );
1025  picker->SetClickHandler( std::bind( showLocalRatsnest, m_toolMgr, _1 ) );
1026  picker->SetSnapping( false );
1027  picker->Activate();
1028  Wait();
1029 
1030  return 0;
1031 }
1032 
1033 
1035 {
1036  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1037  auto& selection = selectionTool->GetSelection();
1038  auto connectivity = getModel<BOARD>()->GetConnectivity();
1039 
1040  if( selection.Empty() )
1041  {
1042  connectivity->ClearDynamicRatsnest();
1043  }
1044  else if( m_slowRatsnest )
1045  {
1046  // Compute ratsnest only when user stops dragging for a moment
1047  connectivity->HideDynamicRatsnest();
1048  m_ratsnestTimer.Start( 20 );
1049  }
1050  else
1051  {
1052  // Check how much time doest it take to calculate ratsnest
1053  PROF_COUNTER counter;
1055  counter.Stop();
1056 
1057  // If it is too slow, then switch to 'slow ratsnest' mode when
1058  // ratsnest is calculated when user stops dragging items for a moment
1059  if( counter.msecs() > 25 )
1060  {
1061  m_slowRatsnest = true;
1062  connectivity->HideDynamicRatsnest();
1063  }
1064  }
1065 
1066  return 0;
1067 }
1068 
1069 
1071 {
1072  getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
1073  m_slowRatsnest = false;
1074  return 0;
1075 }
1076 
1077 
1078 void PCB_EDITOR_CONTROL::ratsnestTimer( wxTimerEvent& aEvent )
1079 {
1080  m_ratsnestTimer.Stop();
1082  static_cast<PCB_DRAW_PANEL_GAL*>( m_frame->GetGalCanvas() )->RedrawRatsnest();
1084 }
1085 
1086 
1088 {
1089  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
1090  auto& selection = selectionTool->GetSelection();
1091  auto connectivity = board()->GetConnectivity();
1092 
1093  std::vector<BOARD_ITEM*> items;
1094  items.reserve( selection.Size() );
1095 
1096  for( auto item : selection )
1097  items.push_back( static_cast<BOARD_ITEM*>( item ) );
1098 
1099  connectivity->ComputeDynamicRatsnest( items );
1100 }
1101 
1102 
1104 {
1105  // Track & via size control
1110 
1111  // Zone actions
1114 
1115  // Placing tools
1118 
1119  // Other
1131 }
1132 
1133 
1134 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:225
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:994
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
static TOOL_ACTION placeModule
Activation of the drawing tool (placing a MODULE)
Definition: pcb_actions.h: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.
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:258
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:175
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:102
virtual 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:178
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:90
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
int ZoneDuplicate(const TOOL_EVENT &aEvent)
Duplicates a zone onto a layer (prompts for new layer)
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo returns the information about the NETINFO_ITEM in aList to display in the me...
bool TestAreaIntersection(ZONE_CONTAINER *area_ref, ZONE_CONTAINER *area_to_test)
Function TestAreaIntersection Test for intersection of 2 copper areas area_to_test must be after area...
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:45
static TOOL_ACTION highlightNetCursor
Definition: pcb_actions.h: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:61
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true) override
Executes the changes.
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h: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:602
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
Class TOOL_MANAGER.
Definition: tool_manager.h:49
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:133
static TOOL_ACTION trackWidthInc
Definition: pcb_actions.h:273
class MODULE, a footprint
Definition: typeinfo.h:89
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:588
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.
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.
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
MODULE * module() const
Definition: pcb_tool.h:136
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
ZONE_EDIT_T InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_CONTAINER *aZone, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing...
void SetPosition(const wxPoint &aPos) override
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
void ratsnestTimer(wxTimerEvent &aEvent)
Event handler to recalculate dynamic ratsnest
int ViaSizeInc(const TOOL_EVENT &aEvent)
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
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp: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
Class NETINFO_ITEM handles the data for a net.
Definition: class_netinfo.h:69
CONTEXT_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes. ...
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h: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 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
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
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:465
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.
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
ZONE_EDIT_T InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing...
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
std::vector< VIA_DIMENSION > m_ViasDimensionsList
Vias size and drill list.
unsigned GetTrackWidthIndex() const
Function GetTrackWidthIndex.
void Activate()
Function Activate() Runs the tool.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:864
PCB_TARGET class definition.
void SetAuxOrigin(const wxPoint &aPoint) override
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Notifies eeschema about the selected item.
ZONE_EDIT_T InvokeKeepoutAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeKeepoutAreaEditor invokes up a modal dialog window for copper zone editing...
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp: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:101
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:73
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.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:460
static SELECTION_CONDITION SameNet(bool aAllowUnconnected=false)
Function SameNet Creates a functor that tests if selection contains items belonging to the same net o...
BOARD * board() const
Definition: pcb_tool.h:135
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39