KiCad PCB EDA Suite
pcbnew_control.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014-2016 CERN
5  * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include "edit_tool.h"
27 #include "pcb_actions.h"
28 #include "pcbnew_control.h"
29 #include "pcbnew_picker_tool.h"
30 #include "selection_tool.h"
32 #include <bitmaps.h>
33 #include <board_commit.h>
34 #include <class_board.h>
35 #include <class_board_item.h>
36 #include <class_module.h>
37 #include <class_track.h>
38 #include <class_zone.h>
39 #include <class_edge_mod.h>
40 #include <confirm.h>
42 #include <kicad_clipboard.h>
43 #include <origin_viewitem.h>
44 #include <pcb_edit_frame.h>
45 #include <pcb_painter.h>
46 #include <properties.h>
48 #include <tool/tool_manager.h>
49 #include <view/view_controls.h>
50 #include <footprint_viewer_frame.h>
51 #include <footprint_edit_frame.h>
52 
53 using namespace std::placeholders;
54 
55 
56 // files.cpp
57 extern bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName,
58  bool aKicadFilesOnly = false );
59 extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
60 
61 
63  PCB_TOOL_BASE( "pcbnew.Control" ),
64  m_frame( nullptr ),
65  m_pickerItem( nullptr )
66 {
67  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
68 }
69 
70 
72 {
73 }
74 
75 
77 {
78  m_frame = getEditFrame<PCB_BASE_FRAME>();
79 
80  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
81  {
82  m_gridOrigin->SetPosition( board()->GetDesignSettings().m_GridOrigin );
83  m_gridOrigin->SetColor( m_frame->GetGridColor() );
84  getView()->Remove( m_gridOrigin.get() );
85  getView()->Add( m_gridOrigin.get() );
86  }
87 }
88 
89 
91 {
93  {
94  if( aEvent.IsAction( &ACTIONS::newLibrary ) )
95  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->CreateNewLibrary();
96  else if( aEvent.IsAction( &ACTIONS::addLibrary ) )
97  static_cast<PCB_BASE_EDIT_FRAME*>( m_frame )->AddLibrary();
98  }
99 
100  return 0;
101 }
102 
103 
104 int PCBNEW_CONTROL::Quit( const TOOL_EVENT& aEvent )
105 {
106  m_frame->Close( false );
107  return 0;
108 }
109 
110 
111 template<class T> void Flip( T& aValue )
112 {
113  aValue = !aValue;
114 }
115 
116 
118 {
119  auto opts = displayOptions();
120 
121  Flip( opts.m_DisplayPcbTrackFill );
122  m_frame->SetDisplayOptions( opts );
123  view()->UpdateDisplayOptions( opts );
124 
125  for( auto track : board()->Tracks() )
126  {
127  if( track->Type() == PCB_TRACE_T )
128  view()->Update( track, KIGFX::GEOMETRY );
129  }
130 
131  canvas()->Refresh();
132 
133  return 0;
134 }
135 
136 
138 {
139  auto opts = displayOptions();
140 
141  if( aEvent.IsAction( &PCB_ACTIONS::showRatsnest ) )
142  {
143  // N.B. Do not disable the Ratsnest layer here. We use it for local ratsnest
144  Flip( opts.m_ShowGlobalRatsnest );
145  m_frame->SetDisplayOptions( opts );
146  view()->UpdateDisplayOptions( opts );
147  getEditFrame<PCB_EDIT_FRAME>()->SetElementVisibility( LAYER_RATSNEST,
148  opts.m_ShowGlobalRatsnest );
149 
150  }
151  else if( aEvent.IsAction( &PCB_ACTIONS::ratsnestLineMode ) )
152  {
153  Flip( opts.m_DisplayRatsnestLinesCurved );
154  m_frame->SetDisplayOptions( opts );
155  view()->UpdateDisplayOptions( opts );
156  }
157 
158  canvas()->RedrawRatsnest();
159  canvas()->Refresh();
160 
161  return 0;
162 }
163 
164 
166 {
167  auto opts = displayOptions();
168 
169  Flip( opts.m_DisplayViaFill );
170  view()->UpdateDisplayOptions( opts );
171  m_frame->SetDisplayOptions( opts );
172 
173  for( auto track : board()->Tracks() )
174  {
175  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
176  view()->Update( track, KIGFX::GEOMETRY );
177  }
178 
179  canvas()->Refresh();
180 
181  return 0;
182 }
183 
184 
186 {
187  auto opts = displayOptions();
188 
189  // Apply new display options to the GAL canvas
191  opts.m_DisplayZonesMode = 0;
192  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
193  opts.m_DisplayZonesMode = 1;
194  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
195  opts.m_DisplayZonesMode = 2;
196  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayToggle ) )
197  opts.m_DisplayZonesMode = ( opts.m_DisplayZonesMode + 1 ) % 3;
198  else
199  wxFAIL;
200 
201  m_frame->SetDisplayOptions( opts );
202  view()->UpdateDisplayOptions( opts );
203 
204  for( int i = 0; i < board()->GetAreaCount(); ++i )
205  view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
206 
207  canvas()->Refresh();
208 
209  return 0;
210 }
211 
212 
214 {
215  auto opts = displayOptions();
216 
217  Flip( opts.m_ContrastModeDisplay );
218  m_frame->SetDisplayOptions( opts );
219  view()->UpdateDisplayOptions( opts );
221 
222  return 0;
223 }
224 
225 
226 // Layer control
228 {
230 
231  // Router tool may also consume this
232  aEvent.PassEvent();
233 
234  return 0;
235 }
236 
237 
239 {
240  PCB_BASE_FRAME* editFrame = m_frame;
241  BOARD* brd = board();
242  LAYER_NUM layer = editFrame->GetActiveLayer();
243  LAYER_NUM startLayer = layer;
244 
245  if( layer < F_Cu || layer > B_Cu )
246  return 0;
247 
248  while( startLayer != ++layer )
249  {
250  if( brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) && IsCopperLayer( layer ) )
251  break;
252 
253  if( layer >= B_Cu )
254  layer = F_Cu - 1;
255  }
256 
257  wxCHECK( IsCopperLayer( layer ), 0 );
258  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
259 
260  // Router tool may also consume this
261  aEvent.PassEvent();
262 
263  return 0;
264 }
265 
266 
268 {
269  PCB_BASE_FRAME* editFrame = m_frame;
270  BOARD* brd = board();
271  LAYER_NUM layer = editFrame->GetActiveLayer();
272  LAYER_NUM startLayer = layer;
273 
274  if( layer < F_Cu || layer > B_Cu )
275  return 0;
276 
277  while( startLayer != --layer )
278  {
279  if( IsCopperLayer( layer ) // also test for valid layer id (layer >= F_Cu)
280  && brd->IsLayerVisible( static_cast<PCB_LAYER_ID>( layer ) ) )
281  break;
282 
283  if( layer <= F_Cu )
284  layer = B_Cu + 1;
285  }
286 
287 
288  wxCHECK( IsCopperLayer( layer ), 0 );
289  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
290 
291  // Router tool may also consume this
292  aEvent.PassEvent();
293 
294  return 0;
295 }
296 
297 
299 {
300  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
301  PCB_SCREEN* screen = m_frame->GetScreen();
302 
303  if( currentLayer == screen->m_Route_Layer_TOP )
305  else
307 
308  return 0;
309 }
310 
311 
312 // It'd be nice to share the min/max with the DIALOG_COLOR_PICKER, but those are
313 // set in wxFormBuilder.
314 #define ALPHA_MIN 0.20
315 #define ALPHA_MAX 1.00
316 #define ALPHA_STEP 0.05
317 
319 {
320  auto settings = m_frame->GetColorSettings();
321 
322  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
323  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
324 
325  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
326  {
327  currentColor.a += ALPHA_STEP;
328  settings->SetColor( currentLayer, currentColor );
330 
332  view->UpdateLayerColor( currentLayer );
333 
334  wxUpdateUIEvent dummy;
335  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
336  }
337  else
338  wxBell();
339 
340  return 0;
341 }
342 
343 
345 {
346  auto settings = m_frame->GetColorSettings();
347 
348  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
349  KIGFX::COLOR4D currentColor = settings->GetColor( currentLayer );
350 
351  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
352  {
353  currentColor.a -= ALPHA_STEP;
354  settings->SetColor( currentLayer, currentColor );
356 
358  view->UpdateLayerColor( currentLayer );
359 
360  wxUpdateUIEvent dummy;
361  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
362  }
363  else
364  wxBell();
365 
366  return 0;
367 }
368 
369 
370 // Grid control
372  BOARD_ITEM* originViewItem, const VECTOR2D& aPoint )
373 {
374  aFrame->GetDesignSettings().m_GridOrigin = (wxPoint) aPoint;
375  aView->GetGAL()->SetGridOrigin( aPoint );
376  originViewItem->SetPosition( (wxPoint) aPoint );
377  aView->MarkDirty();
378  aFrame->OnModify();
379 }
380 
381 
383 {
384  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
385 
386  if( origin )
387  {
388  // We can't undo the other grid dialog settings, so no sense undoing just the origin
389  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
390  delete origin;
391  }
392  else
393  {
394  if( m_editModules && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
395  return 0;
396 
397  std::string tool = aEvent.GetCommandStr().get();
399 
400  // Deactivate other tools; particularly important if another PICKER is currently running
401  Activate();
402 
403  picker->SetClickHandler(
404  [this] ( const VECTOR2D& pt ) -> bool
405  {
407  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), pt );
408  return false; // drill origin is a one-shot; don't continue with tool
409  } );
410 
411  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
412  }
413 
414  return 0;
415 }
416 
417 
419 {
421  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
422  return 0;
423 }
424 
425 
426 #define HITTEST_THRESHOLD_PIXELS 5
427 
428 
430 {
432  return 0;
433 
434  std::string tool = aEvent.GetCommandStr().get();
436 
437  m_pickerItem = nullptr;
439 
440  // Deactivate other tools; particularly important if another PICKER is currently running
441  Activate();
442 
443  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
444 
445  picker->SetClickHandler(
446  [this] ( const VECTOR2D& aPosition ) -> bool
447  {
448  if( m_pickerItem )
449  {
451  {
452  STATUS_TEXT_POPUP statusPopup( m_frame );
453  statusPopup.SetText( _( "Item locked." ) );
454  statusPopup.PopupFor( 2000 );
455  statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
456  return true;
457  }
458 
459  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
460  selectionTool->UnbrightenItem( m_pickerItem );
461  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
463  m_pickerItem = nullptr;
464  }
465 
466  return true;
467  } );
468 
469  picker->SetMotionHandler(
470  [this] ( const VECTOR2D& aPos )
471  {
472  BOARD* board = m_frame->GetBoard();
473  SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
475  GENERAL_COLLECTOR collector;
476  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
477 
478  if( m_editModules )
479  collector.Collect( board, GENERAL_COLLECTOR::ModuleItems, (wxPoint) aPos, guide );
480  else
481  collector.Collect( board, GENERAL_COLLECTOR::BoardLevelItems, (wxPoint) aPos, guide );
482 
483  // Remove unselectable items
484  for( int i = collector.GetCount() - 1; i >= 0; --i )
485  {
486  if( !selectionTool->Selectable( collector[ i ] ) )
487  collector.Remove( i );
488  }
489 
490  if( collector.GetCount() > 1 )
491  selectionTool->GuessSelectionCandidates( collector, aPos );
492 
493  BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
494 
495  if( m_pickerItem != item )
496  {
497 
498  if( m_pickerItem )
499  selectionTool->UnbrightenItem( m_pickerItem );
500 
501  m_pickerItem = item;
502 
503  if( m_pickerItem )
504  selectionTool->BrightenItem( m_pickerItem );
505  }
506  } );
507 
508  picker->SetFinalizeHandler(
509  [this] ( const int& aFinalState )
510  {
511  if( m_pickerItem )
513  } );
514 
515  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
516 
517  return 0;
518 }
519 
520 
521 void pasteModuleItemsToModEdit( MODULE* aClipModule, BOARD* aBoard,
522  std::vector<BOARD_ITEM*>& aPastedItems )
523 {
524  MODULE* editModule = aBoard->GetFirstModule();
525 
526  aClipModule->SetParent( aBoard );
527 
528  for( D_PAD* pad : aClipModule->Pads() )
529  {
530  pad->SetParent( editModule );
531  aPastedItems.push_back( pad );
532  }
533 
534  aClipModule->Pads().clear();
535 
536  for( BOARD_ITEM* item : aClipModule->GraphicalItems() )
537  {
538  if( item->Type() == PCB_MODULE_EDGE_T )
539  {
540  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );
541 
542  edge->SetParent( nullptr );
543  edge->SetLocalCoord();
544  }
545  else if( item->Type() == PCB_MODULE_TEXT_T )
546  {
547  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
548 
549  if( text->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
551 
552  if( text->GetText() == "${VALUE}" )
553  text->SetText( aClipModule->GetValue() );
554  else if( text->GetText() == "${REFERENCE}" )
555  text->SetText( aClipModule->GetReference() );
556 
557  text->SetTextAngle( aClipModule->GetOrientation() );
558 
559  text->SetParent( nullptr );
560  text->SetLocalCoord();
561  }
562 
563  item->SetParent( editModule );
564  aPastedItems.push_back( item );
565  }
566 
567  aClipModule->GraphicalItems().clear();
568 
569  if( !aClipModule->GetReference().IsEmpty() )
570  {
571  TEXTE_MODULE* text = new TEXTE_MODULE( aClipModule->Reference() );
573  text->SetTextAngle( aClipModule->GetOrientation() );
574 
575  text->SetParent( nullptr );
576  text->SetLocalCoord();
577 
578  text->SetParent( editModule );
579  aPastedItems.push_back( text );
580  }
581 
582  if( !aClipModule->GetValue().IsEmpty() )
583  {
584  TEXTE_MODULE* text = new TEXTE_MODULE( aClipModule->Value() );
586  text->SetTextAngle( aClipModule->GetOrientation() );
587 
588  text->SetParent( nullptr );
589  text->SetLocalCoord();
590 
591  text->SetParent( editModule );
592  aPastedItems.push_back( text );
593  }
594 }
595 
596 
597 int PCBNEW_CONTROL::Paste( const TOOL_EVENT& aEvent )
598 {
599  CLIPBOARD_IO pi;
600  BOARD_ITEM* clipItem = pi.Parse();
601 
602  if( !clipItem )
603  return 0;
604 
605  bool editModules = m_editModules || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
606 
607  if( clipItem->Type() == PCB_T )
608  {
609  if( editModules )
610  {
611  for( BOARD_CONNECTED_ITEM* item : static_cast<BOARD*>( clipItem )->AllConnectedItems() )
612  item->SetNet( NETINFO_LIST::OrphanedItem() );
613  }
614  else
615  static_cast<BOARD*>( clipItem )->MapNets( m_frame->GetBoard() );
616  }
617 
618  // The clipboard can contain two different things, an entire kicad_pcb
619  // or a single module
620 
621  if( editModules && ( !board() || !module() ) )
622  {
623  wxLogDebug( wxT( "Attempting to paste to empty module editor window\n") );
624  return 0;
625  }
626 
627  switch( clipItem->Type() )
628  {
629  case PCB_T:
630  {
631  BOARD* clipBoard = static_cast<BOARD*>( clipItem );
632 
633  if( editModules )
634  {
635  MODULE* editModule = board()->GetFirstModule();
636  std::vector<BOARD_ITEM*> pastedItems;
637 
638  for( MODULE* clipModule : clipBoard->Modules() )
639  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
640 
641  for( BOARD_ITEM* clipDrawItem : clipBoard->Drawings() )
642  {
643  if( clipDrawItem->Type() == PCB_LINE_T )
644  {
645  DRAWSEGMENT* clipDrawSeg = static_cast<DRAWSEGMENT*>( clipDrawItem );
646 
647  // Convert to PCB_MODULE_EDGE_T
648  EDGE_MODULE* pastedDrawSeg = new EDGE_MODULE( editModule );
649  static_cast<DRAWSEGMENT*>( pastedDrawSeg )->SwapData( clipDrawSeg );
650  pastedDrawSeg->SetLocalCoord();
651 
652  pastedItems.push_back( pastedDrawSeg );
653  }
654  else if( clipDrawItem->Type() == PCB_TEXT_T )
655  {
656  TEXTE_PCB* clipTextItem = static_cast<TEXTE_PCB*>( clipDrawItem );
657 
658  // Convert to PCB_MODULE_TEXT_T
659  TEXTE_MODULE* pastedTextItem = new TEXTE_MODULE( editModule );
660  static_cast<EDA_TEXT*>( pastedTextItem )->SwapText( *clipTextItem );
661  static_cast<EDA_TEXT*>( pastedTextItem )->SwapEffects( *clipTextItem );
662 
663  pastedItems.push_back( pastedTextItem );
664  }
665  }
666 
667  delete clipBoard;
668 
669  placeBoardItems( pastedItems, true, true );
670  }
671  else
672  {
673  placeBoardItems( clipBoard, true );
674 
676  m_frame->Compile_Ratsnest( true );
677  }
678 
679  break;
680  }
681 
682  case PCB_MODULE_T:
683  {
684  MODULE* clipModule = static_cast<MODULE*>( clipItem );
685  std::vector<BOARD_ITEM*> pastedItems;
686 
687  if( editModules )
688  {
689  pasteModuleItemsToModEdit( clipModule, board(), pastedItems );
690  delete clipModule;
691  }
692  else
693  {
694  clipModule->SetParent( board() );
695  pastedItems.push_back( clipModule );
696  }
697 
698  placeBoardItems( pastedItems, true, true );
699  break;
700  }
701 
702  default:
703  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
704  break;
705  }
706 
707  return 1;
708 }
709 
710 
712 {
713  int open_ctl;
714  wxString fileName;
715 
716  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
717 
718  if( !editFrame )
719  return 1;
720 
721  // Pick a file to append
722  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
723  return 1;
724 
725  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
726  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
727 
728  return AppendBoard( *pi, fileName );
729 }
730 
731 
732 // Helper function for PCBNEW_CONTROL::placeBoardItems()
733 template<typename T>
734 static void moveUnflaggedItems( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget,
735  bool aIsNew )
736 {
737  std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
738  [aIsNew]( T aItem )
739  {
740  bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
741 
742  aItem->ClearFlags( SKIP_STRUCT );
743  aItem->SetFlags( aIsNew ? IS_NEW : 0 );
744 
745  return doCopy;
746  } );
747 
748  if( aIsNew )
749  aList.clear();
750 }
751 
752 
753 static void moveUnflaggedItems( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*>& aTarget,
754  bool aIsNew )
755 {
756  if( aList.size() == 0 )
757  return;
758 
759  auto obj = aList.front();
760  int idx = 0;
761 
762  if( aIsNew )
763  {
764  obj = aList.back();
765  aList.pop_back();
766  }
767 
768  for( ; obj ; )
769  {
770  if( obj->HasFlag( SKIP_STRUCT ) )
771  obj->ClearFlags( SKIP_STRUCT );
772  else
773  aTarget.push_back( obj );
774 
775  if( aIsNew )
776  {
777  if( aList.size() )
778  {
779  obj = aList.back();
780  aList.pop_back();
781  }
782  else
783  obj = nullptr;
784  }
785  else
786  obj = idx < int(aList.size()-1) ? aList[++idx] : nullptr;
787  }
788 }
789 
790 
791 
792 int PCBNEW_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
793 {
794  // items are new if the current board is not the board source
795  bool isNew = board() != aBoard;
796  std::vector<BOARD_ITEM*> items;
797 
798  moveUnflaggedItems( aBoard->Tracks(), items, isNew );
799  moveUnflaggedItems( aBoard->Modules(), items, isNew );
800  moveUnflaggedItems( aBoard->Drawings(), items, isNew );
801  moveUnflaggedItems( aBoard->Zones(), items, isNew );
802 
803  return placeBoardItems( items, isNew, aAnchorAtOrigin );
804 }
805 
806 
807 int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
808  bool aAnchorAtOrigin )
809 {
811 
812  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
813  auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
814 
815  PCBNEW_SELECTION& selection = selectionTool->GetSelection();
816 
817  for( auto item : aItems )
818  {
819  item->SetSelected();
820  selection.Add( item );
821 
822  // Add or just select items for the move/place command
823  if( aIsNew )
824  editTool->GetCurrentCommit()->Add( item );
825  else
826  editTool->GetCurrentCommit()->Added( item );
827  }
828 
829  if( selection.Size() > 0 )
830  {
831  if( aAnchorAtOrigin )
832  {
834  }
835  else
836  {
837  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.GetTopLeftItem() );
839  }
840 
841  getViewControls()->SetCursorPosition( getViewControls()->GetMousePosition(), false );
842 
845  }
846 
847  return 0;
848 }
849 
850 
851 int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
852 {
853  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
854 
855  if( !editFrame )
856  return 1;
857 
858  BOARD* brd = board();
859 
860  if( !brd )
861  return 1;
862 
863  // Mark existing items, in order to know what are the new items so we can select only
864  // the new items after loading
865  for( auto track : brd->Tracks() )
866  track->SetFlags( SKIP_STRUCT );
867 
868  for( auto module : brd->Modules() )
870 
871  for( auto drawing : brd->Drawings() )
872  drawing->SetFlags( SKIP_STRUCT );
873 
874  for( auto zone : brd->Zones() )
875  zone->SetFlags( SKIP_STRUCT );
876 
877  // Keep also the count of copper layers, to adjust if necessary
878  int initialCopperLayerCount = brd->GetCopperLayerCount();
879  LSET initialEnabledLayers = brd->GetEnabledLayers();
880 
881  // Load the data
882  try
883  {
884  PROPERTIES props;
885  char xbuf[30];
886  char ybuf[30];
887 
888  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
889  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
890  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
891 
892  props["page_width"] = xbuf;
893  props["page_height"] = ybuf;
894 
895  editFrame->GetDesignSettings().GetNetClasses().Clear();
896  pi.Load( fileName, brd, &props );
897  }
898  catch( const IO_ERROR& ioe )
899  {
900  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
901  DisplayError( editFrame, msg );
902 
903  return 0;
904  }
905 
906  // rebuild nets and ratsnest before any use of nets
907  brd->BuildListOfNets();
909  brd->BuildConnectivity();
910 
911  // Synchronize layers
912  // we should not ask PLUGINs to do these items:
913  int copperLayerCount = brd->GetCopperLayerCount();
914 
915  if( copperLayerCount > initialCopperLayerCount )
916  brd->SetCopperLayerCount( copperLayerCount );
917 
918  // Enable all used layers, and make them visible:
919  LSET enabledLayers = brd->GetEnabledLayers();
920  enabledLayers |= initialEnabledLayers;
921  brd->SetEnabledLayers( enabledLayers );
922  brd->SetVisibleLayers( enabledLayers );
923 
924  return placeBoardItems( brd, false );
925 }
926 
927 
928 int PCBNEW_CONTROL::Undo( const TOOL_EVENT& aEvent )
929 {
930  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
931  wxCommandEvent dummy;
932 
933  if( editFrame )
934  editFrame->RestoreCopyFromUndoList( dummy );
935 
936  return 0;
937 }
938 
939 
940 int PCBNEW_CONTROL::Redo( const TOOL_EVENT& aEvent )
941 {
942  PCB_BASE_EDIT_FRAME* editFrame = dynamic_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
943  wxCommandEvent dummy;
944 
945  if( editFrame )
946  editFrame->RestoreCopyFromRedoList( dummy );
947 
948  return 0;
949 }
950 
951 
953 {
956 
957  if( selection.GetSize() == 1 )
958  {
959  EDA_ITEM* item = selection.Front();
960  MSG_PANEL_ITEMS msgItems;
961 
962  item->GetMsgPanelInfo( m_frame, msgItems );
963  m_frame->SetMsgPanel( msgItems );
964  }
965  else if( selection.GetSize() > 1 )
966  {
967  MSG_PANEL_ITEMS msgItems;
968  wxString msg = wxString::Format( wxT( "%d" ), selection.GetSize() );
969 
970  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Selected Items" ), msg, DARKCYAN ) );
971  m_frame->SetMsgPanel( msgItems );
972  }
973  else if( auto editFrame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame ) )
974  {
975  MODULE* footprint = static_cast<MODULE*>( editFrame->GetModel() );
976 
977  if( !footprint )
978  return 0;
979 
980  MSG_PANEL_ITEMS msgItems;
981  wxString msg;
982 
983  msg = footprint->GetFPID().GetLibNickname().wx_str();
984  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Library" ), msg, DARKCYAN ) );
985 
986  msg = footprint->GetFPID().GetLibItemName().wx_str();
987  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Footprint Name" ), msg, DARKCYAN ) );
988 
989  wxDateTime date( static_cast<time_t>( footprint->GetLastEditTime() ) );
990 
991  if( footprint->GetLastEditTime() && date.IsValid() )
992  // Date format: see http://www.cplusplus.com/reference/ctime/strftime
993  msg = date.Format( wxT( "%b %d, %Y" ) ); // Abbreviated_month_name Day, Year
994  else
995  msg = _( "Unknown" );
996 
997  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) );
998 
999  msg.Printf( wxT( "%zu" ), (size_t) footprint->GetPadCount( DO_NOT_INCLUDE_NPTH ) );
1000  msgItems.emplace_back( MSG_PANEL_ITEM( _( "Pads" ), msg, BLUE ) );
1001 
1002  wxString doc, keyword;
1003  doc.Printf( _( "Doc: %s" ), footprint->GetDescription() );
1004  keyword.Printf( _( "Key Words: %s" ), footprint->GetKeywords() );
1005  msgItems.emplace_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) );
1006 
1007  m_frame->SetMsgPanel( msgItems );
1008  }
1009  else
1010  {
1012  }
1013 
1014  return 0;
1015 }
1016 
1017 
1019 {
1022  Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
1023  Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1024 
1025  // Display modes
1035 
1036  // Layer control
1074 
1075  // Grid control
1078 
1079  Go( &PCBNEW_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1080  Go( &PCBNEW_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1081 
1082  // Miscellaneous
1084 
1085  // Append control
1087 
1088  Go( &PCBNEW_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1089 
1094 }
1095 
1096 
unsigned GetPadCount(INCLUDE_NPTH_T aIncludeNPTH=INCLUDE_NPTH_T(INCLUDE_NPTH)) const
GetPadCount returns the number of pads.
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
timestamp_t GetLastEditTime() const
Definition: class_module.h:345
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:265
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:260
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
void BuildListOfNets()
Definition: class_board.h:718
double GetOrientation() const
Definition: class_module.h:211
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:202
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
TEXTE_MODULE & Reference()
Definition: class_module.h:474
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
int m_Threshold
Definition: collector.h:66
static TOOL_ACTION layerNext
Definition: pcb_actions.h:266
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
int ToggleRatsnest(const TOOL_EVENT &aEvent)
Definition: typeinfo.h:85
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:236
wxPoint m_GridOrigin
origin for grid offsets
static NETINFO_ITEM * OrphanedItem()
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
Definition: netinfo.h:469
BOARD * board() const
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:239
virtual void SetPosition(const wxPoint &aPos)=0
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:203
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:240
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:241
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:242
int AddLibrary(const TOOL_EVENT &aEvent)
VIEW_CONTROLS class definition.
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:255
static TOOL_ACTION ratsnestLineMode
Definition: pcb_actions.h:222
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:269
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:539
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:228
SELECTION_TOOL.
virtual COLOR_SETTINGS * GetColorSettings() override
Helper to retrieve the current color settings.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
#define ALPHA_MIN
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int Quit(const TOOL_EVENT &aEvent)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:268
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:169
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:227
const wxString GetValue() const
Function GetValue.
Definition: class_module.h:458
int HighContrastMode(const TOOL_EVENT &aEvent)
Definition: color4d.h:61
void SetCopperLayerCount(int aCount)
#define HITTEST_THRESHOLD_PIXELS
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
int LayerPrev(const TOOL_EVENT &aEvent)
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
int Paste(const TOOL_EVENT &aEvent)
int GridSetOrigin(const TOOL_EVENT &aEvent)
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
const LIB_ID & GetFPID() const
Definition: class_module.h:215
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
Definition: color4d.h:44
static TOOL_ACTION print
Definition: actions.h:60
DRAWINGS & GraphicalItems()
Definition: class_module.h:179
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
static void moveUnflaggedItems(std::deque< T > &aList, std::vector< BOARD_ITEM * > &aTarget, bool aIsNew)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void setTransitions() override
Sets up handlers for various events.
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:237
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:258
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:245
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:206
void RedrawRatsnest()
Forces refresh of the ratsnest visual representation
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:433
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION layerTop
Definition: pcb_actions.h:234
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
virtual const wxPoint GetPosition() const
Definition: base_struct.h:337
static TOOL_ACTION pickerTool
Definition: actions.h:148
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
PCB_BASE_EDIT_FRAME * frame() const
RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destructor.
Definition: io_mgr.h:579
virtual PCB_LAYER_ID GetActiveLayer() const
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:257
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 ...
class MODULE, a footprint
Definition: typeinfo.h:89
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:412
static TOOL_ACTION zoneDisplayToggle
Definition: pcb_actions.h:229
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:369
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
Generic tool for picking a point.
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:247
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:232
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:267
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
#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
MODULES & Modules()
Definition: class_board.h:266
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:473
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:259
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:252
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: base_struct.h:295
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
TOOL_EVENT.
Definition: tool_event.h:171
void AddItemToSel(BOARD_ITEM *aItem, bool aQuietMode=false)
TEXT_TYPE GetType() const
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:264
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:330
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:263
static TOOL_ACTION showRatsnest
Definition: pcb_actions.h:221
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:244
static const TOOL_EVENT ClearedEvent
Definition: actions.h:204
NETCLASSES & GetNetClasses() const
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
virtual void Move(const wxPoint &aWhere)
virtual COLOR4D GetGridColor()
virtual void PopupFor(int aMsecs)
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:249
void SetTextAngle(double aAngle) override
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:221
void SetType(TEXT_TYPE aType)
static TOOL_ACTION newLibrary
Definition: actions.h:51
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:262
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:261
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.
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:251
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:254
bool AskLoadBoardFileName(wxWindow *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly=false)
Function AskLoadBoardFileName puts up a wxFileDialog asking for a BOARD filename to open.
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:225
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:777
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:218
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:256
virtual void OnModify()
Function OnModify Must be called after a change in order to set the "modify" flag of the current scre...
void SetLocalCoord()
Set relative coordinates.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
int LayerAlphaDec(const TOOL_EVENT &aEvent)
Definition: color4d.h:56
virtual bool IsLocked() const
Function IsLocked.
ZONE_CONTAINERS & Zones()
Definition: class_board.h:280
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one.
Definition: netclass.h:239
Declaration of the eda_3d_viewer class.
bool PassEvent() const
These give a tool a method of informing the TOOL_MANAGER that a particular event should be passed on ...
Definition: tool_event.h:255
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:180
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:61
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:273
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:248
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:243
int GetCopperLayerCount() const
Function GetCopperLayerCount.
wxString wx_str() const
Definition: utf8.cpp:51
int placeBoardItems(std::vector< BOARD_ITEM * > &aItems, bool aIsNew, bool aAnchorAtOrigin)
Add and select or just select for move/place command a list of board items.
PCB_EDIT_FRAME is the main frame for Pcbnew.
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
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:68
int TrackDisplayMode(const TOOL_EVENT &aEvent)
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:250
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:238
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
static TOOL_ACTION undo
Definition: actions.h:67
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
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:253
void BrightenItem(BOARD_ITEM *aItem)
EDGE_MODULE class definition.
int LayerSwitch(const TOOL_EVENT &aEvent)
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
int UpdateMessagePanel(const TOOL_EVENT &aEvent)
PCB_DRAW_PANEL_GAL * canvas() const
void pasteModuleItemsToModEdit(MODULE *aClipModule, BOARD *aBoard, std::vector< BOARD_ITEM * > &aPastedItems)
PCB_FILE_T
Enum PCB_FILE_T is a set of file types that the IO_MGR knows about, and for which there has been a pl...
Definition: io_mgr.h:54
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:235
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:275
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
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:257
int Print(const TOOL_EVENT &aEvent)
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:610
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:223
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:184
void DisplayToolMsg(const wxString &msg) override
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:246
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
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:270
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:226