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