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 <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 <pcb_edit_frame.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::graphicDisplayMode( "pcbnew.Control.graphicDisplayMode",
84  AS_GLOBAL, 0,
85  "", "" );
86 
87 TOOL_ACTION PCB_ACTIONS::moduleEdgeOutlines( "pcbnew.Control.graphicOutlines",
88  AS_GLOBAL, 0,
89  "", "" );
90 
91 TOOL_ACTION PCB_ACTIONS::moduleTextOutlines( "pcbnew.Control.textOutlines",
92  AS_GLOBAL, 0,
93  "", "" );
94 
95 TOOL_ACTION PCB_ACTIONS::zoneDisplayEnable( "pcbnew.Control.zoneDisplayEnable",
96  AS_GLOBAL, 0,
97  "", "" );
98 
99 TOOL_ACTION PCB_ACTIONS::zoneDisplayDisable( "pcbnew.Control.zoneDisplayDisable",
100  AS_GLOBAL, 0,
101  "", "" );
102 
103 TOOL_ACTION PCB_ACTIONS::zoneDisplayOutlines( "pcbnew.Control.zoneDisplayOutlines",
104  AS_GLOBAL, 0,
105  "", "" );
106 
107 TOOL_ACTION PCB_ACTIONS::highContrastMode( "pcbnew.Control.highContrastMode",
109  "", "" );
110 
111 TOOL_ACTION PCB_ACTIONS::highContrastInc( "pcbnew.Control.highContrastInc",
113  "", "" );
114 
115 TOOL_ACTION PCB_ACTIONS::highContrastDec( "pcbnew.Control.highContrastDec",
117  "", "" );
118 
119 
120 // Layer control
121 TOOL_ACTION PCB_ACTIONS::layerTop( "pcbnew.Control.layerTop",
123  "", "", NULL, AF_NONE, (void*) F_Cu );
124 
125 TOOL_ACTION PCB_ACTIONS::layerInner1( "pcbnew.Control.layerInner1",
127  "", "", NULL, AF_NONE, (void*) In1_Cu );
128 
129 TOOL_ACTION PCB_ACTIONS::layerInner2( "pcbnew.Control.layerInner2",
131  "", "", NULL, AF_NONE, (void*) In2_Cu );
132 
133 TOOL_ACTION PCB_ACTIONS::layerInner3( "pcbnew.Control.layerInner3",
135  "", "", NULL, AF_NONE, (void*) In3_Cu );
136 
137 TOOL_ACTION PCB_ACTIONS::layerInner4( "pcbnew.Control.layerInner4",
139  "", "", NULL, AF_NONE, (void*) In4_Cu );
140 
141 TOOL_ACTION PCB_ACTIONS::layerInner5( "pcbnew.Control.layerInner5",
143  "", "", NULL, AF_NONE, (void*) In5_Cu );
144 
145 TOOL_ACTION PCB_ACTIONS::layerInner6( "pcbnew.Control.layerInner6",
147  "", "", NULL, AF_NONE, (void*) In6_Cu );
148 
149 TOOL_ACTION PCB_ACTIONS::layerBottom( "pcbnew.Control.layerBottom",
151  "", "", NULL, AF_NONE, (void*) B_Cu );
152 
153 TOOL_ACTION PCB_ACTIONS::layerNext( "pcbnew.Control.layerNext",
155  "", "" );
156 
157 TOOL_ACTION PCB_ACTIONS::layerPrev( "pcbnew.Control.layerPrev",
159  "", "" );
160 
161 TOOL_ACTION PCB_ACTIONS::layerToggle( "pcbnew.Control.layerToggle",
163  "", "" );
164 
165 TOOL_ACTION PCB_ACTIONS::layerAlphaInc( "pcbnew.Control.layerAlphaInc",
167  "", "" );
168 
169 TOOL_ACTION PCB_ACTIONS::layerAlphaDec( "pcbnew.Control.layerAlphaDec",
171  "", "" );
172 
173 TOOL_ACTION PCB_ACTIONS::layerChanged( "pcbnew.Control.layerChanged",
174  AS_GLOBAL, 0,
175  "", "", NULL, AF_NOTIFY );
176 
177 // Cursor control
178 TOOL_ACTION PCB_ACTIONS::cursorUp( "pcbnew.Control.cursorUp",
179  AS_GLOBAL, WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP );
180 TOOL_ACTION PCB_ACTIONS::cursorDown( "pcbnew.Control.cursorDown",
181  AS_GLOBAL, WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN );
182 TOOL_ACTION PCB_ACTIONS::cursorLeft( "pcbnew.Control.cursorLeft",
183  AS_GLOBAL, WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT );
184 TOOL_ACTION PCB_ACTIONS::cursorRight( "pcbnew.Control.cursorRight",
185  AS_GLOBAL, WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT );
186 
187 TOOL_ACTION PCB_ACTIONS::cursorUpFast( "pcbnew.Control.cursorUpFast",
188  AS_GLOBAL, MD_CTRL + WXK_UP, "", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) );
189 TOOL_ACTION PCB_ACTIONS::cursorDownFast( "pcbnew.Control.cursorDownFast",
190  AS_GLOBAL, MD_CTRL + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) );
191 TOOL_ACTION PCB_ACTIONS::cursorLeftFast( "pcbnew.Control.cursorLeftFast",
192  AS_GLOBAL, MD_CTRL + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) );
193 TOOL_ACTION PCB_ACTIONS::cursorRightFast( "pcbnew.Control.cursorRightFast",
194  AS_GLOBAL, MD_CTRL + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) );
195 
196 TOOL_ACTION PCB_ACTIONS::cursorClick( "pcbnew.Control.cursorClick",
198  "", "", NULL, AF_NONE, (void*) CURSOR_CLICK );
199 TOOL_ACTION PCB_ACTIONS::cursorDblClick( "pcbnew.Control.cursorDblClick",
201  "", "", NULL, AF_NONE, (void*) CURSOR_DBL_CLICK );
202 
203 TOOL_ACTION PCB_ACTIONS::panUp( "pcbnew.Control.panUp",
204  AS_GLOBAL, MD_SHIFT + WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP );
205 TOOL_ACTION PCB_ACTIONS::panDown( "pcbnew.Control.panDown",
206  AS_GLOBAL, MD_SHIFT + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN );
207 TOOL_ACTION PCB_ACTIONS::panLeft( "pcbnew.Control.panLeft",
208  AS_GLOBAL, MD_SHIFT + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT );
209 TOOL_ACTION PCB_ACTIONS::panRight( "pcbnew.Control.panRight",
210  AS_GLOBAL, MD_SHIFT + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT );
211 
212 // Miscellaneous
213 TOOL_ACTION PCB_ACTIONS::selectionTool( "pcbnew.Control.selectionTool",
214  AS_GLOBAL, 0,
215  "", "", NULL, AF_ACTIVATE );
216 
217 TOOL_ACTION PCB_ACTIONS::resetCoords( "pcbnew.Control.resetCoords",
219  "", "" );
220 
221 TOOL_ACTION PCB_ACTIONS::switchCursor( "pcbnew.Control.switchCursor",
222  AS_GLOBAL, 0,
223  "", "" );
224 
225 TOOL_ACTION PCB_ACTIONS::switchUnits( "pcbnew.Control.switchUnits",
227  "", "" );
228 
229 TOOL_ACTION PCB_ACTIONS::deleteItemCursor( "pcbnew.Control.deleteItemCursor",
230  AS_GLOBAL, 0,
231  "", "" );
232 
233 TOOL_ACTION PCB_ACTIONS::showHelp( "pcbnew.Control.showHelp",
235  "", "" );
236 
237 TOOL_ACTION PCB_ACTIONS::toBeDone( "pcbnew.Control.toBeDone",
238  AS_GLOBAL, 0, // dialog saying it is not implemented yet
239  "", "" ); // so users are aware of that
240 
241 TOOL_ACTION PCB_ACTIONS::pasteFromClipboard( "pcbnew.InteractiveEdit.pasteFromClipboard",
242  AS_GLOBAL, 0, // do not define a hotkey and let TranslateLegacyId() handle the event
243  _( "Paste" ), _( "Paste content from clipboard" ),
244  paste_xpm );
245 
246 
248  PCB_TOOL( "pcbnew.Control" ), m_frame( NULL )
249 {
250  m_gridOrigin.reset( new KIGFX::ORIGIN_VIEWITEM() );
251 }
252 
253 
255 {
256 }
257 
258 
260 {
261  m_frame = getEditFrame<PCB_BASE_FRAME>();
262 
263  if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
264  {
265  m_gridOrigin->SetPosition( board()->GetGridOrigin() );
266  m_gridOrigin->SetColor( m_frame->GetGridColor() );
267  getView()->Remove( m_gridOrigin.get() );
268  getView()->Add( m_gridOrigin.get() );
269  }
270 }
271 
272 template<class T> void Flip( T& aValue )
273 {
274  aValue = !aValue;
275 }
276 
278 {
279  auto opts = displayOptions();
280 
281  Flip( opts->m_DisplayPcbTrackFill );
282  view()->UpdateDisplayOptions( opts );
283 
284  for( auto track : board()->Tracks() )
285  {
286  if( track->Type() == PCB_TRACE_T )
287  view()->Update( track, KIGFX::GEOMETRY );
288  }
289 
290  canvas()->Refresh();
291 
292  return 0;
293 }
294 
296 {
297  auto opts = displayOptions();
298 
299  Flip( opts->m_DisplayPadFill );
300  view()->UpdateDisplayOptions( opts );
301 
302  for( auto module : board()->Modules() ) // fixme: move to PCB_VIEW
303  {
304  for( auto pad : module->Pads() )
305  view()->Update( pad, KIGFX::GEOMETRY );
306  }
307 
308  canvas()->Refresh();
309 
310  return 0;
311 }
312 
313 
315 {
316  auto opts = displayOptions();
317 
318  Flip( opts->m_DisplayViaFill );
319  view()->UpdateDisplayOptions( opts );
320 
321  for( auto track : board()->Tracks() )
322  {
323  if( track->Type() == PCB_TRACE_T || track->Type() == PCB_VIA_T )
324  view()->Update( track, KIGFX::GEOMETRY );
325  }
326 
327  canvas()->Refresh();
328 
329  return 0;
330 }
331 
332 
334 {
335  auto opts = displayOptions();
336 
337  Flip( opts->m_DisplayDrawItemsFill );
338  view()->UpdateDisplayOptions( opts );
339 
340  for( auto item : board()->Drawings() )
341  {
342  view()->Update( item, KIGFX::GEOMETRY );
343  }
344 
345  canvas()->Refresh();
346 
347  return 0;
348 }
349 
350 
352 {
353  auto opts = displayOptions();
354 
355  Flip( opts->m_DisplayModEdgeFill );
356  view()->UpdateDisplayOptions( opts );
357 
358  for( auto module : board()->Modules() )
359  {
360  for( auto item : module->GraphicalItems() )
361  {
362  if( item->Type() == PCB_MODULE_EDGE_T )
363  view()->Update( item, KIGFX::GEOMETRY );
364  }
365  }
366 
367  canvas()->Refresh();
368 
369  return 0;
370 }
371 
372 
374 {
375  auto opts = displayOptions();
376 
377  Flip( opts->m_DisplayModTextFill );
378  view()->UpdateDisplayOptions( opts );
379 
380  for( auto module : board()->Modules() )
381  {
382  for( auto item : module->GraphicalItems() )
383  {
384  if( item->Type() == PCB_MODULE_TEXT_T )
385  view()->Update( item, KIGFX::GEOMETRY );
386  }
387 
390  }
391 
392  canvas()->Refresh();
393 
394  return 0;
395 }
396 
397 
399 {
400  auto opts = displayOptions();
401 
402  // Apply new display options to the GAL canvas
404  opts->m_DisplayZonesMode = 0;
405  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayDisable ) )
406  opts->m_DisplayZonesMode = 1;
407  else if( aEvent.IsAction( &PCB_ACTIONS::zoneDisplayOutlines ) )
408  opts->m_DisplayZonesMode = 2;
409  else
410  assert( false );
411 
412  view()->UpdateDisplayOptions( opts );
413 
414  for( int i = 0; i < board()->GetAreaCount(); ++i )
415  view()->Update( board()->GetArea( i ), KIGFX::GEOMETRY );
416 
417  canvas()->Refresh();
418 
419  return 0;
420 }
421 
422 
424 {
425  auto opts = displayOptions();
426 
427  Flip( opts->m_ContrastModeDisplay );
428  view()->UpdateDisplayOptions( opts );
430 
431  return 0;
432 }
433 
434 
436 {
437  return 0;
438 }
439 
440 
442 {
443  return 0;
444 }
445 
446 
447 // Layer control
449 {
450  m_frame->SwitchLayer( NULL, (PCB_LAYER_ID) aEvent.Parameter<intptr_t>() );
451 
452  return 0;
453 }
454 
455 
457 {
458  PCB_BASE_FRAME* editFrame = m_frame;
459  LAYER_NUM layer = editFrame->GetActiveLayer();
460 
461  if( layer < F_Cu || layer > B_Cu )
462  return 0;
463 
464  int layerCount = board()->GetCopperLayerCount();
465 
466  if( layer == layerCount - 2 || layerCount < 2 )
467  layer = B_Cu;
468  else if( layer == B_Cu )
469  layer = F_Cu;
470  else
471  ++layer;
472 
473  assert( IsCopperLayer( layer ) );
474  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
475 
476  return 0;
477 }
478 
479 
481 {
482  PCB_BASE_FRAME* editFrame = m_frame;
483  LAYER_NUM layer = editFrame->GetActiveLayer();
484 
485  if( layer < F_Cu || layer > B_Cu )
486  return 0;
487 
488  int layerCount = board()->GetCopperLayerCount();
489 
490  if( layer == F_Cu || layerCount < 2 )
491  layer = B_Cu;
492  else if( layer == B_Cu )
493  layer = layerCount - 2;
494  else
495  --layer;
496 
497  assert( IsCopperLayer( layer ) );
498  editFrame->SwitchLayer( NULL, ToLAYER_ID( layer ) );
499 
500  return 0;
501 }
502 
503 
505 {
506  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
507  PCB_SCREEN* screen = m_frame->GetScreen();
508 
509  if( currentLayer == screen->m_Route_Layer_TOP )
510  m_frame->SwitchLayer( NULL, screen->m_Route_Layer_BOTTOM );
511  else
512  m_frame->SwitchLayer( NULL, screen->m_Route_Layer_TOP );
513 
514  return 0;
515 }
516 
517 
518 // It'd be nice to share the min/max with the COLOR4D_PICKER_DLG, but those are
519 // set in wxFormBuilder.
520 #define ALPHA_MIN 0.20
521 #define ALPHA_MAX 1.00
522 #define ALPHA_STEP 0.05
523 
525 {
526  auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
527  auto settings = painter->GetSettings();
528 
529  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
530  KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
531 
532  if( currentColor.a <= ALPHA_MAX - ALPHA_STEP )
533  {
534  currentColor.a += ALPHA_STEP;
535  settings->SetLayerColor( currentLayer, currentColor );
536  m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
537 
538  wxUpdateUIEvent dummy;
539  static_cast<PCB_EDIT_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
540  }
541  else
542  wxBell();
543 
544  return 0;
545 }
546 
547 
549 {
550  auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
551  auto settings = painter->GetSettings();
552 
553  LAYER_NUM currentLayer = m_frame->GetActiveLayer();
554  KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer );
555 
556  if( currentColor.a >= ALPHA_MIN + ALPHA_STEP )
557  {
558  currentColor.a -= ALPHA_STEP;
559  settings->SetLayerColor( currentLayer, currentColor );
560  m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer );
561 
562  wxUpdateUIEvent dummy;
563  static_cast<PCB_BASE_FRAME*>( m_frame )->OnUpdateLayerAlpha( dummy );
564  }
565  else
566  wxBell();
567 
568  return 0;
569 }
570 
571 
572 // Cursor control
574 {
575  long type = aEvent.Parameter<intptr_t>();
576  bool fastMove = type & PCB_ACTIONS::CURSOR_FAST_MOVE;
577  type &= ~PCB_ACTIONS::CURSOR_FAST_MOVE;
578  bool mirroredX = getView()->IsMirroredX();
579 
580  GRID_HELPER gridHelper( m_frame );
581  VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true );
582  VECTOR2I gridSize = gridHelper.GetGrid();
583 
584  if( fastMove )
585  gridSize = gridSize * 10;
586 
587  switch( type )
588  {
590  cursor -= VECTOR2D( 0, gridSize.y );
591  break;
592 
594  cursor += VECTOR2D( 0, gridSize.y );
595  break;
596 
598  cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
599  break;
600 
602  cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
603  break;
604 
605  case PCB_ACTIONS::CURSOR_CLICK: // fall through
607  {
608  TOOL_ACTIONS action = TA_NONE;
609  int modifiers = 0;
610 
611  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
612  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
613  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
614 
615  if( type == PCB_ACTIONS::CURSOR_CLICK )
616  action = TA_MOUSE_CLICK;
617  else if( type == PCB_ACTIONS::CURSOR_DBL_CLICK )
618  action = TA_MOUSE_DBLCLICK;
619  else
620  assert( false );
621 
622  TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
623  evt.SetMousePosition( getViewControls()->GetCursorPosition() );
624  m_toolMgr->ProcessEvent( evt );
625 
626  return 0;
627  }
628  break;
629  }
630 
631  getViewControls()->SetCursorPosition( cursor );
632 
633  return 0;
634 }
635 
636 
638 {
639  long type = aEvent.Parameter<intptr_t>();
640  KIGFX::VIEW* view = getView();
641  GRID_HELPER gridHelper( m_frame );
642  VECTOR2D center = view->GetCenter();
643  VECTOR2I gridSize = gridHelper.GetGrid() * 10;
644  bool mirroredX = view->IsMirroredX();
645 
646  switch( type )
647  {
649  center -= VECTOR2D( 0, gridSize.y );
650  break;
651 
653  center += VECTOR2D( 0, gridSize.y );
654  break;
655 
657  center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
658  break;
659 
661  center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
662  break;
663 
664  default:
665  assert( false );
666  break;
667  }
668 
669  view->SetCenter( center );
670 
671  return 0;
672 }
673 
674 
675 // Grid control
677 {
679  updateGrid();
680 
681  return 0;
682 }
683 
684 
686 {
688  updateGrid();
689 
690  return 0;
691 }
692 
693 
695  BOARD_ITEM* originViewItem, const VECTOR2D& aPoint )
696 {
697  aFrame->SetGridOrigin( wxPoint( aPoint.x, aPoint.y ) );
698  aView->GetGAL()->SetGridOrigin( aPoint );
699  originViewItem->SetPosition( wxPoint( aPoint.x, aPoint.y ) );
700  aView->MarkDirty();
701  aFrame->OnModify();
702  return true;
703 }
704 
705 
707  BOARD_ITEM* originViewItem, const VECTOR2D& aPoint )
708 {
709  aFrame->SaveCopyInUndoList( originViewItem, UR_GRIDORIGIN );
710  return DoSetGridOrigin( aView, aFrame, originViewItem, aPoint );
711 }
712 
713 
715 {
716  VECTOR2D* origin = aEvent.Parameter<VECTOR2D*>();
717 
718  if( origin )
719  {
720  // We can't undo the other grid dialog settings, so no sense undoing just the origin
721 
722  DoSetGridOrigin( getView(), m_frame, m_gridOrigin.get(), *origin );
723  delete origin;
724  }
725  else
726  {
727  Activate();
728 
730  assert( picker );
731 
732  // TODO it will not check the toolbar button in module editor, as it uses a different ID..
733  m_frame->SetToolID( ID_PCB_PLACE_GRID_COORD_BUTT, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
734  picker->SetClickHandler( std::bind( SetGridOrigin, getView(), m_frame, m_gridOrigin.get(), _1 ) );
735  picker->Activate();
736  Wait();
737  }
738 
739  return 0;
740 }
741 
742 
744 {
745  SetGridOrigin( getView(), m_frame, m_gridOrigin.get(), VECTOR2D( 0, 0 ) );
746 
747  return 0;
748 }
749 
750 
751 // Miscellaneous
753 {
754  auto vcSettings = m_toolMgr->GetCurrentToolVC();
755 
756  // Use either the active tool forced cursor position or the general settings
757  VECTOR2I cursorPos = vcSettings.m_forceCursorPosition ? vcSettings.m_forcedPosition :
759 
760  m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
762 
763  return 0;
764 }
765 
766 
768 {
769  auto& galOpts = m_frame->GetGalDisplayOptions();
770 
771  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
772  galOpts.NotifyChanged();
773 
774  return 0;
775 }
776 
777 
779 {
780  // TODO should not it be refactored to pcb_frame member function?
781  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
782 
783  if( g_UserUnit == INCHES )
784  evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
785  else
786  evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
787 
788  m_frame->ProcessEvent( evt );
789 
790  return 0;
791 }
792 
793 
794 static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
795 {
796  SELECTION_TOOL* selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
797  assert( selectionTool );
798 
799  aToolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
800  aToolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
801  selectionTool->SanitizeSelection();
802 
803  const SELECTION& selection = selectionTool->GetSelection();
804 
805  if( selection.Empty() )
806  return true;
807 
808  aToolMgr->RunAction( PCB_ACTIONS::remove, true );
809 
810  return true;
811 }
812 
813 
815 {
816  Activate();
817 
819  assert( picker );
820 
821  // TODO it will not check the toolbar button in the module editor, as it uses a different ID..
822  m_frame->SetToolID( ID_PCB_DELETE_ITEM_BUTT, wxCURSOR_BULLSEYE, _( "Delete item" ) );
823  picker->SetSnapping( false );
824  picker->SetClickHandler( std::bind( deleteItem, m_toolMgr, _1 ) );
825  picker->Activate();
826  Wait();
827 
828  return 0;
829 }
830 
832 {
833  CLIPBOARD_IO pi;
834  BOARD tmpBoard;
835  BOARD_ITEM* clipItem = pi.Parse();
836 
837  if( !clipItem )
838  {
839  return 0;
840  }
841 
842  if( clipItem->Type() == PCB_T )
843  static_cast<BOARD*>(clipItem)->ClearAllNetCodes();
844 
845  bool editModules = m_editModules || frame()->IsType( FRAME_PCB_MODULE_EDITOR );
846 
847  // The clipboard can contain two different things, an entire kicad_pcb
848  // or a single module
849 
850  if( editModules && ( !board() || !module() ) )
851  {
852  wxLogDebug( wxT( "Attempting to paste to empty module editor window\n") );
853  return 0;
854  }
855 
856 
857  switch( clipItem->Type() )
858  {
859  case PCB_T:
860  {
861  if( editModules )
862  {
863  wxLogDebug( wxT( "attempting to paste a pcb in the footprint editor\n") );
864  return 0;
865  }
866 
867  placeBoardItems( static_cast<BOARD*>( clipItem ) );
868  break;
869  }
870 
871  case PCB_MODULE_T:
872  {
873  std::vector<BOARD_ITEM *> items;
874 
875  clipItem->SetParent( board() );
876 
877  if( editModules )
878  {
879  auto mod = static_cast<MODULE *>( clipItem );
880 
881  for( auto pad : mod->Pads() )
882  {
883  pad->SetParent ( board()->m_Modules.GetFirst() );
884  items.push_back( pad );
885  }
886  for( auto item : mod->GraphicalItems() )
887  {
888  item->SetParent ( board()->m_Modules.GetFirst() );
889  items.push_back( item );
890  }
891  }
892  else
893  {
894  items.push_back( clipItem );
895  }
896 
897  placeBoardItems( items, true );
898  break;
899  }
900  default:
901  m_frame->DisplayToolMsg( _( "Invalid clipboard contents" ) );
902  // FAILED
903  break;
904  }
905  return 1;
906 }
907 
909 {
910  int open_ctl;
911  wxString fileName;
912 
913  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
914 
915  if( !editFrame )
916  return 1;
917 
918  // Pick a file to append
919  if( !AskLoadBoardFileName( editFrame, &open_ctl, &fileName, true ) )
920  return 1;
921 
922  IO_MGR::PCB_FILE_T pluginType = plugin_type( fileName, open_ctl );
923  PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
924 
925  return AppendBoard( *pi, fileName );
926 }
927 
929 {
930  std::vector<BOARD_ITEM*> items;
931 
932  for( auto track : aBoard->Tracks() )
933  {
934  if( track->GetFlags() & FLAG0 )
935  track->ClearFlags( FLAG0 );
936  else
937  items.push_back( track );
938  }
939 
940  for( auto module : aBoard->Modules() )
941  {
942  if( module->GetFlags() & FLAG0 )
943  module->ClearFlags( FLAG0 );
944  else
945  items.push_back( module );
946  }
947 
948  for( auto drawing : aBoard->Drawings() )
949  {
950  if( drawing->GetFlags() & FLAG0 )
951  drawing->ClearFlags( FLAG0 );
952  else
953  items.push_back( drawing );
954  }
955 
956  for( auto zone : aBoard->Zones() )
957  {
958  if( zone->GetFlags() & FLAG0 )
959  zone->ClearFlags( FLAG0 );
960  else
961  items.push_back( zone );
962  }
963 
964  // items are new if the current board is not the board source
965  bool isNew = board() != aBoard;
966  return placeBoardItems( items, isNew );
967 }
968 
969 
970 int PCBNEW_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew )
971 {
973 
974  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
975  auto editTool = m_toolMgr->GetTool<EDIT_TOOL>();
976 
977  SELECTION& selection = selectionTool->GetSelection();
978 
979  for( auto item : aItems )
980  {
981  item->SetSelected();
982  selection.Add( item );
983 
984  // Add or just select items for the move/place command
985  if( aIsNew )
986  editTool->GetCurrentCommit()->Add( item );
987  else
988  editTool->GetCurrentCommit()->Added( item );
989  }
990 
991  selection.SetReferencePoint( VECTOR2I( 0, 0 ) );
992 
995 
996  return 0;
997 }
998 
999 
1000 int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
1001 {
1002  PCB_EDIT_FRAME* editFrame = dynamic_cast<PCB_EDIT_FRAME*>( m_frame );
1003 
1004  if( !editFrame )
1005  return 1;
1006 
1007  BOARD* brd = board();
1008 
1009  if( !brd )
1010  return 1;
1011 
1012  // Mark existing items, in order to know what are the new items
1013  // to be ble to select only the new items after loadind
1014  for( auto track : brd->Tracks() )
1015  {
1016  track->SetFlags( FLAG0 );
1017  }
1018 
1019  for( auto module : brd->Modules() )
1020  {
1021  module->SetFlags( FLAG0 );
1022  }
1023 
1024  for( auto drawing : brd->Drawings() )
1025  {
1026  drawing->SetFlags( FLAG0 );
1027  }
1028 
1029  for( auto zone : brd->Zones() )
1030  {
1031  zone->SetFlags( FLAG0 );
1032  }
1033 
1034  // Keep also the count of copper layers, to adjust if necessary
1035  int initialCopperLayerCount = brd->GetCopperLayerCount();
1036  LSET initialEnabledLayers = brd->GetEnabledLayers();
1037 
1038  // Load the data
1039  try
1040  {
1041  PROPERTIES props;
1042  char xbuf[30];
1043  char ybuf[30];
1044 
1045  // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
1046  sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
1047  sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
1048 
1049  props["page_width"] = xbuf;
1050  props["page_height"] = ybuf;
1051 
1052  editFrame->GetDesignSettings().m_NetClasses.Clear();
1053  pi.Load( fileName, brd, &props );
1054  }
1055  catch( const IO_ERROR& ioe )
1056  {
1057  wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
1058  DisplayError( editFrame, msg );
1059 
1060  return 0;
1061  }
1062 
1063  // rebuild nets and ratsnest before any use of nets
1064  brd->BuildListOfNets();
1066  brd->BuildConnectivity();
1067 
1068  // Synchronize layers
1069  // we should not ask PLUGINs to do these items:
1070  int copperLayerCount = brd->GetCopperLayerCount();
1071 
1072  if( copperLayerCount > initialCopperLayerCount )
1073  brd->SetCopperLayerCount( copperLayerCount );
1074 
1075  // Enable all used layers, and make them visible:
1076  LSET enabledLayers = brd->GetEnabledLayers();
1077  enabledLayers |= initialEnabledLayers;
1078  brd->SetEnabledLayers( enabledLayers );
1079  brd->SetVisibleLayers( enabledLayers );
1080 
1081 
1082  return placeBoardItems( brd );
1083 }
1084 
1085 
1087 {
1089 
1090  return 0;
1091 }
1092 
1093 
1095 {
1096  DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) );
1097 
1098  return 0;
1099 }
1100 
1101 
1103 {
1104  // Display modes
1117 
1118  // Layer control
1132 
1133  // Cursor control
1144 
1145  // Pan control
1150 
1151  // Grid control
1156 
1157  // Miscellaneous
1164 
1165  // Append control
1167  PCB_ACTIONS::appendBoard.MakeEvent() );
1168 
1170  PCB_ACTIONS::pasteFromClipboard.MakeEvent() );
1171 }
1172 
1173 
1175 {
1176  BASE_SCREEN* screen = m_frame->GetScreen();
1177  //GRID_TYPE grid = screen->GetGrid( idx );
1178  getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
1180 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:276
BOARD_ITEM * Parse()
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
const KIGFX::VC_SETTINGS & GetCurrentToolVC() const
Returns the view controls settings for the current tool or the general settings if there is no active...
void BuildListOfNets()
Definition: class_board.h:722
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:56
int SwitchCursor(const TOOL_EVENT &aEvent)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:266
int PanControl(const TOOL_EVENT &aEvent)
int PadDisplayMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorUpFast
Definition: pcb_actions.h:358
TEXTE_MODULE & Reference()
Definition: class_module.h:502
static TOOL_ACTION move
move an item
Definition: pcb_actions.h:93
static TOOL_ACTION layerNext
Definition: pcb_actions.h:277
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:271
static TOOL_ACTION cursorDblClick
Definition: pcb_actions.h:364
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:916
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:274
virtual void SetPosition(const wxPoint &aPos)=0
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:275
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:97
static TOOL_ACTION showHelp
Definition: pcb_actions.h:391
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:280
static TOOL_ACTION gridResetOrigin
Definition: actions.h:66
int LayerAlphaInc(const TOOL_EVENT &aEvent)
static TOOL_ACTION zoneDisplayOutlines
Definition: pcb_actions.h:263
Class SELECTION_TOOL.
TOOL_ACTIONS
Definition: tool_event.h:55
Class BOARD to handle a board.
void SetFastGrid2()
Function SetFastGrid2()
#define ALPHA_MIN
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION layerAlphaInc
Definition: pcb_actions.h:279
int GetCopperLayerCount() const
Function GetCopperLayerCount.
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:364
static TOOL_ACTION zoneDisplayDisable
Definition: pcb_actions.h:262
DLIST_ITERATOR_WRAPPER< D_PAD > Pads()
Definition: class_module.h:167
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:397
void SetCopperLayerCount(int aCount)
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
int ModuleEdgeOutlines(const TOOL_EVENT &aEvent)
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:353
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:320
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:186
static TOOL_ACTION switchUnits
Definition: pcb_actions.h:383
void setTransitions() override
Sets up handlers for various events.
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:272
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:405
int LayerNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION deleteItemCursor
Definition: pcb_actions.h:384
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
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
static TOOL_ACTION resetCoords
Definition: pcb_actions.h:380
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:123
Auxiliary rendering target (noncached)
Definition: definitions.h:42
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
PCB_BASE_FRAME * m_frame
Pointer to the currently used edit frame.
static TOOL_ACTION layerTop
Definition: pcb_actions.h:269
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:214
Class RELEASER releases a PLUGIN in the context of a potential thrown exception, through its destruct...
Definition: io_mgr.h:563
PCB_DISPLAY_OPTIONS * displayOptions() const
Definition: pcb_tool.cpp:209
Class TOOL_MANAGER.
Definition: tool_manager.h:49
void SynchronizeNetsAndNetClasses()
Function SynchronizeNetsAndNetClasses copies NETCLASS info to each NET, based on NET membership in a ...
Definition: netclass.cpp:158
static TOOL_ACTION highContrastMode
Definition: pcb_actions.h:264
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > GraphicalItems()
Definition: class_module.h:172
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:390
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.
#define ALPHA_STEP
static TOOL_ACTION cursorRightFast
Definition: pcb_actions.h:361
static bool deleteItem(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:264
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:278
static TOOL_ACTION toBeDone
Definition: pcb_actions.h:393
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:198
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 &#39;dirty&#39; flag.
Definition: view.h:577
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:224
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:370
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
int GraphicDisplayMode(const TOOL_EVENT &aEvent)
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
Definition: common.h:145
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:135
Class TOOL_EVENT.
Definition: tool_event.h:162
static TOOL_ACTION cursorClick
Definition: pcb_actions.h:363
SELECTION & GetSelection()
Function GetSelection()
int LayerToggle(const TOOL_EVENT &aEvent)
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
static TOOL_ACTION panUp
Definition: pcb_actions.h:367
MODULE * module() const
Definition: pcb_tool.h:137
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
int ZoneDisplayMode(const TOOL_EVENT &aEvent)
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1011
const SELECTION & selection() const
Definition: pcb_tool.cpp:219
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:356
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:517
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:127
std::unique_ptr< KIGFX::ORIGIN_VIEWITEM > m_gridOrigin
Grid origin marker.
int ModuleTextOutlines(const TOOL_EVENT &aEvent)
int AppendBoardFromFile(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectionTool
Definition: pcb_actions.h:378
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 TOOL_ACTION moduleEdgeOutlines
Display module edges as outlines.
Definition: pcb_actions.h:326
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:369
bool m_editModules
Definition: pcb_tool.h:143
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:258
bool AskLoadBoardFileName(wxWindow *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly=false)
Function AskLoadBoardFileName puts up a wxFileDialog asking for a BOARD filename to open...
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
static TOOL_ACTION viaDisplayMode
Definition: pcb_actions.h:259
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:725
static bool DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
static TOOL_ACTION moduleTextOutlines
Display module texts as outlines.
Definition: pcb_actions.h:329
#define ALPHA_MAX
int ShowHelp(const TOOL_EVENT &aEvent)
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
static TOOL_ACTION cursorLeft
Definition: pcb_actions.h:355
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:283
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
Class PCB_ACTIONS.
Definition: pcb_actions.h:42
static TOOL_ACTION highContrastInc
Definition: pcb_actions.h:265
ZONE_CONTAINERS & Zones()
Definition: class_board.h:252
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:553
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.
Definition: netclass.h:249
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:382
IO_MGR::PCB_FILE_T plugin_type(const wxString &aFileName, int aCtl)
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
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:133
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:266
Class TOOL_ACTION.
Definition: tool_action.h:46
size_t i
Definition: json11.cpp:597
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
static bool SetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, BOARD_ITEM *originViewItem, const VECTOR2D &aPoint)
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.
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.
static TOOL_ACTION graphicDisplayMode
Definition: pcb_actions.h:260
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:265
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:895
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:273
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:354
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:334
bool IsType(FRAME_T aType) const
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:129
static TOOL_ACTION cursorLeftFast
Definition: pcb_actions.h:360
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:52
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:270
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:216
int AppendBoard(PLUGIN &pi, wxString &fileName)
Rendering engine changes.
Definition: tool_base.h:84
static TOOL_ACTION panDown
Definition: pcb_actions.h:368
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:185
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
static TOOL_ACTION highContrastDec
Definition: pcb_actions.h:266
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
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...
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:603
static TOOL_ACTION trackDisplayMode
Definition: pcb_actions.h:257
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:45
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:281
BOARD * board() const
Definition: pcb_tool.h:136
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:261
int HighContrastDec(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorDownFast
Definition: pcb_actions.h:359