KiCad PCB EDA Suite
pcb_base_frame.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) 2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
31 #include <fctsys.h>
32 #include <kiface_i.h>
33 #include <eda_base_frame.h>
34 #include <confirm.h>
35 #include <kiface_i.h>
36 #include <dialog_helpers.h>
37 #include <kicad_device_context.h>
38 #include <pcb_base_frame.h>
39 #include <base_units.h>
40 #include <msgpanel.h>
41 #include <pgm_base.h>
42 #include <3d_viewer/eda_3d_viewer.h> // To include VIEWER3D_FRAMENAME
43 
44 #include <pcbnew.h>
45 #include <fp_lib_table.h>
46 #include <pcbnew_id.h>
47 #include <class_board.h>
48 #include <class_track.h>
49 #include <class_module.h>
50 #include <class_drawsegment.h>
51 
52 #include <collectors.h>
53 #include <class_drawpanel.h>
54 #include <pcb_draw_panel_gal.h>
55 #include <pcb_view.h>
56 #include <math/vector2d.h>
57 #include <trigo.h>
58 #include <pcb_painter.h>
59 
60 #include <tool/tool_manager.h>
61 #include <tool/tool_dispatcher.h>
62 #include <tools/pcb_actions.h>
63 
64 const wxChar PCB_BASE_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
65 const wxChar PCB_BASE_FRAME::AUTO_ZOOM_KEY[] = wxT( "AutoZoom" );
66 const wxChar PCB_BASE_FRAME::ZOOM_KEY[] = wxT( "Zoom" );
67 
68 // Configuration entry names.
69 static const wxChar UserGridSizeXEntry[] = wxT( "PcbUserGrid_X" );
70 static const wxChar UserGridSizeYEntry[] = wxT( "PcbUserGrid_Y" );
71 static const wxChar UserGridUnitsEntry[] = wxT( "PcbUserGrid_Unit" );
72 static const wxChar DisplayPadFillEntry[] = wxT( "DiPadFi" );
73 static const wxChar DisplayViaFillEntry[] = wxT( "DiViaFi" );
74 static const wxChar DisplayPadNumberEntry[] = wxT( "DiPadNu" );
75 static const wxChar DisplayModuleEdgeEntry[] = wxT( "DiModEd" );
76 static const wxChar DisplayModuleTextEntry[] = wxT( "DiModTx" );
77 static const wxChar FastGrid1Entry[] = wxT( "FastGrid1" );
78 static const wxChar FastGrid2Entry[] = wxT( "FastGrid2" );
79 
80 
81 BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
83  PCB_BASE_FRAME::ProcessItemSelection )
84 
87  EVT_TOOL( ID_TB_OPTIONS_SHOW_GRAPHIC_SKETCH, PCB_BASE_FRAME::OnToggleGraphicDrawMode )
90 
91  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLAR_COORD, PCB_BASE_FRAME::OnUpdateCoordType )
92  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_PADS_SKETCH, PCB_BASE_FRAME::OnUpdatePadDrawMode )
93  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRAPHIC_SKETCH, PCB_BASE_FRAME::OnUpdateGraphicDrawMode )
94  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, PCB_BASE_FRAME::OnUpdateEdgeDrawMode )
95  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, PCB_BASE_FRAME::OnUpdateTextDrawMode )
96  EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid )
97  EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom )
98  // Switching canvases
99  EVT_UPDATE_UI( ID_MENU_CANVAS_LEGACY, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
100  EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
101  EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
102 
104 END_EVENT_TABLE()
105 
106 
107 PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
108  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
109  long aStyle, const wxString & aFrameName ) :
110  EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
111  m_Pcb( nullptr ),
112  m_configSettings( aFrameType )
113 {
114  m_UserGridSize = wxPoint( (int) 10 * IU_PER_MILS, (int) 10 * IU_PER_MILS );
115  m_Collector = new GENERAL_COLLECTOR();
116 
117  m_FastGrid1 = 0;
118  m_FastGrid2 = 0;
119 
120  m_zoomLevelCoeff = 11.0 * IU_PER_MILS; // Adjusted to roughly displays zoom level = 1
121  // when the screen shows a 1:1 image
122  // obviously depends on the monitor,
123  // but this is an acceptable value
124 }
125 
126 
128 {
129  delete m_Collector;
130  delete m_Pcb;
131 }
132 
133 
135 {
136  // return the 3D viewer frame, when exists, or NULL
137  return static_cast<EDA_3D_VIEWER*>
138  ( wxWindow::FindWindowByName( VIEWER3D_FRAMENAME ) );
139 }
140 
141 
142 bool PCB_BASE_FRAME::Update3DView( const wxString* aTitle )
143 {
144  // Update the 3D view only if the viewer is opened by this frame
145  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
146 
147  if( draw3DFrame == NULL )
148  return false;
149 
150  // Ensure the viewer was created by me, and not by another editor:
151  PCB_BASE_FRAME* owner = draw3DFrame->Parent();
152 
153  // if I am not the owner, do not use the current viewer instance
154  if( this != owner )
155  return false;
156 
157  if( aTitle )
158  draw3DFrame->SetTitle( *aTitle );
159 
160  draw3DFrame->NewDisplay( true );
161 
162  return true;
163 }
164 
165 
167 {
168  // This is a lazy loading function, it loads the project specific table when
169  // that table is asked for, not before.
170 
171  FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL );
172 
173  // its gotta be NULL or a FP_LIB_TABLE, or a bug.
174  wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
175 
176  if( !tbl )
177  {
178  // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
179  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
180  // stack this way, all using the same global fallback table.
181  tbl = new FP_LIB_TABLE( &GFootprintTable );
182 
183  SetElem( ELEM_FPTBL, tbl );
184 
185  wxString projectFpLibTableFileName = FootprintLibTblName();
186 
187  try
188  {
189  tbl->Load( projectFpLibTableFileName );
190  }
191  catch( const IO_ERROR& ioe )
192  {
193  DisplayErrorMessage( nullptr,
194  _( "Error loading project footprint libraries" ),
195  ioe.What() );
196  }
197  }
198 
199  return tbl;
200 }
201 
202 
204 {
205  if( m_Pcb != aBoard )
206  {
207  delete m_Pcb;
208  m_Pcb = aBoard;
209  m_Pcb->SetColorsSettings( &Settings().Colors() );
210  }
211 }
212 
213 
215 {
216  if( module )
217  {
218  GetBoard()->Add( module, ADD_APPEND );
219 
220  module->SetFlags( IS_NEW );
221 
222  if( IsGalCanvasActive() )
223  module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
224  else
225  module->SetPosition( GetCrossHairPosition() );
226 
227  module->SetTimeStamp( GetNewTimeStamp() );
228  GetBoard()->m_Status_Pcb = 0;
229 
230  // Put it on FRONT layer,
231  // (Can be stored flipped if the lib is an archive built from a board)
232  if( module->IsFlipped() )
233  module->Flip( module->GetPosition() );
234 
235  // Place it in orientation 0,
236  // even if it is not saved with orientation 0 in lib
237  // (Can happen if the lib is an archive built from a board)
238  module->SetOrientation( 0 );
239  }
240 }
241 
242 
243 void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
244 {
245  wxASSERT( m_Pcb );
246  m_Pcb->SetPageSettings( aPageSettings );
247 
248  if( GetScreen() )
249  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
250 }
251 
252 
254 {
255  wxASSERT( m_Pcb );
256  return m_Pcb->GetPageSettings();
257 }
258 
259 
260 const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
261 {
262  wxASSERT( m_Pcb );
263 
264  // this function is only needed because EDA_DRAW_FRAME is not compiled
265  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
266  // into an application specific source file.
267  return m_Pcb->GetPageSettings().GetSizeIU();
268 }
269 
270 
272 {
273  wxASSERT( m_Pcb );
274  return m_Pcb->GetAuxOrigin();
275 }
276 
277 
279 {
280  wxASSERT( m_Pcb );
281  m_Pcb->SetAuxOrigin( aPoint );
282 }
283 
284 
286 {
287  wxASSERT( m_Pcb );
288  return m_Pcb->GetGridOrigin();
289 }
290 
291 
293 {
294  wxASSERT( m_Pcb );
295  m_Pcb->SetGridOrigin( aPoint );
296 }
297 
298 
300 {
301  wxASSERT( m_Pcb );
302  return m_Pcb->GetTitleBlock();
303 }
304 
305 
306 void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
307 {
308  wxASSERT( m_Pcb );
309  m_Pcb->SetTitleBlock( aTitleBlock );
310 }
311 
312 
314 {
315  wxASSERT( m_Pcb );
316  return m_Pcb->GetDesignSettings();
317 }
318 
319 
321 {
322  wxASSERT( m_Pcb );
323  m_Pcb->SetDesignSettings( aSettings );
324 }
325 
326 
328 {
329  m_drawBgColor= aColor;
330  m_auimgr.Update();
331 }
332 
333 
335 {
336  wxASSERT( m_Pcb );
337  return m_Pcb->GetZoneSettings();
338 }
339 
340 
342 {
343  wxASSERT( m_Pcb );
344  m_Pcb->SetZoneSettings( aSettings );
345 }
346 
347 
349 {
350  wxASSERT( m_Pcb );
351  return m_Pcb->GetPlotOptions();
352 }
353 
354 
356 {
357  wxASSERT( m_Pcb );
358  m_Pcb->SetPlotOptions( aSettings );
359 }
360 
361 
362 EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
363 {
364  wxASSERT( m_Pcb );
365 
366  EDA_RECT area = aBoardEdgesOnly ? m_Pcb->GetBoardEdgesBoundingBox() : m_Pcb->GetBoundingBox();
367 
368  if( area.GetWidth() == 0 && area.GetHeight() == 0 )
369  {
370  wxSize pageSize = GetPageSizeIU();
371 
373  {
374  area.SetOrigin( 0, 0 );
375  area.SetEnd( pageSize.x, pageSize.y );
376  }
377  else
378  {
379  area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
380  area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
381  }
382  }
383 
384  return area;
385 }
386 
387 
389 {
390  EDA_RECT ibbbox = GetBoardBoundingBox();
391 
392  double sizeX = (double) ibbbox.GetWidth();
393  double sizeY = (double) ibbbox.GetHeight();
394  wxPoint centre = ibbbox.Centre();
395 
396  // Reserve a 10% margin around board bounding box.
397  double margin_scale_factor = 1.1;
398 
399  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
400 }
401 
402 
403 // Virtual function
405 {
406 }
407 
408 
410 {
411  // call my base class
413 
414  // tooltips in toolbars
419 
420  // status bar
421  UpdateMsgPanel();
422 }
423 
424 
425 // Virtual functions: Do nothing for PCB_BASE_FRAME window
426 void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
427 {
428 }
429 
430 
431 bool PCB_BASE_FRAME::CreateAndShow3D_Frame( bool aForceRecreateIfNotOwner )
432 {
433  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
434 
435  // Ensure the viewer was created by me, and not by another editor:
436  PCB_BASE_FRAME* owner = draw3DFrame ? draw3DFrame->Parent() : nullptr;
437 
438  // if I am not the owner, do not use the current viewer instance
439  if( draw3DFrame && this != owner )
440  {
441  if( aForceRecreateIfNotOwner )
442  {
443  draw3DFrame->Destroy();
444  draw3DFrame = nullptr;
445  }
446  else
447  return false;
448  }
449 
450  if( !draw3DFrame )
451  {
452  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
453  draw3DFrame->Raise(); // Needed with some Window Managers
454  draw3DFrame->Show( true );
455  return true;
456  }
457 
458  // Raising the window does not show the window on Windows if iconized.
459  // This should work on any platform.
460  if( draw3DFrame->IsIconized() )
461  draw3DFrame->Iconize( false );
462 
463  draw3DFrame->Raise();
464 
465  // Raising the window does not set the focus on Linux. This should work on any platform.
466  if( wxWindow::FindFocus() != draw3DFrame )
467  draw3DFrame->SetFocus();
468 
469  return true;
470 }
471 
472 
473 // Note: virtual, overridden in PCB_EDIT_FRAME;
475 {
476  PCB_LAYER_ID preslayer = GetActiveLayer();
477  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
478 
479  // Check if the specified layer matches the present layer
480  if( layer == preslayer )
481  return;
482 
483  // Copper layers cannot be selected unconditionally; how many
484  // of those layers are currently enabled needs to be checked.
485  if( IsCopperLayer( layer ) )
486  {
487  // If only one copper layer is enabled, the only such layer
488  // that can be selected to is the "Copper" layer (so the
489  // selection of any other copper layer is disregarded).
490  if( m_Pcb->GetCopperLayerCount() < 2 )
491  {
492  if( layer != B_Cu )
493  {
494  return;
495  }
496  }
497 
498  // If more than one copper layer is enabled, the "Copper"
499  // and "Component" layers can be selected, but the total
500  // number of copper layers determines which internal
501  // layers are also capable of being selected.
502  else
503  {
504  if( ( layer != B_Cu ) && ( layer != F_Cu )
505  && ( layer >= m_Pcb->GetCopperLayerCount() - 1 ) )
506  {
507  return;
508  }
509  }
510  }
511 
512  // Is yet more checking required? E.g. when the layer to be selected
513  // is a non-copper layer, or when switching between a copper layer
514  // and a non-copper layer, or vice-versa?
515  // ...
516 
517  GetScreen()->m_Active_Layer = layer;
518 
519  if( displ_opts->m_ContrastModeDisplay )
520  m_canvas->Refresh();
521 }
522 
523 
524 void PCB_BASE_FRAME::OnTogglePolarCoords( wxCommandEvent& aEvent )
525 {
526  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
527  SetStatusText( wxEmptyString );
528 
529  displ_opts->m_DisplayPolarCood = !displ_opts->m_DisplayPolarCood;
530 
531  UpdateStatusBar();
532 }
533 
534 
535 void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
536 {
537  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
538 
539  displ_opts->m_DisplayPadFill = !displ_opts->m_DisplayPadFill;
541 
542  if( gal )
543  {
544  // Apply new display options to the GAL canvas
545  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
546  view->UpdateDisplayOptions( displ_opts );
547 
548  // Update pads
549  BOARD* board = GetBoard();
550  for( MODULE* module = board->m_Modules; module; module = module->Next() )
551  {
552  for( auto pad : module->Pads() )
553  view->Update( pad, KIGFX::GEOMETRY );
554  }
555  }
556 
557  m_canvas->Refresh();
558 }
559 
560 
561 void PCB_BASE_FRAME::OnToggleGraphicDrawMode( wxCommandEvent& aEvent )
562 {
563  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
564  displ_opts->m_DisplayDrawItemsFill = !displ_opts->m_DisplayDrawItemsFill;
565  m_canvas->Refresh();
566 }
567 
568 
569 void PCB_BASE_FRAME::OnToggleEdgeDrawMode( wxCommandEvent& aEvent )
570 {
571  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
572  displ_opts->m_DisplayModEdgeFill = !displ_opts->m_DisplayModEdgeFill;
574 
575  if( gal )
576  {
577  // Apply new display options to the GAL canvas
578  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
579  view->UpdateDisplayOptions( displ_opts );
580  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
581  }
582 
583  m_canvas->Refresh();
584 }
585 
586 
587 void PCB_BASE_FRAME::OnToggleTextDrawMode( wxCommandEvent& aEvent )
588 {
589  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
590  displ_opts->m_DisplayModTextFill = !displ_opts->m_DisplayModTextFill;
592 
593  if( gal )
594  {
595  // Apply new display options to the GAL canvas
596  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
597  view->UpdateDisplayOptions( displ_opts );
598  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
599  }
600 
601  m_canvas->Refresh();
602 }
603 
604 
605 void PCB_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
606 {
607  switch( aEvent.GetId() )
608  {
611  break;
612 
615  break;
616 
619  break;
620  }
621 }
622 
623 
624 void PCB_BASE_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent )
625 {
626  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
627 
628  aEvent.Check( displ_opts->m_DisplayPolarCood );
630  displ_opts->m_DisplayPolarCood ?
631  _( "Display rectangular coordinates" ) :
632  _( "Display polar coordinates" ) );
633 }
634 
635 
636 void PCB_BASE_FRAME::OnUpdatePadDrawMode( wxUpdateUIEvent& aEvent )
637 {
638  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
639 
640  aEvent.Check( !displ_opts->m_DisplayPadFill );
642  displ_opts->m_DisplayPadFill ?
643  _( "Show pads in outline mode" ) :
644  _( "Show pads in fill mode" ) );
645 }
646 
647 
648 void PCB_BASE_FRAME::OnUpdateGraphicDrawMode( wxUpdateUIEvent& aEvent )
649 {
650  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
651  aEvent.Check( !displ_opts->m_DisplayDrawItemsFill);
652 }
653 
654 
655 void PCB_BASE_FRAME::OnUpdateEdgeDrawMode( wxUpdateUIEvent& aEvent )
656 {
657  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
658  aEvent.Check( !displ_opts->m_DisplayModEdgeFill );
659 
660  wxString msgEdgesFill[2] = { _( "Show outlines in filled mode" ),
661  _( "Show outlines in sketch mode" ) };
662 
663  unsigned i = displ_opts->m_DisplayModTextFill == SKETCH ? 0 : 1;
664  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, msgEdgesFill[i] );
665 }
666 
667 
668 void PCB_BASE_FRAME::OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent )
669 {
670  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
671  aEvent.Check( !displ_opts->m_DisplayModTextFill );
672 
673  wxString msgTextsFill[2] = { _( "Show texts in filled mode" ),
674  _( "Show texts in sketch mode" ) };
675  unsigned i = displ_opts->m_DisplayModTextFill == SKETCH ? 0 : 1;
676  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, msgTextsFill[i] );
677 }
678 
679 
680 void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
681 {
682  if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL )
683  return;
684 
685  int current = 0; // display Auto if no match found
686 
687  // check for a match within 1%
688  double zoom = IsGalCanvasActive() ? GetGalCanvas()->GetLegacyZoom() : GetScreen()->GetZoom();
689 
690  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
691  {
692  if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
693  {
694  current = i + 1;
695  break;
696  }
697  }
698 
699  if( current != m_zoomSelectBox->GetSelection() )
700  m_zoomSelectBox->SetSelection( current );
701 }
702 
703 
704 void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent )
705 {
706  int id = aEvent.GetId();
707 
708  // index into the collector list:
709  int itemNdx = id - ID_POPUP_PCB_ITEM_SELECTION_START;
710 
711  if( id >= ID_POPUP_PCB_ITEM_SELECTION_START && id <= ID_POPUP_PCB_ITEM_SELECTION_END )
712  {
713  BOARD_ITEM* item = (*m_Collector)[itemNdx];
714  m_canvas->SetAbortRequest( false );
715 
716 #if 0 && defined (DEBUG)
717  item->Show( 0, std::cout );
718 #endif
719 
720  SetCurItem( item );
721  }
722 }
723 
724 
725 void PCB_BASE_FRAME::SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo )
726 {
727  GetScreen()->SetCurItem( aItem );
728 
729  if( aDisplayInfo )
730  UpdateMsgPanel();
731 }
732 
733 
735 {
736  BOARD_ITEM* item = GetScreen()->GetCurItem();
737  MSG_PANEL_ITEMS items;
738 
739  if( item )
740  {
741  item->GetMsgPanelInfo( m_UserUnits, items );
742  }
743  else // show general information about the board
744  {
745  if( IsGalCanvasActive() )
747  else
748  m_Pcb->GetMsgPanelInfo( m_UserUnits, items );
749  }
750 
751  SetMsgPanel( items );
752 }
753 
754 
756 {
757  return GetScreen()->GetCurItem();
758 }
759 
760 
762 {
764  GetGalCanvas()->GetView() );
765 
766  // account for the globals
768  guide.SetIgnoreMTextsOnBack( ! m_Pcb->IsElementVisible( LAYER_MOD_TEXT_BK ) );
769  guide.SetIgnoreMTextsOnFront( ! m_Pcb->IsElementVisible( LAYER_MOD_TEXT_FR ) );
770  guide.SetIgnoreModulesOnBack( ! m_Pcb->IsElementVisible( LAYER_MOD_BK ) );
771  guide.SetIgnoreModulesOnFront( ! m_Pcb->IsElementVisible( LAYER_MOD_FR ) );
772  guide.SetIgnorePadsOnBack( ! m_Pcb->IsElementVisible( LAYER_PAD_BK ) );
773  guide.SetIgnorePadsOnFront( ! m_Pcb->IsElementVisible( LAYER_PAD_FR ) );
774  guide.SetIgnoreThroughHolePads( ! m_Pcb->IsElementVisible( LAYER_PADS_TH ) );
775  guide.SetIgnoreModulesVals( ! m_Pcb->IsElementVisible( LAYER_MOD_VALUES ) );
776  guide.SetIgnoreModulesRefs( ! m_Pcb->IsElementVisible( LAYER_MOD_REFERENCES ) );
777  guide.SetIgnoreThroughVias( ! m_Pcb->IsElementVisible( LAYER_VIA_THROUGH ) );
778  guide.SetIgnoreBlindBuriedVias( ! m_Pcb->IsElementVisible( LAYER_VIA_BBLIND ) );
779  guide.SetIgnoreMicroVias( ! m_Pcb->IsElementVisible( LAYER_VIA_MICROVIA ) );
780  guide.SetIgnoreTracks( ! m_Pcb->IsElementVisible( LAYER_TRACKS ) );
781 
782  return guide;
783 }
784 
785 void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
786 {
787  bool redraw = false;
788 
789  EDA_DRAW_FRAME::SetToolID( aId, aCursor, aToolMsg );
790 
791  if( aId < 0 )
792  return;
793 
794  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
795 
796  // handle color changes for transitions in and out of ID_TRACK_BUTT
797  if( ( GetToolId() == ID_TRACK_BUTT && aId != ID_TRACK_BUTT )
798  || ( GetToolId() != ID_TRACK_BUTT && aId == ID_TRACK_BUTT ) )
799  {
800  if( displ_opts->m_ContrastModeDisplay )
801  redraw = true;
802  }
803 
804  // must do this after the tool has been set, otherwise pad::Draw() does
805  // not show proper color when GetDisplayOptions().ContrastModeDisplay is true.
806  if( redraw && m_canvas )
807  m_canvas->Refresh();
808 }
809 
810 
811 /*
812  * Update the status bar information.
813  */
815 {
816  PCB_SCREEN* screen = GetScreen();
817 
818  if( !screen )
819  return;
820 
821  int dx;
822  int dy;
823  double dXpos;
824  double dYpos;
825  wxString line;
826  wxString locformatter;
827  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
828 
830 
831  if( displ_opts->m_DisplayPolarCood ) // display polar coordinates
832  {
833  double theta, ro;
834 
835  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
836  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
837 
838  theta = ArcTangente( -dy, dx ) / 10;
839 
840  ro = hypot( dx, dy );
841  wxString formatter;
842  switch( GetUserUnits() )
843  {
844  case INCHES:
845  formatter = wxT( "r %.6f theta %.1f" );
846  break;
847 
848  case MILLIMETRES:
849  formatter = wxT( "r %.6f theta %.1f" );
850  break;
851 
852  case UNSCALED_UNITS:
853  formatter = wxT( "r %f theta %f" );
854  break;
855 
856  case DEGREES:
857  wxASSERT( false );
858  break;
859  }
860 
861  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
862 
863  SetStatusText( line, 3 );
864  }
865 
866  // Display absolute coordinates:
869 
870  // The following sadly is an if Eeschema/if Pcbnew
871  wxString absformatter;
872 
873  switch( GetUserUnits() )
874  {
875  case INCHES:
876  absformatter = wxT( "X %.6f Y %.6f" );
877  locformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
878  break;
879 
880  case MILLIMETRES:
881  absformatter = wxT( "X %.6f Y %.6f" );
882  locformatter = wxT( "dx %.6f dy %.6f dist %.3f" );
883  break;
884 
885  case UNSCALED_UNITS:
886  absformatter = wxT( "X %f Y %f" );
887  locformatter = wxT( "dx %f dy %f dist %f" );
888  break;
889 
890  case DEGREES:
891  wxASSERT( false );
892  break;
893  }
894 
895  line.Printf( absformatter, dXpos, dYpos );
896  SetStatusText( line, 2 );
897 
898  if( !displ_opts->m_DisplayPolarCood ) // display relative cartesian coordinates
899  {
900  // Display relative coordinates:
901  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
902  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
903  dXpos = To_User_Unit( GetUserUnits(), dx );
904  dYpos = To_User_Unit( GetUserUnits(), dy );
905 
906  // We already decided the formatter above
907  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
908  SetStatusText( line, 3 );
909  }
910 }
911 
912 
914 {
915  EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
916 
918 }
919 
920 
921 void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
922 {
924 
925  // Ensure grid id is an existent grid id:
926  if( (m_LastGridSizeId <= 0) ||
929 
930  wxString baseCfgName = GetName();
931 
932  EDA_UNITS_T userGridUnits;
933  aCfg->Read( baseCfgName + UserGridUnitsEntry, ( int* )&userGridUnits, ( int )INCHES );
934 
935  double tmp;
936  aCfg->Read( baseCfgName + UserGridSizeXEntry, &tmp, 0.01 );
937  m_UserGridSize.x = From_User_Unit( userGridUnits, tmp );
938 
939  aCfg->Read( baseCfgName + UserGridSizeYEntry, &tmp, 0.01 );
940  m_UserGridSize.y = From_User_Unit( userGridUnits, tmp );
941 
942  aCfg->Read( baseCfgName + DisplayPadFillEntry, &m_DisplayOptions.m_DisplayPadFill, true );
943  aCfg->Read( baseCfgName + DisplayViaFillEntry, &m_DisplayOptions.m_DisplayViaFill, true );
944  aCfg->Read( baseCfgName + DisplayPadNumberEntry, &m_DisplayOptions.m_DisplayPadNum, true );
945  aCfg->Read( baseCfgName + DisplayModuleEdgeEntry, &m_DisplayOptions.m_DisplayModEdgeFill, true );
946 
947  long itmp;
948  aCfg->Read( baseCfgName + FastGrid1Entry, &itmp, ( long )0);
949  m_FastGrid1 = itmp;
950  aCfg->Read( baseCfgName + FastGrid2Entry, &itmp, ( long )0);
951  m_FastGrid2 = itmp;
952 
953  aCfg->Read( baseCfgName + DisplayModuleTextEntry, &m_DisplayOptions.m_DisplayModTextFill, true );
954 }
955 
956 
957 void PCB_BASE_FRAME::SaveSettings( wxConfigBase* aCfg )
958 {
960 
961  wxString baseCfgName = GetName();
962 
963  aCfg->Write( baseCfgName + UserGridSizeXEntry, To_User_Unit( m_UserUnits, m_UserGridSize.x ) );
964  aCfg->Write( baseCfgName + UserGridSizeYEntry, To_User_Unit( m_UserUnits, m_UserGridSize.y ) );
965  aCfg->Write( baseCfgName + UserGridUnitsEntry, ( long )m_UserUnits );
966  aCfg->Write( baseCfgName + DisplayPadFillEntry, m_DisplayOptions.m_DisplayPadFill );
967  aCfg->Write( baseCfgName + DisplayViaFillEntry, m_DisplayOptions.m_DisplayViaFill );
968  aCfg->Write( baseCfgName + DisplayPadNumberEntry, m_DisplayOptions.m_DisplayPadNum );
969  aCfg->Write( baseCfgName + DisplayModuleEdgeEntry, m_DisplayOptions.m_DisplayModEdgeFill );
970  aCfg->Write( baseCfgName + DisplayModuleTextEntry, m_DisplayOptions.m_DisplayModTextFill );
971  aCfg->Write( baseCfgName + FastGrid1Entry, ( long )m_FastGrid1 );
972  aCfg->Write( baseCfgName + FastGrid2Entry, ( long )m_FastGrid2 );
973 }
974 
975 
977 {
979 
984 
985  EDA_3D_VIEWER* viewer = Get3DViewerFrame();
986 
987  if( viewer )
988  {
989  bool option;
990  Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
991  viewer->GetSettings().SetFlag( FL_MOUSEWHEEL_PANNING, option );
992  }
993 }
994 
995 
997 {
998  GetScreen()->SetModify();
999  GetScreen()->SetSave();
1000 
1001  if( IsGalCanvasActive() )
1002  {
1003  UpdateStatusBar();
1004  UpdateMsgPanel();
1005  }
1006 }
1007 
1008 
1010 {
1012 }
1013 
1014 
1016 {
1017  UpdateStatusBar();
1018  DisplayUnitsMsg();
1019 
1020  if( m_gridSelectBox == NULL )
1021  return;
1022 
1023  // Update grid values with the current units setting.
1024  m_gridSelectBox->Clear();
1025  wxArrayString gridsList;
1026  int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1027 
1028  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
1029  {
1030  GRID_TYPE& grid = GetScreen()->GetGrid( i );
1031  m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
1032  }
1033 
1034  m_gridSelectBox->Append( wxT( "---" ) );
1035  m_gridSelectBox->Append( _( "Edit user grid..." ) );
1036 
1037  m_gridSelectBox->SetSelection( icurr );
1038 }
1039 
1040 
1042 {
1043  if( m_zoomSelectBox == NULL )
1044  return;
1045 
1046  wxString msg;
1047 
1048  m_zoomSelectBox->Clear();
1049  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
1050  m_zoomSelectBox->SetSelection( 0 );
1051 
1052  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
1053  {
1054  msg = _( "Zoom " );
1055 
1056  double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
1057  wxString value = wxString::Format( wxT( "%.2f" ), level );
1058  msg += value;
1059 
1060  m_zoomSelectBox->Append( msg );
1061 
1062  if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
1063  m_zoomSelectBox->SetSelection( i + 1 );
1064  }
1065 }
1066 
1067 
1069 {
1070  if( m_FastGrid1 >= (int)GetScreen()->GetGridCount() )
1071  return;
1072 
1073  int cmdId = GetScreen()->GetGrids()[m_FastGrid1].m_CmdId;
1075 
1076  if( m_gridSelectBox )
1077  {
1078  wxCommandEvent cmd( wxEVT_CHOICE );
1079  cmd.SetEventObject( this );
1080  OnSelectGrid( cmd );
1081  }
1082  else
1083  GetCanvas()->Refresh();
1084 }
1085 
1086 
1088 {
1089  if( m_FastGrid2 >= (int)GetScreen()->GetGridCount() )
1090  return;
1091 
1092  int cmdId = GetScreen()->GetGrids()[m_FastGrid2].m_CmdId;
1094 
1095  if( m_gridSelectBox )
1096  {
1097  wxCommandEvent cmd( wxEVT_CHOICE );
1098  cmd.SetEventObject( this );
1099  OnSelectGrid( cmd );
1100  }
1101  else
1102  GetCanvas()->Refresh();
1103 }
1104 
1106 {
1108 
1109  if( m_gridSelectBox )
1110  {
1111  wxCommandEvent cmd( wxEVT_CHOICE );
1112  cmd.SetEventObject( this );
1113  OnSelectGrid( cmd );
1114  }
1115  else
1116  GetCanvas()->Refresh();
1117 }
1118 
1119 
1121 {
1123 
1124  if( m_gridSelectBox )
1125  {
1126  wxCommandEvent cmd( wxEVT_CHOICE );
1127  cmd.SetEventObject( this );
1128  OnSelectGrid( cmd );
1129  }
1130  else
1131  GetCanvas()->Refresh();
1132 }
1133 
1134 
1135 void PCB_BASE_FRAME::UseGalCanvas( bool aEnable )
1136 {
1137  EDA_DRAW_FRAME::UseGalCanvas( aEnable );
1138 
1139  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
1140 
1141  if( m_toolManager )
1143  GetGalCanvas()->GetViewControls(), this );
1144 
1145  if( aEnable )
1146  {
1147  SetBoard( m_Pcb );
1148 
1149  if( m_toolManager )
1151 
1152  // Transfer latest current display options from legacy to GAL canvas:
1153  auto painter = static_cast<KIGFX::PCB_PAINTER*>( galCanvas->GetView()->GetPainter() );
1154  auto settings = painter->GetSettings();
1155  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1156  settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
1157 
1158  galCanvas->GetView()->RecacheAllItems();
1159  galCanvas->SetEventDispatcher( m_toolDispatcher );
1160  galCanvas->StartDrawing();
1161  }
1162  else
1163  {
1164  if( m_toolManager )
1166 
1167  // Redirect all events to the legacy canvas
1168  galCanvas->SetEventDispatcher( NULL );
1169  }
1170 }
1171 
1172 
1173 void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
1174 {
1175  wxMenuBar* menuBar = GetMenuBar();
1176  EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
1178 
1179  if( IsGalCanvasActive() && gal_canvas )
1180  canvasType = gal_canvas->GetBackend();
1181 
1182  struct { int menuId; int galType; } menuList[] =
1183  {
1187  };
1188 
1189  for( auto ii: menuList )
1190  {
1191  wxMenuItem* item = menuBar->FindItem( ii.menuId );
1192  if( ii.galType == canvasType )
1193  item->Check( true );
1194  }
1195 }
bool ShowPageLimits() const
Definition: draw_frame.h:385
void SetColorsSettings(COLORS_DESIGN_SETTINGS *aColorsSettings)
Function SetColorsSettings.
Definition: class_board.h:575
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:61
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:125
virtual void ReCreateVToolbar()=0
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: class_board.h:792
virtual void SetBoard(BOARD *aBoard)
Function SetBoard sets the m_Pcb member in such as way as to ensure deleting any previous BOARD...
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
Definition: class_board.h:563
to draw blind/buried vias
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
void SetCurItem(BOARD_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: pcb_screen.h:82
virtual void ShowChangedLanguage() override
Function ShowChangedLanguage redraws the menus and what not in current language.
void OnTogglePadDrawMode(wxCommandEvent &aEvent)
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_MODEDIT_INSERT_MODULE_IN_BOARD
const ZONE_SETTINGS & GetZoneSettings() const
Definition: class_board.h:562
virtual void Show3D_Frame(wxCommandEvent &event)
Shows the 3D view frame.
virtual void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
void SetGridOrigin(const wxPoint &aPoint)
Function SetGridOrigin sets the origin point of the grid.
Definition: class_board.h:355
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:388
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
void OnToggleTextDrawMode(wxCommandEvent &aEvent)
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
const wxPoint & GetGridOrigin() const
Definition: class_board.h:356
void SetGridOrigin(const wxPoint &aPoint) override
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
virtual void AddModuleToBoard(MODULE *module)
Adds the given module to the board.
void SetSave()
Definition: base_screen.h:326
multilayer pads, usually with holes
CINFO3D_VISU & GetSettings()
Function GetSettings.
GAL_TYPE GetBackend() const
Function GetBackend Returns the type of backend currently used by GAL canvas.
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:126
static const wxChar DisplayViaFillEntry[]
static const wxChar UserGridSizeYEntry[]
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: class_board.h:560
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
void OnUpdateCoordType(wxUpdateUIEvent &aEvent)
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
virtual void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
static const wxChar DisplayModuleEdgeEntry[]
void OnToggleEdgeDrawMode(wxCommandEvent &aEvent)
Class BOARD to handle a board.
void SetFastGrid2()
Function SetFastGrid2()
const ZONE_SETTINGS & GetZoneSettings() const
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: class_board.h:554
static const wxChar DisplayModuleTextEntry[]
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1392
MODULE * Next() const
Definition: class_module.h:123
Definition: id.h:241
int GetCopperLayerCount() const
Function GetCopperLayerCount.
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
show modules on back
int GetHeight() const
Definition: eda_rect.h:118
void OnToggleGraphicDrawMode(wxCommandEvent &aEvent)
const GRIDS & GetGrids() const
Function GetGrids().
Definition: base_screen.h:472
void OnUpdatePadDrawMode(wxUpdateUIEvent &aEvent)
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
show modules values (when texts are visibles)
virtual void ReCreateOptToolbar()
BOARD * GetBoard() const
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void OnUpdateEdgeDrawMode(wxUpdateUIEvent &aEvent)
wxAuiManager m_auimgr
void SetDrawBgColor(COLOR4D aColor) override
double From_User_Unit(EDA_UNITS_T aUnits, double aValue, bool aUseMils)
Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg"...
Definition: base_units.cpp:278
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
static const wxChar FastGrid2Entry[]
void SetNextGrid() override
Virtual function SetNextGrid() changes the grid size settings to the next one available.
virtual void SetPrevGrid()
Change the grid size settings to the previous one available.
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:211
COLOR4D m_drawBgColor
the background color of the draw canvas BLACK for Pcbnew, BLACK or WHITE for eeschema ...
Definition: draw_frame.h:113
PCB_LAYER_ID m_Active_Layer
Definition: pcb_screen.h:44
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
smd pads, back layer
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
wxChoice * m_gridSelectBox
Definition: draw_frame.h:148
virtual void OnSwitchCanvas(wxCommandEvent &aEvent)
virtual void UseGalCanvas(bool aEnable)
Use to switch between standard and GAL-based canvas.
void SetAuxOrigin(const wxPoint &aPoint)
Function SetAuxOrigin sets the origin point used for plotting.
Definition: class_board.h:348
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
static const wxChar AUTO_ZOOM_KEY[]
Functions relatives to tracks, vias and segments used to fill zones.
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:457
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Auxiliary rendering target (noncached)
Definition: definitions.h:42
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:333
virtual void UseGalCanvas(bool aEnable) override
>
void DisplayUnitsMsg()
Display current unit pane on the status bar.
Classes used in Pcbnew, CvPcb and GerbView.
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:804
GENERAL_COLLECTOR * m_Collector
show modules on front
void SetFastGrid1()
Function SetFastGrid1()
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:72
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
timestamp_t GetNewTimeStamp()
Definition: common.cpp:212
void OnUpdateTextDrawMode(wxUpdateUIEvent &aEvent)
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_LAYER_ID
A quick note on layer IDs:
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
a helper to handle the real device context used in KiCad
BOARD_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: pcb_screen.h:72
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:160
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:170
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:417
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:223
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void OnTogglePolarCoords(wxCommandEvent &aEvent)
PCB_GENERAL_SETTINGS & Settings()
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
double To_User_Unit(EDA_UNITS_T aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:93
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:143
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard EVT_UPDATE_UI_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
void SetEnd(int x, int y)
Definition: eda_rect.h:134
Definition: common.h:160
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:149
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:259
to draw usual through hole vias
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
EVT_MENU_RANGE(ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END, PCB_BASE_FRAME::ProcessItemSelection) PCB_BASE_FRAME
void OnUpdateSwitchCanvas(wxUpdateUIEvent &aEvent)
Update UI called when switches currently used canvas (default / Cairo / OpenGL).
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:48
Base window classes and related definitions.
static const wxChar UserGridSizeXEntry[]
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: class_board.h:556
virtual void ReCreateAuxiliaryToolbar()
Helper dialog and control classes.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
static const wxChar DisplayPadNumberEntry[]
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:914
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aDesignSettings)
Function SetDesignSettings.
Definition: class_board.h:548
virtual bool SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
void SetPresetGrid(int aIndex)
Change the grid size to one of the preset values.
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
wxPoint Centre() const
Definition: eda_rect.h:60
void SetPosition(const wxPoint &aPos) override
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: class_board.h:557
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
virtual void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
Definition: base_struct.h:297
void UpdateDisplayOptions(PCB_DISPLAY_OPTIONS *aOptions)
Definition: pcb_view.cpp:113
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:547
wxPoint m_UserGridSize
virtual void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
int m_LastGridSizeId
Definition: draw_frame.h:107
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board...
virtual bool CreateAndShow3D_Frame(bool aForceRecreateIfNotOwner)
Shows the 3D view frame.
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
void SetAbortRequest(bool aAbortRequest)
KICAD_T Type() override
Definition: fp_lib_table.h:108
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:553
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
virtual double BestZoom() override
Function BestZoom.
PCB_DISPLAY_OPTIONS m_DisplayOptions
virtual void SetNextGrid()
Change the grid size settings to the next one available.
static const wxChar FastGrid1Entry[]
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
Class ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:48
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
const wxPoint & GetAuxOrigin() const
Definition: class_board.h:349
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void OnUpdateGraphicDrawMode(wxUpdateUIEvent &aEvent)
const TITLE_BLOCK & GetTitleBlock() const override
static const wxChar UserGridUnitsEntry[]
EDA_RECT GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Function GetBoardBoundingBox calculates the bounding box containing all board items (or board edge se...
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
virtual void UpdateStatusBar() override
Update the status bar information.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:115
virtual void ReCreateHToolbar()=0
smd pads, front layer
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:559
see class PGM_BASE
virtual void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
Declaration of the eda_3d_viewer class.
static const wxChar DisplayPadFillEntry[]
Class to handle a graphic segment.
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
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:45
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
static const wxChar CANVAS_TYPE_KEY[]
Key in KifaceSettings to store the canvas type.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools...
DLIST< MODULE > m_Modules
Definition: class_board.h:248
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
void SetOrientation(double newangle)
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:245
int GetToolId() const
Definition: draw_frame.h:519
virtual void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings)
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const PAGE_INFO & GetPageSettings() const override
#define IU_PER_MILS
Definition: plotter.cpp:134
int GetWidth() const
Definition: eda_rect.h:117
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:921
void SetAuxOrigin(const wxPoint &aPoint) override
Class EDA_3D_VIEWER Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard...
Definition: eda_3d_viewer.h:50
Module description (excepted pads)
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
void UpdateMsgPanel() override
>
void SetModify()
Definition: base_screen.h:324
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:391
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
int m_CmdId
Definition: base_screen.h:48
Message panel definition file.
BOARD_ITEM * GetCurItem()
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:120
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
Rendering engine changes.
Definition: tool_base.h:84
EDA_3D_VIEWER * Get3DViewerFrame()
virtual void UpdateStatusBar()
Update the status bar information.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void ProcessItemSelection(wxCommandEvent &event)
virtual void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
const wxPoint GetPosition() const override
Definition: class_module.h:184
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
#define VIEWER3D_FRAMENAME
Definition: eda_3d_viewer.h:44
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
EDA_UNITS_T
Definition: common.h:159
show modules references (when texts are visibles)
static const wxChar ZOOM_KEY[]
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219
bool Update3DView(const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:206
Color has changed.
Definition: view_item.h:57
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
int m_Status_Pcb
Flags used in ratsnest calculation and update.
Definition: class_board.h:240
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void SetPrevGrid() override
Virtual function SetPrevGrid() changes the grid size settings to the previous one available...