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 <class_board.h>
35 #include <class_board_item.h>
36 #include <class_module.h>
37 #include <class_track.h>
38 #include <class_zone.h>
39 #include <class_edge_mod.h>
40 #include <confirm.h>
42 #include <kicad_clipboard.h>
43 #include <origin_viewitem.h>
44 #include <pcb_edit_frame.h>
45 #include <pcb_painter.h>
46 #include <properties.h>
48 #include <tool/tool_manager.h>
49 #include <view/view_controls.h>
50 #include <footprint_viewer_frame.h>
51 #include <footprint_edit_frame.h>
52 
53 using namespace std::placeholders;
54 
55 
56 // files.cpp
57 extern bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName,
58  bool aKicadFilesOnly = false );
59 extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
60 
61 
63  PCB_TOOL_BASE( "pcbnew.Control" ),
64  m_frame( nullptr ),
65  m_pickerItem( nullptr )
66 {
67  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
68 }
69 
70 
72 {
73 }
74 
75 
77 {
78  m_frame = getEditFrame<PCB_BASE_FRAME>();
79 
80  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
81  {
82  m_gridOrigin->SetPosition( board()->GetDesignSettings().m_GridOrigin );
83  m_gridOrigin->SetColor( m_frame->GetGridColor() );
84  getView()->Remove( m_gridOrigin.get() );
85  getView()->Add( m_gridOrigin.get() );
86  }
87 }
88 
89 
91 {
93  {
94  if( aEvent.IsAction( &ACTIONS::newLibrary ) )
95  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
96  else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
97  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
98  }
99 
100  return 0;
101 }
102 
103 
104 int PCBNEW_CONTROL::Quit( const TOOL_EVENT& aEvent )
105 {
106  m_frame->Close( false );
107  return 0;
108 }
109 
110 
111 template<class T> void Flip( T& aValue )
112 {
113  aValue = !aValue;
114 }
115 
116 
118 {
119  auto opts = displayOptions();
120 
121  Flip( opts.m_DisplayPcbTrackFill );
122  m_frame->SetDisplayOptions( opts );
123 
124  for( auto track : board()->Tracks() )
125  {
126  if( track->Type() == PCB_TRACE_T )
127  view()->Update( track, KIGFX::GEOMETRY );
128  }
129 
130  canvas()->Refresh();
131 
132  return 0;
133 }
134 
135 
137 {
138  auto opts = displayOptions();
139 
140  if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
141  {
142  // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
143  Flip( opts.m_ShowGlobalRatsnest );
144  m_frame->SetDisplayOptions( opts );
145  getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
146  opts.m_ShowGlobalRatsnest );
147 
148  }
149  else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
150  {
151  Flip( opts.m_DisplayRatsnestLinesCurved );
152  m_frame->SetDisplayOptions( opts );
153  }
154 
155  canvas()->RedrawRatsnest();
156  canvas()->Refresh();
157 
158  return 0;
159 }
160 
161 
163 {
164  auto opts = displayOptions();
165 
166  Flip( opts.m_DisplayViaFill );
167  m_frame->SetDisplayOptions( opts );
168 
169  for( auto track : board()->Tracks() )
170  {
171  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
172  view()->Update( track, KIGFX::GEOMETRY );
173  }
174 
175  canvas()->Refresh();
176 
177  return 0;
178 }
179 
180 
182 {
183  auto opts = displayOptions();
184 
185  // Apply new display options to the GAL canvas
187  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_FILLED;
188  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
189  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::HIDE_FILLED;
190  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
191  opts.m_ZoneDisplayMode = ZONE_DISPLAY_MODE::SHOW_OUTLINED;
192  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
193  {
194  int nextMode = ( static_cast<int>( opts.m_ZoneDisplayMode ) + 1 ) % 3;
195  opts.m_ZoneDisplayMode = static_cast<ZONE_DISPLAY_MODE>( nextMode );
196  }
197  else
198  wxFAIL;
199 
200  m_frame->SetDisplayOptions( opts );
201 
202  for( ZONE_CONTAINER* zone : board()->Zones() )
203  view()->Update( zone, KIGFX::GEOMETRY );
204 
205  canvas()->Refresh();
206 
207  return 0;
208 }
209 
210 
212 {
213  auto opts = displayOptions();
214 
215  opts.m_ContrastModeDisplay =
216  ( opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL ) ?
219 
220  m_frame->SetDisplayOptions( opts );
221 
222  return 0;
223 }
224 
225 
227 {
228  auto opts = displayOptions();
229 
230  switch( opts.m_ContrastModeDisplay )
231  {
233  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED;
234  break;
235 
237  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN;
238  break;
239 
241  opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
242  break;
243  }
244 
245  m_frame->SetDisplayOptions( opts );
246 
247  return 0;
248 }
249 
250 
251 // Layer control
253 {
255 
256  return 0;
257 }
258 
259 
261 {
262  PCB_BASE_FRAME* editFrame = m_frame;
263  BOARD* brd = board();
264  LAYER_NUM layer = editFrame->GetActiveLayer();
265  LAYER_NUM startLayer = layer;
266 
267  if( layer < F_Cu || layer > B_Cu )
268  return 0;
269 
270  while( startLayer != ++layer )
271  {
272  if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
273  break;
274 
275  if( layer >= B_Cu )
276  layer = F_Cu - 1;
277  }
278 
279  wxCHECK( IsCopperLayer( layer ), 0 );
280  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
281 
282  return 0;
283 }
284 
285 
287 {
288  PCB_BASE_FRAME* editFrame = m_frame;
289  BOARD* brd = board();
290  LAYER_NUM layer = editFrame->GetActiveLayer();
291  LAYER_NUM startLayer = layer;
292 
293  if( layer < F_Cu || layer > B_Cu )
294  return 0;
295 
296  while( startLayer != --layer )
297  {
298  if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
299  && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
300  break;
301 
302  if( layer <= F_Cu )
303  layer = B_Cu + 1;
304  }
305 
306 
307  wxCHECK( IsCopperLayer( layer ), 0 );
308  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
309 
310  return 0;
311 }
312 
313 
315 {
316  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
317  PCB_SCREEN* screen = m_frame->GetScreen();
318 
319  if( currentLayer == screen->m_Route_Layer_TOP )
321  else
323 
324  return 0;
325 }
326 
327 
328 // It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
329 // set in wxFormBuilder.
330 #define ALPHA_MIN 0.20
331 #define ALPHA_MAX 1.00
332 #define ALPHA_STEP 0.05
333 
335 {
336  auto settings = m_frame->GetColorSettings();
337 
338  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
339  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
340 
341  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
342  {
343  currentColor.a += ALPHA_STEP;
344  settings->SetColor( currentLayer, currentColor );
346 
348  view->UpdateLayerColor( currentLayer );
349 
350  wxUpdateUIEvent dummy;
351  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
352  }
353  else
354  wxBell();
355 
356  return 0;
357 }
358 
359 
361 {
362  auto settings = m_frame->GetColorSettings();
363 
364  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
365  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
366 
367  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
368  {
369  currentColor.a -= ALPHA_STEP;
370  settings->SetColor( currentLayer, currentColor );
372 
374  view->UpdateLayerColor( currentLayer );
375 
376  wxUpdateUIEvent dummy;
377  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
378  }
379  else
380  wxBell();
381 
382  return 0;
383 }
384 
385 
386 // Grid control
388  EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
389 {
390  aFrame->GetDesignSettings().m_GridOrigin = (wxPoint) aPoint;
391  aView->GetGAL()->SetGridOrigin( aPoint );
392  originViewItem->SetPosition( (wxPoint) aPoint );
393  aView->MarkDirty();
394  aFrame->OnModify();
395 }
396 
397 
399 {
400  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
401 
402  if( origin )
403  {
404  // We can't undo the other grid dialog settings, so no sense undoing just the origin
405  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
406  delete origin;
407  }
408  else
409  {
410  if( m_editModules && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
411  return 0;
412 
413  std::string tool = aEvent.GetCommandStr().get();
415 
416  // Deactivate other tools; particularly important if another PICKER is currently running
417  Activate();
418 
419  picker->SetClickHandler(
420  [this] ( const VECTOR2D& pt ) -> bool
421  {
423  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
424  return false; // drill origin is a one-shot; don't continue with tool
425  } );
426 
427  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
428  }
429 
430  return 0;
431 }
432 
433 
435 {
437  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
438  return 0;
439 }
440 
441 
442 #define HITTEST_THRESHOLD_PIXELS 5
443 
444 
446 {
448  return 0;
449 
450  std::string tool = aEvent.GetCommandStr().get();
452 
453  m_pickerItem = nullptr;
455 
456  // Deactivate other tools; particularly important if another PICKER is currently running
457  Activate();
458 
459  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
460 
461  picker->SetClickHandler(
462  [this] ( const VECTOR2D& aPosition ) -> bool
463  {
464  if( m_pickerItem )
465  {
467  {
468  STATUS_TEXT_POPUP statusPopup( m_frame );
469  statusPopup.SetText( _( "Item locked." ) );
470  statusPopup.PopupFor( 2000 );
471  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
472  return true;
473  }
474 
475  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
476  selectionTool->UnbrightenItem( m_pickerItem );
477  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
479  m_pickerItem = nullptr;
480  }
481 
482  return true;
483  } );
484 
485  picker->SetMotionHandler(
486  [this] ( const VECTOR2D& aPos )
487  {
488  BOARD* board = m_frame->GetBoard();
489  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
491  GENERAL_COLLECTOR collector;
492  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
493 
494  if( m_editModules )
495  collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
496  else
497  collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
498 
499  // Remove unselectable items
500  for( int i = collector.GetCount() - 1; i >= 0; --i )
501  {
502  if( !selectionTool->Selectable( collector[ i ] ) )
503  collector.Remove( i );
504  }
505 
506  if( collector.GetCount() > 1 )
507  selectionTool->GuessSelectionCandidates( collector, aPos );
508 
509  BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
510 
511  if( m_pickerItem != item )
512  {
513 
514  if( m_pickerItem )
515  selectionTool->UnbrightenItem( m_pickerItem );
516 
517  m_pickerItem = item;
518 
519  if( m_pickerItem )
520  selectionTool->BrightenItem( m_pickerItem );
521  }
522  } );
523 
524  picker->SetFinalizeHandler(
525  [this] ( const int& aFinalState )
526  {
527  if( m_pickerItem )
529  } );
530 
531  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
532 
533  return 0;
534 }
535 
536 
537 void pasteModuleItemsToModEdit( MODULE* aClipModule, BOARD* aBoard,
538  std::vector<BOARD_ITEM*>& aPastedItems )
539 {
540  MODULE* editModule = aBoard->GetFirstModule();
541 
542  aClipModule->SetParent( aBoard );
543 
544  for( D_PAD* pad : aClipModule->Pads() )
545  {
546  pad->SetParent( editModule );
547  aPastedItems.push_back( pad );
548  }
549 
550  aClipModule->Pads().clear();
551 
552  for( BOARD_ITEM* item : aClipModule->GraphicalItems() )
553  {
554  if( item->Type() == PCB_MODULE_EDGE_T )
555  {
556  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );
557 
558  edge->SetParent( nullptr );
559  edge->SetLocalCoord();
560  }
561  else if( item->Type() == PCB_MODULE_TEXT_T )
562  {
563  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
564 
565  if( text->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
567 
568  if( text->GetText() == "${VALUE}" )
569  text->SetText( aClipModule->GetValue() );
570  else if( text->GetText() == "${REFERENCE}" )
571  text->SetText( aClipModule->GetReference() );
572 
573  text->SetTextAngle( aClipModule->GetOrientation() );
574 
575  text->SetParent( nullptr );
576  text->SetLocalCoord();
577  }
578 
579  item->SetParent( editModule );
580  aPastedItems.push_back( item );
581  }
582 
583  aClipModule->GraphicalItems().clear();
584 
585  if( !aClipModule->GetReference().IsEmpty() )
586  {
587  TEXTE_MODULE* text = new TEXTE_MODULE( aClipModule->Reference() );
589  text->SetTextAngle( aClipModule->GetOrientation() );
590 
591  text->SetParent( nullptr );
592  text->SetLocalCoord();
593 
594  text->SetParent( editModule );
595  aPastedItems.push_back( text );
596  }
597 
598  if( !aClipModule->GetValue().IsEmpty() )
599  {
600  TEXTE_MODULE* text = new TEXTE_MODULE( aClipModule->Value() );
602  text->SetTextAngle( aClipModule->GetOrientation() );
603 
604  text->SetParent( nullptr );
605  text->SetLocalCoord();
606 
607  text->SetParent( editModule );
608  aPastedItems.push_back( text );
609  }
610 }
611 
612 
613 int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
614 {
615  CLIPBOARD_IO pi;
616  BOARD_ITEM* clipItem = pi.Parse();
617 
618  if( !clipItem )
619  return 0;
620 
621  bool editModules = m_editModules || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
622 
623  if( clipItem->Type() == PCB_T )
624  {
625  if( editModules )
626  {
627  for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
628  item->SetNet( NETINFO_LIST::OrphanedItem() );
629  }
630  else
631  static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
632  }
633 
634  // The clipboard can contain two different things, an entire kicad_pcb
635  // or a single module
636 
637  if( editModules && ( !board() || !module() ) )
638  {
639  return 0;
640  }
641 
642  switch( clipItem->Type() )
643  {
644  case PCB_T:
645  {
646  BOARD* clipBoard = static_cast<BOARD*>( clipItem );
647 
648  if( editModules )
649  {
650  MODULE* editModule = board()->GetFirstModule();
651  std::vector<BOARD_ITEM*> pastedItems;
652 
653  for( MODULE* clipModule : clipBoard->Modules() )
654  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
655 
656  for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
657  {
658  if( clipDrawItem->Type() == PCB_LINE_T )
659  {
660  DRAWSEGMENT* clipDrawSeg = static_cast<DRAWSEGMENT*>( clipDrawItem );
661 
662  // Convert to PCB_MODULE_EDGE_T
663  EDGE_MODULE* pastedDrawSeg = new EDGE_MODULE( editModule );
664  static_cast<DRAWSEGMENT*>( pastedDrawSeg )->SwapData( clipDrawSeg );
665  pastedDrawSeg->SetLocalCoord();
666 
667  // Replace parent nuked by above call to SwapData()
668  pastedDrawSeg->SetParent( editModule );
669  pastedItems.push_back( pastedDrawSeg );
670  }
671  else if( clipDrawItem->Type() == PCB_TEXT_T )
672  {
673  TEXTE_PCB* clipTextItem = static_cast<TEXTE_PCB*>( clipDrawItem );
674 
675  // Convert to PCB_MODULE_TEXT_T
676  TEXTE_MODULE* pastedTextItem = new TEXTE_MODULE( editModule );
677  static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
678  static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
679 
680  pastedTextItem->SetParent( editModule );
681  pastedItems.push_back( pastedTextItem );
682  }
683  }
684 
685  delete clipBoard;
686 
687  placeBoardItems( pastedItems, true, true );
688  }
689  else
690  {
691  placeBoardItems( clipBoard, true );
692 
694  m_frame->Compile_Ratsnest( true );
695  }
696 
697  break;
698  }
699 
700  case PCB_MODULE_T:
701  {
702  MODULE* clipModule = static_cast<MODULE*>( clipItem );
703  std::vector<BOARD_ITEM*> pastedItems;
704 
705  if( editModules )
706  {
707  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
708  delete clipModule;
709  }
710  else
711  {
712  clipModule->SetParent( board() );
713  pastedItems.push_back( clipModule );
714  }
715 
716  placeBoardItems( pastedItems, true, true );
717  break;
718  }
719 
720  default:
721  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
722  break;
723  }
724 
725  return 1;
726 }
727 
728 
730 {
731  int open_ctl;
732  wxString fileName;
733 
734  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
735 
736  if( !editFrame )
737  return 1;
738 
739  // Pick a file to append
740  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
741  return 1;
742 
743  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
744  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
745 
746  return AppendBoard( *pi, fileName );
747 }
748 
749 
750 // Helper function for PCBNEW_CONTROL::placeBoardItems()
751 template<typename T>
752 static void moveUnflaggedItems( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
753  bool aIsNew )
754 {
755  std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
756  [aIsNew]( T aItem )
757  {
758  bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
759 
760  aItem->ClearFlags( SKIP_STRUCT );
761  aItem->SetFlags( aIsNew ? IS_NEW : 0 );
762 
763  return doCopy;
764  } );
765 
766  if( aIsNew )
767  aList.clear();
768 }
769 
770 
771 static void moveUnflaggedItems( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*>& aTarget,
772  bool aIsNew )
773 {
774  if( aList.size() == 0 )
775  return;
776 
777  auto obj = aList.front();
778  int idx = 0;
779 
780  if( aIsNew )
781  {
782  obj = aList.back();
783  aList.pop_back();
784  }
785 
786  for( ; obj ; )
787  {
788  if( obj->HasFlag( SKIP_STRUCT ) )
789  obj->ClearFlags( SKIP_STRUCT );
790  else
791  aTarget.push_back( obj );
792 
793  if( aIsNew )
794  {
795  if( aList.size() )
796  {
797  obj = aList.back();
798  aList.pop_back();
799  }
800  else
801  obj = nullptr;
802  }
803  else
804  obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
805  }
806 }
807 
808 
809 
810 int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
811 {
812  // items are new if the current board is not the board source
813  bool isNew = board() != aBoard;
814  std::vector<BOARD_ITEM*> items;
815 
816  moveUnflaggedItems( aBoard->Tracks(), items, isNew );
817  moveUnflaggedItems( aBoard->Modules(), items, isNew );
818  moveUnflaggedItems( aBoard->Drawings(), items, isNew );
819  moveUnflaggedItems( aBoard->Zones(), items, isNew );
820 
821  // Subtlety: When selecting a group via the mouse,
822  // SELECTION_TOOL::highlightInternal runs, which does a SetSelected() on all
823  // descendants. In PCBNEW_CONTROL::placeBoardItems, below, we skip that and
824  // mark items non-recursively. That works because the saving of the
825  // selection created aBoard that has the group and all descendents in it.
826  moveUnflaggedItems( aBoard->Groups(), items, isNew );
827 
828  return placeBoardItems( items, isNew, aAnchorAtOrigin );
829 }
830 
831 
832 int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
833  bool aAnchorAtOrigin )
834 {
836 
837  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
838  EDIT_TOOL* editTool = m_toolMgr->GetTool<EDIT_TOOL>();
839 
840  PCBNEW_SELECTION& selection = selectionTool->GetSelection();
841 
842  for( BOARD_ITEM* item : aItems )
843  {
844  if( aIsNew )
845  {
846  const_cast<KIID&>( item->m_Uuid ) = KIID();
847 
848  if( item->Type() == PCB_MODULE_T )
849  {
850  static_cast<MODULE*>( item )->SetPath( KIID_PATH() );
851  }
852  else if( item->Type() == PCB_GROUP_T )
853  {
854  // If pasting a group, its immediate children must be updated to have its new KIID
855  static_cast<PCB_GROUP*>( item )->RunOnChildren( [item] ( BOARD_ITEM* aBrdItem )
856  {
857  aBrdItem->SetGroup( item->m_Uuid );
858  } );
859  }
860  }
861 
862  // Add or just select items for the move/place command
863  if( aIsNew )
864  editTool->GetCurrentCommit()->Add( item );
865  else
866  editTool->GetCurrentCommit()->Added( item );
867 
868  // Matching the logic of SELECTION_TOOL::select for PCB_GROUP_T, there
869  // is a distinction between which items are SetSelected and which are in
870  // the selection object. Top-level groups or items not in groups are
871  // added to the selection object (via selection.Add(), below), but all
872  // items have SetSelected called. This is because much of the selection
873  // management logic (e.g. move) recursively acts on groups in the
874  // selection, so descendents of groups should not be in the selection
875  // object.
876  item->SetSelected();
877  }
878 
879  // Filter out from selection any items that are in groups that are also in the selection
880  // For PCB_GROUP_T, a selection including the group should not include its descendants.
881  std::unordered_set<PCB_GROUP*> groups;
882  for( BOARD_ITEM* item : aItems )
883  {
884  if( item->Type() == PCB_GROUP_T )
885  groups.insert( static_cast<PCB_GROUP*>( item ) );
886  }
887  for( BOARD_ITEM* item : aItems )
888  {
889  bool inGroup = false;
890  for( PCB_GROUP* grp : groups )
891  {
892  if( grp->GetItems().find( item ) != grp->GetItems().end() )
893  {
894  inGroup = true;
895  break;
896  }
897  }
898  if( !inGroup )
899  {
900  selection.Add( item );
901  }
902  }
903 
904 
905  if( selection.Size() > 0 )
906  {
907  if( aAnchorAtOrigin )
908  {
910  }
911  else
912  {
913  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
915  }
916 
917  getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
918 
921  }
922 
923  return 0;
924 }
925 
926 
927 int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
928 {
929  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
930 
931  if( !editFrame )
932  return 1;
933 
934  BOARD* brd = board();
935 
936  if( !brd )
937  return 1;
938 
939  // Mark existing items, in order to know what are the new items so we can select only
940  // the new items after loading
941  for( auto track : brd->Tracks() )
942  track->SetFlags( SKIP_STRUCT );
943 
944  for( auto module : brd->Modules() )
946 
947  for( auto group : brd->Groups() )
948  group->SetFlags( SKIP_STRUCT );
949 
950  for( auto drawing : brd->Drawings() )
951  drawing->SetFlags( SKIP_STRUCT );
952 
953  for( auto zone : brd->Zones() )
954  zone->SetFlags( SKIP_STRUCT );
955 
956  std::map<wxString, wxString> oldProperties = brd->GetProperties();
957  std::map<wxString, wxString> newProperties;
958 
959  // Keep also the count of copper layers, to adjust if necessary
960  int initialCopperLayerCount = brd->GetCopperLayerCount();
961  LSET initialEnabledLayers = brd->GetEnabledLayers();
962 
963  // Load the data
964  try
965  {
966  PROPERTIES props;
967  char xbuf[30];
968  char ybuf[30];
969 
970  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
971  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
972  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
973 
974  props["page_width"] = xbuf;
975  props["page_height"] = ybuf;
976 
977  editFrame->GetDesignSettings().GetNetClasses().Clear();
978  pi.Load( fileName, brd, &props );
979  }
980  catch( const IO_ERROR& ioe )
981  {
982  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
983  DisplayError( editFrame, msg );
984 
985  return 0;
986  }
987 
988  newProperties = brd->GetProperties();
989 
990  for( const std::pair<const wxString, wxString>& prop : oldProperties )
991  newProperties[ prop.first ] = prop.second;
992 
993  brd->SetProperties( newProperties );
994 
995  // rebuild nets and ratsnest before any use of nets
996  brd->BuildListOfNets();
998  brd->BuildConnectivity();
999 
1000  // Synchronize layers
1001  // we should not ask PLUGINs to do these items:
1002  int copperLayerCount = brd->GetCopperLayerCount();
1003 
1004  if( copperLayerCount > initialCopperLayerCount )
1005  brd->SetCopperLayerCount( copperLayerCount );
1006 
1007  // Enable all used layers, and make them visible:
1008  LSET enabledLayers = brd->GetEnabledLayers();
1009  enabledLayers |= initialEnabledLayers;
1010  brd->SetEnabledLayers( enabledLayers );
1011  brd->SetVisibleLayers( enabledLayers );
1012 
1013  return placeBoardItems( brd, false );
1014 }
1015 
1016 
1017 int PCBNEW_CONTROL::Undo( const TOOL_EVENT& aEvent )
1018 {
1019  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1020  wxCommandEvent dummy;
1021 
1022  if( editFrame )
1023  editFrame->RestoreCopyFromUndoList( dummy );
1024 
1025  return 0;
1026 }
1027 
1028 
1029 int PCBNEW_CONTROL::Redo( const TOOL_EVENT& aEvent )
1030 {
1031  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1032  wxCommandEvent dummy;
1033 
1034  if( editFrame )
1035  editFrame->RestoreCopyFromRedoList( dummy );
1036 
1037  return 0;
1038 }
1039 
1040 
1042 {
1044  PCBNEW_SELECTION& selection = selTool->GetSelection();
1045 
1046  if( selection.GetSize() == 1 )
1047  {
1048  EDA_ITEM* item = selection.Front();
1049  MSG_PANEL_ITEMS msgItems;
1050 
1051  item->GetMsgPanelInfo( m_frame, msgItems );
1052  m_frame->SetMsgPanel( msgItems );
1053  }
1054  else if( selection.GetSize() > 1 )
1055  {
1056  MSG_PANEL_ITEMS msgItems;
1057  wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
1058 
1059  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
1060  m_frame->SetMsgPanel( msgItems );
1061  }
1062  else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
1063  {
1064  MODULE* footprint = static_cast<MODULE*>( editFrame->GetModel() );
1065 
1066  if( !footprint )
1067  return 0;
1068 
1069  MSG_PANEL_ITEMS msgItems;
1070  wxString msg;
1071 
1072  msg = footprint->GetFPID().GetLibNickname().wx_str();
1073  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg, DARKCYAN ) );
1074 
1075  msg = footprint->GetFPID().GetLibItemName().wx_str();
1076  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg, DARKCYAN ) );
1077 
1078  wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
1079 
1080  if( footprint->GetLastEditTime() && date.IsValid() )
1081  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
1082  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
1083  else
1084  msg = _( "Unknown" );
1085 
1086  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
1087 
1088  msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
1089  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
1090 
1091  wxString doc, keyword;
1092  doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
1093  keyword.Printf( _( "Key Words: %s" ), footprint->GetKeywords() );
1094  msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
1095 
1096  m_frame->SetMsgPanel( msgItems );
1097  }
1098  else
1099  {
1101  }
1102 
1103  return 0;
1104 }
1105 
1106 
1108 {
1111  Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
1112  Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1113 
1114  // Display modes
1125 
1126  // Layer control
1164 
1165  // Grid control
1168 
1169  Go( &PCBNEW_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1170  Go( &PCBNEW_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1171 
1172  // Miscellaneous
1174 
1175  // Append control
1177 
1178  Go( &PCBNEW_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1179 
1184 }
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
GetPadCount returns the number of pads.
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
timestamp_t GetLastEditTime() const
Definition: class_module.h:352
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:269
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:264
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Function RestoreCopyFromUndoList Undo the last edit:
Definition: undo_redo.cpp:335
Filled polygons are shown.
void BuildListOfNets()
Definition: class_board.h:686
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
double GetOrientation() const
Definition: class_module.h:217
static const KICAD_T BoardLevelItems[]
A scan list for all primary board items, omitting items which are subordinate to a MODULE,...
Definition: collectors.h:283
static const TOOL_EVENT SelectedEvent
Definition: actions.h:206
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
TEXTE_MODULE & Reference()
Definition: class_module.h:485
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:95
int m_Threshold
Definition: collector.h:67
static TOOL_ACTION layerNext
Definition: pcb_actions.h:270
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
int ToggleRatsnest(const TOOL_EVENT &aEvent)
Definition: typeinfo.h:85
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:240
wxPoint m_GridOrigin
origin for grid offsets
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
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:243
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
Model changes (required full reload)
Definition: tool_base.h:82
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
void Compile_Ratsnest(bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:93
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:75
virtual void SetPosition(const wxPoint &aPos)
Definition: base_struct.h:338
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:244
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:109
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:245
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:246
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: class_board.h:272
int AddLibrary(const TOOL_EVENT &aEvent)
VIEW_CONTROLS class definition.
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:259
GROUPS & Groups()
The groups must maintain the folowing invariants.
Definition: class_board.h:267
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:226
PCB_GROUP is a set of BOARD_ITEMs (i.e., without duplicates)
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:273
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:574
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
static TOOL_ACTION gridResetOrigin
Definition: actions.h:136
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:232
SELECTION_TOOL.
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
#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:272
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:375
PADS & Pads()
Definition: class_module.h:174
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:231
const wxString GetValue() const
Function GetValue.
Definition: class_module.h:469
int HighContrastMode(const TOOL_EVENT &aEvent)
Definition: color4d.h:61
void SetCopperLayerCount(int aCount)
#define HITTEST_THRESHOLD_PIXELS
class TEXTE_PCB, 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:140
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:180
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.
const LIB_ID & GetFPID() const
Definition: class_module.h:221
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
Definition: color4d.h:44
static TOOL_ACTION print
Definition: actions.h:60
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
DRAWINGS & GraphicalItems()
Definition: class_module.h:184
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:241
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:262
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()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:249
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:130
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:211
void RedrawRatsnest()
Forces refresh of the ratsnest visual representation
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
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
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:444
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:238
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
static TOOL_ACTION pickerTool
Definition: actions.h:151
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
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:580
virtual PCB_LAYER_ID GetActiveLayer() const
const std::map< wxString, wxString > & GetProperties() const
Definition: class_board.h:271
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:261
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
Definition: common.h:68
class MODULE, a footprint
Definition: typeinfo.h:89
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:420
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:233
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:369
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:251
const PCBNEW_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:271
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
#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
MODULES & Modules()
Definition: class_board.h:249
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:484
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:263
void SetGroup(const KIID &aGroup)
Set the group that this item belongs to.
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:256
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: base_struct.h:295
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
TOOL_EVENT.
Definition: tool_event.h:171
void AddItemToSel(BOARD_ITEM *aItem, bool aQuietMode=false)
TEXT_TYPE GetType() const
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:268
KIGFX::PCB_VIEW * view() const
MODULE * GetFirstModule() const
Gets the first module in the list (used in footprint viewer/editor) or NULL if none.
Definition: class_board.h:310
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:267
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:225
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:248
static const TOOL_EVENT ClearedEvent
Definition: actions.h:208
NETCLASSES & GetNetClasses() const
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
virtual void Move(const wxPoint &aWhere)
virtual COLOR4D GetGridColor()
virtual void PopupFor(int aMsecs)
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:253
void SetTextAngle(double aAngle) override
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.
const wxString & GetKeywords() const
Definition: class_module.h:227
void SetType(TEXT_TYPE aType)
static TOOL_ACTION newLibrary
Definition: actions.h:51
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:266
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
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:265
void UpdateColors()
Updates the color settings in the painter and GAL.
const PCB_DISPLAY_OPTIONS & displayOptions() const
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:255
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:258
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:100
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:229
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:773
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
void SetLocalCoord()
Set relative coordinates from draw coordinates.
#define ALPHA_MAX
static TOOL_ACTION redo
Definition: actions.h:68
const wxString & GetDescription() const
Definition: class_module.h:224
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:260
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
void SetLocalCoord()
Set relative coordinates.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
int LayerAlphaDec(const TOOL_EVENT &aEvent)
Definition: color4d.h:56
virtual bool IsLocked() const
Function IsLocked.
ZONE_CONTAINERS & Zones()
Definition: class_board.h:254
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one, and clears any membe...
Definition: netclass.h:237
Declaration of the eda_3d_viewer class.
bool IsType(FRAME_T aType) const
Common, abstract interface for edit frames.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
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.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
static const KICAD_T ModuleItems[]
A scan list for primary module items.
Definition: collectors.h:308
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:62
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:240
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Function RestoreCopyFromRedoList Redo the last edit:
Definition: undo_redo.cpp:364
PLUGIN is a base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:274
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:252
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:247
int GetCopperLayerCount() const
Function GetCopperLayerCount.
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:127
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: base_struct.h:159
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:102
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:254
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)
Function IsCopperLayer 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)
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:242
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:345
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:53
VIEW.
Definition: view.h:61
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:390
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:257
void BrightenItem(BOARD_ITEM *aItem)
EDGE_MODULE class definition.
int LayerSwitch(const TOOL_EVENT &aEvent)
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
PCB_DRAW_PANEL_GAL * canvas() const
void pasteModuleItemsToModEdit(MODULE *aClipModule, BOARD *aBoard, std::vector< BOARD_ITEM * > &aPastedItems)
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:239
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: class_board.h:252
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:856
void SetEnabledLayers(LSET aLayerMask)
Function SetEnabledLayers is a proxy function that calls the correspondent function in m_BoardSetting...
static TOOL_ACTION paste
Definition: actions.h:71
void SetCursor(const wxCursor &aCursor)
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
TRACKS & Tracks()
Definition: class_board.h:246
int Print(const TOOL_EVENT &aEvent)
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:599
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:227
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:184
Outlines of filled polygons are shown.
void DisplayToolMsg(const wxString &msg) override
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:250
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
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:46
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:274
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:230