KiCad PCB EDA Suite
pcb_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-2016 CERN
5  * Copyright (C) 2019-2020 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 
26 #include "edit_tool.h"
27 #include "pcb_actions.h"
28 #include "pcb_control.h"
29 #include "pcb_picker_tool.h"
30 #include "pcb_selection_tool.h"
32 #include <bitmaps.h>
33 #include <board_commit.h>
34 #include <board.h>
35 #include <board_item.h>
36 #include <dimension.h>
37 #include <footprint.h>
38 #include <track.h>
39 #include <zone.h>
40 #include <fp_shape.h>
41 #include <confirm.h>
43 #include <core/kicad_algo.h>
44 #include <kicad_clipboard.h>
45 #include <origin_viewitem.h>
46 #include <pcb_edit_frame.h>
47 #include <pcb_painter.h>
48 #include <properties.h>
50 #include <tool/tool_manager.h>
51 #include <view/view_controls.h>
52 #include <footprint_viewer_frame.h>
53 #include <footprint_edit_frame.h>
54 
55 using namespace std::placeholders;
56 
57 
58 // files.cpp
59 extern bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, int* aCtl, wxString* aFileName,
60  bool aKicadFilesOnly = false );
61 extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
62 
63 
65  PCB_TOOL_BASE( "pcbnew.Control" ),
66  m_frame( nullptr ),
67  m_pickerItem( nullptr )
68 {
69  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
70 }
71 
72 
74 {
75 }
76 
77 
79 {
80  m_frame = getEditFrame<PCB_BASE_FRAME>();
81 
82  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
83  {
84  m_gridOrigin->SetPosition( board()->GetDesignSettings().m_GridOrigin );
85  m_gridOrigin->SetColor( m_frame->GetGridColor() );
86  getView()->Remove( m_gridOrigin.get() );
87  getView()->Add( m_gridOrigin.get() );
88  }
89 }
90 
91 
92 int PCB_CONTROL::AddLibrary( const TOOL_EVENT& aEvent )
93 {
95  {
96  if( aEvent.IsAction( &ACTIONS::newLibrary ) )
97  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
98  else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
99  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
100  }
101 
102  return 0;
103 }
104 
105 
106 int PCB_CONTROL::Quit( const TOOL_EVENT& aEvent )
107 {
108  m_frame->Close( false );
109  return 0;
110 }
111 
112 
113 template<class T> void Flip( T& aValue )
114 {
115  aValue = !aValue;
116 }
117 
118 
120 {
121  auto opts = displayOptions();
122 
123  Flip( opts.m_DisplayPcbTrackFill );
124  m_frame->SetDisplayOptions( opts );
125 
126  for( auto track : board()->Tracks() )
127  {
128  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_ARC_T )
129  view()->Update( track, KIGFX::GEOMETRY );
130  }
131 
132  canvas()->Refresh();
133 
134  return 0;
135 }
136 
137 
139 {
140  auto opts = displayOptions();
141 
142  if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
143  {
144  // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
145  Flip( opts.m_ShowGlobalRatsnest );
146  m_frame->SetDisplayOptions( opts );
147  getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
148  opts.m_ShowGlobalRatsnest );
149 
150  }
151  else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
152  {
153  Flip( opts.m_DisplayRatsnestLinesCurved );
154  m_frame->SetDisplayOptions( opts );
155  }
156 
157  canvas()->RedrawRatsnest();
158  canvas()->Refresh();
159 
160  return 0;
161 }
162 
163 
165 {
166  auto opts = displayOptions();
167 
168  Flip( opts.m_DisplayViaFill );
169  m_frame->SetDisplayOptions( opts );
170 
171  for( auto track : board()->Tracks() )
172  {
173  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
174  view()->Update( track, KIGFX::GEOMETRY );
175  }
176 
177  canvas()->Refresh();
178 
179  return 0;
180 }
181 
182 
184 {
185  auto opts = displayOptions();
186 
187  // Apply new display options to the GAL canvas
189  {
190  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
191  }
192  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
193  {
194  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_ZONE_OUTLINE;
195  }
196  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
197  {
198  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED_OUTLINE;
199  }
200  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
201  {
202  int nextMode = ( static_cast<int>( opts.m_ZoneDisplayMode ) + 1 ) % 3;
203  opts.m_ZoneDisplayMode = static_cast<ZONE_DISPLAY_MODE>( nextMode );
204  }
205  else
206  {
207  wxFAIL;
208  }
209 
210  m_frame->SetDisplayOptions( opts );
211 
212  for( ZONE* zone : board()->Zones() )
213  view()->Update( zone, KIGFX::GEOMETRY );
214 
215  canvas()->Refresh();
216 
217  return 0;
218 }
219 
220 
222 {
223  auto opts = displayOptions();
224 
225  opts.m_ContrastModeDisplay =
226  ( opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL ) ?
229 
230  m_frame->SetDisplayOptions( opts );
231 
232  return 0;
233 }
234 
235 
237 {
238  auto opts = displayOptions();
239 
240  switch( opts.m_ContrastModeDisplay )
241  {
243  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED;
244  break;
245 
247  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN;
248  break;
249 
251  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
252  break;
253  }
254 
255  m_frame->SetDisplayOptions( opts );
256 
257  return 0;
258 }
259 
260 
261 // Layer control
263 {
265 
266  return 0;
267 }
268 
269 
270 int PCB_CONTROL::LayerNext( const TOOL_EVENT& aEvent )
271 {
272  PCB_BASE_FRAME* editFrame = m_frame;
273  BOARD* brd = board();
274  LAYER_NUM layer = editFrame->GetActiveLayer();
275  LAYER_NUM startLayer = layer;
276 
277  if( layer < F_Cu || layer > B_Cu )
278  return 0;
279 
280  while( startLayer != ++layer )
281  {
282  if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
283  break;
284 
285  if( layer >= B_Cu )
286  layer = F_Cu - 1;
287  }
288 
289  wxCHECK( IsCopperLayer( layer ), 0 );
290  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
291 
292  return 0;
293 }
294 
295 
296 int PCB_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
297 {
298  PCB_BASE_FRAME* editFrame = m_frame;
299  BOARD* brd = board();
300  LAYER_NUM layer = editFrame->GetActiveLayer();
301  LAYER_NUM startLayer = layer;
302 
303  if( layer < F_Cu || layer > B_Cu )
304  return 0;
305 
306  while( startLayer != --layer )
307  {
308  if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
309  && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
310  break;
311 
312  if( layer <= F_Cu )
313  layer = B_Cu + 1;
314  }
315 
316 
317  wxCHECK( IsCopperLayer( layer ), 0 );
318  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
319 
320  return 0;
321 }
322 
323 
325 {
326  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
327  PCB_SCREEN* screen = m_frame->GetScreen();
328 
329  if( currentLayer == screen->m_Route_Layer_TOP )
331  else
333 
334  return 0;
335 }
336 
337 
338 // It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
339 // set in wxFormBuilder.
340 #define ALPHA_MIN 0.20
341 #define ALPHA_MAX 1.00
342 #define ALPHA_STEP 0.05
343 
345 {
346  auto settings = m_frame->GetColorSettings();
347 
348  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
349  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
350 
351  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
352  {
353  currentColor.a += ALPHA_STEP;
354  settings->SetColor( currentLayer, currentColor );
356 
358  view->UpdateLayerColor( currentLayer );
359  view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
360 
361  if( IsCopperLayer( currentLayer ) )
362  view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
363 
364  wxUpdateUIEvent dummy;
365  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
366  }
367  else
368  wxBell();
369 
370  return 0;
371 }
372 
373 
375 {
376  auto settings = m_frame->GetColorSettings();
377 
378  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
379  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
380 
381  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
382  {
383  currentColor.a -= ALPHA_STEP;
384  settings->SetColor( currentLayer, currentColor );
386 
388  view->UpdateLayerColor( currentLayer );
389  view->UpdateLayerColor( GetNetnameLayer( currentLayer ) );
390 
391  if( IsCopperLayer( currentLayer ) )
392  view->UpdateLayerColor( ZONE_LAYER_FOR( currentLayer ) );
393 
394  wxUpdateUIEvent dummy;
395  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
396  }
397  else
398  wxBell();
399 
400  return 0;
401 }
402 
403 
404 // Grid control
406  EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
407 {
408  aFrame->GetDesignSettings().m_GridOrigin = (wxPoint) aPoint;
409  aView->GetGAL()->SetGridOrigin( aPoint );
410  originViewItem->SetPosition( (wxPoint) aPoint );
411  aView->MarkDirty();
412  aFrame->OnModify();
413 }
414 
415 
417 {
418  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
419 
420  if( origin )
421  {
422  // We can't undo the other grid dialog settings, so no sense undoing just the origin
423  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
424  delete origin;
425  }
426  else
427  {
428  if( m_isFootprintEditor && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
429  return 0;
430 
431  std::string tool = aEvent.GetCommandStr().get();
433 
434  // Deactivate other tools; particularly important if another PICKER is currently running
435  Activate();
436 
437  picker->SetClickHandler(
438  [this] ( const VECTOR2D& pt ) -> bool
439  {
441  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
442  return false; // drill origin is a one-shot; don't continue with tool
443  } );
444 
445  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
446  }
447 
448  return 0;
449 }
450 
451 
453 {
455  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
456  return 0;
457 }
458 
459 
460 #define HITTEST_THRESHOLD_PIXELS 5
461 
462 
464 {
466  return 0;
467 
468  std::string tool = aEvent.GetCommandStr().get();
470 
471  m_pickerItem = nullptr;
473 
474  // Deactivate other tools; particularly important if another PICKER is currently running
475  Activate();
476 
477  picker->SetCursor( KICURSOR::REMOVE );
478 
479  picker->SetClickHandler(
480  [this] ( const VECTOR2D& aPosition ) -> bool
481  {
482  if( m_pickerItem )
483  {
485  {
486  STATUS_TEXT_POPUP statusPopup( m_frame );
487  statusPopup.SetText( _( "Item locked." ) );
488  statusPopup.PopupFor( 2000 );
489  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
490  return true;
491  }
492 
494  selectionTool->UnbrightenItem( m_pickerItem );
495  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
497  m_pickerItem = nullptr;
498  }
499 
500  return true;
501  } );
502 
503  picker->SetMotionHandler(
504  [this] ( const VECTOR2D& aPos )
505  {
506  BOARD* board = m_frame->GetBoard();
509  GENERAL_COLLECTOR collector;
510  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
511 
512  if( m_isFootprintEditor )
513  collector.Collect( board, GENERAL_COLLECTOR::FootprintItems, (wxPoint) aPos, guide );
514  else
515  collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
516 
517  // Remove unselectable items
518  for( int i = collector.GetCount() - 1; i >= 0; --i )
519  {
520  if( !selectionTool->Selectable( collector[ i ] ) )
521  collector.Remove( i );
522  }
523 
524  if( collector.GetCount() > 1 )
525  selectionTool->GuessSelectionCandidates( collector, aPos );
526 
527  BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
528 
529  if( m_pickerItem != item )
530  {
531 
532  if( m_pickerItem )
533  selectionTool->UnbrightenItem( m_pickerItem );
534 
535  m_pickerItem = item;
536 
537  if( m_pickerItem )
538  selectionTool->BrightenItem( m_pickerItem );
539  }
540  } );
541 
542  picker->SetFinalizeHandler(
543  [this] ( const int& aFinalState )
544  {
545  if( m_pickerItem )
547 
548  // Ensure the cursor gets changed&updated
550  m_frame->GetCanvas()->Refresh();
551  } );
552 
553  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
554 
555  return 0;
556 }
557 
558 
559 static void pasteFootprintItemsToFootprintEditor( FOOTPRINT* aClipFootprint, BOARD* aBoard,
560  std::vector<BOARD_ITEM*>& aPastedItems )
561 {
562  FOOTPRINT* editorFootprint = aBoard->GetFirstFootprint();
563 
564  aClipFootprint->SetParent( aBoard );
565 
566  for( PAD* pad : aClipFootprint->Pads() )
567  {
568  pad->SetParent( editorFootprint );
569  aPastedItems.push_back( pad );
570  }
571 
572  aClipFootprint->Pads().clear();
573 
574  // Not all graphic items can be added to the current footprint:
575  // Reference and value are already existing in the current footprint, and
576  // must be unique.
577  // So they will be skipped
578  for( BOARD_ITEM* item : aClipFootprint->GraphicalItems() )
579  {
580  if( item->Type() == PCB_FP_SHAPE_T )
581  {
582  FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
583 
584  shape->SetParent( nullptr );
585  shape->SetLocalCoord();
586  }
587  else if( item->Type() == PCB_FP_TEXT_T )
588  {
589  FP_TEXT* text = static_cast<FP_TEXT*>( item );
590 
591  if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
592  continue;
593 
594  text->SetTextAngle( aClipFootprint->GetOrientation() );
595 
596  text->SetParent( nullptr );
597  text->SetLocalCoord();
598  }
599 
600  item->SetParent( editorFootprint );
601  aPastedItems.push_back( item );
602  }
603 
604  aClipFootprint->GraphicalItems().clear();
605 
606  for( FP_ZONE* zone : aClipFootprint->Zones() )
607  {
608  zone->SetParent( editorFootprint );
609  aPastedItems.push_back( zone );
610  }
611 
612  aClipFootprint->Zones().clear();
613 
614  for( PCB_GROUP* group : aClipFootprint->Groups() )
615  {
616  group->SetParent( editorFootprint );
617  aPastedItems.push_back( group );
618  }
619 
620  aClipFootprint->Groups().clear();
621 }
622 
623 
624 int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
625 {
626  CLIPBOARD_IO pi;
627  BOARD_ITEM* clipItem = pi.Parse();
628 
629  if( !clipItem )
630  return 0;
631 
632  // The viewer frames cannot paste
633  if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
634  return 0;
635 
636  bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
637 
638  if( clipItem->Type() == PCB_T )
639  {
640  if( isFootprintEditor )
641  {
642  for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
643  item->SetNet( NETINFO_LIST::OrphanedItem() );
644  }
645  else
646  {
647  static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
648  }
649  }
650 
651  // The clipboard can contain two different things, an entire kicad_pcb or a single footprint
652  if( isFootprintEditor && ( !board() || !footprint() ) )
653  {
654  return 0;
655  }
656 
657  switch( clipItem->Type() )
658  {
659  case PCB_T:
660  {
661  BOARD* clipBoard = static_cast<BOARD*>( clipItem );
662 
663  if( isFootprintEditor )
664  {
665  FOOTPRINT* editorFootprint = board()->GetFirstFootprint();
666  std::vector<BOARD_ITEM*> pastedItems;
667 
668  for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
669  pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
670 
671  for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
672  {
673  if( clipDrawItem->Type() == PCB_SHAPE_T )
674  {
675  PCB_SHAPE* clipShape = static_cast<PCB_SHAPE*>( clipDrawItem );
676 
677  // Convert to PCB_FP_SHAPE_T
678  FP_SHAPE* pastedShape = new FP_SHAPE( editorFootprint );
679  static_cast<PCB_SHAPE*>( pastedShape )->SwapData( clipShape );
680  pastedShape->SetLocalCoord();
681 
682  // Replace parent nuked by above call to SwapData()
683  pastedShape->SetParent( editorFootprint );
684  pastedItems.push_back( pastedShape );
685  }
686  else if( clipDrawItem->Type() == PCB_TEXT_T )
687  {
688  PCB_TEXT* clipTextItem = static_cast<PCB_TEXT*>( clipDrawItem );
689 
690  // Convert to PCB_FP_TEXT_T
691  FP_TEXT* pastedTextItem = new FP_TEXT( editorFootprint );
692  static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
693  static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
694 
695  pastedTextItem->SetParent( editorFootprint );
696  pastedItems.push_back( pastedTextItem );
697  }
698  }
699 
700  delete clipBoard;
701 
702  placeBoardItems( pastedItems, true, true );
703  }
704  else
705  {
706  placeBoardItems( clipBoard, true );
707 
709  m_frame->Compile_Ratsnest( true );
710  }
711 
712  break;
713  }
714 
715  case PCB_FOOTPRINT_T:
716  {
717  FOOTPRINT* clipFootprint = static_cast<FOOTPRINT*>( clipItem );
718  std::vector<BOARD_ITEM*> pastedItems;
719 
720  if( isFootprintEditor )
721  {
722  pasteFootprintItemsToFootprintEditor( clipFootprint, board(), pastedItems );
723  delete clipFootprint;
724  }
725  else
726  {
727  clipFootprint->SetParent( board() );
728  pastedItems.push_back( clipFootprint );
729  }
730 
731  placeBoardItems( pastedItems, true, true );
732  break;
733  }
734 
735  default:
736  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
737  break;
738  }
739 
740  return 1;
741 }
742 
743 
745 {
746  int open_ctl;
747  wxString fileName;
748 
749  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
750 
751  if( !editFrame )
752  return 1;
753 
754  // Pick a file to append
755  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
756  return 1;
757 
758  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
759  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
760 
761  return AppendBoard( *pi, fileName );
762 }
763 
764 
765 // Helper function for PCB_CONTROL::placeBoardItems()
766 template<typename T>
767 static void moveUnflaggedItems( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
768  bool aIsNew )
769 {
770  std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
771  [aIsNew]( T aItem )
772  {
773  bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
774 
775  aItem->ClearFlags( SKIP_STRUCT );
776  aItem->SetFlags( aIsNew ? IS_NEW : 0 );
777 
778  return doCopy;
779  } );
780 
781  if( aIsNew )
782  aList.clear();
783 }
784 
785 
786 static void moveUnflaggedItems( ZONES& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
787 {
788  if( aList.size() == 0 )
789  return;
790 
791  auto obj = aList.front();
792  int idx = 0;
793 
794  if( aIsNew )
795  {
796  obj = aList.back();
797  aList.pop_back();
798  }
799 
800  for( ; obj ; )
801  {
802  if( obj->HasFlag( SKIP_STRUCT ) )
803  obj->ClearFlags( SKIP_STRUCT );
804  else
805  aTarget.push_back( obj );
806 
807  if( aIsNew )
808  {
809  if( aList.size() )
810  {
811  obj = aList.back();
812  aList.pop_back();
813  }
814  else
815  obj = nullptr;
816  }
817  else
818  obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
819  }
820 }
821 
822 
823 
824 int PCB_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
825 {
826  // items are new if the current board is not the board source
827  bool isNew = board() != aBoard;
828  std::vector<BOARD_ITEM*> items;
829 
830  moveUnflaggedItems( aBoard->Tracks(), items, isNew );
831  moveUnflaggedItems( aBoard->Footprints(), items, isNew );
832  moveUnflaggedItems( aBoard->Drawings(), items, isNew );
833  moveUnflaggedItems( aBoard->Zones(), items, isNew );
834 
835  // Subtlety: When selecting a group via the mouse,
836  // PCB_SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
837  // descendants. In PCB_CONTROL::placeBoardItems, below, we skip that and
838  // mark items non-recursively. That works because the saving of the
839  // selection created aBoard that has the group and all descendents in it.
840  moveUnflaggedItems( aBoard->Groups(), items, isNew );
841 
842  return placeBoardItems( items, isNew, aAnchorAtOrigin );
843 }
844 
845 
846 int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
847  bool aAnchorAtOrigin )
848 {
850 
852  EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
853  PCB_SELECTION& selection = selectionTool->GetSelection();
854 
855  for( BOARD_ITEM* item : aItems )
856  {
857  if( aIsNew )
858  {
859  const_cast<KIID&>( item->m_Uuid ) = KIID();
860 
861  if( selectionTool->GetEnteredGroup() && !item->GetParentGroup() )
862  selectionTool->GetEnteredGroup()->AddItem( item );
863  }
864 
865  // Update item attributes if needed
866  switch( item->Type() )
867  {
868  case PCB_DIMENSION_T:
869  case PCB_DIM_ALIGNED_T:
870  case PCB_DIM_CENTER_T:
872  case PCB_DIM_LEADER_T:
873  {
874  // Dimensions need to have their units updated if they are automatic
875  DIMENSION_BASE* dim = static_cast<DIMENSION_BASE*>( item );
876 
878  dim->SetUnits( frame()->GetUserUnits() );
879 
880  break;
881  }
882 
883  case PCB_FOOTPRINT_T:
884  // Update the footprint path with the new KIID path if the footprint is new
885  if( aIsNew )
886  static_cast<FOOTPRINT*>( item )->SetPath( KIID_PATH() );
887 
888  break;
889 
890  default:
891  break;
892  }
893 
894  // Add or just select items for the move/place command
895  if( aIsNew )
896  editTool->GetCurrentCommit()->Add( item );
897  else
898  editTool->GetCurrentCommit()->Added( item );
899 
900  // Matching the logic of PCB_SELECTION_TOOL::select for PCB_GROUP_T, there
901  // is a distinction between which items are SetSelected and which are in
902  // the selection object. Top-level groups or items not in groups are
903  // added to the selection object (via selection.Add(), below), but all
904  // items have SetSelected called. This is because much of the selection
905  // management logic (e.g. move) recursively acts on groups in the
906  // selection, so descendents of groups should not be in the selection
907  // object.
908  item->SetSelected();
909 
910  if( !item->GetParentGroup() || !alg::contains( aItems, item->GetParentGroup() ) )
911  selection.Add( item );
912  }
913 
914  if( selection.Size() > 0 )
915  {
916  if( aAnchorAtOrigin )
917  {
919  }
920  else
921  {
922  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
924  }
925 
926  getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
927 
930  }
931 
932  return 0;
933 }
934 
935 
936 int PCB_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
937 {
938  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
939 
940  if( !editFrame )
941  return 1;
942 
943  BOARD* brd = board();
944 
945  if( !brd )
946  return 1;
947 
948  // Mark existing items, in order to know what are the new items so we can select only
949  // the new items after loading
950  for( TRACK* track : brd->Tracks() )
951  track->SetFlags( SKIP_STRUCT );
952 
953  for( FOOTPRINT* footprint : brd->Footprints() )
955 
956  for( PCB_GROUP* group : brd->Groups() )
957  group->SetFlags( SKIP_STRUCT );
958 
959  for( BOARD_ITEM* drawing : brd->Drawings() )
960  drawing->SetFlags( SKIP_STRUCT );
961 
962  for( ZONE* zone : brd->Zones() )
963  zone->SetFlags( SKIP_STRUCT );
964 
965  std::map<wxString, wxString> oldProperties = brd->GetProperties();
966  std::map<wxString, wxString> newProperties;
967 
968  // Keep also the count of copper layers, to adjust if necessary
969  int initialCopperLayerCount = brd->GetCopperLayerCount();
970  LSET initialEnabledLayers = brd->GetEnabledLayers();
971 
972  // Load the data
973  try
974  {
975  PROPERTIES props;
976  char xbuf[30];
977  char ybuf[30];
978 
979  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
980  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
981  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
982 
983  props["page_width"] = xbuf;
984  props["page_height"] = ybuf;
985 
986  editFrame->GetDesignSettings().GetNetClasses().Clear();
987  pi.Load( fileName, brd, &props );
988  }
989  catch( const IO_ERROR& ioe )
990  {
991  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), ioe.What() );
992  DisplayError( editFrame, msg );
993 
994  return 0;
995  }
996 
997  newProperties = brd->GetProperties();
998 
999  for( const std::pair<const wxString, wxString>& prop : oldProperties )
1000  newProperties[ prop.first ] = prop.second;
1001 
1002  brd->SetProperties( newProperties );
1003 
1004  // rebuild nets and ratsnest before any use of nets
1005  brd->BuildListOfNets();
1007  brd->BuildConnectivity();
1008 
1009  // Synchronize layers
1010  // we should not ask PLUGINs to do these items:
1011  int copperLayerCount = brd->GetCopperLayerCount();
1012 
1013  if( copperLayerCount > initialCopperLayerCount )
1014  brd->SetCopperLayerCount( copperLayerCount );
1015 
1016  // Enable all used layers, and make them visible:
1017  LSET enabledLayers = brd->GetEnabledLayers();
1018  enabledLayers |= initialEnabledLayers;
1019  brd->SetEnabledLayers( enabledLayers );
1020  brd->SetVisibleLayers( enabledLayers );
1021 
1022  return placeBoardItems( brd, false );
1023 }
1024 
1025 
1026 int PCB_CONTROL::Undo( const TOOL_EVENT& aEvent )
1027 {
1028  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1029  wxCommandEvent dummy;
1030 
1031  if( editFrame )
1032  editFrame->RestoreCopyFromUndoList( dummy );
1033 
1034  return 0;
1035 }
1036 
1037 
1038 int PCB_CONTROL::Redo( const TOOL_EVENT& aEvent )
1039 {
1040  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1041  wxCommandEvent dummy;
1042 
1043  if( editFrame )
1044  editFrame->RestoreCopyFromRedoList( dummy );
1045 
1046  return 0;
1047 }
1048 
1049 
1051 {
1053  PCB_SELECTION& selection = selTool->GetSelection();
1054 
1055  if( selection.GetSize() == 1 )
1056  {
1057  EDA_ITEM* item = selection.Front();
1058  MSG_PANEL_ITEMS msgItems;
1059 
1060  item->GetMsgPanelInfo( m_frame, msgItems );
1061  m_frame->SetMsgPanel( msgItems );
1062  }
1063  else if( selection.GetSize() > 1 )
1064  {
1065  MSG_PANEL_ITEMS msgItems;
1066  wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
1067 
1068  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg ) );
1069  m_frame->SetMsgPanel( msgItems );
1070  }
1071  else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
1072  {
1073  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( editFrame->GetModel() );
1074 
1075  if( !footprint )
1076  return 0;
1077 
1078  MSG_PANEL_ITEMS msgItems;
1079  wxString msg;
1080 
1081  msg = footprint->GetFPID().GetLibNickname().wx_str();
1082  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg ) );
1083 
1084  msg = footprint->GetFPID().GetLibItemName().wx_str();
1085  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg ) );
1086 
1087  wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
1088 
1089  if( footprint->GetLastEditTime() && date.IsValid() )
1090  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
1091  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
1092  else
1093  msg = _( "Unknown" );
1094 
1095  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg ) );
1096 
1097  msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
1098  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg ) );
1099 
1100  wxString doc, keyword;
1101  doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
1102  keyword.Printf( _( "Keywords: %s" ), footprint->GetKeywords() );
1103  msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword ) );
1104 
1105  m_frame->SetMsgPanel( msgItems );
1106  }
1107  else
1108  {
1110  }
1111 
1112  return 0;
1113 }
1114 
1115 
1117 {
1118  view()->SetMirror( !view()->IsMirroredX(), false );
1119  view()->RecacheAllItems();
1120  frame()->GetCanvas()->ForceRefresh();
1122  return 0;
1123 }
1124 
1125 
1127 {
1130  Go( &PCB_CONTROL::Print, ACTIONS::print.MakeEvent() );
1131  Go( &PCB_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1132 
1133  // Display modes
1145 
1146  // Layer control
1184 
1185  // Grid control
1188 
1189  Go( &PCB_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1190  Go( &PCB_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1191 
1192  // Miscellaneous
1194 
1195  // Append control
1197 
1198  Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1199 
1204 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:42
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:93
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:286
BOARD_ITEM * Parse()
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:281
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Undo the last edit:
Definition: undo_redo.cpp:315
Filled polygons are shown.
void BuildListOfNets()
Definition: board.h:733
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:38
static const KICAD_T FootprintItems[]
A scan list for primary footprint items.
Definition: collectors.h:294
static const KICAD_T BoardLevelItems[]
A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT,...
Definition: collectors.h:279
const wxString & GetDescription() const
Definition: footprint.h:193
int GridSetOrigin(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:209
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:96
int m_Threshold
Definition: collector.h:248
class ALIGNED_DIMENSION, a linear dimension (graphic item)
Definition: typeinfo.h:100
void ForceRefresh()
Force a redraw.
static TOOL_ACTION layerNext
Definition: pcb_actions.h:287
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
class LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
Definition: typeinfo.h:84
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:257
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
wxPoint m_GridOrigin
origin for grid offsets
BOARD_ITEM * m_pickerItem
Definition: pcb_control.h:121
ZONES & Zones()
Definition: board.h:309
static NETINFO_ITEM * OrphanedItem()
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Definition: netinfo.h:373
BOARD * board() const
int LayerAlphaDec(const TOOL_EVENT &aEvent)
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
Return the number of pads.
Definition: footprint.cpp:1003
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:260
int GetUserUnits()
Returns the currently selected user unit value for the interface.
int Redo(const TOOL_EVENT &aEvent)
Model changes (required full reload)
Definition: tool_base.h:81
int LayerNext(const TOOL_EVENT &aEvent)
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:210
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
Definition: ratsnest.cpp:41
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual void OnDisplayOptionsChanged()
This file is part of the common library.
#define ZONE_LAYER_FOR(copperLayer)
Macro for getting the zone layer for a given copper layer.
static TOOL_ACTION doDelete
Definition: actions.h:75
PCB_BASE_FRAME * m_frame
Grid origin marker.
Definition: pcb_control.h:116
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:302
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:261
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
DIM_UNITS_MODE GetUnitsMode() const
Definition: dimension.cpp:150
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:262
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:263
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:329
Outlines of filled polygons are shown.
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:276
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:323
int placeBoardItems(std::vector< BOARD_ITEM * > &aItems, bool aIsNew, bool aAnchorAtOrigin)
Add and select or just select for move/place command a list of board items.
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:243
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:290
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:567
static TOOL_ACTION gridResetOrigin
Definition: actions.h:141
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:249
int LayerAlphaInc(const TOOL_EVENT &aEvent)
class CENTER_DIMENSION, a center point marking (graphic item)
Definition: typeinfo.h:102
void SetTextAngle(double aAngle) override
Definition: fp_text.cpp:70
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:79
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1372
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:289
void Flip(T &aValue)
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:351
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:248
#define ALPHA_MIN
double GetOrientation() const
Definition: footprint.h:186
void SetCopperLayerCount(int aCount)
Definition: board.cpp:441
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition: pcb_control.cpp:78
PCB_GROUP * GetEnteredGroup()
Apply the SELECTION_FILTER_OPTIONS to a collection of items.
void SetUnits(EDA_UNITS aUnits)
Definition: dimension.cpp:144
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
Definition: board.cpp:447
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:100
static TOOL_ACTION print
Definition: actions.h:60
virtual wxPoint GetPosition() const
Definition: eda_item.h:301
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
Definition: view.cpp:540
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
A name/value tuple with unique names and optional values.
Definition: properties.h:33
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:258
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:279
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:266
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
timestamp_t GetLastEditTime() const
Definition: footprint.h:329
virtual BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PLUGIN implementation knows about into either ...
Definition: plugin.cpp:46
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:165
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PADS & Pads()
Definition: footprint.h:164
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:77
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:70
static TOOL_ACTION layerTop
Definition: pcb_actions.h:255
static TOOL_ACTION pickerTool
Definition: actions.h:158
int Undo(const TOOL_EVENT &aEvent)
PCB_BASE_EDIT_FRAME * frame() const
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
Releases a PLUGIN in the context of a potential thrown exception through its destructor.
Definition: io_mgr.h:545
virtual PCB_LAYER_ID GetActiveLayer() const
#define HITTEST_THRESHOLD_PIXELS
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:328
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:278
void setTransitions() override
< Sets up handlers for various events.
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1413
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
FP_ZONES & Zones()
Definition: footprint.h:170
void UnbrightenItem(BOARD_ITEM *aItem)
Definition: kiid.h:44
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:264
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:435
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:250
Non-active layers are dimmed (old high-contrast mode)
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:361
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
LSET is a set of PCB_LAYER_IDs.
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:268
const PCB_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:202
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:288
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
Definition: board.h:380
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
TEXT_TYPE GetType() const
Definition: fp_text.h:141
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:473
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:280
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:273
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: eda_item.h:263
void AddItemToSel(BOARD_ITEM *aItem, bool aQuietMode=false)
Select all items on the board.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
FOOTPRINTS & Footprints()
Definition: board.h:303
Generic, UI-independent tool event.
Definition: tool_event.h:173
Non-active layers are shown normally (no high-contrast mode)
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:80
#define ALPHA_MAX
FOOTPRINT * footprint() const
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:285
KIGFX::PCB_VIEW * view() const
int GridResetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:284
int DeleteItemCursor(const TOOL_EVENT &aEvent)
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:242
bool Selectable(const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
static TOOL_ACTION addLibrary
Definition: actions.h:52
static TOOL_ACTION quit
Definition: actions.h:62
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:265
EDA_ITEM * GetTopLeftItem(bool aFootprintsOnly=false) const override
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:211
DRAWINGS & GraphicalItems()
Definition: footprint.h:167
void BrightenItem(BOARD_ITEM *aItem)
NETCLASSES & GetNetClasses() const
const LIB_ID & GetFPID() const
Definition: footprint.h:190
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
Definition: board.cpp:133
static void moveUnflaggedItems(std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
virtual void Move(const wxPoint &aWhere)
virtual COLOR4D GetGridColor()
virtual void PopupFor(int aMsecs)
int HighContrastMode(const TOOL_EVENT &aEvent)
class DIMENSION_BASE: abstract dimension meta-type
Definition: typeinfo.h:99
const wxString & GetKeywords() const
Definition: footprint.h:196
bool m_isFootprintEditor
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:270
The interactive edit tool.
Definition: edit_tool.h:64
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
static TOOL_ACTION newLibrary
Definition: actions.h:51
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:283
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:81
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:282
void UpdateColors()
Update the color settings in the painter and GAL.
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:60
const PCB_DISPLAY_OPTIONS & displayOptions() const
Generic tool for picking an item.
int LAYER_NUM
This can be replaced with int and removed.
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:272
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:275
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:101
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:69
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:246
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
Definition: view.cpp:749
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
FP_GROUPS & Groups()
Definition: footprint.h:173
int Quit(const TOOL_EVENT &aEvent)
static TOOL_ACTION redo
Definition: actions.h:68
#define ALPHA_STEP
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:277
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
int LayerSwitch(const TOOL_EVENT &aEvent)
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:453
virtual bool IsLocked() const
Definition: board_item.h:249
int Print(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
int AppendBoard(PLUGIN &pi, wxString &fileName)
void Clear()
Destroy any contained NETCLASS instances except the default one, and clears any members from the defa...
Definition: netclass.h:228
Declaration of the eda_3d_viewer class.
static void pasteFootprintItemsToFootprintEditor(FOOTPRINT *aClipFootprint, BOARD *aBoard, std::vector< BOARD_ITEM * > &aPastedItems)
bool IsType(FRAME_T aType) const
Common, abstract interface for edit frames.
Only the zone outline is shown.
bool AskLoadBoardFileName(PCB_EDIT_FRAME *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly=false)
Show a wxFileDialog asking for a BOARD filename to open.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
int FlipPcbView(const TOOL_EVENT &aEvent)
#define _(s)
Definition: 3d_actions.cpp:33
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Return a PLUGIN which the caller can use to import, export, save, or load design documents.
Definition: io_mgr.cpp:58
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:241
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
Definition: undo_redo.cpp:344
A base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:267
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:269
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:264
int HighContrastModeCycle(const TOOL_EVENT &aEvent)
int GetCopperLayerCount() const
Definition: board.cpp:435
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Definition: pcb_control.h:119
wxString wx_str() const
Definition: utf8.cpp:51
The main frame for Pcbnew.
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
The selection tool: currently supports:
void SetLocalCoord()
Definition: fp_text.cpp:218
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)=0
Create a new entry in undo list of commands.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:271
int AddLibrary(const TOOL_EVENT &aEvent)
Definition: pcb_control.cpp:92
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
int LayerPrev(const TOOL_EVENT &aEvent)
void Activate()
Run the tool.
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION highContrastModeCycle
Definition: actions.h:107
void SetLocalCoord()
Set relative coordinates from draw coordinates.
Definition: fp_shape.cpp:53
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:259
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
Definition: typeinfo.h:103
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
static TOOL_ACTION undo
Definition: actions.h:67
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:321
int ToggleRatsnest(const TOOL_EVENT &aEvent)
Non-active layers are hidden.
static TOOL_ACTION flipBoard
Definition: pcb_actions.h:295
BOARD * GetBoard() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
static TOOL_ACTION gridSetOrigin
Definition: actions.h:140
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: eda_item.h:117
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:381
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:274
Definition: pad.h:60
int LayerToggle(const TOOL_EVENT &aEvent)
PCB_DRAW_PANEL_GAL * canvas() const
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
Definition: io_mgr.h:52
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:256
void GuessSelectionCandidates(GENERAL_COLLECTOR &aCollector, const VECTOR2I &aWhere) const
Try to guess best selection candidates in case multiple items are clicked, by doing some brain-dead h...
Abstract dimension API.
Definition: dimension.h:95
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
static TOOL_ACTION highContrastMode
Definition: actions.h:106
Rendering engine changes.
Definition: tool_base.h:82
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
DRAWINGS & Drawings()
Definition: board.h:306
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
Definition: board.cpp:467
static TOOL_ACTION paste
Definition: actions.h:71
FP_ZONE is a specialization of ZONE for use in footprints.
Definition: zone.h:965
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
TRACKS & Tracks()
Definition: board.h:300
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:598
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:244
Definition: track.h:83
void SetText(const wxString &aText)
Display a text.
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
int TrackDisplayMode(const TOOL_EVENT &aEvent)
EDA_ITEM * Front() const
Definition: selection.h:203
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
void DisplayToolMsg(const wxString &msg) override
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:267
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
IO_MGR::PCB_FILE_T plugin_type(const wxString &aFileName, int aCtl)
Position or shape has changed.
Definition: view_item.h:54
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:291
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:247
int ViaDisplayMode(const TOOL_EVENT &aEvent)