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-2020 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 
52 #include <pcb_painter.h>
54 #include <pcbnew_settings.h>
55 #include <tool/tool_manager.h>
56 #include <tool/tool_dispatcher.h>
57 #include <tools/pcb_actions.h>
58 #include <tool/grid_menu.h>
59 #include "cleanup_item.h"
60 #include <zoom_defines.h>
61 
62 
63 wxDEFINE_EVENT( BOARD_CHANGED, wxCommandEvent );
64 
65 PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
66  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
67  long aStyle, const wxString & aFrameName ) :
68  EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
69  m_pcb( nullptr ),
70  m_originTransforms( *this )
71 {
72  m_settings = static_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
73 }
74 
75 
77 {
78  // Ensure m_canvasType is up to date, to save it in config
80 
81  delete m_pcb;
82 }
83 
84 
86 {
87  return dynamic_cast<EDA_3D_VIEWER*>( FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) ) );
88 }
89 
90 
91 void PCB_BASE_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
92 {
93  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
94 
95  if( draw3DFrame )
96  {
97  if( aTitle )
98  draw3DFrame->SetTitle( *aTitle );
99 
100  if( aMarkDirty )
101  draw3DFrame->ReloadRequest();
102 
103  if( aRefresh )
104  draw3DFrame->Redraw();
105  }
106 }
107 
108 
110 {
111  // This is a lazy loading function, it loads the project specific table when
112  // that table is asked for, not before.
113 
115 
116  // its gotta be NULL or a FP_LIB_TABLE, or a bug.
117  wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
118 
119  if( !tbl )
120  {
121  // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
122  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
123  // stack this way, all using the same global fallback table.
124  tbl = new FP_LIB_TABLE( &GFootprintTable );
125 
126  SetElem( ELEM_FPTBL, tbl );
127 
128  wxString projectFpLibTableFileName = FootprintLibTblName();
129 
130  try
131  {
132  tbl->Load( projectFpLibTableFileName );
133  }
134  catch( const IO_ERROR& ioe )
135  {
136  DisplayErrorMessage( nullptr, _( "Error loading project footprint libraries" ),
137  ioe.What() );
138  }
139  }
140 
141  return tbl;
142 }
143 
144 
146 {
147  if( m_pcb != aBoard )
148  {
149  delete m_pcb;
150  m_pcb = aBoard;
151 
152  wxCommandEvent e( BOARD_CHANGED );
153  ProcessEventLocally( e );
154  }
155 }
156 
157 
159 {
160  if( aFootprint )
161  {
162  GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
163 
164  aFootprint->SetFlags( IS_NEW );
165  aFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized yet
166 
167  // Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
168  // built from a board)
169  if( aFootprint->IsFlipped() )
170  aFootprint->Flip( aFootprint->GetPosition(), m_settings->m_FlipLeftRight );
171 
172  // Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
173  // it might be stored in another orientation if the lib is an archive built from a board)
174  aFootprint->SetOrientation( 0 );
175  }
176 }
177 
178 
180 {
181  return GetBoard()->GetItem( aId );
182 }
183 
184 
186 {
187  static KIID lastBrightenedItemID( niluuid );
188 
189  BOARD_ITEM* lastItem = nullptr;
190 
193 #if BOOST_VERSION >= 106700
194  try
195  {
196  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
197  }
198  catch( const boost::uuids::entropy_error& )
199  {
200  wxLogError( "A Boost UUID entropy exception was thrown in %s:%s.", __FILE__, __FUNCTION__ );
201  }
202 #else
203  lastItem = GetBoard()->GetItem( lastBrightenedItemID );
204 #endif
205 
206  if( lastItem && lastItem != aItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
207  {
208  lastItem->ClearBrightened();
209 
210  if( lastItem->Type() == PCB_FOOTPRINT_T )
211  {
212  static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
213  [&]( BOARD_ITEM* child )
214  {
215  child->ClearBrightened();
216  } );
217  }
218  else if( lastItem->Type() == PCB_GROUP_T )
219  {
220  static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
221  [&]( BOARD_ITEM* child )
222  {
223  child->ClearBrightened();
224  } );
225  }
226 
227  GetCanvas()->GetView()->Update( lastItem );
228  lastBrightenedItemID = niluuid;
229  GetCanvas()->Refresh();
230  }
231 
232  if( aItem && aItem != DELETED_BOARD_ITEM::GetInstance() )
233  {
234  aItem->SetBrightened();
235 
236  if( aItem->Type() == PCB_FOOTPRINT_T )
237  {
238  static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
239  [&]( BOARD_ITEM* child )
240  {
241  child->SetBrightened();
242  });
243  }
244  else if( aItem->Type() == PCB_GROUP_T )
245  {
246  static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
247  [&]( BOARD_ITEM* child )
248  {
249  child->SetBrightened();
250  });
251  }
252 
253  GetCanvas()->GetView()->Update( aItem );
254  lastBrightenedItemID = aItem->m_Uuid;
255  FocusOnLocation( aItem->GetFocusPosition() );
256  GetCanvas()->Refresh();
257  }
258 }
259 
260 
261 void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
262 {
263  m_pcb->SetPageSettings( aPageSettings );
264 
265  if( GetScreen() )
266  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
267 }
268 
269 
271 {
272  return m_pcb->GetPageSettings();
273 }
274 
275 
276 const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
277 {
278  // this function is only needed because EDA_DRAW_FRAME is not compiled
279  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
280  // into an application specific source file.
281  return m_pcb->GetPageSettings().GetSizeIU();
282 }
283 
284 
285 const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
286 {
288 }
289 
290 
291 void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
292 {
294 }
295 
296 
297 const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
298 {
300 }
301 
302 
303 const wxPoint PCB_BASE_FRAME::GetUserOrigin() const
304 {
305  auto& displ_opts = GetDisplayOptions();
306  wxPoint origin( 0, 0 );
307 
308  switch( displ_opts.m_DisplayOrigin )
309  {
311  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
312  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID: origin = GetGridOrigin(); break;
313  default: wxASSERT( false ); break;
314  }
315 
316  return origin;
317 }
318 
320 {
321  return m_originTransforms;
322 }
323 
324 
326 {
327  return m_pcb->GetTitleBlock();
328 }
329 
330 
331 void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
332 {
333  m_pcb->SetTitleBlock( aTitleBlock );
334 }
335 
336 
338 {
339  return m_pcb->GetDesignSettings();
340 }
341 
342 
344 {
345  m_drawBgColor= aColor;
346  m_auimgr.Update();
347 }
348 
349 
351 {
353 }
354 
355 
357 {
359 }
360 
361 
363 {
364  return m_pcb->GetPlotOptions();
365 }
366 
367 
369 {
370  m_pcb->SetPlotOptions( aSettings );
371 }
372 
373 
374 EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
375 {
376  EDA_RECT area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
377 
378  if( area.GetWidth() == 0 && area.GetHeight() == 0 )
379  {
380  wxSize pageSize = GetPageSizeIU();
381 
383  {
384  area.SetOrigin( 0, 0 );
385  area.SetEnd( pageSize.x, pageSize.y );
386  }
387  else
388  {
389  area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
390  area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
391  }
392  }
393 
394  return area;
395 }
396 
397 
398 // Virtual function
400 {
401 }
402 
403 
405 {
406  // call my base class
408 
409  // tooltips in toolbars
411 
412  // status bar
413  UpdateMsgPanel();
414 }
415 
416 
418 {
419  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
420 
421  if( !draw3DFrame )
422  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
423 
424  // Raising the window does not show the window on Windows if iconized. This should work
425  // on any platform.
426  if( draw3DFrame->IsIconized() )
427  draw3DFrame->Iconize( false );
428 
429  draw3DFrame->Raise();
430  draw3DFrame->Show( true );
431 
432  // Raising the window does not set the focus on Linux. This should work on any platform.
433  if( wxWindow::FindFocus() != draw3DFrame )
434  draw3DFrame->SetFocus();
435 
436  return draw3DFrame;
437 }
438 
439 
440 // Note: virtual, overridden in PCB_EDIT_FRAME;
442 {
443  PCB_LAYER_ID preslayer = GetActiveLayer();
444  auto& displ_opts = GetDisplayOptions();
445 
446  // Check if the specified layer matches the present layer
447  if( layer == preslayer )
448  return;
449 
450  // Copper layers cannot be selected unconditionally; how many of those layers are
451  // currently enabled needs to be checked.
452  if( IsCopperLayer( layer ) )
453  {
454  // If only one copper layer is enabled, the only such layer that can be selected to
455  // is the "Copper" layer (so the selection of any other copper layer is disregarded).
456  if( m_pcb->GetCopperLayerCount() < 2 )
457  {
458  if( layer != B_Cu )
459  return;
460  }
461 
462  // If more than one copper layer is enabled, the "Copper" and "Component" layers
463  // can be selected, but the total number of copper layers determines which internal
464  // layers are also capable of being selected.
465  else
466  {
467  if( layer != B_Cu && layer != F_Cu && layer >= ( m_pcb->GetCopperLayerCount() - 1 ) )
468  return;
469  }
470  }
471 
472  // Is yet more checking required? E.g. when the layer to be selected is a non-copper
473  // layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
474  // ...
475 
476  SetActiveLayer( layer );
477 
478  if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
479  GetCanvas()->Refresh();
480 }
481 
482 
484 {
486  GetCanvas()->GetView() );
487 
488  // account for the globals
490  guide.SetIgnoreMTextsOnBack( ! m_pcb->IsElementVisible( LAYER_MOD_TEXT_BK ) );
491  guide.SetIgnoreMTextsOnFront( ! m_pcb->IsElementVisible( LAYER_MOD_TEXT_FR ) );
492  guide.SetIgnoreModulesOnBack( ! m_pcb->IsElementVisible( LAYER_MOD_BK ) );
493  guide.SetIgnoreModulesOnFront( ! m_pcb->IsElementVisible( LAYER_MOD_FR ) );
494  guide.SetIgnorePadsOnBack( ! m_pcb->IsElementVisible( LAYER_PAD_BK ) );
495  guide.SetIgnorePadsOnFront( ! m_pcb->IsElementVisible( LAYER_PAD_FR ) );
496  guide.SetIgnoreThroughHolePads( ! m_pcb->IsElementVisible( LAYER_PADS_TH ) );
497  guide.SetIgnoreModulesVals( ! m_pcb->IsElementVisible( LAYER_MOD_VALUES ) );
498  guide.SetIgnoreModulesRefs( ! m_pcb->IsElementVisible( LAYER_MOD_REFERENCES ) );
499  guide.SetIgnoreThroughVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
500  guide.SetIgnoreBlindBuriedVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
501  guide.SetIgnoreMicroVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
502  guide.SetIgnoreTracks( ! m_pcb->IsElementVisible( LAYER_TRACKS ) );
503 
504  return guide;
505 }
506 
507 
508 /*
509  * Display the grid status.
510  */
512 {
513  wxString line;
514 
515  line.Printf( "grid X %s Y %s",
516  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
517  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
518 
519  SetStatusText( line, 4 );
520 }
521 
522 
523 /*
524  * Update the status bar information.
525  */
527 {
529 
530  BASE_SCREEN* screen = GetScreen();
531 
532  if( !screen )
533  return;
534 
535  wxString line;
537 
538  if( GetShowPolarCoords() ) // display polar coordinates
539  {
540  double dx = cursorPos.x - screen->m_LocalOrigin.x;
541  double dy = cursorPos.y - screen->m_LocalOrigin.y;
542  double theta = RAD2DEG( atan2( -dy, dx ) );
543  double ro = hypot( dx, dy );
544 
545  line.Printf( wxT( "r %s theta %.3f" ),
546  MessageTextFromValue( GetUserUnits(), ro, false ), theta );
547 
548  SetStatusText( line, 3 );
549  }
550 
551  // Transform absolute coordinates for user origin preferences
552  double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
553  double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
554 
555  // Display absolute coordinates:
556  line.Printf( wxT( "X %s Y %s" ),
557  MessageTextFromValue( GetUserUnits(), userXpos, false ),
558  MessageTextFromValue( GetUserUnits(), userYpos, false ) );
559  SetStatusText( line, 2 );
560 
561  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
562  {
563  // Calculate relative coordinates
564  double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
565  double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
566 
567  // Transform relative coordinates for user origin preferences
568  userXpos = m_originTransforms.ToDisplayRelX( relXpos );
569  userYpos = m_originTransforms.ToDisplayRelY( relYpos );
570 
571  line.Printf( wxT( "dx %s dy %s dist %s" ),
572  MessageTextFromValue( GetUserUnits(), userXpos, false ),
573  MessageTextFromValue( GetUserUnits(), userYpos, false ),
574  MessageTextFromValue( GetUserUnits(), hypot( userXpos, userYpos ), false ) );
575  SetStatusText( line, 3 );
576  }
577 
578  DisplayGridMsg();
579 }
580 
581 
583 {
584  EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
585 
587 }
588 
589 
591 {
593 
594  if( aCfg->m_Window.grid.sizes.empty() )
595  aCfg->m_Window.grid.sizes = aCfg->DefaultGridSizeList();
596 
597  // Currently values read from config file are not used because the user cannot
598  // change this config
599  // if( aCfg->m_Window.zoom_factors.empty() )
600  {
602  }
603 
604  // Some, but not all derived classes have a PCBNEW_SETTINGS.
605  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
606 
607  if( cfg )
608  {
611  }
612 
613  wxASSERT( GetCanvas() );
614 
615  if( GetCanvas() )
616  {
618 
619  if( rs )
620  {
624  }
625  }
626 }
627 
628 
629 SEVERITY PCB_BASE_FRAME::GetSeverity( int aErrorCode ) const
630 {
631  if( aErrorCode >= CLEANUP_FIRST )
632  return RPT_SEVERITY_ACTION;
633 
635 
636  return bds.m_DRCSeverities[ aErrorCode ];
637 }
638 
639 
641 {
643 
644  // Some, but not all derived classes have a PCBNEW_SETTINGS.
645  PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
646 
647  if( cfg )
648  {
651  }
652 }
653 
654 
656 {
657  return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
658 }
659 
660 
662 {
663  return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
664 }
665 
667 {
668  wxCHECK( m_settings, nullptr );
669  return &m_settings->m_MagneticItems;
670 }
671 
672 
673 void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
674 {
675  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
676 
679 
681 
682  // The 3D viewer isn't in the Kiway, so send its update manually
683  EDA_3D_VIEWER* viewer = Get3DViewerFrame();
684 
685  if( viewer )
686  viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
687 }
688 
689 
691 {
692  GetScreen()->SetModify();
693  GetScreen()->SetSave();
694 
696 
697  UpdateStatusBar();
698  UpdateMsgPanel();
699 }
700 
701 
703 {
704  return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
705 }
706 
707 
709 {
711 
712  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
713 
714  if( m_toolManager )
715  {
717  GetCanvas()->GetViewControls(), config(), this );
718  }
719 
720  if( m_toolManager )
722 
723  // Transfer latest current display options from legacy to GAL canvas:
724  auto painter = static_cast<KIGFX::PCB_PAINTER*>( canvas->GetView()->GetPainter() );
725  auto settings = painter->GetSettings();
726  auto displ_opts = GetDisplayOptions();
727  settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
728  settings->LoadColors( GetColorSettings() );
729 
730  canvas->GetView()->RecacheAllItems();
732  canvas->StartDrawing();
733 }
734 
735 
736 void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh )
737 {
738  bool hcChanged = m_displayOptions.m_ContrastModeDisplay != aOptions.m_ContrastModeDisplay;
739  m_displayOptions = aOptions;
740 
741  EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
742  KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
743 
744  view->UpdateDisplayOptions( aOptions );
747 
748  // Vias on a restricted layer set must be redrawn when high contrast mode is changed
749  if( hcChanged )
750  {
752  []( KIGFX::VIEW_ITEM* aItem ) -> bool
753  {
754  if( VIA* via = dynamic_cast<VIA*>( aItem ) )
755  {
756  return via->GetViaType() == VIATYPE::BLIND_BURIED
757  || via->GetViaType() == VIATYPE::MICROVIA;
758  }
759 
760  return false;
761  } );
762  }
763 
764  if( aRefresh )
765  canvas->Refresh();
766 }
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:815
#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:798
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:90
virtual void SetBoard(BOARD *aBoard)
Set the #m_Pcb member in such as way as to ensure deleting any previous BOARD.
Definition: track.h:343
virtual void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: board.h:608
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:56
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:611
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
!!!!!!!!!!!!!! This code is obsolete because of the merge into pcbnew, don't bother with it.
Definition: cvpcb.cpp:120
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
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:265
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.
void SetSave()
Definition: base_screen.h:61
multilayer pads, usually with holes
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:82
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:616
SEVERITY
Definition: ui_common.h:83
const EDA_RECT GetBoardEdgesBoundingBox() const
Returns the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:812
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:609
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:309
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:114
show footprints on back
void SetBrightened()
Definition: eda_item.h:180
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings Returns a bit-mask of all t...
Definition: board.cpp:461
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:126
const wxPoint GetUserOrigin() const
show footprints values (when texts are visibles)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
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:247
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
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:259
void ClearBrightened()
Definition: eda_item.h:183
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:47
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:563
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
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
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:29
EDA_3D_VIEWER * CreateAndShow3D_Frame()
Shows the 3D view frame.
GRID_SETTINGS grid
Definition: app_settings.h:89
T ToDisplayAbsY(T aInternalValue) const
static DELETED_BOARD_ITEM * GetInstance()
Definition: board_item.h:398
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:187
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1557
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:1367
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
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:612
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:537
virtual void ReCreateMenuBar() override
Recreates the menu bar.
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
void IncrementTimeStamp()
Definition: board.h:271
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:115
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:159
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:525
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:285
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:507
bool IsFlipped() const
Definition: footprint.h:266
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
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
smd pads, front layer
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:614
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.
#define _(s)
Definition: 3d_actions.cpp:33
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:435
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:150
wxPoint GetPosition() const override
Definition: footprint.h:182
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)
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:66
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
void SetModify()
Definition: base_screen.h:59
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:381
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:1438
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.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification that common settings are updated.
PCB_DISPLAY_OPTIONS m_Display
Rendering engine changes.
Definition: tool_base.h:82
EDA_3D_VIEWER * Get3DViewerFrame()
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
Definition: eda_3d_viewer.h:51
void FocusOnItem(BOARD_ITEM *aItem)
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
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:147
show footprints references (when texts are visibles)
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:94
void ReloadRequest()
Request reloading the 3D view.
PCB_ORIGIN_TRANSFORMS m_originTransforms
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163
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:98
const wxPoint & GetAuxOrigin() const