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 <pcbnew_settings.h>
52 #include <properties.h>
54 #include <tool/tool_manager.h>
55 #include <view/view_controls.h>
56 #include <functional>
57 #include <footprint_viewer_frame.h>
58 #include <footprint_edit_frame.h>
59 #include <math/util.h> // for KiROUND
60 
61 using namespace std::placeholders;
62 
63 
64 // files.cpp
65 extern bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName,
66  bool aKicadFilesOnly = false );
67 extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
68 
69 
71  PCB_TOOL_BASE( "pcbnew.Control" ),
72  m_frame( nullptr ),
73  m_pickerItem( nullptr )
74 {
75  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
76 }
77 
78 
80 {
81 }
82 
83 
85 {
86  m_frame = getEditFrame<PCB_BASE_FRAME>();
87 
88  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
89  {
90  m_gridOrigin->SetPosition( board()->GetGridOrigin() );
91  m_gridOrigin->SetColor( m_frame->GetGridColor() );
92  getView()->Remove( m_gridOrigin.get() );
93  getView()->Add( m_gridOrigin.get() );
94  }
95 }
96 
97 
99 {
101  {
102  if( aEvent.IsAction( &ACTIONS::newLibrary ) )
103  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
104  else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
105  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
106  }
107 
108  return 0;
109 }
110 
111 
112 int PCBNEW_CONTROL::Quit( const TOOL_EVENT& aEvent )
113 {
114  m_frame->Close( false );
115  return 0;
116 }
117 
118 
119 template<class T> void Flip( T& aValue )
120 {
121  aValue = !aValue;
122 }
123 
125 {
126  auto opts = displayOptions();
127 
128  Flip( opts.m_DisplayPcbTrackFill );
129  m_frame->SetDisplayOptions( opts );
130  view()->UpdateDisplayOptions( opts );
131 
132  for( auto track : board()->Tracks() )
133  {
134  if( track->Type() == PCB_TRACE_T )
135  view()->Update( track, KIGFX::GEOMETRY );
136  }
137 
138  canvas()->Refresh();
139 
140  return 0;
141 }
142 
143 
145 {
146  auto opts = displayOptions();
147 
148  if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
149  {
150  // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
151  Flip( opts.m_ShowGlobalRatsnest );
152  m_frame->SetDisplayOptions( opts );
153  view()->UpdateDisplayOptions( opts );
154  getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
155  opts.m_ShowGlobalRatsnest );
156 
157  }
158  else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
159  {
160  Flip( opts.m_DisplayRatsnestLinesCurved );
161  m_frame->SetDisplayOptions( opts );
162  view()->UpdateDisplayOptions( opts );
163  }
164 
165  canvas()->RedrawRatsnest();
166  canvas()->Refresh();
167 
168  return 0;
169 }
170 
171 
173 {
174  auto opts = displayOptions();
175 
176  Flip( opts.m_DisplayPadFill );
177  m_frame->SetDisplayOptions( opts );
178  view()->UpdateDisplayOptions( opts );
179 
180  for( auto module : board()->Modules() ) // fixme: move to PCB_VIEW
181  {
182  for( auto pad : module->Pads() )
183  view()->Update( pad, KIGFX::GEOMETRY );
184  }
185 
186  canvas()->Refresh();
187 
188  return 0;
189 }
190 
191 
193 {
194  auto opts = displayOptions();
195 
196  Flip( opts.m_DisplayViaFill );
197  view()->UpdateDisplayOptions( opts );
198  m_frame->SetDisplayOptions( opts );
199 
200  for( auto track : board()->Tracks() )
201  {
202  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
203  view()->Update( track, KIGFX::GEOMETRY );
204  }
205 
206  canvas()->Refresh();
207 
208  return 0;
209 }
210 
211 
213 {
214  auto opts = displayOptions();
215 
216  Flip( opts.m_DisplayDrawItemsFill );
217  m_frame->SetDisplayOptions( opts );
218  view()->UpdateDisplayOptions( opts );
219 
220  for( auto item : board()->Drawings() )
221  {
222  view()->Update( item, KIGFX::GEOMETRY );
223  }
224 
225  canvas()->Refresh();
226 
227  return 0;
228 }
229 
230 
232 {
233  auto opts = displayOptions();
234 
235  Flip( opts.m_DisplayModEdgeFill );
236  m_frame->SetDisplayOptions( opts );
237  view()->UpdateDisplayOptions( opts );
238 
239  for( auto module : board()->Modules() )
240  {
241  for( auto item : module->GraphicalItems() )
242  {
243  if( item->Type() == PCB_MODULE_EDGE_T )
244  view()->Update( item, KIGFX::GEOMETRY );
245  }
246  }
247 
248  canvas()->Refresh();
249 
250  return 0;
251 }
252 
253 
255 {
256  auto opts = displayOptions();
257 
258  Flip( opts.m_DisplayModTextFill );
259  m_frame->SetDisplayOptions( opts );
260  view()->UpdateDisplayOptions( opts );
261 
262  for( auto module : board()->Modules() )
263  {
266 
267  for( auto item : module->GraphicalItems() )
268  {
269  if( item->Type() == PCB_MODULE_TEXT_T )
270  view()->Update( item, KIGFX::GEOMETRY );
271  }
272  }
273 
274  canvas()->Refresh();
275 
276  return 0;
277 }
278 
279 
281 {
282  auto opts = displayOptions();
283 
284  // Apply new display options to the GAL canvas
286  opts.m_DisplayZonesMode = 0;
287  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
288  opts.m_DisplayZonesMode = 1;
289  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
290  opts.m_DisplayZonesMode = 2;
291  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
292  opts.m_DisplayZonesMode = ( opts.m_DisplayZonesMode + 1 ) % 3;
293  else
294  wxFAIL;
295 
296  m_frame->SetDisplayOptions( opts );
297  view()->UpdateDisplayOptions( opts );
298 
299  for( int i = 0; i < board()->GetAreaCount(); ++i )
300  view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
301 
302  canvas()->Refresh();
303 
304  return 0;
305 }
306 
307 
309 {
310  auto opts = displayOptions();
311 
312  Flip( opts.m_ContrastModeDisplay );
313  m_frame->SetDisplayOptions( opts );
314  view()->UpdateDisplayOptions( opts );
316 
317  return 0;
318 }
319 
320 
321 // Layer control
323 {
325 
326  return 0;
327 }
328 
329 
331 {
332  PCB_BASE_FRAME* editFrame = m_frame;
333  BOARD* brd = board();
334  LAYER_NUM layer = editFrame->GetActiveLayer();
335  LAYER_NUM startLayer = layer;
336 
337  if( layer < F_Cu || layer > B_Cu )
338  return 0;
339 
340  while( startLayer != ++layer )
341  {
342  if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
343  break;
344 
345  if( layer >= B_Cu )
346  layer = F_Cu - 1;
347  }
348 
349  wxCHECK( IsCopperLayer( layer ), 0 );
350  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
351 
352  return 0;
353 }
354 
355 
357 {
358  PCB_BASE_FRAME* editFrame = m_frame;
359  BOARD* brd = board();
360  LAYER_NUM layer = editFrame->GetActiveLayer();
361  LAYER_NUM startLayer = layer;
362 
363  if( layer < F_Cu || layer > B_Cu )
364  return 0;
365 
366  while( startLayer != --layer )
367  {
368  if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
369  && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
370  break;
371 
372  if( layer <= F_Cu )
373  layer = B_Cu + 1;
374  }
375 
376 
377  wxCHECK( IsCopperLayer( layer ), 0 );
378  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
379 
380  return 0;
381 }
382 
383 
385 {
386  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
387  PCB_SCREEN* screen = m_frame->GetScreen();
388 
389  if( currentLayer == screen->m_Route_Layer_TOP )
391  else
393 
394  return 0;
395 }
396 
397 
398 // It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
399 // set in wxFormBuilder.
400 #define ALPHA_MIN 0.20
401 #define ALPHA_MAX 1.00
402 #define ALPHA_STEP 0.05
403 
405 {
406  auto settings = m_frame->ColorSettings();
407 
408  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
409  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
410 
411  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
412  {
413  currentColor.a += ALPHA_STEP;
414  settings->SetColor( currentLayer, currentColor );
416 
418  view->UpdateLayerColor( currentLayer );
419 
420  wxUpdateUIEvent dummy;
421  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
422  }
423  else
424  wxBell();
425 
426  return 0;
427 }
428 
429 
431 {
432  auto settings = m_frame->ColorSettings();
433 
434  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
435  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
436 
437  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
438  {
439  currentColor.a -= ALPHA_STEP;
440  settings->SetColor( currentLayer, currentColor );
442 
444  view->UpdateLayerColor( currentLayer );
445 
446  wxUpdateUIEvent dummy;
447  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
448  }
449  else
450  wxBell();
451 
452  return 0;
453 }
454 
455 
456 // Grid control
458 {
460  updateGrid();
461  return 0;
462 }
463 
464 
466 {
468  updateGrid();
469  return 0;
470 }
471 
472 
474  BOARD_ITEM* originViewItem, const VECTOR2D& aPoint )
475 {
476  aFrame->SetGridOrigin( wxPoint( aPoint.x, aPoint.y ) );
477  aView->GetGAL()->SetGridOrigin( aPoint );
478  originViewItem->SetPosition( wxPoint( aPoint.x, aPoint.y ) );
479  aView->MarkDirty();
480  aFrame->OnModify();
481 }
482 
483 
485 {
486  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
487 
488  if( origin )
489  {
490  // We can't undo the other grid dialog settings, so no sense undoing just the origin
491  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
492  delete origin;
493  }
494  else
495  {
496  if( m_editModules && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
497  return 0;
498 
499  std::string tool = aEvent.GetCommandStr().get();
501 
502  // Deactivate other tools; particularly important if another PICKER is currently running
503  Activate();
504 
505  picker->SetClickHandler(
506  [this] ( const VECTOR2D& pt ) -> bool
507  {
509  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
510  return false; // drill origin is a one-shot; don't continue with tool
511  } );
512 
513  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
514  }
515 
516  return 0;
517 }
518 
519 
521 {
523  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
524  return 0;
525 }
526 
527 
528 #define HITTEST_THRESHOLD_PIXELS 5
529 
530 
532 {
534  return 0;
535 
536  std::string tool = aEvent.GetCommandStr().get();
538 
539  m_pickerItem = nullptr;
541 
542  // Deactivate other tools; particularly important if another PICKER is currently running
543  Activate();
544 
545  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
546 
547  picker->SetClickHandler(
548  [this] ( const VECTOR2D& aPosition ) -> bool
549  {
550  if( m_pickerItem )
551  {
553  {
554  STATUS_TEXT_POPUP statusPopup( m_frame );
555  statusPopup.SetText( _( "Item locked." ) );
556  statusPopup.PopupFor( 2000 );
557  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
558  return true;
559  }
560 
561  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
562  selectionTool->UnbrightenItem( m_pickerItem );
563  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
565  m_pickerItem = nullptr;
566  }
567 
568  return true;
569  } );
570 
571  picker->SetMotionHandler(
572  [this] ( const VECTOR2D& aPos )
573  {
574  BOARD* board = m_frame->GetBoard();
575  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
577  GENERAL_COLLECTOR collector;
578  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
579 
580  if( m_editModules )
581  collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
582  else
583  collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
584 
585  // Remove unselectable items
586  for( int i = collector.GetCount() - 1; i >= 0; --i )
587  {
588  if( !selectionTool->Selectable( collector[ i ] ) )
589  collector.Remove( i );
590  }
591 
592  if( collector.GetCount() > 1 )
593  selectionTool->GuessSelectionCandidates( collector, aPos );
594 
595  BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
596 
597  if( m_pickerItem != item )
598  {
599 
600  if( m_pickerItem )
601  selectionTool->UnbrightenItem( m_pickerItem );
602 
603  m_pickerItem = item;
604 
605  if( m_pickerItem )
606  selectionTool->BrightenItem( m_pickerItem );
607  }
608  } );
609 
610  picker->SetFinalizeHandler(
611  [this] ( const int& aFinalState )
612  {
613  if( m_pickerItem )
615  } );
616 
617  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
618 
619  return 0;
620 }
621 
622 
623 void pasteModuleItemsToModEdit( MODULE* aClipModule, BOARD* aBoard,
624  std::vector<BOARD_ITEM*>& aPastedItems )
625 {
626  MODULE* editModule = aBoard->GetFirstModule();
627 
628  aClipModule->SetParent( aBoard );
629 
630  for( D_PAD* pad : aClipModule->Pads() )
631  {
632  pad->SetParent( editModule );
633  aPastedItems.push_back( pad );
634  }
635 
636  aClipModule->Pads().clear();
637 
638  for( BOARD_ITEM* item : aClipModule->GraphicalItems() )
639  {
640  if( item->Type() == PCB_MODULE_EDGE_T )
641  {
642  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );
643 
644  edge->SetParent( nullptr );
645  edge->SetLocalCoord();
646  }
647  else if( item->Type() == PCB_MODULE_TEXT_T )
648  {
649  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
650 
651  if( text->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
653 
654  if( text->GetText() == "%V" )
655  text->SetText( aClipModule->GetValue() );
656  else if( text->GetText() == "%R" )
657  text->SetText( aClipModule->GetReference() );
658 
659  text->SetTextAngle( aClipModule->GetOrientation() );
660 
661  text->SetParent( nullptr );
662  text->SetLocalCoord();
663  }
664 
665  item->SetParent( editModule );
666  aPastedItems.push_back( item );
667  }
668 
669  aClipModule->GraphicalItems().clear();
670 
671  if( !aClipModule->GetReference().IsEmpty() )
672  {
673  TEXTE_MODULE* text = new TEXTE_MODULE( aClipModule->Reference() );
675  text->SetTextAngle( aClipModule->GetOrientation() );
676 
677  text->SetParent( nullptr );
678  text->SetLocalCoord();
679 
680  text->SetParent( editModule );
681  aPastedItems.push_back( text );
682  }
683 
684  if( !aClipModule->GetValue().IsEmpty() )
685  {
686  TEXTE_MODULE* text = new TEXTE_MODULE( aClipModule->Value() );
688  text->SetTextAngle( aClipModule->GetOrientation() );
689 
690  text->SetParent( nullptr );
691  text->SetLocalCoord();
692 
693  text->SetParent( editModule );
694  aPastedItems.push_back( text );
695  }
696 }
697 
698 
699 int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
700 {
701  CLIPBOARD_IO pi;
702  BOARD_ITEM* clipItem = pi.Parse();
703 
704  if( !clipItem )
705  return 0;
706 
707  bool editModules = m_editModules || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
708 
709  if( clipItem->Type() == PCB_T )
710  {
711  if( editModules )
712  {
713  for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
714  item->SetNet( NETINFO_LIST::OrphanedItem() );
715  }
716  else
717  static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
718  }
719 
720  // The clipboard can contain two different things, an entire kicad_pcb
721  // or a single module
722 
723  if( editModules && ( !board() || !module() ) )
724  {
725  wxLogDebug( wxT( "Attempting to paste to empty module editor window\n") );
726  return 0;
727  }
728 
729  switch( clipItem->Type() )
730  {
731  case PCB_T:
732  {
733  BOARD* clipBoard = static_cast<BOARD*>( clipItem );
734 
735  if( editModules )
736  {
737  MODULE* editModule = board()->GetFirstModule();
738  std::vector<BOARD_ITEM*> pastedItems;
739 
740  for( MODULE* clipModule : clipBoard->Modules() )
741  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
742 
743  for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
744  {
745  if( clipDrawItem->Type() == PCB_LINE_T )
746  {
747  DRAWSEGMENT* clipDrawSeg = static_cast<DRAWSEGMENT*>( clipDrawItem );
748 
749  // Convert to PCB_MODULE_EDGE_T
750  EDGE_MODULE* pastedDrawSeg = new EDGE_MODULE( editModule );
751  static_cast<DRAWSEGMENT*>( pastedDrawSeg )->SwapData( clipDrawSeg );
752  pastedDrawSeg->SetLocalCoord();
753 
754  pastedItems.push_back( pastedDrawSeg );
755  }
756  else if( clipDrawItem->Type() == PCB_TEXT_T )
757  {
758  TEXTE_PCB* clipTextItem = static_cast<TEXTE_PCB*>( clipDrawItem );
759 
760  // Convert to PCB_MODULE_TEXT_T
761  TEXTE_MODULE* pastedTextItem = new TEXTE_MODULE( editModule );
762  static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
763  static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
764 
765  pastedItems.push_back( pastedTextItem );
766  }
767  }
768 
769  delete clipBoard;
770 
771  placeBoardItems( pastedItems, true, true );
772  }
773  else
774  {
775  placeBoardItems( clipBoard, true );
776 
777  m_frame->Compile_Ratsnest( true );
779  }
780 
781  break;
782  }
783 
784  case PCB_MODULE_T:
785  {
786  MODULE* clipModule = static_cast<MODULE*>( clipItem );
787  std::vector<BOARD_ITEM*> pastedItems;
788 
789  if( editModules )
790  {
791  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
792  delete clipModule;
793  }
794  else
795  {
796  clipModule->SetParent( board() );
797  pastedItems.push_back( clipModule );
798  }
799 
800  placeBoardItems( pastedItems, true, true );
801  break;
802  }
803 
804  default:
805  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
806  break;
807  }
808 
809  return 1;
810 }
811 
812 
814 {
815  int open_ctl;
816  wxString fileName;
817 
818  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
819 
820  if( !editFrame )
821  return 1;
822 
823  // Pick a file to append
824  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
825  return 1;
826 
827  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
828  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
829 
830  return AppendBoard( *pi, fileName );
831 }
832 
833 
834 // Helper function for PCBNEW_CONTROL::placeBoardItems()
835 template<typename T>
836 static void moveNoFlagToVector( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
837 {
838  std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
839  [](T aItem)
840  {
841  bool retval = ( aItem->GetFlags() & FLAG0 ) == 0;
842  aItem->ClearFlags( FLAG0 );
843  return retval;
844  } );
845 
846  if( aIsNew )
847  aList.clear();
848 }
849 
850 
851 static void moveNoFlagToVector( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
852 {
853  if( aList.size() == 0 )
854  return;
855 
856  auto obj = aList.front();
857  int idx = 0;
858 
859  if( aIsNew )
860  {
861  obj = aList.back();
862  aList.pop_back();
863  }
864 
865  for( ; obj ; )
866  {
867  if( obj->HasFlag( FLAG0 ) )
868  obj->ClearFlags( FLAG0 );
869  else
870  aTarget.push_back( obj );
871 
872  if( aIsNew )
873  {
874  if( aList.size() )
875  {
876  obj = aList.back();
877  aList.pop_back();
878  }
879  else
880  obj = nullptr;
881  }
882  else
883  obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
884  }
885 }
886 
887 
888 
889 int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
890 {
891  // items are new if the current board is not the board source
892  bool isNew = board() != aBoard;
893  std::vector<BOARD_ITEM*> items;
894 
895  moveNoFlagToVector( aBoard->Tracks(), items, isNew );
896  moveNoFlagToVector( aBoard->Modules(), items, isNew );
897  moveNoFlagToVector( aBoard->Drawings(), items, isNew );
898  moveNoFlagToVector( aBoard->Zones(), items, isNew );
899 
900  return placeBoardItems( items, isNew, aAnchorAtOrigin );
901 }
902 
903 
904 int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
905  bool aAnchorAtOrigin )
906 {
908 
909  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
910  auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
911 
912  PCBNEW_SELECTION& selection = selectionTool->GetSelection();
913 
914  for( auto item : aItems )
915  {
916  item->SetSelected();
917  selection.Add( item );
918 
919  // Add or just select items for the move/place command
920  if( aIsNew )
921  editTool->GetCurrentCommit()->Add( item );
922  else
923  editTool->GetCurrentCommit()->Added( item );
924  }
925 
926  if( selection.Size() > 0 )
927  {
928  if( aAnchorAtOrigin )
929  {
931  }
932  else
933  {
934  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
936  }
937 
938  getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
939 
942  }
943 
944  return 0;
945 }
946 
947 
948 int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
949 {
950  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
951 
952  if( !editFrame )
953  return 1;
954 
955  BOARD* brd = board();
956 
957  if( !brd )
958  return 1;
959 
960  // Mark existing items, in order to know what are the new items so we can select only
961  // the new items after loading
962  for( auto track : brd->Tracks() )
963  track->SetFlags( FLAG0 );
964 
965  for( auto module : brd->Modules() )
966  module->SetFlags( FLAG0 );
967 
968  for( auto drawing : brd->Drawings() )
969  drawing->SetFlags( FLAG0 );
970 
971  for( auto zone : brd->Zones() )
972  zone->SetFlags( FLAG0 );
973 
974  // Keep also the count of copper layers, to adjust if necessary
975  int initialCopperLayerCount = brd->GetCopperLayerCount();
976  LSET initialEnabledLayers = brd->GetEnabledLayers();
977 
978  // Load the data
979  try
980  {
981  PROPERTIES props;
982  char xbuf[30];
983  char ybuf[30];
984 
985  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
986  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
987  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
988 
989  props["page_width"] = xbuf;
990  props["page_height"] = ybuf;
991 
992  editFrame->GetDesignSettings().m_NetClasses.Clear();
993  pi.Load( fileName, brd, &props );
994  }
995  catch( const IO_ERROR& ioe )
996  {
997  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
998  DisplayError( editFrame, msg );
999 
1000  return 0;
1001  }
1002 
1003  // rebuild nets and ratsnest before any use of nets
1004  brd->BuildListOfNets();
1006  brd->BuildConnectivity();
1007 
1008  // Synchronize layers
1009  // we should not ask PLUGINs to do these items:
1010  int copperLayerCount = brd->GetCopperLayerCount();
1011 
1012  if( copperLayerCount > initialCopperLayerCount )
1013  brd->SetCopperLayerCount( copperLayerCount );
1014 
1015  // Enable all used layers, and make them visible:
1016  LSET enabledLayers = brd->GetEnabledLayers();
1017  enabledLayers |= initialEnabledLayers;
1018  brd->SetEnabledLayers( enabledLayers );
1019  brd->SetVisibleLayers( enabledLayers );
1020 
1021  return placeBoardItems( brd, false );
1022 }
1023 
1024 
1025 int PCBNEW_CONTROL::Undo( const TOOL_EVENT& aEvent )
1026 {
1027  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1028  wxCommandEvent dummy;
1029 
1030  if( editFrame )
1031  editFrame->RestoreCopyFromUndoList( dummy );
1032 
1033  return 0;
1034 }
1035 
1036 
1037 int PCBNEW_CONTROL::Redo( const TOOL_EVENT& aEvent )
1038 {
1039  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1040  wxCommandEvent dummy;
1041 
1042  if( editFrame )
1043  editFrame->RestoreCopyFromRedoList( dummy );
1044 
1045  return 0;
1046 }
1047 
1048 
1050 {
1051  EDA_3D_VIEWER* draw3DFrame = m_frame->CreateAndShow3D_Frame();
1052 
1053  // Suppress warnings on non-Mac systems
1054  [&draw3DFrame] {}();
1055 
1059  {
1060  m_frame->Update3DView( true );
1061 
1062 #ifdef __WXMAC__
1063  // A stronger version of Raise() which promotes the window to its parent's level.
1064  draw3DFrame->ReparentQuasiModal();
1065 #endif
1066  }
1067 
1068  return 0;
1069 }
1070 
1071 
1073 {
1074  BASE_SCREEN* screen = m_frame->GetScreen();
1075  getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
1077 }
1078 
1079 
1081 {
1083  PCBNEW_SELECTION& selection = selTool->GetSelection();
1084 
1085  if( selection.GetSize() == 1 )
1086  {
1087  EDA_ITEM* item = selection.Front();
1088  MSG_PANEL_ITEMS msgItems;
1089 
1090  item->GetMsgPanelInfo( m_frame->GetUserUnits(), msgItems );
1091  m_frame->SetMsgPanel( msgItems );
1092  }
1093  else if( selection.GetSize() > 1 )
1094  {
1095  MSG_PANEL_ITEMS msgItems;
1096  wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
1097 
1098  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
1099  m_frame->SetMsgPanel( msgItems );
1100  }
1101  else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
1102  {
1103  MODULE* footprint = static_cast<MODULE*>( editFrame->GetModel() );
1104 
1105  if( !footprint )
1106  return 0;
1107 
1108  MSG_PANEL_ITEMS msgItems;
1109  wxString msg;
1110 
1111  msg = footprint->GetFPID().GetLibNickname().wx_str();
1112  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg, DARKCYAN ) );
1113 
1114  msg = footprint->GetFPID().GetLibItemName().wx_str();
1115  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg, DARKCYAN ) );
1116 
1117  wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
1118 
1119  if( footprint->GetLastEditTime() && date.IsValid() )
1120  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
1121  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
1122  else
1123  msg = _( "Unknown" );
1124 
1125  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
1126 
1127  msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
1128  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
1129 
1130  wxString doc, keyword;
1131  doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
1132  keyword.Printf( _( "Key Words: %s" ), footprint->GetKeywords() );
1133  msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
1134 
1135  m_frame->SetMsgPanel( msgItems );
1136  }
1137  else
1138  {
1140  }
1141 
1142  return 0;
1143 }
1144 
1145 
1147 {
1150  Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
1151  Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1152 
1153  // Display modes
1167 
1168  // Layer control
1206 
1207  // Grid control
1212 
1213  Go( &PCBNEW_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1214  Go( &PCBNEW_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1215 
1216  // Miscellaneous
1219 
1220  // Append control
1222 
1223  Go( &PCBNEW_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1224 
1229 }
1230 
1231 
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:239
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:270
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:265
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:151
void BuildListOfNets()
Definition: class_board.h:692
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:279
double GetOrientation() const
Definition: class_module.h:215
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:201
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:66
static TOOL_ACTION layerNext
Definition: pcb_actions.h:271
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:241
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:470
BOARD * board() const
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:244
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:81
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:202
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:245
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:246
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:247
int AddLibrary(const TOOL_EVENT &aEvent)
VIEW_CONTROLS class definition.
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:260
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:228
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:274
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:535
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:133
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:235
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:218
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:273
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:234
const wxString GetValue() const
Function GetValue.
Definition: class_module.h:461
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:139
int ModuleEdgeOutlines(const TOOL_EVENT &aEvent)
int LayerPrev(const TOOL_EVENT &aEvent)
static TOOL_ACTION gridFast1
Definition: actions.h:128
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:242
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:263
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:250
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:129
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:205
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
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:436
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION layerTop
Definition: pcb_actions.h:239
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
static TOOL_ACTION pickerTool
Definition: actions.h:148
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:262
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:100
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:415
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:236
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:305
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
Generic tool for picking a point.
static TOOL_ACTION gridFast2
Definition: actions.h:129
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:919
void UnbrightenItem(BOARD_ITEM *aItem)
LSET is a set of PCB_LAYER_IDs.
#define ALPHA_STEP
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:252
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:257
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:272
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
#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:229
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
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:218
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:264
int GraphicDisplayMode(const TOOL_EVENT &aEvent)
COLOR_SETTINGS * ColorSettings()
Helper to retrieve the current color settings.
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:257
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)
TEXT_TYPE GetType() const
int Show3DViewer(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:269
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:283
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:268
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:227
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:249
static const TOOL_EVENT ClearedEvent
Definition: actions.h:203
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:254
EDIT_TOOL.
Definition: edit_tool.h:67
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
void SetType(TEXT_TYPE aType)
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:267
#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:266
static TOOL_ACTION moduleEdgeOutlines
Display module edges as outlines.
Definition: pcb_actions.h:371
void UpdateColors()
Updates the color settings in the painter and GAL.
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:256
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:259
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:230
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:231
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:374
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:222
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:261
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
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 ...
Definition: class_board.h:431
int LayerAlphaDec(const TOOL_EVENT &aEvent)
virtual bool IsLocked() const
Function IsLocked.
ZONE_CONTAINERS & Zones()
Definition: class_board.h:243
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:163
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: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:253
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:248
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:166
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:232
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:78
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:255
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:243
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:65
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
void SetTextAngle(double aAngle)
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:320
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:132
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:258
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
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:240
int AppendBoard(PLUGIN &pi, wxString &fileName)
static TOOL_ACTION highContrastMode
Definition: actions.h:99
Rendering engine changes.
Definition: tool_base.h:82
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:238
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
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:220
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:229
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:251
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:275
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:233
Definition: colors.h:62