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::AUTO_ZOOM_KEY[] = wxT( "AutoZoom" );
65 const wxChar PCB_BASE_FRAME::ZOOM_KEY[] = wxT( "Zoom" );
66 
67 // Configuration entry names.
68 static const wxChar UserGridSizeXEntry[] = wxT( "PcbUserGrid_X" );
69 static const wxChar UserGridSizeYEntry[] = wxT( "PcbUserGrid_Y" );
70 static const wxChar UserGridUnitsEntry[] = wxT( "PcbUserGrid_Unit" );
71 static const wxChar DisplayPadFillEntry[] = wxT( "DiPadFi" );
72 static const wxChar DisplayViaFillEntry[] = wxT( "DiViaFi" );
73 static const wxChar DisplayPadNumberEntry[] = wxT( "DiPadNu" );
74 static const wxChar DisplayModuleEdgeEntry[] = wxT( "DiModEd" );
75 static const wxChar DisplayModuleTextEntry[] = wxT( "DiModTx" );
76 static const wxChar FastGrid1Entry[] = wxT( "FastGrid1" );
77 static const wxChar FastGrid2Entry[] = wxT( "FastGrid2" );
78 
79 
80 BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
82  PCB_BASE_FRAME::ProcessItemSelection )
83 
86  EVT_TOOL( ID_TB_OPTIONS_SHOW_GRAPHIC_SKETCH, PCB_BASE_FRAME::OnToggleGraphicDrawMode )
89 
91  EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid )
92  EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom )
93  // Switching canvases
94  EVT_UPDATE_UI( ID_MENU_CANVAS_LEGACY, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
95  EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
96  EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
97 
99 END_EVENT_TABLE()
100 
101 
102 PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
103  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
104  long aStyle, const wxString & aFrameName ) :
105  EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
106  m_Pcb( nullptr ),
107  m_configSettings( aFrameType )
108 {
109  m_UserGridSize = wxPoint( (int) 10 * IU_PER_MILS, (int) 10 * IU_PER_MILS );
110  m_Collector = new GENERAL_COLLECTOR();
111 
112  m_FastGrid1 = 0;
113  m_FastGrid2 = 0;
114 
115  m_zoomLevelCoeff = 11.0 * IU_PER_MILS; // Adjusted to roughly displays zoom level = 1
116  // when the screen shows a 1:1 image
117  // obviously depends on the monitor,
118  // but this is an acceptable value
119 }
120 
121 
123 {
124  // Ensure m_canvasType is up to date, to save it in config
125  if( !GetGalCanvas() )
127  else
129 
130  delete m_Collector;
131  delete m_Pcb;
132 }
133 
134 
136 {
137  // return the 3D viewer frame, when exists, or NULL
138  return static_cast<EDA_3D_VIEWER*>
139  ( wxWindow::FindWindowByName( VIEWER3D_FRAMENAME ) );
140 }
141 
142 
143 bool PCB_BASE_FRAME::Update3DView( const wxString* aTitle )
144 {
145  // Update the 3D view only if the viewer is opened by this frame
146  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
147 
148  if( draw3DFrame == NULL )
149  return false;
150 
151  // Ensure the viewer was created by me, and not by another editor:
152  PCB_BASE_FRAME* owner = draw3DFrame->Parent();
153 
154  // if I am not the owner, do not use the current viewer instance
155  if( this != owner )
156  return false;
157 
158  if( aTitle )
159  draw3DFrame->SetTitle( *aTitle );
160 
161  // The 3D view update can be time consumming to rebuild a board 3D view.
162  // So do not use a immediate update in the board editor
163  bool immediate_update = true;
164 
165  if( IsType( FRAME_PCB ) )
166  immediate_update = false;
167 
168  draw3DFrame->NewDisplay( immediate_update );
169 
170  return true;
171 }
172 
173 
175 {
176  // This is a lazy loading function, it loads the project specific table when
177  // that table is asked for, not before.
178 
180 
181  // its gotta be NULL or a FP_LIB_TABLE, or a bug.
182  wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
183 
184  if( !tbl )
185  {
186  // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
187  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
188  // stack this way, all using the same global fallback table.
189  tbl = new FP_LIB_TABLE( &GFootprintTable );
190 
191  SetElem( ELEM_FPTBL, tbl );
192 
193  wxString projectFpLibTableFileName = FootprintLibTblName();
194 
195  try
196  {
197  tbl->Load( projectFpLibTableFileName );
198  }
199  catch( const IO_ERROR& ioe )
200  {
201  DisplayErrorMessage( nullptr,
202  _( "Error loading project footprint libraries" ),
203  ioe.What() );
204  }
205  }
206 
207  return tbl;
208 }
209 
210 
212 {
213  if( m_Pcb != aBoard )
214  {
215  delete m_Pcb;
216  m_Pcb = aBoard;
217  m_Pcb->SetColorsSettings( &Settings().Colors() );
218  }
219 }
220 
221 
223 {
224  if( module )
225  {
226  GetBoard()->Add( module, ADD_APPEND );
227 
228  module->SetFlags( IS_NEW );
229 
230  if( IsGalCanvasActive() )
231  module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
232  else
233  module->SetPosition( GetCrossHairPosition() );
234 
235  module->SetTimeStamp( GetNewTimeStamp() );
236  GetBoard()->m_Status_Pcb = 0;
237 
238  // Put it on FRONT layer,
239  // (Can be stored flipped if the lib is an archive built from a board)
240  if( module->IsFlipped() )
241  module->Flip( module->GetPosition() );
242 
243  // Place it in orientation 0,
244  // even if it is not saved with orientation 0 in lib
245  // (Can happen if the lib is an archive built from a board)
246  module->SetOrientation( 0 );
247  }
248 }
249 
250 
251 void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
252 {
253  wxASSERT( m_Pcb );
254  m_Pcb->SetPageSettings( aPageSettings );
255 
256  if( GetScreen() )
257  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
258 }
259 
260 
262 {
263  wxASSERT( m_Pcb );
264  return m_Pcb->GetPageSettings();
265 }
266 
267 
268 const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
269 {
270  wxASSERT( m_Pcb );
271 
272  // this function is only needed because EDA_DRAW_FRAME is not compiled
273  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
274  // into an application specific source file.
275  return m_Pcb->GetPageSettings().GetSizeIU();
276 }
277 
278 
279 const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
280 {
281  wxASSERT( m_Pcb );
282  return m_Pcb->GetAuxOrigin();
283 }
284 
285 
286 void PCB_BASE_FRAME::SetAuxOrigin( const wxPoint& aPoint )
287 {
288  wxASSERT( m_Pcb );
289  m_Pcb->SetAuxOrigin( aPoint );
290 }
291 
292 
293 const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
294 {
295  wxASSERT( m_Pcb );
296  return m_Pcb->GetGridOrigin();
297 }
298 
299 
300 void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
301 {
302  wxASSERT( m_Pcb );
303  m_Pcb->SetGridOrigin( aPoint );
304 }
305 
306 
308 {
309  wxASSERT( m_Pcb );
310  return m_Pcb->GetTitleBlock();
311 }
312 
313 
314 void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
315 {
316  wxASSERT( m_Pcb );
317  m_Pcb->SetTitleBlock( aTitleBlock );
318 }
319 
320 
322 {
323  wxASSERT( m_Pcb );
324  return m_Pcb->GetDesignSettings();
325 }
326 
327 
329 {
330  wxASSERT( m_Pcb );
331  m_Pcb->SetDesignSettings( aSettings );
332 }
333 
334 
336 {
337  m_drawBgColor= aColor;
338  m_auimgr.Update();
339 }
340 
341 
343 {
344  wxASSERT( m_Pcb );
345  return m_Pcb->GetZoneSettings();
346 }
347 
348 
350 {
351  wxASSERT( m_Pcb );
352  m_Pcb->SetZoneSettings( aSettings );
353 }
354 
355 
357 {
358  wxASSERT( m_Pcb );
359  return m_Pcb->GetPlotOptions();
360 }
361 
362 
364 {
365  wxASSERT( m_Pcb );
366  m_Pcb->SetPlotOptions( aSettings );
367 }
368 
369 
370 EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
371 {
372  wxASSERT( m_Pcb );
373 
374  EDA_RECT area = aBoardEdgesOnly ? m_Pcb->GetBoardEdgesBoundingBox() : m_Pcb->GetBoundingBox();
375 
376  if( area.GetWidth() == 0 && area.GetHeight() == 0 )
377  {
378  wxSize pageSize = GetPageSizeIU();
379 
381  {
382  area.SetOrigin( 0, 0 );
383  area.SetEnd( pageSize.x, pageSize.y );
384  }
385  else
386  {
387  area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
388  area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
389  }
390  }
391 
392  return area;
393 }
394 
395 
397 {
398  EDA_RECT ibbbox = GetBoardBoundingBox();
399 
400  double sizeX = (double) ibbbox.GetWidth();
401  double sizeY = (double) ibbbox.GetHeight();
402  wxPoint centre = ibbbox.Centre();
403 
404  // Reserve a 10% margin around board bounding box.
405  double margin_scale_factor = 1.1;
406 
407  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
408 }
409 
410 
411 // Virtual function
413 {
414 }
415 
416 
418 {
419  // call my base class
421 
422  // tooltips in toolbars
427 
428  // status bar
429  UpdateMsgPanel();
430 }
431 
432 
433 // Virtual functions: Do nothing for PCB_BASE_FRAME window
434 void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
435 {
436 }
437 
438 
439 bool PCB_BASE_FRAME::CreateAndShow3D_Frame( bool aForceRecreateIfNotOwner )
440 {
441  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
442 
443  // Ensure the viewer was created by me, and not by another editor:
444  PCB_BASE_FRAME* owner = draw3DFrame ? draw3DFrame->Parent() : nullptr;
445 
446  // if I am not the owner, do not use the current viewer instance
447  if( draw3DFrame && this != owner )
448  {
449  if( aForceRecreateIfNotOwner )
450  {
451  draw3DFrame->Destroy();
452  draw3DFrame = nullptr;
453  }
454  else
455  return false;
456  }
457 
458  if( !draw3DFrame )
459  {
460  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
461  draw3DFrame->Raise(); // Needed with some Window Managers
462  draw3DFrame->Show( true );
463  return true;
464  }
465 
466  // Raising the window does not show the window on Windows if iconized.
467  // This should work on any platform.
468  if( draw3DFrame->IsIconized() )
469  draw3DFrame->Iconize( false );
470 
471  draw3DFrame->Raise();
472 
473  // Raising the window does not set the focus on Linux. This should work on any platform.
474  if( wxWindow::FindFocus() != draw3DFrame )
475  draw3DFrame->SetFocus();
476 
477  return true;
478 }
479 
480 
481 // Note: virtual, overridden in PCB_EDIT_FRAME;
483 {
484  PCB_LAYER_ID preslayer = GetActiveLayer();
485  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
486 
487  // Check if the specified layer matches the present layer
488  if( layer == preslayer )
489  return;
490 
491  // Copper layers cannot be selected unconditionally; how many
492  // of those layers are currently enabled needs to be checked.
493  if( IsCopperLayer( layer ) )
494  {
495  // If only one copper layer is enabled, the only such layer
496  // that can be selected to is the "Copper" layer (so the
497  // selection of any other copper layer is disregarded).
498  if( m_Pcb->GetCopperLayerCount() < 2 )
499  {
500  if( layer != B_Cu )
501  {
502  return;
503  }
504  }
505 
506  // If more than one copper layer is enabled, the "Copper"
507  // and "Component" layers can be selected, but the total
508  // number of copper layers determines which internal
509  // layers are also capable of being selected.
510  else
511  {
512  if( ( layer != B_Cu ) && ( layer != F_Cu )
513  && ( layer >= m_Pcb->GetCopperLayerCount() - 1 ) )
514  {
515  return;
516  }
517  }
518  }
519 
520  // Is yet more checking required? E.g. when the layer to be selected
521  // is a non-copper layer, or when switching between a copper layer
522  // and a non-copper layer, or vice-versa?
523  // ...
524 
525  GetScreen()->m_Active_Layer = layer;
526 
527  if( displ_opts->m_ContrastModeDisplay )
528  m_canvas->Refresh();
529 }
530 
531 
532 void PCB_BASE_FRAME::OnTogglePolarCoords( wxCommandEvent& aEvent )
533 {
534  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
535  SetStatusText( wxEmptyString );
536 
537  displ_opts->m_DisplayPolarCood = !displ_opts->m_DisplayPolarCood;
538 
539  UpdateStatusBar();
540 }
541 
542 
543 void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
544 {
545  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
546 
547  displ_opts->m_DisplayPadFill = !displ_opts->m_DisplayPadFill;
549 
550  if( gal )
551  {
552  // Apply new display options to the GAL canvas
553  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
554  view->UpdateDisplayOptions( displ_opts );
555 
556  // Update pads
557  BOARD* board = GetBoard();
558  for( MODULE* module = board->m_Modules; module; module = module->Next() )
559  {
560  for( auto pad : module->Pads() )
561  view->Update( pad, KIGFX::GEOMETRY );
562  }
563  }
564 
565  m_canvas->Refresh();
566 }
567 
568 
569 void PCB_BASE_FRAME::OnToggleGraphicDrawMode( wxCommandEvent& aEvent )
570 {
571  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
572  displ_opts->m_DisplayDrawItemsFill = !displ_opts->m_DisplayDrawItemsFill;
573  m_canvas->Refresh();
574 }
575 
576 
577 void PCB_BASE_FRAME::OnToggleEdgeDrawMode( wxCommandEvent& aEvent )
578 {
579  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
580  displ_opts->m_DisplayModEdgeFill = !displ_opts->m_DisplayModEdgeFill;
582 
583  if( gal )
584  {
585  // Apply new display options to the GAL canvas
586  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
587  view->UpdateDisplayOptions( displ_opts );
588  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
589  }
590 
591  m_canvas->Refresh();
592 }
593 
594 
595 void PCB_BASE_FRAME::OnToggleTextDrawMode( wxCommandEvent& aEvent )
596 {
597  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
598  displ_opts->m_DisplayModTextFill = !displ_opts->m_DisplayModTextFill;
600 
601  if( gal )
602  {
603  // Apply new display options to the GAL canvas
604  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
605  view->UpdateDisplayOptions( displ_opts );
606  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
607  }
608 
609  m_canvas->Refresh();
610 }
611 
612 
613 void PCB_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
614 {
615  switch( aEvent.GetId() )
616  {
619  break;
620 
623  break;
624 
627  break;
628  }
629 }
630 
631 
632 void PCB_BASE_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent )
633 {
634  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
635 
636  aEvent.Check( displ_opts->m_DisplayPolarCood );
638  displ_opts->m_DisplayPolarCood ?
639  _( "Display rectangular coordinates" ) :
640  _( "Display polar coordinates" ) );
641 }
642 
643 
644 void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
645 {
646  if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL )
647  return;
648 
649  int current = 0; // display Auto if no match found
650 
651  // check for a match within 1%
652  double zoom = IsGalCanvasActive() ? GetGalCanvas()->GetLegacyZoom() : GetScreen()->GetZoom();
653 
654  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
655  {
656  if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
657  {
658  current = i + 1;
659  break;
660  }
661  }
662 
663  if( current != m_zoomSelectBox->GetSelection() )
664  m_zoomSelectBox->SetSelection( current );
665 }
666 
667 
668 void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent )
669 {
670  int id = aEvent.GetId();
671 
672  // index into the collector list:
673  int itemNdx = id - ID_POPUP_PCB_ITEM_SELECTION_START;
674 
676  {
677  BOARD_ITEM* item = (*m_Collector)[itemNdx];
678  m_canvas->SetAbortRequest( false );
679 
680 #if 0 && defined (DEBUG)
681  item->Show( 0, std::cout );
682 #endif
683 
684  SetCurItem( item );
685  }
686 }
687 
688 
689 void PCB_BASE_FRAME::SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo )
690 {
691  GetScreen()->SetCurItem( aItem );
692 
693  if( aDisplayInfo )
694  UpdateMsgPanel();
695 }
696 
697 
699 {
700  BOARD_ITEM* item = GetScreen()->GetCurItem();
701  MSG_PANEL_ITEMS items;
702 
703  if( item )
704  {
705  item->GetMsgPanelInfo( m_UserUnits, items );
706  }
707  else // show general information about the board
708  {
709  if( IsGalCanvasActive() )
711  else
712  m_Pcb->GetMsgPanelInfo( m_UserUnits, items );
713  }
714 
715  SetMsgPanel( items );
716 }
717 
718 
720 {
721  return GetScreen()->GetCurItem();
722 }
723 
724 
726 {
728  GetGalCanvas()->GetView() );
729 
730  // account for the globals
732  guide.SetIgnoreMTextsOnBack( ! m_Pcb->IsElementVisible( LAYER_MOD_TEXT_BK ) );
733  guide.SetIgnoreMTextsOnFront( ! m_Pcb->IsElementVisible( LAYER_MOD_TEXT_FR ) );
734  guide.SetIgnoreModulesOnBack( ! m_Pcb->IsElementVisible( LAYER_MOD_BK ) );
735  guide.SetIgnoreModulesOnFront( ! m_Pcb->IsElementVisible( LAYER_MOD_FR ) );
736  guide.SetIgnorePadsOnBack( ! m_Pcb->IsElementVisible( LAYER_PAD_BK ) );
737  guide.SetIgnorePadsOnFront( ! m_Pcb->IsElementVisible( LAYER_PAD_FR ) );
738  guide.SetIgnoreThroughHolePads( ! m_Pcb->IsElementVisible( LAYER_PADS_TH ) );
739  guide.SetIgnoreModulesVals( ! m_Pcb->IsElementVisible( LAYER_MOD_VALUES ) );
740  guide.SetIgnoreModulesRefs( ! m_Pcb->IsElementVisible( LAYER_MOD_REFERENCES ) );
741  guide.SetIgnoreThroughVias( ! m_Pcb->IsElementVisible( LAYER_VIA_THROUGH ) );
742  guide.SetIgnoreBlindBuriedVias( ! m_Pcb->IsElementVisible( LAYER_VIA_BBLIND ) );
743  guide.SetIgnoreMicroVias( ! m_Pcb->IsElementVisible( LAYER_VIA_MICROVIA ) );
744  guide.SetIgnoreTracks( ! m_Pcb->IsElementVisible( LAYER_TRACKS ) );
745 
746  return guide;
747 }
748 
749 void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
750 {
751  bool redraw = false;
752 
753  EDA_DRAW_FRAME::SetToolID( aId, aCursor, aToolMsg );
754 
755  if( aId < 0 )
756  return;
757 
758  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
759 
760  // handle color changes for transitions in and out of ID_TRACK_BUTT
761  if( ( GetToolId() == ID_TRACK_BUTT && aId != ID_TRACK_BUTT )
762  || ( GetToolId() != ID_TRACK_BUTT && aId == ID_TRACK_BUTT ) )
763  {
764  if( displ_opts->m_ContrastModeDisplay )
765  redraw = true;
766  }
767 
768  // must do this after the tool has been set, otherwise pad::Draw() does
769  // not show proper color when GetDisplayOptions().ContrastModeDisplay is true.
770  if( redraw && m_canvas )
771  m_canvas->Refresh();
772 }
773 
774 
775 /*
776  * Update the status bar information.
777  */
779 {
780  PCB_SCREEN* screen = GetScreen();
781 
782  if( !screen )
783  return;
784 
785  wxString line;
786  wxString locformatter;
787  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
788 
790 
791  if( displ_opts->m_DisplayPolarCood ) // display polar coordinates
792  {
793  double dx = (double)GetCrossHairPosition().x - (double)screen->m_O_Curseur.x;
794  double dy = (double)GetCrossHairPosition().y - (double)screen->m_O_Curseur.y;
795 
796  double theta = ArcTangente( -dy, dx ) / 10;
797  double ro = hypot( dx, dy );
798 
799  wxString formatter;
800  switch( GetUserUnits() )
801  {
802  case INCHES:
803  formatter = "r %.6f theta %.1f";
804  break;
805 
806  case MILLIMETRES:
807  formatter = "r %.6f theta %.1f";
808  break;
809 
810  case UNSCALED_UNITS:
811  formatter = "r %f theta %f";
812  break;
813 
814  case DEGREES:
815  wxASSERT( false );
816  break;
817  }
818 
819  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
820 
821  SetStatusText( line, 3 );
822  }
823 
824  // Display absolute coordinates:
825  double dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x );
826  double dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y );
827 
828  // The following sadly is an if Eeschema/if Pcbnew
829  wxString absformatter;
830 
831  switch( GetUserUnits() )
832  {
833  case INCHES:
834  absformatter = "X %.6f Y %.6f";
835  locformatter = "dx %.6f dy %.6f dist %.4f";
836  break;
837 
838  case MILLIMETRES:
839  absformatter = "X %.6f Y %.6f";
840  locformatter = "dx %.6f dy %.6f dist %.3f";
841  break;
842 
843  case UNSCALED_UNITS:
844  absformatter = "X %f Y %f";
845  locformatter = "dx %f dy %f dist %f";
846  break;
847 
848  case DEGREES:
849  wxASSERT( false );
850  break;
851  }
852 
853  line.Printf( absformatter, dXpos, dYpos );
854  SetStatusText( line, 2 );
855 
856  if( !displ_opts->m_DisplayPolarCood ) // display relative cartesian coordinates
857  {
858  // Display relative coordinates:
859  double dx = (double)GetCrossHairPosition().x - (double)screen->m_O_Curseur.x;
860  double dy = (double)GetCrossHairPosition().y - (double)screen->m_O_Curseur.y;
861  dXpos = To_User_Unit( GetUserUnits(), dx );
862  dYpos = To_User_Unit( GetUserUnits(), dy );
863 
864  // We already decided the formatter above
865  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
866  SetStatusText( line, 3 );
867  }
868 }
869 
870 
872 {
873  EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
874 
876 }
877 
878 
879 void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
880 {
882 
883  // Ensure grid id is an existent grid id:
884  if( (m_LastGridSizeId <= 0) ||
887 
888  wxString baseCfgName = GetName();
889 
890  EDA_UNITS_T userGridUnits;
891  aCfg->Read( baseCfgName + UserGridUnitsEntry, ( int* )&userGridUnits, ( int )INCHES );
892 
893  double tmp;
894  aCfg->Read( baseCfgName + UserGridSizeXEntry, &tmp, 0.01 );
895  m_UserGridSize.x = From_User_Unit( userGridUnits, tmp );
896 
897  aCfg->Read( baseCfgName + UserGridSizeYEntry, &tmp, 0.01 );
898  m_UserGridSize.y = From_User_Unit( userGridUnits, tmp );
899 
900  aCfg->Read( baseCfgName + DisplayPadFillEntry, &m_DisplayOptions.m_DisplayPadFill, true );
901  aCfg->Read( baseCfgName + DisplayViaFillEntry, &m_DisplayOptions.m_DisplayViaFill, true );
902  aCfg->Read( baseCfgName + DisplayPadNumberEntry, &m_DisplayOptions.m_DisplayPadNum, true );
903  aCfg->Read( baseCfgName + DisplayModuleEdgeEntry, &m_DisplayOptions.m_DisplayModEdgeFill, true );
904 
905  long itmp;
906  aCfg->Read( baseCfgName + FastGrid1Entry, &itmp, ( long )0);
907  m_FastGrid1 = itmp;
908  aCfg->Read( baseCfgName + FastGrid2Entry, &itmp, ( long )0);
909  m_FastGrid2 = itmp;
910 
911  aCfg->Read( baseCfgName + DisplayModuleTextEntry, &m_DisplayOptions.m_DisplayModTextFill, true );
912 }
913 
914 
915 void PCB_BASE_FRAME::SaveSettings( wxConfigBase* aCfg )
916 {
918 
919  wxString baseCfgName = GetName();
920 
921  aCfg->Write( baseCfgName + UserGridSizeXEntry, To_User_Unit( m_UserUnits, m_UserGridSize.x ) );
922  aCfg->Write( baseCfgName + UserGridSizeYEntry, To_User_Unit( m_UserUnits, m_UserGridSize.y ) );
923  aCfg->Write( baseCfgName + UserGridUnitsEntry, ( long )m_UserUnits );
924  aCfg->Write( baseCfgName + DisplayPadFillEntry, m_DisplayOptions.m_DisplayPadFill );
925  aCfg->Write( baseCfgName + DisplayViaFillEntry, m_DisplayOptions.m_DisplayViaFill );
926  aCfg->Write( baseCfgName + DisplayPadNumberEntry, m_DisplayOptions.m_DisplayPadNum );
927  aCfg->Write( baseCfgName + DisplayModuleEdgeEntry, m_DisplayOptions.m_DisplayModEdgeFill );
928  aCfg->Write( baseCfgName + DisplayModuleTextEntry, m_DisplayOptions.m_DisplayModTextFill );
929  aCfg->Write( baseCfgName + FastGrid1Entry, ( long )m_FastGrid1 );
930  aCfg->Write( baseCfgName + FastGrid2Entry, ( long )m_FastGrid2 );
931 }
932 
933 
935 {
937 
942 
943  EDA_3D_VIEWER* viewer = Get3DViewerFrame();
944 
945  if( viewer )
946  {
947  // The 3D viewer isn't in the Kiway, so send its update manually
948  viewer->CommonSettingsChanged();
949  }
950 }
951 
952 
954 {
955  GetScreen()->SetModify();
956  GetScreen()->SetSave();
957 
958  if( IsGalCanvasActive() )
959  {
960  UpdateStatusBar();
961  UpdateMsgPanel();
962  }
963 }
964 
965 
967 {
969 }
970 
971 
973 {
974  UpdateStatusBar();
975  DisplayUnitsMsg();
976 
977  if( m_gridSelectBox == NULL )
978  return;
979 
980  // Update grid values with the current units setting.
981  m_gridSelectBox->Clear();
982  wxArrayString gridsList;
983  int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
984 
985  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
986  {
987  GRID_TYPE& grid = GetScreen()->GetGrid( i );
988  m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
989  }
990 
991  m_gridSelectBox->Append( wxT( "---" ) );
992  m_gridSelectBox->Append( _( "Edit user grid..." ) );
993 
994  m_gridSelectBox->SetSelection( icurr );
995 }
996 
997 
999 {
1000  if( m_zoomSelectBox == NULL )
1001  return;
1002 
1003  wxString msg;
1004 
1005  m_zoomSelectBox->Clear();
1006  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
1007  m_zoomSelectBox->SetSelection( 0 );
1008 
1009  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
1010  {
1011  msg = _( "Zoom " );
1012 
1013  double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
1014  wxString value = wxString::Format( wxT( "%.2f" ), level );
1015  msg += value;
1016 
1017  m_zoomSelectBox->Append( msg );
1018 
1019  if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
1020  m_zoomSelectBox->SetSelection( i + 1 );
1021  }
1022 }
1023 
1024 
1026 {
1027  if( m_FastGrid1 >= (int)GetScreen()->GetGridCount() )
1028  return;
1029 
1030  int cmdId = GetScreen()->GetGrids()[m_FastGrid1].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
1031  GetToolManager()->RunAction( "common.Control.gridPreset", true, cmdId );
1032 }
1033 
1034 
1036 {
1037  if( m_FastGrid2 >= (int)GetScreen()->GetGridCount() )
1038  return;
1039 
1040  int cmdId = GetScreen()->GetGrids()[m_FastGrid2].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
1041  GetToolManager()->RunAction( "common.Control.gridPreset", true, cmdId );
1042 }
1043 
1044 
1045 void PCB_BASE_FRAME::UseGalCanvas( bool aEnable )
1046 {
1047  EDA_DRAW_FRAME::UseGalCanvas( aEnable );
1048 
1049  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
1050 
1051  if( m_toolManager )
1053  GetGalCanvas()->GetViewControls(), this );
1054 
1055  if( aEnable )
1056  {
1057  SetBoard( m_Pcb );
1058 
1059  if( m_toolManager )
1061 
1062  // Transfer latest current display options from legacy to GAL canvas:
1063  auto painter = static_cast<KIGFX::PCB_PAINTER*>( galCanvas->GetView()->GetPainter() );
1064  auto settings = painter->GetSettings();
1065  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1066  settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
1067 
1068  galCanvas->GetView()->RecacheAllItems();
1069  galCanvas->SetEventDispatcher( m_toolDispatcher );
1070  galCanvas->StartDrawing();
1071  }
1072  else
1073  {
1074  if( m_toolManager )
1076 
1077  // Redirect all events to the legacy canvas
1078  galCanvas->SetEventDispatcher( NULL );
1079  }
1080 }
1081 
1082 
1083 void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
1084 {
1085  wxMenuBar* menuBar = GetMenuBar();
1086  EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
1088 
1089  if( IsGalCanvasActive() && gal_canvas )
1090  canvasType = gal_canvas->GetBackend();
1091 
1092  struct { int menuId; int galType; } menuList[] =
1093  {
1097  };
1098 
1099  for( auto ii: menuList )
1100  {
1101  wxMenuItem* item = menuBar->FindItem( ii.menuId );
1102  if( item && ii.galType == canvasType )
1103  item->Check( true );
1104  }
1105 }
void SetColorsSettings(COLORS_DESIGN_SETTINGS *aColorsSettings)
Function SetColorsSettings.
Definition: class_board.h:573
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:130
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:790
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:559
to draw blind/buried vias
void CommonSettingsChanged() override
Notification event that some of the common (suite-wide) settings have changed.
void SetCurItem(BOARD_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: pcb_screen.h:82
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:549
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:61
void OnTogglePadDrawMode(wxCommandEvent &aEvent)
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: class_board.h:552
virtual void Show3D_Frame(wxCommandEvent &event)
Shows the 3D view frame.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
virtual void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
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:351
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:258
void OnToggleTextDrawMode(wxCommandEvent &aEvent)
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
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's internal state for displ...
virtual void AddModuleToBoard(MODULE *module)
Adds the given module to the board.
void SetSave()
Definition: base_screen.h:326
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:258
multilayer pads, usually with holes
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:131
static const wxChar DisplayViaFillEntry[]
static const wxChar UserGridSizeYEntry[]
ACTION_TOOLBAR * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:166
BOARD_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: pcb_screen.h:72
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: class_board.h:556
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
void OnUpdateCoordType(wxUpdateUIEvent &aEvent)
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:802
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
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
Definition: draw_frame.h:182
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)
static const wxChar DisplayModuleEdgeEntry[]
void OnToggleEdgeDrawMode(wxCommandEvent &aEvent)
Class BOARD to handle a board.
void SetFastGrid2()
Function SetFastGrid2()
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: class_board.h:550
EVT_TOOL(ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE, PCB_EDIT_FRAME::OnSelectOptionToolbar) EVT_TOOL_RANGE(ID_TB_OPTIONS_SHOW_ZONES
static const wxChar DisplayModuleTextEntry[]
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1401
Definition: id.h:235
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.
int GetWidth() const
Definition: eda_rect.h:117
void OnToggleGraphicDrawMode(wxCommandEvent &aEvent)
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_DRAW_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
show modules values (when texts are visibles)
virtual void ReCreateOptToolbar()
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:417
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:534
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
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
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:205
static const wxChar FastGrid2Entry[]
The base class for create windows for drawing purpose.
Definition: draw_frame.h:82
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
COLOR4D m_drawBgColor
the background color of the draw canvas BLACK for Pcbnew, BLACK or WHITE for eeschema
Definition: draw_frame.h:118
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,...
Definition: title_block.h:40
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
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:153
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:344
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
static const wxChar AUTO_ZOOM_KEY[]
Key in KifaceSettings to store the canvas type.
Functions relatives to tracks, vias and segments used to fill zones.
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
bool ShowPageLimits() const
Definition: draw_frame.h:396
Auxiliary rendering target (noncached)
Definition: definitions.h:49
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:326
virtual void UseGalCanvas(bool aEnable) override
void DisplayUnitsMsg()
Display current unit pane on the status bar.
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:217
Classes used in Pcbnew, CvPcb and GerbView.
GENERAL_COLLECTOR * m_Collector
show modules on front
void SetFastGrid1()
Function SetFastGrid1()
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use.
Definition: draw_frame.h:924
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:72
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
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
Notification event that some of the common (suite-wide) settings have changed.
a helper to handle the real device context used in KiCad
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:170
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void OnTogglePolarCoords(wxCommandEvent &aEvent)
GAL not used (the legacy wxDC engine is used)
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:148
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:289
void SetEnd(int x, int y)
Definition: eda_rect.h:134
Definition: common.h:158
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:154
TOOL_MANAGER * GetToolManager() const override
Return the tool manager instance, if any.
Definition: draw_frame.h:937
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
to draw usual through hole vias
const ZONE_SETTINGS & GetZoneSettings() const
const GRIDS & GetGrids() const
Function GetGrids().
Definition: base_screen.h:472
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).
Base window classes and related definitions.
static const wxChar UserGridSizeXEntry[]
virtual void ReCreateAuxiliaryToolbar()
Helper dialog and control classes.
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)
EDA_RECT GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Function GetBoardBoundingBox calculates the bounding box containing all board items (or board edge se...
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aDesignSettings)
Function SetDesignSettings.
Definition: class_board.h:544
virtual bool SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
void SetPosition(const wxPoint &aPos) override
const wxPoint & GetAuxOrigin() const
Definition: class_board.h:345
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: class_board.h:553
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
virtual void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: base_struct.h:321
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:542
wxPoint m_UserGridSize
virtual void ReCreateMenuBar() override
Recreates the menu bar.
int m_LastGridSizeId
Definition: draw_frame.h:112
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
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
int GetHeight() const
Definition: eda_rect.h:118
const wxPoint & GetGridOrigin() const
Definition: class_board.h:352
virtual double BestZoom() override
Function BestZoom.
PCB_DISPLAY_OPTIONS m_DisplayOptions
void UpdateGridSelectBox()
static const wxChar FastGrid1Entry[]
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
Class ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:49
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:128
const TITLE_BLOCK & GetTitleBlock() const override
static const wxChar UserGridUnitsEntry[]
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
virtual void UpdateStatusBar() override
Update the status bar information.
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:120
virtual void ReCreateHToolbar()=0
smd pads, front layer
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:555
see class PGM_BASE
Declaration of the eda_3d_viewer class.
static const wxChar DisplayPadFillEntry[]
bool IsType(FRAME_T aType) const
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
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
Load common frame parameters from a configuration file.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void SetOrientation(double newangle)
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
virtual void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings)
size_t i
Definition: json11.cpp:597
int GetCopperLayerCount() const
Function GetCopperLayerCount.
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:457
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:60
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
const ZONE_SETTINGS & GetZoneSettings() const
Definition: class_board.h:558
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
wxPoint Centre() const
Definition: eda_rect.h:60
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)
void SetAuxOrigin(const wxPoint &aPoint) override
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:49
GAL_TYPE GetBackend() const
Function GetBackend Returns the type of backend currently used by GAL canvas.
Module description (excepted pads)
BOARD * GetBoard() const
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 updateZoomSelectBox()
void UpdateMsgPanel() override
void SetModify()
Definition: base_screen.h:324
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:386
void CommonSettingsChanged() override
Notification that common settings are updated.
int m_CmdId
Definition: base_screen.h:48
Message panel definition file.
BOARD_ITEM * GetCurItem()
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:125
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.
void ProcessItemSelection(wxCommandEvent &event)
virtual void ShowChangedLanguage()
Redraw 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:183
#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:157
VTBL_ENTRY const wxString FootprintLibTblName() const
Function FootprintLibTblName returns the path and filename of this project's fp-lib-table,...
Definition: project.cpp:120
show modules references (when texts are visibles)
static const wxChar ZOOM_KEY[]
int GetToolId() const
Definition: draw_frame.h:524
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.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:209
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
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_ADD_FOOTPRINT_TO_BOARD