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 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>
43 #include <io_mgr.h>
44 #include <kicad_clipboard.h>
45 #include <kicad_plugin.h>
46 #include <kiway.h>
47 #include <origin_viewitem.h>
48 #include <pcb_edit_frame.h>
49 #include <pcb_painter.h>
50 #include <pcb_screen.h>
51 #include <properties.h>
52 #include <tool/tool_manager.h>
53 #include <view/view_controls.h>
54 #include <functional>
55 #include <footprint_viewer_frame.h>
56 #include <footprint_edit_frame.h>
57 #include <math/util.h> // for KiROUND
58 
59 using namespace std::placeholders;
60 
61 
62 // files.cpp
63 extern bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName,
64  bool aKicadFilesOnly = false );
65 extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
66 
67 
69  PCB_TOOL_BASE( "pcbnew.Control" ),
70  m_frame( nullptr ),
71  m_pickerItem( nullptr )
72 {
73  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
74 }
75 
76 
78 {
79 }
80 
81 
83 {
84  m_frame = getEditFrame<PCB_BASE_FRAME>();
85 
86  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
87  {
88  m_gridOrigin->SetPosition( board()->GetGridOrigin() );
89  m_gridOrigin->SetColor( m_frame->GetGridColor() );
90  getView()->Remove( m_gridOrigin.get() );
91  getView()->Add( m_gridOrigin.get() );
92  }
93 }
94 
95 
97 {
99  {
100  if( aEvent.IsAction( &ACTIONS::newLibrary ) )
101  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
102  else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
103  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
104  }
105 
106  return 0;
107 }
108 
109 
110 int PCBNEW_CONTROL::Quit( const TOOL_EVENT& aEvent )
111 {
112  m_frame->Close( false );
113  return 0;
114 }
115 
116 
117 template<class T> void Flip( T& aValue )
118 {
119  aValue = !aValue;
120 }
121 
123 {
124  auto opts = displayOptions();
125 
126  Flip( opts.m_DisplayPcbTrackFill );
127  m_frame->SetDisplayOptions( opts );
128  view()->UpdateDisplayOptions( opts );
129 
130  for( auto track : board()->Tracks() )
131  {
132  if( track->Type() == PCB_TRACE_T )
133  view()->Update( track, KIGFX::GEOMETRY );
134  }
135 
136  canvas()->Refresh();
137 
138  return 0;
139 }
140 
141 
143 {
144  auto opts = displayOptions();
145 
146  if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
147  {
148  // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
149  Flip( opts.m_ShowGlobalRatsnest );
150  m_frame->SetDisplayOptions( opts );
151  view()->UpdateDisplayOptions( opts );
152  getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
153  opts.m_ShowGlobalRatsnest );
154 
155  }
156  else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
157  {
158  Flip( opts.m_DisplayRatsnestLinesCurved );
159  m_frame->SetDisplayOptions( opts );
160  view()->UpdateDisplayOptions( opts );
161  }
162 
163  canvas()->RedrawRatsnest();
164  canvas()->Refresh();
165 
166  return 0;
167 }
168 
169 
171 {
172  auto opts = displayOptions();
173 
174  Flip( opts.m_DisplayPadFill );
175  m_frame->SetDisplayOptions( opts );
176  view()->UpdateDisplayOptions( opts );
177 
178  for( auto module : board()->Modules() ) // fixme: move to PCB_VIEW
179  {
180  for( auto pad : module->Pads() )
181  view()->Update( pad, KIGFX::GEOMETRY );
182  }
183 
184  canvas()->Refresh();
185 
186  return 0;
187 }
188 
189 
191 {
192  auto opts = displayOptions();
193 
194  Flip( opts.m_DisplayViaFill );
195  view()->UpdateDisplayOptions( opts );
196  m_frame->SetDisplayOptions( opts );
197 
198  for( auto track : board()->Tracks() )
199  {
200  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
201  view()->Update( track, KIGFX::GEOMETRY );
202  }
203 
204  canvas()->Refresh();
205 
206  return 0;
207 }
208 
209 
211 {
212  auto opts = displayOptions();
213 
214  Flip( opts.m_DisplayDrawItemsFill );
215  m_frame->SetDisplayOptions( opts );
216  view()->UpdateDisplayOptions( opts );
217 
218  for( auto item : board()->Drawings() )
219  {
220  view()->Update( item, KIGFX::GEOMETRY );
221  }
222 
223  canvas()->Refresh();
224 
225  return 0;
226 }
227 
228 
230 {
231  auto opts = displayOptions();
232 
233  Flip( opts.m_DisplayModEdgeFill );
234  m_frame->SetDisplayOptions( opts );
235  view()->UpdateDisplayOptions( opts );
236 
237  for( auto module : board()->Modules() )
238  {
239  for( auto item : module->GraphicalItems() )
240  {
241  if( item->Type() == PCB_MODULE_EDGE_T )
242  view()->Update( item, KIGFX::GEOMETRY );
243  }
244  }
245 
246  canvas()->Refresh();
247 
248  return 0;
249 }
250 
251 
253 {
254  auto opts = displayOptions();
255 
256  Flip( opts.m_DisplayModTextFill );
257  m_frame->SetDisplayOptions( opts );
258  view()->UpdateDisplayOptions( opts );
259 
260  for( auto module : board()->Modules() )
261  {
264 
265  for( auto item : module->GraphicalItems() )
266  {
267  if( item->Type() == PCB_MODULE_TEXT_T )
268  view()->Update( item, KIGFX::GEOMETRY );
269  }
270  }
271 
272  canvas()->Refresh();
273 
274  return 0;
275 }
276 
277 
279 {
280  auto opts = displayOptions();
281 
282  // Apply new display options to the GAL canvas
284  opts.m_DisplayZonesMode = 0;
285  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
286  opts.m_DisplayZonesMode = 1;
287  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
288  opts.m_DisplayZonesMode = 2;
289  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
290  opts.m_DisplayZonesMode = ( opts.m_DisplayZonesMode + 1 ) % 3;
291  else
292  wxFAIL;
293 
294  m_frame->SetDisplayOptions( opts );
295  view()->UpdateDisplayOptions( opts );
296 
297  for( int i = 0; i < board()->GetAreaCount(); ++i )
298  view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
299 
300  canvas()->Refresh();
301 
302  return 0;
303 }
304 
305 
307 {
308  auto opts = displayOptions();
309 
310  Flip( opts.m_ContrastModeDisplay );
311  m_frame->SetDisplayOptions( opts );
312  view()->UpdateDisplayOptions( opts );
314 
315  return 0;
316 }
317 
318 
319 // Layer control
321 {
323 
324  return 0;
325 }
326 
327 
329 {
330  PCB_BASE_FRAME* editFrame = m_frame;
331  BOARD* brd = board();
332  LAYER_NUM layer = editFrame->GetActiveLayer();
333  LAYER_NUM startLayer = layer;
334 
335  if( layer < F_Cu || layer > B_Cu )
336  return 0;
337 
338  while( startLayer != ++layer )
339  {
340  if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
341  break;
342 
343  if( layer >= B_Cu )
344  layer = F_Cu - 1;
345  }
346 
347  wxCHECK( IsCopperLayer( layer ), 0 );
348  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
349 
350  return 0;
351 }
352 
353 
355 {
356  PCB_BASE_FRAME* editFrame = m_frame;
357  BOARD* brd = board();
358  LAYER_NUM layer = editFrame->GetActiveLayer();
359  LAYER_NUM startLayer = layer;
360 
361  if( layer < F_Cu || layer > B_Cu )
362  return 0;
363 
364  while( startLayer != --layer )
365  {
366  if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
367  && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
368  break;
369 
370  if( layer <= F_Cu )
371  layer = B_Cu + 1;
372  }
373 
374 
375  wxCHECK( IsCopperLayer( layer ), 0 );
376  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
377 
378  return 0;
379 }
380 
381 
383 {
384  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
385  PCB_SCREEN* screen = m_frame->GetScreen();
386 
387  if( currentLayer == screen->m_Route_Layer_TOP )
389  else
391 
392  return 0;
393 }
394 
395 
396 // It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
397 // set in wxFormBuilder.
398 #define ALPHA_MIN 0.20
399 #define ALPHA_MAX 1.00
400 #define ALPHA_STEP 0.05
401 
403 {
404  auto& settings = m_frame->Settings().Colors();
405 
406  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
407  KIGFX::COLOR4D currentColor = settings.GetLayerColor( currentLayer );
408 
409  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
410  {
411  currentColor.a += ALPHA_STEP;
412  settings.SetLayerColor( currentLayer, currentColor );
413 
415  view->GetPainter()->GetSettings()->ImportLegacyColors( &settings );
416  view->UpdateLayerColor( currentLayer );
417 
418  wxUpdateUIEvent dummy;
419  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
420  }
421  else
422  wxBell();
423 
424  return 0;
425 }
426 
427 
429 {
430  auto& settings = m_frame->Settings().Colors();
431 
432  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
433  KIGFX::COLOR4D currentColor = settings.GetLayerColor( currentLayer );
434 
435  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
436  {
437  currentColor.a -= ALPHA_STEP;
438  settings.SetLayerColor( currentLayer, currentColor );
439 
441  view->GetPainter()->GetSettings()->ImportLegacyColors( &settings );
442  view->UpdateLayerColor( currentLayer );
443 
444  wxUpdateUIEvent dummy;
445  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
446  }
447  else
448  wxBell();
449 
450  return 0;
451 }
452 
453 
454 // Grid control
456 {
458  updateGrid();
459  return 0;
460 }
461 
462 
464 {
466  updateGrid();
467  return 0;
468 }
469 
470 
472  BOARD_ITEM* originViewItem, const VECTOR2D& aPoint )
473 {
474  aFrame->SetGridOrigin( wxPoint( aPoint.x, aPoint.y ) );
475  aView->GetGAL()->SetGridOrigin( aPoint );
476  originViewItem->SetPosition( wxPoint( aPoint.x, aPoint.y ) );
477  aView->MarkDirty();
478  aFrame->OnModify();
479 }
480 
481 
483 {
484  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
485 
486  if( origin )
487  {
488  // We can't undo the other grid dialog settings, so no sense undoing just the origin
489  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
490  delete origin;
491  }
492  else
493  {
494  if( m_editModules && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
495  return 0;
496 
497  std::string tool = aEvent.GetCommandStr().get();
499 
500  // Deactivate other tools; particularly important if another PICKER is currently running
501  Activate();
502 
503  picker->SetClickHandler(
504  [this] ( const VECTOR2D& pt ) -> bool
505  {
507  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
508  return false; // drill origin is a one-shot; don't continue with tool
509  } );
510 
511  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
512  }
513 
514  return 0;
515 }
516 
517 
519 {
521  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
522  return 0;
523 }
524 
525 
526 #define HITTEST_THRESHOLD_PIXELS 5
527 
528 
530 {
532  return 0;
533 
534  std::string tool = aEvent.GetCommandStr().get();
536 
537  m_pickerItem = nullptr;
539 
540  // Deactivate other tools; particularly important if another PICKER is currently running
541  Activate();
542 
543  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
544 
545  picker->SetClickHandler(
546  [this] ( const VECTOR2D& aPosition ) -> bool
547  {
548  if( m_pickerItem )
549  {
551  {
552  STATUS_TEXT_POPUP statusPopup( m_frame );
553  statusPopup.SetText( _( "Item locked." ) );
554  statusPopup.PopupFor( 2000 );
555  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
556  return true;
557  }
558 
559  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
560  selectionTool->UnbrightenItem( m_pickerItem );
561  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
563  m_pickerItem = nullptr;
564  }
565 
566  return true;
567  } );
568 
569  picker->SetMotionHandler(
570  [this] ( const VECTOR2D& aPos )
571  {
572  BOARD* board = m_frame->GetBoard();
573  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
575  GENERAL_COLLECTOR collector;
576  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
577 
578  if( m_editModules )
579  collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
580  else
581  collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
582 
583  // Remove unselectable items
584  for( int i = collector.GetCount() - 1; i >= 0; --i )
585  {
586  if( !selectionTool->Selectable( collector[ i ] ) )
587  collector.Remove( i );
588  }
589 
590  if( collector.GetCount() > 1 )
591  selectionTool->GuessSelectionCandidates( collector, aPos );
592 
593  BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
594 
595  if( m_pickerItem != item )
596  {
597 
598  if( m_pickerItem )
599  selectionTool->UnbrightenItem( m_pickerItem );
600 
601  m_pickerItem = item;
602 
603  if( m_pickerItem )
604  selectionTool->BrightenItem( m_pickerItem );
605  }
606  } );
607 
608  picker->SetFinalizeHandler(
609  [this] ( const int& aFinalState )
610  {
611  if( m_pickerItem )
613  } );
614 
615  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
616 
617  return 0;
618 }
619 
620 
621 int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
622 {
623  CLIPBOARD_IO pi;
624  BOARD_ITEM* clipItem = pi.Parse();
625 
626  if( !clipItem )
627  return 0;
628 
629  if( clipItem->Type() == PCB_T )
630  static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
631 
632  bool editModules = m_editModules || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
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  wxLogDebug( wxT( "Attempting to paste to empty module editor window\n") );
640  return 0;
641  }
642 
643  switch( clipItem->Type() )
644  {
645  case PCB_T:
646  {
647  BOARD* clipBoard = static_cast<BOARD*>( clipItem );
648 
649  if( editModules )
650  {
651  MODULE* editModule = board()->GetFirstModule();
652  std::vector<BOARD_ITEM*> pastedItems;
653 
654  for( MODULE* clipModule : clipBoard->Modules() )
655  {
656  clipModule->SetParent( board() );
657 
658  for( auto pad : clipModule->Pads() )
659  {
660  pad->SetParent( editModule );
661  pastedItems.push_back( pad );
662  }
663 
664  clipModule->Pads().clear();
665 
666  for( auto item : clipModule->GraphicalItems() )
667  {
668  item->SetParent( editModule );
669  pastedItems.push_back( item );
670  }
671 
672  clipModule->GraphicalItems().clear();
673  }
674 
675  for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
676  {
677  if( clipDrawItem->Type() == PCB_LINE_T )
678  {
679  DRAWSEGMENT* clipDrawSeg = static_cast<DRAWSEGMENT*>( clipDrawItem );
680 
681  // Convert to PCB_MODULE_EDGE_T
682  EDGE_MODULE* pastedDrawSeg = new EDGE_MODULE( editModule );
683  static_cast<DRAWSEGMENT*>( pastedDrawSeg )->SwapData( clipDrawSeg );
684  pastedDrawSeg->SetLocalCoord();
685 
686  pastedItems.push_back( pastedDrawSeg );
687  }
688  else if( clipDrawItem->Type() == PCB_TEXT_T )
689  {
690  TEXTE_PCB* clipTextItem = static_cast<TEXTE_PCB*>( clipDrawItem );
691 
692  // Convert to PCB_MODULE_TEXT_T
693  TEXTE_MODULE* pastedTextItem = new TEXTE_MODULE( editModule );
694  static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
695  static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
696 
697  pastedItems.push_back( pastedTextItem );
698  }
699  }
700 
701  delete clipBoard;
702 
703  placeBoardItems( pastedItems, true, true );
704  }
705  else
706  {
707  placeBoardItems( clipBoard, true );
708 
709  m_frame->Compile_Ratsnest( true );
711  }
712 
713  break;
714  }
715 
716  case PCB_MODULE_T:
717  {
718  MODULE* clipModule = static_cast<MODULE*>( clipItem );
719  std::vector<BOARD_ITEM*> pastedItems;
720 
721  if( editModules )
722  {
723  MODULE* editModule = board()->GetFirstModule();
724 
725  for( auto pad : clipModule->Pads() )
726  {
727  pad->SetParent( editModule );
728  pastedItems.push_back( pad );
729  }
730 
731  clipModule->Pads().clear();
732 
733  for( auto item : clipModule->GraphicalItems() )
734  {
735  item->SetParent( editModule );
736  pastedItems.push_back( item );
737  }
738 
739  clipModule->GraphicalItems().clear();
740 
741  delete clipModule;
742  }
743  else
744  {
745  clipModule->SetParent( board() );
746  pastedItems.push_back( clipModule );
747  }
748 
749  placeBoardItems( pastedItems, true, true );
750  break;
751  }
752 
753  default:
754  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
755  break;
756  }
757 
758  return 1;
759 }
760 
761 
763 {
764  int open_ctl;
765  wxString fileName;
766 
767  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
768 
769  if( !editFrame )
770  return 1;
771 
772  // Pick a file to append
773  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
774  return 1;
775 
776  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
777  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
778 
779  return AppendBoard( *pi, fileName );
780 }
781 
782 
783 // Helper function for PCBNEW_CONTROL::placeBoardItems()
784 template<typename T>
785 static void moveNoFlagToVector( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
786 {
787  std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
788  [](T aItem)
789  {
790  bool retval = ( aItem->GetFlags() & FLAG0 ) == 0;
791  aItem->ClearFlags( FLAG0 );
792  return retval;
793  } );
794 
795  if( aIsNew )
796  aList.clear();
797 }
798 
799 
800 static void moveNoFlagToVector( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
801 {
802  if( aList.size() == 0 )
803  return;
804 
805  auto obj = aList.front();
806  int idx = 0;
807 
808  if( aIsNew )
809  {
810  obj = aList.back();
811  aList.pop_back();
812  }
813 
814  for( ; obj ; )
815  {
816  if( obj->HasFlag( FLAG0 ) )
817  obj->ClearFlags( FLAG0 );
818  else
819  aTarget.push_back( obj );
820 
821  if( aIsNew )
822  {
823  if( aList.size() )
824  {
825  obj = aList.back();
826  aList.pop_back();
827  }
828  else
829  obj = nullptr;
830  }
831  else
832  obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
833  }
834 }
835 
836 
837 
838 int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
839 {
840  // items are new if the current board is not the board source
841  bool isNew = board() != aBoard;
842  std::vector<BOARD_ITEM*> items;
843 
844  moveNoFlagToVector( aBoard->Tracks(), items, isNew );
845  moveNoFlagToVector( aBoard->Modules(), items, isNew );
846  moveNoFlagToVector( aBoard->Drawings(), items, isNew );
847  moveNoFlagToVector( aBoard->Zones(), items, isNew );
848 
849  return placeBoardItems( items, isNew, aAnchorAtOrigin );
850 }
851 
852 
853 int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
854  bool aAnchorAtOrigin )
855 {
857 
858  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
859  auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
860 
861  PCBNEW_SELECTION& selection = selectionTool->GetSelection();
862 
863  for( auto item : aItems )
864  {
865  item->SetSelected();
866  selection.Add( item );
867 
868  // Add or just select items for the move/place command
869  if( aIsNew )
870  editTool->GetCurrentCommit()->Add( item );
871  else
872  editTool->GetCurrentCommit()->Added( item );
873  }
874 
875  if( selection.Size() > 0 )
876  {
877  if( aAnchorAtOrigin )
878  {
880  }
881  else
882  {
883  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
885  }
886 
887  getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
888 
891  }
892 
893  return 0;
894 }
895 
896 
897 int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
898 {
899  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
900 
901  if( !editFrame )
902  return 1;
903 
904  BOARD* brd = board();
905 
906  if( !brd )
907  return 1;
908 
909  // Mark existing items, in order to know what are the new items so we can select only
910  // the new items after loading
911  for( auto track : brd->Tracks() )
912  track->SetFlags( FLAG0 );
913 
914  for( auto module : brd->Modules() )
915  module->SetFlags( FLAG0 );
916 
917  for( auto drawing : brd->Drawings() )
918  drawing->SetFlags( FLAG0 );
919 
920  for( auto zone : brd->Zones() )
921  zone->SetFlags( FLAG0 );
922 
923  // Keep also the count of copper layers, to adjust if necessary
924  int initialCopperLayerCount = brd->GetCopperLayerCount();
925  LSET initialEnabledLayers = brd->GetEnabledLayers();
926 
927  // Load the data
928  try
929  {
930  PROPERTIES props;
931  char xbuf[30];
932  char ybuf[30];
933 
934  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
935  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
936  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
937 
938  props["page_width"] = xbuf;
939  props["page_height"] = ybuf;
940 
941  editFrame->GetDesignSettings().m_NetClasses.Clear();
942  pi.Load( fileName, brd, &props );
943  }
944  catch( const IO_ERROR& ioe )
945  {
946  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
947  DisplayError( editFrame, msg );
948 
949  return 0;
950  }
951 
952  // rebuild nets and ratsnest before any use of nets
953  brd->BuildListOfNets();
955  brd->BuildConnectivity();
956 
957  // Synchronize layers
958  // we should not ask PLUGINs to do these items:
959  int copperLayerCount = brd->GetCopperLayerCount();
960 
961  if( copperLayerCount > initialCopperLayerCount )
962  brd->SetCopperLayerCount( copperLayerCount );
963 
964  // Enable all used layers, and make them visible:
965  LSET enabledLayers = brd->GetEnabledLayers();
966  enabledLayers |= initialEnabledLayers;
967  brd->SetEnabledLayers( enabledLayers );
968  brd->SetVisibleLayers( enabledLayers );
969 
970  return placeBoardItems( brd, false );
971 }
972 
973 
974 int PCBNEW_CONTROL::Undo( const TOOL_EVENT& aEvent )
975 {
976  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
977  wxCommandEvent dummy;
978 
979  if( editFrame )
980  editFrame->RestoreCopyFromUndoList( dummy );
981 
982  return 0;
983 }
984 
985 
986 int PCBNEW_CONTROL::Redo( const TOOL_EVENT& aEvent )
987 {
988  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
989  wxCommandEvent dummy;
990 
991  if( editFrame )
992  editFrame->RestoreCopyFromRedoList( dummy );
993 
994  return 0;
995 }
996 
997 
999 {
1000  EDA_3D_VIEWER* draw3DFrame = m_frame->CreateAndShow3D_Frame();
1001 
1002  // Suppress warnings on non-Mac systems
1003  [&draw3DFrame] {}();
1004 
1008  {
1009  m_frame->Update3DView( true );
1010 
1011 #ifdef __WXMAC__
1012  // A stronger version of Raise() which promotes the window to its parent's level.
1013  draw3DFrame->ReparentQuasiModal();
1014 #endif
1015  }
1016 
1017  return 0;
1018 }
1019 
1020 
1022 {
1023  BASE_SCREEN* screen = m_frame->GetScreen();
1024  getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
1026 }
1027 
1028 
1030 {
1032  PCBNEW_SELECTION& selection = selTool->GetSelection();
1033 
1034  if( selection.GetSize() == 1 )
1035  {
1036  EDA_ITEM* item = selection.Front();
1037  MSG_PANEL_ITEMS msgItems;
1038 
1039  item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems );
1040  m_frame->SetMsgPanel( msgItems );
1041  }
1042  else if( selection.GetSize() > 1 )
1043  {
1044  MSG_PANEL_ITEMS msgItems;
1045  wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
1046 
1047  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
1048  m_frame->SetMsgPanel( msgItems );
1049  }
1050  else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
1051  {
1052  MODULE* footprint = static_cast<MODULE*>( editFrame->GetModel() );
1053 
1054  if( !footprint )
1055  return 0;
1056 
1057  MSG_PANEL_ITEMS msgItems;
1058  wxString msg;
1059 
1060  msg = footprint->GetFPID().GetLibNickname().wx_str();
1061  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg, DARKCYAN ) );
1062 
1063  msg = footprint->GetFPID().GetLibItemName().wx_str();
1064  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg, DARKCYAN ) );
1065 
1066  wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
1067 
1068  if( footprint->GetLastEditTime() && date.IsValid() )
1069  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
1070  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
1071  else
1072  msg = _( "Unknown" );
1073 
1074  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
1075 
1076  msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
1077  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
1078 
1079  wxString doc, keyword;
1080  doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
1081  keyword.Printf( _( "Key Words: %s" ), footprint->GetKeywords() );
1082  msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
1083 
1084  m_frame->SetMsgPanel( msgItems );
1085  }
1086  else
1087  {
1089  }
1090 
1091  return 0;
1092 }
1093 
1094 
1096 {
1099  Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
1100  Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1101 
1102  // Display modes
1116 
1117  // Layer control
1155 
1156  // Grid control
1161 
1162  Go( &PCBNEW_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1163  Go( &PCBNEW_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1164 
1165  // Miscellaneous
1168 
1169  // Append control
1171 
1172  Go( &PCBNEW_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1173 
1178 }
1179 
1180 
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:73
Definition: colors.h:57
timestamp_t GetLastEditTime() const
Definition: class_module.h:349
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:268
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:263
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Function RestoreCopyFromUndoList Undo the last edit:
Definition: undo_redo.cpp:332
static TOOL_ACTION show3DViewer
Definition: actions.h:148
void BuildListOfNets()
Definition: class_board.h:716
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:279
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:197
int PadDisplayMode(const TOOL_EVENT &aEvent)
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
TEXTE_MODULE & Reference()
Definition: class_module.h:477
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:103
int m_Threshold
Definition: collector.h:68
static TOOL_ACTION layerNext
Definition: pcb_actions.h:269
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
int ToggleRatsnest(const TOOL_EVENT &aEvent)
Definition: typeinfo.h:85
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:239
BOARD * board() const
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:242
virtual void SetPosition(const wxPoint &aPos)=0
void SetGridOrigin(const wxPoint &aPoint) override
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:198
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:91
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:74
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:243
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:244
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:245
int AddLibrary(const TOOL_EVENT &aEvent)
VIEW_CONTROLS class definition.
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:258
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:226
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:272
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:480
static void moveNoFlagToVector(std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
static TOOL_ACTION gridResetOrigin
Definition: actions.h:130
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:233
SELECTION_TOOL.
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
void SetFastGrid2()
Function SetFastGrid2()
#define ALPHA_MIN
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int Quit(const TOOL_EVENT &aEvent)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:271
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
PADS & Pads()
Definition: class_module.h:173
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:232
int HighContrastMode(const TOOL_EVENT &aEvent)
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:109
int ModuleEdgeOutlines(const TOOL_EVENT &aEvent)
int LayerPrev(const TOOL_EVENT &aEvent)
static TOOL_ACTION gridFast1
Definition: actions.h:125
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:219
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
static TOOL_ACTION print
Definition: actions.h:60
DRAWINGS & GraphicalItems()
Definition: class_module.h:183
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
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void setTransitions() override
Sets up handlers for various events.
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:240
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:261
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:248
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:145
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:201
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
void RedrawRatsnest()
Forces refresh of the ratsnest visual representation
Definitions for tracks, vias and zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
Auxiliary rendering target (noncached)
Definition: definitions.h:49
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
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION layerTop
Definition: pcb_actions.h:237
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
static TOOL_ACTION pickerTool
Definition: actions.h:145
void SetFastGrid1()
Function SetFastGrid1()
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:577
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:260
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:116
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
Definition: netclass.cpp:155
class MODULE, a footprint
Definition: typeinfo.h:89
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:244
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:413
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:234
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:304
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
Generic tool for picking a point.
static TOOL_ACTION gridFast2
Definition: actions.h:126
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:948
void UnbrightenItem(BOARD_ITEM *aItem)
LSET is a set of PCB_LAYER_IDs.
#define ALPHA_STEP
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:250
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:113
const PCBNEW_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:270
#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:33
EDA_3D_VIEWER * CreateAndShow3D_Frame()
Shows the 3D view frame.
MODULES & Modules()
Definition: class_board.h:226
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
virtual void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings)
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: painter.h:67
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
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:476
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:262
int GraphicDisplayMode(const TOOL_EVENT &aEvent)
PCB_GENERAL_SETTINGS & Settings()
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:255
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
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)
int Show3DViewer(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:267
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:275
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:266
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:46
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:247
static const TOOL_EVENT ClearedEvent
Definition: actions.h:199
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
int GridFast1(const TOOL_EVENT &aEvent)
virtual void Move(const wxPoint &aWhere)
virtual COLOR4D GetGridColor()
virtual void PopupFor(int aMsecs)
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:252
EDIT_TOOL.
Definition: edit_tool.h:66
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:225
static TOOL_ACTION newLibrary
Definition: actions.h:51
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:265
#define FLAG0
Pcbnew: flag used in local computations.
Definition: base_struct.h:137
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
int ModuleTextOutlines(const TOOL_EVENT &aEvent)
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:264
static TOOL_ACTION moduleEdgeOutlines
Display module edges as outlines.
Definition: pcb_actions.h:369
COLORS_DESIGN_SETTINGS & Colors()
virtual void SetHighContrastLayer(int aLayer) override
const PCB_DISPLAY_OPTIONS & displayOptions() const
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
virtual const wxPoint GetPosition() const =0
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:254
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:257
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:228
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
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:777
static TOOL_ACTION moduleTextOutlines
Display module texts as lines.
Definition: pcb_actions.h:372
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
void SetLocalCoord()
Set relative coordinates from draw coordinates.
#define ALPHA_MAX
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
static TOOL_ACTION redo
Definition: actions.h:68
const wxString & GetDescription() const
Definition: class_module.h:222
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:259
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:449
int LayerAlphaDec(const TOOL_EVENT &aEvent)
virtual bool IsLocked() const
Function IsLocked.
ZONE_CONTAINERS & Zones()
Definition: class_board.h:240
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:101
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one.
Definition: netclass.h:242
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:205
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:160
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:31
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:58
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:361
PLUGIN is a base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:271
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:251
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:246
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:126
virtual void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0))=0
Function SaveCopyInUndoList (virtual pure) Creates a new entry in undo list of commands.
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:61
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:163
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.
static TOOL_ACTION graphicDisplayMode
Definition: pcb_actions.h:230
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:253
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:75
int DeleteItemCursor(const TOOL_EVENT &aEvent)
int Undo(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:241
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:56
int GridFast2(const TOOL_EVENT &aEvent)
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:346
virtual void GetMsgPanelInfo(EDA_UNITS aUnits, 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:318
Module description (excepted pads)
Definition: colors.h:45
BOARD * GetBoard() const
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
static TOOL_ACTION gridSetOrigin
Definition: actions.h:129
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:385
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:256
void BrightenItem(BOARD_ITEM *aItem)
virtual void Update3DView(bool aForceReload, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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)
void updateGrid()
Applies the legacy canvas grid settings for GAL.
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:238
int AppendBoard(PLUGIN &pi, wxString &fileName)
static TOOL_ACTION highContrastMode
Definition: actions.h:99
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:235
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
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:217
int Print(const TOOL_EVENT &aEvent)
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:610
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
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:45
EDA_ITEM * Front() const
Definition: selection.h:183
void DisplayToolMsg(const wxString &msg) override
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:249
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
Color has changed.
Definition: view_item.h:57
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:273
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:231
Definition: colors.h:62