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  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <cstdint>
26 
27 #include "pcbnew_control.h"
28 #include "pcb_actions.h"
29 #include "selection_tool.h"
30 #include "edit_tool.h"
31 #include "picker_tool.h"
32 #include "pcb_editor_control.h"
33 #include "grid_helper.h"
34 
35 #include <class_board.h>
36 #include <class_module.h>
37 #include <class_track.h>
38 #include <class_zone.h>
39 #include <class_pcb_screen.h>
40 
41 #include <confirm.h>
42 #include <hotkeys.h>
43 #include <properties.h>
44 #include <io_mgr.h>
45 #include <kicad_plugin.h>
46 #include <kicad_clipboard.h>
47 
48 #include <pcbnew_id.h>
49 #include <wxPcbStruct.h>
50 #include <pcb_draw_panel_gal.h>
51 #include <connectivity_data.h>
52 #include <tool/tool_manager.h>
54 #include <view/view_controls.h>
55 #include <pcb_painter.h>
56 #include <origin_viewitem.h>
57 #include <board_commit.h>
58 #include <bitmaps.h>
59 
60 #include <functional>
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 
70 // Display modes
71 TOOL_ACTION PCB_ACTIONS::trackDisplayMode( "pcbnew.Control.trackDisplayMode",
73  "", "" );
74 
75 TOOL_ACTION PCB_ACTIONS::padDisplayMode( "pcbnew.Control.padDisplayMode",
76  AS_GLOBAL, 0,
77  "", "" );
78 
79 TOOL_ACTION PCB_ACTIONS::viaDisplayMode( "pcbnew.Control.viaDisplayMode",
80  AS_GLOBAL, 0,
81  "", "" );
82 
83 TOOL_ACTION PCB_ACTIONS::zoneDisplayEnable( "pcbnew.Control.zoneDisplayEnable",
84  AS_GLOBAL, 0,
85  "", "" );
86 
87 TOOL_ACTION PCB_ACTIONS::zoneDisplayDisable( "pcbnew.Control.zoneDisplayDisable",
88  AS_GLOBAL, 0,
89  "", "" );
90 
91 TOOL_ACTION PCB_ACTIONS::zoneDisplayOutlines( "pcbnew.Control.zoneDisplayOutlines",
92  AS_GLOBAL, 0,
93  "", "" );
94 
95 TOOL_ACTION PCB_ACTIONS::highContrastMode( "pcbnew.Control.highContrastMode",
97  "", "" );
98 
99 TOOL_ACTION PCB_ACTIONS::highContrastInc( "pcbnew.Control.highContrastInc",
100  AS_GLOBAL, '>',
101  "", "" );
102 
103 TOOL_ACTION PCB_ACTIONS::highContrastDec( "pcbnew.Control.highContrastDec",
104  AS_GLOBAL, '<',
105  "", "" );
106 
107 
108 // Layer control
109 TOOL_ACTION PCB_ACTIONS::layerTop( "pcbnew.Control.layerTop",
111  "", "", NULL, AF_NONE, (void*) F_Cu );
112 
113 TOOL_ACTION PCB_ACTIONS::layerInner1( "pcbnew.Control.layerInner1",
115  "", "", NULL, AF_NONE, (void*) In1_Cu );
116 
117 TOOL_ACTION PCB_ACTIONS::layerInner2( "pcbnew.Control.layerInner2",
119  "", "", NULL, AF_NONE, (void*) In2_Cu );
120 
121 TOOL_ACTION PCB_ACTIONS::layerInner3( "pcbnew.Control.layerInner3",
123  "", "", NULL, AF_NONE, (void*) In3_Cu );
124 
125 TOOL_ACTION PCB_ACTIONS::layerInner4( "pcbnew.Control.layerInner4",
127  "", "", NULL, AF_NONE, (void*) In4_Cu );
128 
129 TOOL_ACTION PCB_ACTIONS::layerInner5( "pcbnew.Control.layerInner5",
131  "", "", NULL, AF_NONE, (void*) In5_Cu );
132 
133 TOOL_ACTION PCB_ACTIONS::layerInner6( "pcbnew.Control.layerInner6",
135  "", "", NULL, AF_NONE, (void*) In6_Cu );
136 
137 TOOL_ACTION PCB_ACTIONS::layerBottom( "pcbnew.Control.layerBottom",
139  "", "", NULL, AF_NONE, (void*) B_Cu );
140 
141 TOOL_ACTION PCB_ACTIONS::layerNext( "pcbnew.Control.layerNext",
143  "", "" );
144 
145 TOOL_ACTION PCB_ACTIONS::layerPrev( "pcbnew.Control.layerPrev",
147  "", "" );
148 
149 TOOL_ACTION PCB_ACTIONS::layerToggle( "pcbnew.Control.layerToggle",
151  "", "" );
152 
153 TOOL_ACTION PCB_ACTIONS::layerAlphaInc( "pcbnew.Control.layerAlphaInc",
155  "", "" );
156 
157 TOOL_ACTION PCB_ACTIONS::layerAlphaDec( "pcbnew.Control.layerAlphaDec",
159  "", "" );
160 
161 TOOL_ACTION PCB_ACTIONS::layerChanged( "pcbnew.Control.layerChanged",
162  AS_GLOBAL, 0,
163  "", "", NULL, AF_NOTIFY );
164 
165 // Cursor control
166 TOOL_ACTION PCB_ACTIONS::cursorUp( "pcbnew.Control.cursorUp",
167  AS_GLOBAL, WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP );
168 TOOL_ACTION PCB_ACTIONS::cursorDown( "pcbnew.Control.cursorDown",
169  AS_GLOBAL, WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN );
170 TOOL_ACTION PCB_ACTIONS::cursorLeft( "pcbnew.Control.cursorLeft",
171  AS_GLOBAL, WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT );
172 TOOL_ACTION PCB_ACTIONS::cursorRight( "pcbnew.Control.cursorRight",
173  AS_GLOBAL, WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT );
174 
175 TOOL_ACTION PCB_ACTIONS::cursorUpFast( "pcbnew.Control.cursorUpFast",
176  AS_GLOBAL, MD_CTRL + WXK_UP, "", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) );
177 TOOL_ACTION PCB_ACTIONS::cursorDownFast( "pcbnew.Control.cursorDownFast",
178  AS_GLOBAL, MD_CTRL + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) );
179 TOOL_ACTION PCB_ACTIONS::cursorLeftFast( "pcbnew.Control.cursorLeftFast",
180  AS_GLOBAL, MD_CTRL + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) );
181 TOOL_ACTION PCB_ACTIONS::cursorRightFast( "pcbnew.Control.cursorRightFast",
182  AS_GLOBAL, MD_CTRL + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) );
183 
184 TOOL_ACTION PCB_ACTIONS::cursorClick( "pcbnew.Control.cursorClick",
186  "", "", NULL, AF_NONE, (void*) CURSOR_CLICK );
187 TOOL_ACTION PCB_ACTIONS::cursorDblClick( "pcbnew.Control.cursorDblClick",
189  "", "", NULL, AF_NONE, (void*) CURSOR_DBL_CLICK );
190 
191 TOOL_ACTION PCB_ACTIONS::panUp( "pcbnew.Control.panUp",
192  AS_GLOBAL, MD_SHIFT + WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP );
193 TOOL_ACTION PCB_ACTIONS::panDown( "pcbnew.Control.panDown",
194  AS_GLOBAL, MD_SHIFT + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN );
195 TOOL_ACTION PCB_ACTIONS::panLeft( "pcbnew.Control.panLeft",
196  AS_GLOBAL, MD_SHIFT + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT );
197 TOOL_ACTION PCB_ACTIONS::panRight( "pcbnew.Control.panRight",
198  AS_GLOBAL, MD_SHIFT + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT );
199 
200 // Miscellaneous
201 TOOL_ACTION PCB_ACTIONS::selectionTool( "pcbnew.Control.selectionTool",
202  AS_GLOBAL, 0,
203  "", "", NULL, AF_ACTIVATE );
204 
205 TOOL_ACTION PCB_ACTIONS::resetCoords( "pcbnew.Control.resetCoords",
207  "", "" );
208 
209 TOOL_ACTION PCB_ACTIONS::switchCursor( "pcbnew.Control.switchCursor",
210  AS_GLOBAL, 0,
211  "", "" );
212 
213 TOOL_ACTION PCB_ACTIONS::switchUnits( "pcbnew.Control.switchUnits",
215  "", "" );
216 
217 TOOL_ACTION PCB_ACTIONS::deleteItemCursor( "pcbnew.Control.deleteItemCursor",
218  AS_GLOBAL, 0,
219  "", "" );
220 
221 TOOL_ACTION PCB_ACTIONS::showHelp( "pcbnew.Control.showHelp",
223  "", "" );
224 
225 TOOL_ACTION PCB_ACTIONS::toBeDone( "pcbnew.Control.toBeDone",
226  AS_GLOBAL, 0, // dialog saying it is not implemented yet
227  "", "" ); // so users are aware of that
228 
229 TOOL_ACTION PCB_ACTIONS::pasteFromClipboard( "pcbnew.InteractiveEdit.pasteFromClipboard",
230  AS_GLOBAL, MD_CTRL + int( 'V' ),
231  _( "Paste" ), _( "Paste content from clipboard" ),
232  paste_xpm );
233 
234 
236  PCB_TOOL( "pcbnew.Control" ), m_frame( NULL )
237 {
238  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
239 }
240 
241 
243 {
244 }
245 
246 
248 {
249  m_frame = getEditFrame<PCB_BASE_FRAME>();
250 
251  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
252  {
253  m_gridOrigin->SetPosition( board()->GetGridOrigin() );
254  getView()->Remove( m_gridOrigin.get() );
255  getView()->Add( m_gridOrigin.get() );
256  }
257 }
258 
259 template<class T> void Flip( T& aValue )
260 {
261  aValue = !aValue;
262 }
263 
265 {
266  auto opts = displayOptions();
267 
268  Flip( opts->m_DisplayPcbTrackFill );
269  view()->UpdateDisplayOptions( opts );
270 
271  for( auto track : board()->Tracks() )
272  {
273  if( track->Type() == PCB_TRACE_T )
274  view()->Update( track, KIGFX::GEOMETRY );
275  }
276 
277  canvas()->Refresh();
278 
279  return 0;
280 }
281 
283 {
284  auto opts = displayOptions();
285 
286  Flip( opts->m_DisplayPadFill );
287  view()->UpdateDisplayOptions( opts );
288 
289  for( auto module : board()->Modules() ) // fixme: move to PCB_VIEW
290  {
291  for( auto pad : module->Pads() )
292  view()->Update( pad, KIGFX::GEOMETRY );
293  }
294 
295  canvas()->Refresh();
296 
297  return 0;
298 }
299 
300 
302 {
303  auto opts = displayOptions();
304 
305  Flip( opts->m_DisplayViaFill );
306  view()->UpdateDisplayOptions( opts );
307 
308  for( auto track : board()->Tracks() )
309  {
310  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
311  view()->Update( track, KIGFX::GEOMETRY );
312  }
313 
314  canvas()->Refresh();
315 
316  return 0;
317 }
318 
319 
321 {
322  auto opts = displayOptions();
323 
324  // Apply new display options to the GAL canvas
326  opts->m_DisplayZonesMode = 0;
327  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
328  opts->m_DisplayZonesMode = 1;
329  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
330  opts->m_DisplayZonesMode = 2;
331  else
332  assert( false );
333 
334  view()->UpdateDisplayOptions( opts );
335 
336  for( int i = 0; i < board()->GetAreaCount(); ++i )
337  view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
338 
339  canvas()->Refresh();
340 
341  return 0;
342 }
343 
344 
346 {
347  auto opts = displayOptions();
348 
349  Flip( opts->m_ContrastModeDisplay );
350  view()->UpdateDisplayOptions( opts );
352 
353  return 0;
354 }
355 
356 
358 {
359  return 0;
360 }
361 
362 
364 {
365  return 0;
366 }
367 
368 
369 // Layer control
371 {
372  m_frame->SwitchLayer( NULL, (PCB_LAYER_ID) aEvent.Parameter<intptr_t>() );
373 
374  return 0;
375 }
376 
377 
379 {
380  PCB_BASE_FRAME* editFrame = m_frame;
381  LAYER_NUM layer = editFrame->GetActiveLayer();
382 
383  if( layer < F_Cu || layer > B_Cu )
384  return 0;
385 
386  int layerCount = board()->GetCopperLayerCount();
387 
388  if( layer == layerCount - 2 || layerCount < 2 )
389  layer = B_Cu;
390  else if( layer == B_Cu )
391  layer = F_Cu;
392  else
393  ++layer;
394 
395  assert( IsCopperLayer( layer ) );
396  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
397 
398  return 0;
399 }
400 
401 
403 {
404  PCB_BASE_FRAME* editFrame = m_frame;
405  LAYER_NUM layer = editFrame->GetActiveLayer();
406 
407  if( layer < F_Cu || layer > B_Cu )
408  return 0;
409 
410  int layerCount = board()->GetCopperLayerCount();
411 
412  if( layer == F_Cu || layerCount < 2 )
413  layer = B_Cu;
414  else if( layer == B_Cu )
415  layer = layerCount - 2;
416  else
417  --layer;
418 
419  assert( IsCopperLayer( layer ) );
420  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
421 
422  return 0;
423 }
424 
425 
427 {
428  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
429  PCB_SCREEN* screen = m_frame->GetScreen();
430 
431  if( currentLayer == screen->m_Route_Layer_TOP )
432  m_frame->SwitchLayer( NULL, screen->m_Route_Layer_BOTTOM );
433  else
434  m_frame->SwitchLayer( NULL, screen->m_Route_Layer_TOP );
435 
436  return 0;
437 }
438 
439 
441 {
442  auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
443  auto settings = painter->GetSettings();
444 
445  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
446  KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
447 
448  if( currentColor.a <= 0.95 )
449  {
450  currentColor.a += 0.05;
451  settings->SetLayerColor( currentLayer, currentColor );
452  m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
453  }
454 
455  return 0;
456 }
457 
458 
460 {
461  auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
462  auto settings = painter->GetSettings();
463 
464  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
465  KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
466 
467  if( currentColor.a >= 0.05 )
468  {
469  currentColor.a -= 0.05;
470  settings->SetLayerColor( currentLayer, currentColor );
471  m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
472  }
473 
474  return 0;
475 }
476 
477 
478 // Cursor control
480 {
481  long type = aEvent.Parameter<intptr_t>();
482  bool fastMove = type & PCB_ACTIONS::CURSOR_FAST_MOVE;
483  type &= ~PCB_ACTIONS::CURSOR_FAST_MOVE;
484  bool mirroredX = getView()->IsMirroredX();
485 
486  GRID_HELPER gridHelper( m_frame );
487  VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true );
488  VECTOR2I gridSize = gridHelper.GetGrid();
489 
490  if( fastMove )
491  gridSize = gridSize * 10;
492 
493  switch( type )
494  {
496  cursor -= VECTOR2D( 0, gridSize.y );
497  break;
498 
500  cursor += VECTOR2D( 0, gridSize.y );
501  break;
502 
504  cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
505  break;
506 
508  cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
509  break;
510 
511  case PCB_ACTIONS::CURSOR_CLICK: // fall through
513  {
514  TOOL_ACTIONS action = TA_NONE;
515  int modifiers = 0;
516 
517  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
518  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
519  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
520 
521  if( type == PCB_ACTIONS::CURSOR_CLICK )
522  action = TA_MOUSE_CLICK;
523  else if( type == PCB_ACTIONS::CURSOR_DBL_CLICK )
524  action = TA_MOUSE_DBLCLICK;
525  else
526  assert( false );
527 
528  TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
529  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
530  m_toolMgr->ProcessEvent( evt );
531 
532  return 0;
533  }
534  break;
535  }
536 
537  getViewControls()->SetCursorPosition( cursor );
538 
539  return 0;
540 }
541 
542 
544 {
545  long type = aEvent.Parameter<intptr_t>();
546  KIGFX::VIEW* view = getView();
547  GRID_HELPER gridHelper( m_frame );
548  VECTOR2D center = view->GetCenter();
549  VECTOR2I gridSize = gridHelper.GetGrid() * 10;
550  bool mirroredX = view->IsMirroredX();
551 
552  switch( type )
553  {
555  center -= VECTOR2D( 0, gridSize.y );
556  break;
557 
559  center += VECTOR2D( 0, gridSize.y );
560  break;
561 
563  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
564  break;
565 
567  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
568  break;
569 
570  default:
571  assert( false );
572  break;
573  }
574 
575  view->SetCenter( center );
576 
577  return 0;
578 }
579 
580 
581 // Grid control
583 {
585  updateGrid();
586 
587  return 0;
588 }
589 
590 
592 {
594  updateGrid();
595 
596  return 0;
597 }
598 
599 
600 static bool setOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
601  KIGFX::ORIGIN_VIEWITEM* aItem, const VECTOR2D& aPoint )
602 {
603  aFrame->SetGridOrigin( wxPoint( aPoint.x, aPoint.y ) );
604  aView->GetGAL()->SetGridOrigin( aPoint );
605  aItem->SetPosition( aPoint );
606  aView->MarkDirty();
607 
608  return true;
609 }
610 
611 
613 {
614  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
615 
616  if( origin )
617  {
618  setOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
619  delete origin;
620  }
621  else
622  {
623  Activate();
624 
626  assert( picker );
627 
628  // TODO it will not check the toolbar button in module editor, as it uses a different ID..
629  m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
630  picker->SetClickHandler( std::bind( setOrigin, getView(), m_frame, m_gridOrigin.get(), _1 ) );
631  picker->Activate();
632  Wait();
633  }
634 
635  return 0;
636 }
637 
638 
640 {
641  board()->SetGridOrigin( wxPoint( 0, 0 ) );
642  m_gridOrigin->SetPosition( VECTOR2D( 0, 0 ) );
643 
644  return 0;
645 }
646 
647 
648 // Miscellaneous
650 {
651  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
652 
653  m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
655 
656  return 0;
657 }
658 
659 
661 {
662  auto& galOpts = m_frame->GetGalDisplayOptions();
663 
664  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
665  galOpts.NotifyChanged();
666 
667  return 0;
668 }
669 
670 
672 {
673  // TODO should not it be refactored to pcb_frame member function?
674  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
675 
676  if( g_UserUnit == INCHES )
677  evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
678  else
679  evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
680 
681  m_frame->ProcessEvent( evt );
682 
683  return 0;
684 }
685 
686 
687 static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
688 {
689  SELECTION_TOOL* selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
690  assert( selectionTool );
691 
692  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
693  aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
694  selectionTool->SanitizeSelection();
695 
696  const SELECTION& selection = selectionTool->GetSelection();
697 
698  if( selection.Empty() )
699  return true;
700 
701  bool canBeRemoved = ( selection.Front()->Type() != PCB_MODULE_T );
702 
703  if( canBeRemoved || IsOK( aToolMgr->GetEditFrame(), _( "Are you sure you want to delete item?" ) ) )
704  aToolMgr->RunAction( PCB_ACTIONS::remove, true );
705  else
706  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
707 
708  return true;
709 }
710 
711 
713 {
714  Activate();
715 
717  assert( picker );
718 
719  // TODO it will not check the toolbar button in the module editor, as it uses a different ID..
720  m_frame->SetToolID( ID_PCB_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
721  picker->SetSnapping( false );
722  picker->SetClickHandler( std::bind( deleteItem, m_toolMgr, _1 ) );
723  picker->Activate();
724  Wait();
725 
726  return 0;
727 }
728 
730 {
731  CLIPBOARD_IO pi;
732  BOARD tmpBoard;
733  BOARD_ITEM* clipItem = pi.Parse();
734 
735  if( !clipItem )
736  {
737  return 0;
738  }
739 
740  if( clipItem->Type() == PCB_T )
741  static_cast<BOARD*>(clipItem)->ClearAllNetCodes();
742 
743  bool editModules = m_editModules || frame()->IsType( FRAME_PCB_MODULE_EDITOR );
744 
745  // The clipboard can contain two different things, an entire kicad_pcb
746  // or a single module
747 
748  if( editModules && ( !board() || !module() ) )
749  {
750  wxLogDebug( wxT( "Attempting to paste to empty module editor window\n") );
751  return 0;
752  }
753 
754 
755  switch( clipItem->Type() )
756  {
757  case PCB_T:
758  {
759  if( editModules )
760  {
761  wxLogDebug( wxT( "attempting to paste a pcb in the footprint editor\n") );
762  return 0;
763  }
764 
765  placeBoardItems( static_cast<BOARD*>( clipItem ) );
766  break;
767  }
768 
769  case PCB_MODULE_T:
770  {
771  std::vector<BOARD_ITEM *> items;
772 
773  clipItem->SetParent( board() );
774 
775  if( editModules )
776  {
777  auto mod = static_cast<MODULE *>( clipItem );
778 
779  for( auto pad : mod->Pads() )
780  {
781  pad->SetParent ( board()->m_Modules.GetFirst() );
782  items.push_back( pad );
783  }
784  for( auto item : mod->GraphicalItems() )
785  {
786  item->SetParent ( board()->m_Modules.GetFirst() );
787  items.push_back( item );
788  }
789  }
790  else
791  {
792  items.push_back( clipItem );
793  }
794 
795  placeBoardItems( items, true );
796  break;
797  }
798  default:
799  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
800  // FAILED
801  break;
802  }
803  return 1;
804 }
805 
807 {
808  int open_ctl;
809  wxString fileName;
810 
811  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
812 
813  if( !editFrame )
814  return 1;
815 
816  // Pick a file to append
817  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
818  return 1;
819 
820  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
821  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
822 
823  return AppendBoard( *pi, fileName );
824 }
825 
827 {
828  std::vector<BOARD_ITEM*> items;
829 
830  for( auto track : aBoard->Tracks() )
831  {
832  if( track->GetFlags() & FLAG0 )
833  track->ClearFlags( FLAG0 );
834  else
835  items.push_back( track );
836  }
837 
838  for( auto module : aBoard->Modules() )
839  {
840  if( module->GetFlags() & FLAG0 )
841  module->ClearFlags( FLAG0 );
842  else
843  items.push_back( module );
844  }
845 
846  for( auto drawing : aBoard->Drawings() )
847  {
848  if( drawing->GetFlags() & FLAG0 )
849  drawing->ClearFlags( FLAG0 );
850  else
851  items.push_back( drawing );
852  }
853 
854  for( auto zone : aBoard->Zones() )
855  {
856  if( zone->GetFlags() & FLAG0 )
857  zone->ClearFlags( FLAG0 );
858  else
859  items.push_back( zone );
860  }
861 
862  // items are new if the current board is not the board source
863  bool isNew = board() != aBoard;
864  return placeBoardItems( items, isNew );
865 }
866 
867 
868 int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew )
869 {
871 
872  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
873  auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
874 
875  SELECTION& selection = selectionTool->GetSelection();
876 
877  for( auto item : aItems )
878  {
879  item->SetSelected();
880  selection.Add( item );
881 
882  // Add or just select items for the move/place command
883  if( aIsNew )
884  editTool->GetCurrentCommit()->Add( item );
885  else
886  editTool->GetCurrentCommit()->Added( item );
887  }
888 
889  selection.SetReferencePoint( VECTOR2I( 0, 0 ) );
890 
893 
894  return 0;
895 }
896 
897 
898 int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
899 {
900  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
901 
902  if( !editFrame )
903  return 1;
904 
905  BOARD* brd = board();
906 
907  if( !brd )
908  return 1;
909 
910  // Mark existing items, in order to know what are the new items
911  // to be ble to select only the new items after loadind
912  for( auto track : brd->Tracks() )
913  {
914  track->SetFlags( FLAG0 );
915  }
916 
917  for( auto module : brd->Modules() )
918  {
919  module->SetFlags( FLAG0 );
920  }
921 
922  for( auto drawing : brd->Drawings() )
923  {
924  drawing->SetFlags( FLAG0 );
925  }
926 
927  for( auto zone : brd->Zones() )
928  {
929  zone->SetFlags( FLAG0 );
930  }
931 
932  // Keep also the count of copper layers, to adjust if necessary
933  int initialCopperLayerCount = brd->GetCopperLayerCount();
934  LSET initialEnabledLayers = brd->GetEnabledLayers();
935 
936  // Load the data
937  try
938  {
939  PROPERTIES props;
940  char xbuf[30];
941  char ybuf[30];
942 
943  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
944  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
945  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
946 
947  props["page_width"] = xbuf;
948  props["page_height"] = ybuf;
949 
950  editFrame->GetDesignSettings().m_NetClasses.Clear();
951  pi.Load( fileName, brd, &props );
952  }
953  catch( const IO_ERROR& ioe )
954  {
955  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
956  DisplayError( editFrame, msg );
957 
958  return 0;
959  }
960 
961  // rebuild nets and ratsnest before any use of nets
962  brd->BuildListOfNets();
964  brd->BuildConnectivity();
965 
966  // Synchronize layers
967  // we should not ask PLUGINs to do these items:
968  int copperLayerCount = brd->GetCopperLayerCount();
969 
970  if( copperLayerCount > initialCopperLayerCount )
971  brd->SetCopperLayerCount( copperLayerCount );
972 
973  // Enable all used layers, and make them visible:
974  LSET enabledLayers = brd->GetEnabledLayers();
975  enabledLayers |= initialEnabledLayers;
976  brd->SetEnabledLayers( enabledLayers );
977  brd->SetVisibleLayers( enabledLayers );
978 
979 
980  return placeBoardItems( brd );
981 }
982 
983 
985 {
987 
988  return 0;
989 }
990 
991 
993 {
994  DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) );
995 
996  return 0;
997 }
998 
999 
1001 {
1002  // Display modes
1012 
1013  // Layer control
1027 
1028  // Cursor control
1039 
1040  // Pan control
1045 
1046  // Grid control
1051 
1052  // Miscellaneous
1059 
1060  // Append control
1062  PCB_ACTIONS::appendBoard.MakeEvent() );
1063 
1065  PCB_ACTIONS::pasteFromClipboard.MakeEvent() );
1066 }
1067 
1068 
1070 {
1071  BASE_SCREEN* screen = m_frame->GetScreen();
1072  //GRID_TYPE grid = screen->GetGrid( idx );
1073  getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
1075 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:263
BOARD_ITEM * Parse()
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
void BuildListOfNets()
Definition: class_board.h:722
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:53
int SwitchCursor(const TOOL_EVENT &aEvent)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:282
int PanControl(const TOOL_EVENT &aEvent)
int PadDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorUpFast
Definition: pcb_actions.h:345
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:90
static TOOL_ACTION layerNext
Definition: pcb_actions.h:264
Definition: typeinfo.h:85
int HighContrastInc(const TOOL_EVENT &aEvent)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:258
void SetGridOrigin(const wxPoint &aPoint)
Function SetGridOrigin sets the origin point of the grid.
Definition: class_board.h:349
static TOOL_ACTION cursorDblClick
Definition: pcb_actions.h:351
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:885
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:261
void SetGridOrigin(const wxPoint &aPoint) override
Model changes (required full reload)
Definition: tool_base.h:83
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:81
This file is part of the common library.
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:262
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:94
T
enum T contains all this lexer's tokens.
static TOOL_ACTION showHelp
Definition: pcb_actions.h:377
bool IsMirroredX() const
Function IsMirroredX() Returns true if view is flipped across the X axis.
Definition: view.h:227
VIEW_CONTROLS class definition.
static TOOL_ACTION layerAlphaDec
Definition: pcb_actions.h:267
static TOOL_ACTION gridResetOrigin
Definition: actions.h:66
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:250
Class SELECTION_TOOL.
wxWindow * GetEditFrame() const
Definition: tool_manager.h:267
TOOL_ACTIONS
Definition: tool_event.h:55
Class BOARD to handle a board.
void SetFastGrid2()
Function SetFastGrid2()
EDA_ITEM * Front() const
Definition: selection.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:266
int GetCopperLayerCount() const
Function GetCopperLayerCount.
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:249
DLIST_ITERATOR_WRAPPER< D_PAD > Pads()
Definition: class_module.h:160
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Action activates a tool
Definition: tool_event.h:146
int HighContrastMode(const TOOL_EVENT &aEvent)
EDA_HOTKEY_CONFIG * GetHotkeyConfig() const
Function GetHotkeyConfig() Returns a structure containing currently used hotkey mapping.
Definition: draw_frame.h:377
void SetCopperLayerCount(int aCount)
static bool setOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, KIGFX::ORIGIN_VIEWITEM *aItem, const VECTOR2D &aPoint)
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
int LayerPrev(const TOOL_EVENT &aEvent)
static int LegacyHotKey(int aHotKey)
Creates a hot key code that refers to a legacy hot key setting, instead of a particular key...
Definition: tool_action.h:174
static TOOL_ACTION gridFast1
Definition: actions.h:61
Classes to handle copper zones.
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:54
int GridSetOrigin(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: pcb_actions.h:340
VECTOR2I GetGrid() const
Definition: grid_helper.cpp:83
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
static TOOL_ACTION pasteFromClipboard
Paste from clipboard.
Definition: pcb_actions.h:307
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:176
static TOOL_ACTION switchUnits
Definition: pcb_actions.h:370
void setTransitions() override
Sets up handlers for various events.
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:259
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:400
int LayerNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION deleteItemCursor
Definition: pcb_actions.h:371
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION resetCoords
Definition: pcb_actions.h:367
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
Pcbnew hotkeys.
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:124
Auxiliary rendering target (noncached)
Definition: definitions.h:42
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION layerTop
Definition: pcb_actions.h:256
Generic tool for picking a point.
Definition: picker_tool.h:34
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves cursor to the requested position expressed in world coordinates.
void SetFastGrid1()
Function SetFastGrid1()
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:213
Class RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destruct...
Definition: io_mgr.h:546
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:208
Class TOOL_MANAGER.
Definition: tool_manager.h:49
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
static TOOL_ACTION highContrastMode
Definition: pcb_actions.h:251
class MODULE, a footprint
Definition: typeinfo.h:89
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
static TOOL_ACTION appendBoard
Definition: pcb_actions.h:376
PCB_LAYER_ID
A quick note on layer IDs:
double a
Alpha component.
Definition: color4d.h:294
static TOOL_ACTION gridFast2
Definition: actions.h:62
Class LSET is a set of PCB_LAYER_IDs.
static TOOL_ACTION cursorRightFast
Definition: pcb_actions.h:348
static bool deleteItem(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:265
static TOOL_ACTION toBeDone
Definition: pcb_actions.h:379
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:250
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
int GridResetOrigin(const TOOL_EVENT &aEvent)
virtual PCB_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: pcb_painter.h:188
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:568
void SetPosition(const VECTOR2D &aPosition)
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:240
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static TOOL_ACTION panRight
Definition: pcb_actions.h:357
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: common.h:145
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
Class TOOL_EVENT.
Definition: tool_event.h:162
static TOOL_ACTION cursorClick
Definition: pcb_actions.h:350
SELECTION & GetSelection()
Function GetSelection()
int LayerToggle(const TOOL_EVENT &aEvent)
PCB_LAYER_ID m_Route_Layer_BOTTOM
static TOOL_ACTION panUp
Definition: pcb_actions.h:354
MODULE * module() const
Definition: pcb_tool.h:136
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:104
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1011
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
int GridFast1(const TOOL_EVENT &aEvent)
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
void UpdateDisplayOptions(PCB_DISPLAY_OPTIONS *aOptions)
Definition: pcb_view.cpp:103
All active tools
Definition: tool_event.h:138
static TOOL_ACTION cursorRight
Definition: pcb_actions.h:343
Class EDIT_TOOL.
Definition: edit_tool.h:45
int placeBoardItems(BOARD *aBoard)
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
#define FLAG0
Pcbnew: flag used in local computations.
Definition: base_struct.h:145
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectionTool
Definition: pcb_actions.h:365
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
virtual void SetHighContrastLayer(int aLayer) override
>
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
static TOOL_ACTION panLeft
Definition: pcb_actions.h:356
bool m_editModules
Definition: pcb_tool.h:142
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
int ResetCoords(const TOOL_EVENT &aEvent)
static TOOL_ACTION padDisplayMode
Definition: pcb_actions.h:246
bool AskLoadBoardFileName(wxWindow *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly=false)
Function AskLoadBoardFileName puts up a wxFileDialog asking for a BOARD filename to open...
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:247
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:657
int ShowHelp(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorLeft
Definition: pcb_actions.h:342
virtual void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
int LayerAlphaDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:270
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
Class PCB_ACTIONS.
Definition: pcb_actions.h:42
static TOOL_ACTION highContrastInc
Definition: pcb_actions.h:252
ZONE_CONTAINERS & Zones()
Definition: class_board.h:252
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:508
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:92
void Clear()
Function Clear destroys any contained NETCLASS instances except the Default one.
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Returns the current cursor position in world coordinates - ingoring the cursorUp position force mode...
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
static TOOL_ACTION switchCursor
Definition: pcb_actions.h:369
IO_MGR::PCB_FILE_T plugin_type(const wxString &aFileName, int aCtl)
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
static PLUGIN * PluginFind(PCB_FILE_T aFileType)
Function PluginFind returns a PLUGIN which the caller can use to import, export, save, or load design documents.
Definition: io_mgr.cpp:58
int ViaDisplayMode(const TOOL_EVENT &aEvent)
Class PLUGIN is a base class that BOARD loading and saving plugins should derive from.
Definition: io_mgr.h:265
Class TOOL_ACTION.
Definition: tool_action.h:46
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
int TrackDisplayMode(const TOOL_EVENT &aEvent)
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
int SwitchUnits(const TOOL_EVENT &aEvent)
const wxSize GetPageSizeIU() const override
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:281
void Activate()
Function Activate() Runs the tool.
int DeleteItemCursor(const TOOL_EVENT &aEvent)
int CursorControl(const TOOL_EVENT &aEvent)
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:864
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:260
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
int GridFast2(const TOOL_EVENT &aEvent)
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:249
static TOOL_ACTION cursorDown
Definition: pcb_actions.h:341
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
bool IsType(FRAME_T aType) const
Definition: wxstruct.h:229
Module description (excepted pads)
static TOOL_ACTION gridSetOrigin
Definition: actions.h:65
Class VIEW.
Definition: view.h:58
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:123
static TOOL_ACTION cursorLeftFast
Definition: pcb_actions.h:347
bool SanitizeSelection()
Makes sure a group selection does not contain items that would cause conflicts when moving/rotating t...
int ToBeDone(const TOOL_EVENT &aEvent)
int LayerSwitch(const TOOL_EVENT &aEvent)
void updateGrid()
Applies the legacy canvas grid settings for GAL.
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:51
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:257
int AppendBoard(PLUGIN &pi, wxString &fileName)
Rendering engine changes.
Definition: tool_base.h:84
static TOOL_ACTION panDown
Definition: pcb_actions.h:355
void Flip(T &aValue)
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:73
int PasteItemsFromClipboard(const TOOL_EVENT &aEvent)
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:131
static TOOL_ACTION highContrastDec
Definition: pcb_actions.h:253
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:774
bool m_fullscreenCursor
Fullscreen crosshair or small cross
void SetEnabledLayers(LSET aLayerMask)
Function SetEnabledLayers is a proxy function that calls the correspondent function in m_BoardSetting...
#define mod(a, n)
Definition: greymap.cpp:24
bool ProcessEvent(wxEvent &aEvent) override
Function ProcessEvent overrides the default process event handler to implement the auto save feature...
Definition: basicframe.cpp:185
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:50
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:594
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:245
PCB_LAYER_ID m_Route_Layer_TOP
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:251
NETCLASSES m_NetClasses
List of current netclasses. There is always the default netclass.
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:47
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:268
BOARD * board() const
Definition: pcb_tool.h:135
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
static TOOL_ACTION zoneDisplayEnable
Definition: pcb_actions.h:248
int HighContrastDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorDownFast
Definition: pcb_actions.h:346