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@gmail.com>
7  * Copyright (C) 1992-2021 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 
29 #include <boost/version.hpp>
30 
31 #if BOOST_VERSION >= 106700
32 #include <boost/uuid/entropy_error.hpp>
33 #endif
34 
35 #include <kiface_i.h>
36 #include <confirm.h>
37 #include <dialog_helpers.h>
38 #include <pcb_base_frame.h>
39 #include <base_units.h>
40 #include <widgets/msgpanel.h>
41 #include <pgm_base.h>
42 #include <3d_viewer/eda_3d_viewer.h> // To include VIEWER3D_FRAMENAME
44 #include <fp_lib_table.h>
45 #include <pcbnew_id.h>
46 #include <board.h>
47 #include <footprint.h>
48 #include <collectors.h>
49 #include <pcb_draw_panel_gal.h>
50 #include <math/vector2d.h>
51 #include <pcb_group.h>
52 
53 #include <pcb_painter.h>
55 #include <pcbnew_settings.h>
56 #include <tool/tool_manager.h>
57 #include <tool/tool_dispatcher.h>
58 #include <tools/pcb_actions.h>
59 #include <tool/grid_menu.h>
60 #include "cleanup_item.h"
61 #include <zoom_defines.h>
62 
63 
64 wxDEFINE_EVENT( BOARD_CHANGED, wxCommandEvent );
65 
66 PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
67  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
68  long aStyle, const wxString & aFrameName ) :
69  EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
70  m_pcb( nullptr ),
71  m_originTransforms( *this )
72 {
73  m_settings = static_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
74 }
75 
76 
78 {
79  // Ensure m_canvasType is up to date, to save it in config
81 
82  delete m_pcb;
83 }
84 
85 
86 bool PCB_BASE_FRAME::canCloseWindow( wxCloseEvent& aEvent )
87 {
88  // Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
89  // board.
90  wxWindow* viewer3D = Get3DViewerFrame();
91 
92  if( viewer3D )
93  viewer3D->Close( true );
94 
95  return true;
96 }
97 
98 
100 {
101  wxWindow* frame = FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) );
102  return dynamic_cast<EDA_3D_VIEWER_FRAME*>( frame );
103 }
104 
105 
106 void PCB_BASE_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
107 {
108  EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
109 
110  if( draw3DFrame )
111  {
112  if( aTitle )
113  draw3DFrame->SetTitle( *aTitle );
114 
115  if( aMarkDirty )
116  draw3DFrame->ReloadRequest();
117 
118  if( aRefresh )
119  draw3DFrame->Redraw();
120  }
121 }
122 
123 
125 {
126  // This is a lazy loading function, it loads the project specific table when
127  // that table is asked for, not before.
128 
130 
131  // its gotta be NULL or a FP_LIB_TABLE, or a bug.
132  wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
133 
134  if( !tbl )
135  {
136  // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
137  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
138  // stack this way, all using the same global fallback table.
139  tbl = new FP_LIB_TABLE( &GFootprintTable );
140 
141  SetElem( ELEM_FPTBL, tbl );
142 
143  wxString projectFpLibTableFileName = FootprintLibTblName();
144 
145  try
146  {
147  tbl->Load( projectFpLibTableFileName );
148  }
149  catch( const IO_ERROR& ioe )
150  {
151  DisplayErrorMessage( nullptr, _( "Error loading project footprint libraries." ),
152  ioe.What() );
153  }
154  catch( ... )
155  {
156  DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ) );
157  }
158  }
159 
160  return tbl;
161 }
162 
163 
165 {
166  if( m_pcb != aBoard )
167  {
168  delete m_pcb;
169  m_pcb = aBoard;
170 
171  wxCommandEvent e( BOARD_CHANGED );
172  ProcessEventLocally( e );
173  }
174 }
175 
176 
178 {
179  if( aFootprint )
180  {
181  GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
182 
183  aFootprint->SetFlags( IS_NEW );
184  aFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
185 
186  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
187  // built from a board)
188  if( aFootprint->IsFlipped() )
189  aFootprint->Flip( aFootprint->GetPosition(), m_settings->m_FlipLeftRight );
190 
191  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
192  // it might be stored in another orientation if the lib is an archive built from a board)
193  aFootprint->SetOrientation( 0 );
194  }
195 }
196 
197 
199 {
200  return GetBoard()->GetItem( aId );
201 }
202 
203 
205 {
206  static KIID lastBrightenedItemID( niluuid );
207 
208  BOARD_ITEM* lastItem = nullptr;
209 
212 #if BOOST_VERSION >= 106700
213  try
214  {
215  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
216  }
217  catch( const boost::uuids::entropy_error& )
218  {
219  wxLogError( "A Boost UUID entropy exception was thrown in %s:%s.", __FILE__, __FUNCTION__ );
220  }
221 #else
222  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
223 #endif
224 
225  if( lastItem && lastItem != aItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
226  {
227  lastItem->ClearBrightened();
228 
229  if( lastItem->Type() == PCB_FOOTPRINT_T )
230  {
231  static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
232  [&]( BOARD_ITEM* child )
233  {
234  child->ClearBrightened();
235  } );
236  }
237  else if( lastItem->Type() == PCB_GROUP_T )
238  {
239  static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
240  [&]( BOARD_ITEM* child )
241  {
242  child->ClearBrightened();
243  } );
244  }
245 
246  GetCanvas()->GetView()->Update( lastItem );
247  lastBrightenedItemID = niluuid;
248  GetCanvas()->Refresh();
249  }
250 
251  if( aItem && aItem != DELETED_BOARD_ITEM::GetInstance() )
252  {
253  aItem->SetBrightened();
254 
255  if( aItem->Type() == PCB_FOOTPRINT_T )
256  {
257  static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
258  [&]( BOARD_ITEM* child )
259  {
260  child->SetBrightened();
261  });
262  }
263  else if( aItem->Type() == PCB_GROUP_T )
264  {
265  static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
266  [&]( BOARD_ITEM* child )
267  {
268  child->SetBrightened();
269  });
270  }
271 
272  GetCanvas()->GetView()->Update( aItem );
273  lastBrightenedItemID = aItem->m_Uuid;
274  FocusOnLocation( aItem->GetFocusPosition() );
275  GetCanvas()->Refresh();
276  }
277 }
278 
279 
280 void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
281 {
282  m_pcb->SetPageSettings( aPageSettings );
283 
284  if( GetScreen() )
285  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
286 }
287 
288 
290 {
291  return m_pcb->GetPageSettings();
292 }
293 
294 
295 const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
296 {
297  // this function is only needed because EDA_DRAW_FRAME is not compiled
298  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
299  // into an application specific source file.
300  return m_pcb->GetPageSettings().GetSizeIU();
301 }
302 
303 
304 const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
305 {
307 }
308 
309 
310 void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
311 {
313 }
314 
315 
316 const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
317 {
319 }
320 
321 
322 const wxPoint PCB_BASE_FRAME::GetUserOrigin() const
323 {
324  auto& displ_opts = GetDisplayOptions();
325  wxPoint origin( 0, 0 );
326 
327  switch( displ_opts.m_DisplayOrigin )
328  {
330  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
331  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID: origin = GetGridOrigin(); break;
332  default: wxASSERT( false ); break;
333  }
334 
335  return origin;
336 }
337 
339 {
340  return m_originTransforms;
341 }
342 
343 
345 {
346  return m_pcb->GetTitleBlock();
347 }
348 
349 
350 void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
351 {
352  m_pcb->SetTitleBlock( aTitleBlock );
353 }
354 
355 
357 {
358  return m_pcb->GetDesignSettings();
359 }
360 
361 
363 {
364  m_drawBgColor= aColor;
365  m_auimgr.Update();
366 }
367 
368 
370 {
372 }
373 
374 
376 {
378 }
379 
380 
382 {
383  return m_pcb->GetPlotOptions();
384 }
385 
386 
388 {
389  m_pcb->SetPlotOptions( aSettings );
390 }
391 
392 
393 EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
394 {
395  EDA_RECT area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
396 
397  if( area.GetWidth() == 0 && area.GetHeight() == 0 )
398  {
399  wxSize pageSize = GetPageSizeIU();
400 
402  {
403  area.SetOrigin( 0, 0 );
404  area.SetEnd( pageSize.x, pageSize.y );
405  }
406  else
407  {
408  area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
409  area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
410  }
411  }
412 
413  return area;
414 }
415 
416 
417 // Virtual function
419 {
420 }
421 
422 
424 {
425  // call my base class
427 
428  // tooltips in toolbars
430 
431  // status bar
432  UpdateMsgPanel();
433 }
434 
435 
437 {
438  EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
439 
440  if( !draw3DFrame )
441  draw3DFrame = new EDA_3D_VIEWER_FRAME( &Kiway(), this, _( "3D Viewer" ) );
442 
443  // Raising the window does not show the window on Windows if iconized. This should work
444  // on any platform.
445  if( draw3DFrame->IsIconized() )
446  draw3DFrame->Iconize( false );
447 
448  draw3DFrame->Raise();
449  draw3DFrame->Show( true );
450 
451  // Raising the window does not set the focus on Linux. This should work on any platform.
452  if( wxWindow::FindFocus() != draw3DFrame )
453  draw3DFrame->SetFocus();
454 
455  // Allocate a slice of time to display the 3D frame
456  // a call to wxSafeYield() should be enough (and better), but on Linux we need
457  // to call wxYield()
458  // otherwise the activity messages are not displayed during the first board loading
459  wxYield();
460 
461  // Note, the caller is responsible to load/update the board 3D view.
462  // after frame creation the board is not automatically created.
463 
464  return draw3DFrame;
465 }
466 
467 
469 {
470  PCB_LAYER_ID preslayer = GetActiveLayer();
471  auto& displ_opts = GetDisplayOptions();
472 
473  // Check if the specified layer matches the present layer
474  if( layer == preslayer )
475  return;
476 
477  // Copper layers cannot be selected unconditionally; how many of those layers are
478  // currently enabled needs to be checked.
479  if( IsCopperLayer( layer ) )
480  {
481  // If only one copper layer is enabled, the only such layer that can be selected to
482  // is the "Copper" layer (so the selection of any other copper layer is disregarded).
483  if( m_pcb->GetCopperLayerCount() < 2 )
484  {
485  if( layer != B_Cu )
486  return;
487  }
488 
489  // If more than one copper layer is enabled, the "Copper" and "Component" layers
490  // can be selected, but the total number of copper layers determines which internal
491  // layers are also capable of being selected.
492  else
493  {
494  if( layer != B_Cu && layer != F_Cu && layer >= ( m_pcb->GetCopperLayerCount() - 1 ) )
495  return;
496  }
497  }
498 
499  // Is yet more checking required? E.g. when the layer to be selected is a non-copper
500  // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
501  // ...
502 
503  SetActiveLayer( layer );
504 
505  if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
506  GetCanvas()->Refresh();
507 }
508 
509 
511 {
513  GetCanvas()->GetView() );
514 
515  // account for the globals
517  guide.SetIgnoreMTextsOnBack( ! m_pcb->IsElementVisible( LAYER_MOD_TEXT_BK ) );
518  guide.SetIgnoreMTextsOnFront( ! m_pcb->IsElementVisible( LAYER_MOD_TEXT_FR ) );
519  guide.SetIgnoreModulesOnBack( ! m_pcb->IsElementVisible( LAYER_MOD_BK ) );
520  guide.SetIgnoreModulesOnFront( ! m_pcb->IsElementVisible( LAYER_MOD_FR ) );
521  guide.SetIgnorePadsOnBack( ! m_pcb->IsElementVisible( LAYER_PAD_BK ) );
522  guide.SetIgnorePadsOnFront( ! m_pcb->IsElementVisible( LAYER_PAD_FR ) );
523  guide.SetIgnoreThroughHolePads( ! m_pcb->IsElementVisible( LAYER_PADS_TH ) );
524  guide.SetIgnoreModulesVals( ! m_pcb->IsElementVisible( LAYER_MOD_VALUES ) );
525  guide.SetIgnoreModulesRefs( ! m_pcb->IsElementVisible( LAYER_MOD_REFERENCES ) );
526  guide.SetIgnoreThroughVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
527  guide.SetIgnoreBlindBuriedVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
528  guide.SetIgnoreMicroVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
529  guide.SetIgnoreTracks( ! m_pcb->IsElementVisible( LAYER_TRACKS ) );
530 
531  return guide;
532 }
533 
534 
536 {
537  wxString line;
538 
539  line.Printf( "grid X %s Y %s",
540  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
541  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
542 
543  SetStatusText( line, 4 );
544 }
545 
546 
548 {
550 
551  BASE_SCREEN* screen = GetScreen();
552 
553  if( !screen )
554  return;
555 
556  wxString line;
558 
559  if( GetShowPolarCoords() ) // display polar coordinates
560  {
561  double dx = cursorPos.x - screen->m_LocalOrigin.x;
562  double dy = cursorPos.y - screen->m_LocalOrigin.y;
563  double theta = RAD2DEG( atan2( -dy, dx ) );
564  double ro = hypot( dx, dy );
565 
566  line.Printf( wxT( "r %s theta %.3f" ),
567  MessageTextFromValue( GetUserUnits(), ro, false ), theta );
568 
569  SetStatusText( line, 3 );
570  }
571 
572  // Transform absolute coordinates for user origin preferences
573  double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
574  double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
575 
576  // Display absolute coordinates:
577  line.Printf( wxT( "X %s Y %s" ),
578  MessageTextFromValue( GetUserUnits(), userXpos, false ),
579  MessageTextFromValue( GetUserUnits(), userYpos, false ) );
580  SetStatusText( line, 2 );
581 
582  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
583  {
584  // Calculate relative coordinates
585  double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
586  double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
587 
588  // Transform relative coordinates for user origin preferences
589  userXpos = m_originTransforms.ToDisplayRelX( relXpos );
590  userYpos = m_originTransforms.ToDisplayRelY( relYpos );
591 
592  line.Printf( wxT( "dx %s dy %s dist %s" ),
593  MessageTextFromValue( GetUserUnits(), userXpos, false ),
594  MessageTextFromValue( GetUserUnits(), userYpos, false ),
595  MessageTextFromValue( GetUserUnits(), hypot( userXpos, userYpos ), false ) );
596  SetStatusText( line, 3 );
597  }
598 
599  DisplayGridMsg();
600 }
601 
602 
604 {
605  EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
606 
608 }
609 
610 
612 {
614 
615  if( aCfg->m_Window.grid.sizes.empty() )
616  aCfg->m_Window.grid.sizes = aCfg->DefaultGridSizeList();
617 
618  // Currently values read from config file are not used because the user cannot
619  // change this config
620  // if( aCfg->m_Window.zoom_factors.empty() )
621  {
623  }
624 
625  // Some, but not all derived classes have a PCBNEW_SETTINGS.
626  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
627 
628  if( cfg )
629  {
632  }
633 
634  wxASSERT( GetCanvas() );
635 
636  if( GetCanvas() )
637  {
639 
640  if( rs )
641  {
645  }
646  }
647 }
648 
649 
650 SEVERITY PCB_BASE_FRAME::GetSeverity( int aErrorCode ) const
651 {
652  if( aErrorCode >= CLEANUP_FIRST )
653  return RPT_SEVERITY_ACTION;
654 
656 
657  return bds.m_DRCSeverities[ aErrorCode ];
658 }
659 
660 
662 {
664 
665  // Some, but not all derived classes have a PCBNEW_SETTINGS.
666  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
667 
668  if( cfg )
669  {
672  }
673 }
674 
675 
677 {
678  return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
679 }
680 
681 
683 {
684  return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
685 }
686 
687 
689 {
690  wxCHECK( m_settings, nullptr );
691  return &m_settings->m_MagneticItems;
692 }
693 
694 
695 void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
696 {
697  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
698 
701 
703 
704  // The 3D viewer isn't in the Kiway, so send its update manually
706 
707  if( viewer )
708  viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
709 }
710 
711 
713 {
715 
717 
718  UpdateStatusBar();
719  UpdateMsgPanel();
720 }
721 
722 
724 {
725  return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
726 }
727 
728 
730 {
732 
733  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
734 
735  if( m_toolManager )
736  {
738  GetCanvas()->GetViewControls(), config(), this );
739  }
740 
741  if( m_toolManager )
743 
744  // Transfer latest current display options from legacy to GAL canvas:
745  auto painter = static_cast<KIGFX::PCB_PAINTER*>( canvas->GetView()->GetPainter() );
746  auto settings = painter->GetSettings();
747  auto displ_opts = GetDisplayOptions();
748  settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
749  settings->LoadColors( GetColorSettings() );
750 
751  canvas->GetView()->RecacheAllItems();
753  canvas->StartDrawing();
754 }
755 
756 
757 void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh )
758 {
759  bool hcChanged = m_displayOptions.m_ContrastModeDisplay != aOptions.m_ContrastModeDisplay;
760  m_displayOptions = aOptions;
761 
762  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
763  KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
764 
765  view->UpdateDisplayOptions( aOptions );
768 
769  // Vias on a restricted layer set must be redrawn when high contrast mode is changed
770  if( hcChanged )
771  {
773  []( KIGFX::VIEW_ITEM* aItem ) -> bool
774  {
775  if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( aItem ) )
776  {
777  return via->GetViaType() == VIATYPE::BLIND_BURIED
778  || via->GetViaType() == VIATYPE::MICROVIA;
779  }
780 
781  return false;
782  } );
783  }
784 
785  if( aRefresh )
786  canvas->Refresh();
787 }
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:867
#define ZOOM_LIST_PCBNEW
Definition: zoom_defines.h:32
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:728
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
virtual void SetBoard(BOARD *aBoard)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: board.h:535
virtual void SetHighContrastLayer(int aLayer)
Take care of display settings for the given layer to be displayed in high contrast mode.
void DisplayGridMsg() override
Display the current grid pane on the status bar.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:538
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
virtual void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
KIID niluuid(0)
wxDEFINE_EVENT(BOARD_CHANGED, wxCommandEvent)
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
wxPoint m_GridOrigin
origin for grid offsets
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1425
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:265
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void SetGridOrigin(const wxPoint &aPoint) override
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
EDA_3D_VIEWER_FRAME * Get3DViewerFrame()
multilayer pads, usually with holes
#define IS_NEW
New item, just created.
virtual void OnDisplayOptionsChanged()
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
void SetDefaultZoneSettings(const ZONE_SETTINGS &aSettings)
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:543
SEVERITY
Definition: ui_common.h:100
const EDA_RECT GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:742
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:32
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:536
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual const wxPoint GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:259
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1380
double RAD2DEG(double rad)
Definition: trigo.h:232
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1415
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
int GetWidth() const
Definition: eda_rect.h:109
show footprints on back
void SetBrightened()
Definition: eda_item.h:130
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification that common settings are updated.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:479
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
const wxPoint GetUserOrigin() const
show footprints values (when texts are visible)
T ToDisplayRelX(T aInternalValue) const
Transform a 2-D coordinate point referenced to the internal origin to the equivalent point referenced...
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
wxAuiManager m_auimgr
void SetDrawBgColor(COLOR4D aColor) override
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
Definition: project.cpp:246
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
Color has changed.
Definition: view_item.h:53
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
PCB_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
The base class for create windows for drawing purpose.
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Return the PCB_PLOT_PARAMS for the BOARD owned by this frame.
PCBNEW_SETTINGS * m_settings
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
COLOR4D m_drawBgColor
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
float high_contrast_factor
How much to darken inactive layers by.
Definition: app_settings.h:118
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
std::vector< double > zoom_factors
Definition: app_settings.h:86
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
SEVERITY GetSeverity(int aErrorCode) const override
bool ShowPageLimits() const
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:258
void ClearBrightened()
Definition: eda_item.h:133
Classes used in Pcbnew, CvPcb and GerbView.
show footprints on front
virtual COLOR_SETTINGS * GetColorSettings() const override
Helper to retrieve the current color settings.
virtual PCB_LAYER_ID GetActiveLayer() const
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:46
PCB_DISPLAY_OPTIONS m_displayOptions
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:606
Definition: kiid.h:44
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
Container for display options like enable/disable some optional drawings.
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
PCB_LAYER_ID
A quick note on layer IDs:
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
void SetHighContrastFactor(float aFactor)
Item needs to be redrawn.
Definition: view_item.h:57
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
std::vector< wxString > sizes
Definition: app_settings.h:52
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition: pcb_view.cpp:125
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:62
GRID_SETTINGS grid
Definition: app_settings.h:89
T ToDisplayAbsY(T aInternalValue) const
static DELETED_BOARD_ITEM * GetInstance()
Definition: board_item.h:387
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
bool m_showBorderAndTitleBlock
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
void SetEnd(int x, int y)
Definition: eda_rect.h:182
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1571
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
const ZONE_SETTINGS & GetZoneSettings() const
Inactive layers are shown normally (no high-contrast mode)
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1381
T ToDisplayRelY(T aInternalValue) const
Helper dialog and control classes.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
#define _(s)
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
EDA_RECT GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
float select_factor
How much to brighten selected objects by.
Definition: app_settings.h:117
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: board.h:539
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:499
virtual void ReCreateMenuBar() override
Recreates the menu bar.
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
Parameters and options when plotting/printing a board.
void IncrementTimeStamp()
Definition: board.cpp:191
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void StartDrawing()
Begin drawing if it was stopped previously.
KICAD_T Type() override
Definition: fp_lib_table.h:99
int GetHeight() const
Definition: eda_rect.h:110
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
const KIID m_Uuid
Definition: eda_item.h:475
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:283
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:531
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
bool IsFlipped() const
Definition: footprint.h:261
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
const TITLE_BLOCK & GetTitleBlock() const override
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
virtual void UpdateStatusBar() override
Update the status bar information.
float highlight_factor
How much to brighten highlighted objects by.
Definition: app_settings.h:116
void ReloadRequest()
Request reloading the 3D view.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
smd pads, front layer
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:541
see class PGM_BASE
Declaration of the eda_3d_viewer class.
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
Meta control for all vias opacity/visibility.
A class to perform either relative or absolute display origin transforms for a single axis of a point...
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
ORIGIN_TRANSFORMS & GetOriginTransforms() override
Return a reference to the default ORIGIN_TRANSFORMS object.
std::map< int, SEVERITY > m_DRCSeverities
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
int GetCopperLayerCount() const
Definition: board.cpp:453
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Handle the component boundary box.
Definition: eda_rect.h:42
void SetSelectFactor(float aFactor)
PCBNEW_SETTINGS * GetPcbNewSettings() const
const PAGE_INFO & GetPageSettings() const override
void SetHighlightFactor(float aFactor)
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.
virtual void AddFootprintToBoard(FOOTPRINT *aFootprint)
Add the given footprint to the board.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
wxPoint GetPosition() const override
Definition: footprint.h:177
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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 IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
EDA_3D_VIEWER_FRAME * CreateAndShow3D_Frame()
Shows the 3D view frame.
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void UpdateStatusBar() override
Update the status bar information.
ZONE_SETTINGS & GetDefaultZoneSettings()
BOARD * GetBoard() const
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:377
MAGNETIC_SETTINGS m_MagneticItems
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1452
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
T ToDisplayAbsX(T aInternalValue) const
Message panel definition file.
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
PCB_DISPLAY_OPTIONS m_Display
Rendering engine changes.
Definition: tool_base.h:81
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void FocusOnItem(BOARD_ITEM *aItem)
wxPoint m_AuxOrigin
origin for plot exports
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
Definition: project.cpp:146
show footprints references (when texts are visible)
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual const std::vector< wxString > DefaultGridSizeList() const
By default, this returns the list of grids available in PcbNew-based applications.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:90
PCB_ORIGIN_TRANSFORMS m_originTransforms
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
virtual void UpdateMsgPanel()
Redraw the message panel.
Container for design settings for a BOARD object.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
const wxPoint & GetAuxOrigin() const